00001 // Filename: physxActorDesc.cxx 00002 // Created by: enn0x (05Sep09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "physxActorDesc.h" 00016 #include "physxBodyDesc.h" 00017 #include "physxManager.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: PhysxActorDesc::add_shape 00021 // Access: Published 00022 // Description: Adds a shape to the list of collision shapes 00023 // composing this actor. 00024 //////////////////////////////////////////////////////////////////// 00025 void PhysxActorDesc:: 00026 add_shape(PhysxShapeDesc &desc) { 00027 00028 _desc.shapes.push_back(desc.ptr()); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: PhysxActorDesc::set_name 00033 // Access: Published 00034 // Description: Sets the optional debug name for the actor. 00035 //////////////////////////////////////////////////////////////////// 00036 void PhysxActorDesc:: 00037 set_name(const char *name) { 00038 00039 _name = name ? name : ""; 00040 _desc.name = _name.c_str(); 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: PhysxActorDesc::set_density 00045 // Access: Published 00046 // Description: Set the density used during mass/intertia 00047 // computation. This value is used if the actor's 00048 // shapes do not have a mass asigned. 00049 //////////////////////////////////////////////////////////////////// 00050 void PhysxActorDesc:: 00051 set_density(float density) { 00052 00053 _desc.density = density; 00054 } 00055 00056 //////////////////////////////////////////////////////////////////// 00057 // Function: PhysxActorDesc::set_global_pos 00058 // Access: Published 00059 // Description: Set the position of the actor in global space. 00060 //////////////////////////////////////////////////////////////////// 00061 void PhysxActorDesc:: 00062 set_global_pos(const LPoint3f &pos) { 00063 00064 _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos); 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: PhysxActorDesc::set_global_mat 00069 // Access: Published 00070 // Description: Set the position and orientation of the actor 00071 // in global space. Scaling and shear arenot 00072 // supported, even if the matrix contains a scale or 00073 // shear. 00074 //////////////////////////////////////////////////////////////////// 00075 void PhysxActorDesc:: 00076 set_global_mat(const LMatrix4f &mat) { 00077 00078 _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat); 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: PhysxActorDesc::set_global_hpr 00083 // Access: Published 00084 // Description: Sets the orientation of the actor in global space 00085 // by providing angles for heading, pitch and roll. 00086 //////////////////////////////////////////////////////////////////// 00087 void PhysxActorDesc:: 00088 set_global_hpr(float h, float p, float r) { 00089 00090 LQuaternionf q; 00091 LMatrix3f rot; 00092 NxMat34 m; 00093 00094 q.set_hpr(LVector3f(h, p, r)); 00095 q.extract_to_matrix(rot); 00096 00097 _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot); 00098 } 00099 00100 //////////////////////////////////////////////////////////////////// 00101 // Function: PhysxActorDesc::set_body 00102 // Access: Published 00103 // Description: Sets the body descriptor for this actor. The actor 00104 // will be dynmaic if a body descriptor is set, and 00105 // static if no body descriptor is set. 00106 //////////////////////////////////////////////////////////////////// 00107 void PhysxActorDesc:: 00108 set_body(PhysxBodyDesc &desc) { 00109 00110 _desc.body = &(desc._desc); 00111 } 00112 00113 //////////////////////////////////////////////////////////////////// 00114 // Function: PhysxActorDesc::get_body 00115 // Access: Published 00116 // Description: Gets the body descriptor for this actor. 00117 //////////////////////////////////////////////////////////////////// 00118 PhysxBodyDesc PhysxActorDesc:: 00119 get_body() const { 00120 00121 throw "Not Implemented"; 00122 00123 //PhysxBodyDesc value; 00124 //value._desc = *(_desc.body); 00125 //return value; 00126 } 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: PhysxActorDesc::get_name 00130 // Access: Published 00131 // Description: Returns the optional debug name for this actor. 00132 //////////////////////////////////////////////////////////////////// 00133 const char *PhysxActorDesc:: 00134 get_name() const { 00135 00136 return _desc.name; 00137 } 00138 00139 //////////////////////////////////////////////////////////////////// 00140 // Function: PhysxActorDesc::get_density 00141 // Access: Published 00142 // Description: Returns the actor's density. 00143 //////////////////////////////////////////////////////////////////// 00144 float PhysxActorDesc:: 00145 get_density() const { 00146 00147 return _desc.density; 00148 } 00149 00150 //////////////////////////////////////////////////////////////////// 00151 // Function: PhysxActorDesc::get_global_pos 00152 // Access: Published 00153 // Description: Returns the actor's position in global space. 00154 //////////////////////////////////////////////////////////////////// 00155 LPoint3f PhysxActorDesc:: 00156 get_global_pos() const { 00157 00158 return PhysxManager::nxVec3_to_point3(_desc.globalPose.t); 00159 } 00160 00161 //////////////////////////////////////////////////////////////////// 00162 // Function: PhysxActorDesc::get_global_mat 00163 // Access: Published 00164 // Description: Returns the actor's transform in global space. 00165 //////////////////////////////////////////////////////////////////// 00166 LMatrix4f PhysxActorDesc:: 00167 get_global_mat() const { 00168 00169 return PhysxManager::nxMat34_to_mat4(_desc.globalPose); 00170 } 00171