00001 // Filename: physxManager.I 00002 // Created by: enn0x (01Sep09) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: PhysxManager::get_sdk 00018 // Access: Public 00019 // Description: Returns a pointer to the NxPhysicsSDK. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE NxPhysicsSDK *PhysxManager:: 00022 get_sdk() const { 00023 00024 return _sdk; 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: PhysxManager::vec3_to_nxVec3 00029 // Access: Public 00030 // Description: Converts from LVector3f to NxVec3. 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE NxVec3 PhysxManager:: 00033 vec3_to_nxVec3(const LVector3f &v) { 00034 00035 return NxVec3(v.get_x(), v.get_y(), v.get_z()); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: PhysxManager::nxVec3_to_vec3 00040 // Access: Public 00041 // Description: Converts from NxVec3 to LVector3f. 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE LVector3f PhysxManager:: 00044 nxVec3_to_vec3(const NxVec3 &v) { 00045 00046 return LVector3f(v.x, v.y, v.z); 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: PhysxManager::vec3_to_nxExtVec3 00051 // Access: Public 00052 // Description: Converts from LVector3f to NxExtendedVec3. 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE NxExtendedVec3 PhysxManager:: 00055 vec3_to_nxExtVec3(const LVector3f &v) { 00056 00057 return NxExtendedVec3(v.get_x(), v.get_y(), v.get_z()); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: PhysxManager::nxExtVec3_to_vec3 00062 // Access: Public 00063 // Description: Converts from NxExtendedVec3 to LVector3f. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE LVector3f PhysxManager:: 00066 nxExtVec3_to_vec3(const NxExtendedVec3 &v) { 00067 00068 return LVector3f(v.x, v.y, v.z); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: PhysxManager::point3_to_nxVec3 00073 // Access: Public 00074 // Description: Converts from LPoint3f to NxVec3. 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE NxVec3 PhysxManager:: 00077 point3_to_nxVec3(const LPoint3f &p) { 00078 00079 return NxVec3(p.get_x(), p.get_y(), p.get_z()); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: PhysxManager::nxVec3_to_point3 00084 // Access: Public 00085 // Description: Converts from NxVec3 to LPoint3f. 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE LPoint3f PhysxManager:: 00088 nxVec3_to_point3(const NxVec3 &p) { 00089 00090 return LPoint3f(p.x, p.y, p.z); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: PhysxManager::point3_to_nxExtVec3 00095 // Access: Public 00096 // Description: Converts from LPoint3f to NxExtendedVec3. 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE NxExtendedVec3 PhysxManager:: 00099 point3_to_nxExtVec3(const LPoint3f &p) { 00100 00101 return NxExtendedVec3(p.get_x(), p.get_y(), p.get_z()); 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: PhysxManager::nxExtVec3_to_point3 00106 // Access: Public 00107 // Description: Converts from NxExtendedVec3 to LPoint3f. 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE LPoint3f PhysxManager:: 00110 nxExtVec3_to_point3(const NxExtendedVec3 &p) { 00111 00112 return LPoint3f(p.x, p.y, p.z); 00113 } 00114 00115 //////////////////////////////////////////////////////////////////// 00116 // Function: PhysxManager::quat_to_nxQuat 00117 // Access: Public 00118 // Description: Converts from LQuaternionf to NxQuat. 00119 //////////////////////////////////////////////////////////////////// 00120 INLINE NxQuat PhysxManager:: 00121 quat_to_nxQuat(const LQuaternionf &q) { 00122 00123 NxQuat nxq; 00124 nxq.setXYZW(q.get_i(), q.get_j(), q.get_k(), q.get_r()); 00125 return nxq; 00126 } 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: PhysxManager::nxQuat_to_quat 00130 // Access: Public 00131 // Description: Converts from NxQuat to LQuaternionf. 00132 //////////////////////////////////////////////////////////////////// 00133 INLINE LQuaternionf PhysxManager:: 00134 nxQuat_to_quat(const NxQuat &q) { 00135 00136 return LQuaternionf(q.w, q.x, q.y, q.z); 00137 } 00138 00139 //////////////////////////////////////////////////////////////////// 00140 // Function: PhysxManager::mat4_to_nxMat34 00141 // Access: Public 00142 // Description: Converts from LMatrix4f to NxMat34. 00143 //////////////////////////////////////////////////////////////////// 00144 INLINE NxMat34 PhysxManager:: 00145 mat4_to_nxMat34(const LMatrix4f &m) { 00146 00147 NxMat33 mat = mat3_to_nxMat33(m.get_upper_3()); 00148 NxVec3 v = vec3_to_nxVec3(m.get_row3(3)); 00149 return NxMat34(mat, v); 00150 } 00151 00152 //////////////////////////////////////////////////////////////////// 00153 // Function: PhysxManager::nxMat34_to_mat4 00154 // Access: Public 00155 // Description: Converts from NxMat34 to LMatrix4f. 00156 //////////////////////////////////////////////////////////////////// 00157 INLINE LMatrix4f PhysxManager:: 00158 nxMat34_to_mat4(const NxMat34 &m) { 00159 00160 return LMatrix4f(nxMat33_to_mat3(m.M), nxVec3_to_vec3(m.t)); 00161 } 00162 00163 //////////////////////////////////////////////////////////////////// 00164 // Function: PhysxManager::mat3_to_nxMat33 00165 // Access: Public 00166 // Description: Converts from LMatrix3f to NxMat33. 00167 //////////////////////////////////////////////////////////////////// 00168 INLINE NxMat33 PhysxManager:: 00169 mat3_to_nxMat33(const LMatrix3f &m) { 00170 00171 NxMat33 mat; 00172 mat.setColumnMajor(m.get_data()); 00173 return mat; 00174 } 00175 00176 //////////////////////////////////////////////////////////////////// 00177 // Function: PhysxManager::nxMat33_to_mat3 00178 // Access: Public 00179 // Description: Converts from NxMat33 to LMatrix3f. 00180 //////////////////////////////////////////////////////////////////// 00181 INLINE LMatrix3f PhysxManager:: 00182 nxMat33_to_mat3(const NxMat33 &m) { 00183 00184 float cells[9]; 00185 m.getColumnMajor(cells); 00186 return LMatrix3f(cells[0], cells[1], cells[2], 00187 cells[3], cells[4], cells[5], 00188 cells[6], cells[7], cells[8]); 00189 } 00190 00191 //////////////////////////////////////////////////////////////////// 00192 // Function: PhysxManager::update_vec3_from_nxVec3 00193 // Access: Public 00194 // Description: 00195 //////////////////////////////////////////////////////////////////// 00196 INLINE void PhysxManager:: 00197 update_vec3_from_nxVec3(LVector3f &v, const NxVec3 &nVec) { 00198 00199 v.set_x(nVec.x); 00200 v.set_y(nVec.y); 00201 v.set_z(nVec.z); 00202 } 00203 00204 //////////////////////////////////////////////////////////////////// 00205 // Function: PhysxManager::update_point3_from_nxVec3 00206 // Access: Public 00207 // Description: 00208 //////////////////////////////////////////////////////////////////// 00209 INLINE void PhysxManager:: 00210 update_point3_from_nxVec3(LPoint3f &p, const NxVec3 &nVec) { 00211 00212 p.set_x(nVec.x); 00213 p.set_y(nVec.y); 00214 p.set_z(nVec.z); 00215 } 00216 00217 00218 //////////////////////////////////////////////////////////////////// 00219 // Function: PhysxManager::ls 00220 // Access: Published 00221 // Description: 00222 //////////////////////////////////////////////////////////////////// 00223 INLINE void PhysxManager:: 00224 ls() const { 00225 00226 ls(nout); 00227 } 00228 00229 //////////////////////////////////////////////////////////////////// 00230 // Function: PhysxManager::ls 00231 // Access: Published 00232 // Description: 00233 //////////////////////////////////////////////////////////////////// 00234 INLINE void PhysxManager:: 00235 ls(ostream &out, int indent_level) const { 00236 00237 indent(out, indent_level) << "PhysxManager\n"; 00238 00239 _scenes.ls(out, indent_level); 00240 _heightfields.ls(out, indent_level); 00241 _convex_meshes.ls(out, indent_level); 00242 _triangle_meshes.ls(out, indent_level); 00243 } 00244