Panda3D
 All Classes Functions Variables Enumerations
physxManager.I
1 // Filename: physxManager.I
2 // Created by: enn0x (01Sep09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PhysxManager::get_sdk
18 // Access: Public
19 // Description: Returns a pointer to the NxPhysicsSDK.
20 ////////////////////////////////////////////////////////////////////
21 INLINE NxPhysicsSDK *PhysxManager::
22 get_sdk() const {
23 
24  return _sdk;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: PhysxManager::vec3_to_nxVec3
29 // Access: Public
30 // Description: Converts from LVector3f to NxVec3.
31 ////////////////////////////////////////////////////////////////////
32 INLINE NxVec3 PhysxManager::
34 
35  return NxVec3(v.get_x(), v.get_y(), v.get_z());
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PhysxManager::nxVec3_to_vec3
40 // Access: Public
41 // Description: Converts from NxVec3 to LVector3f.
42 ////////////////////////////////////////////////////////////////////
44 nxVec3_to_vec3(const NxVec3 &v) {
45 
46  return LVector3f(v.x, v.y, v.z);
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: PhysxManager::vec3_to_nxExtVec3
51 // Access: Public
52 // Description: Converts from LVector3f to NxExtendedVec3.
53 ////////////////////////////////////////////////////////////////////
54 INLINE NxExtendedVec3 PhysxManager::
56 
57  return NxExtendedVec3(v.get_x(), v.get_y(), v.get_z());
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: PhysxManager::nxExtVec3_to_vec3
62 // Access: Public
63 // Description: Converts from NxExtendedVec3 to LVector3f.
64 ////////////////////////////////////////////////////////////////////
66 nxExtVec3_to_vec3(const NxExtendedVec3 &v) {
67 
68  return LVector3f(v.x, v.y, v.z);
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: PhysxManager::point3_to_nxVec3
73 // Access: Public
74 // Description: Converts from LPoint3f to NxVec3.
75 ////////////////////////////////////////////////////////////////////
76 INLINE NxVec3 PhysxManager::
78 
79  return NxVec3(p.get_x(), p.get_y(), p.get_z());
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: PhysxManager::nxVec3_to_point3
84 // Access: Public
85 // Description: Converts from NxVec3 to LPoint3f.
86 ////////////////////////////////////////////////////////////////////
88 nxVec3_to_point3(const NxVec3 &p) {
89 
90  return LPoint3f(p.x, p.y, p.z);
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: PhysxManager::point3_to_nxExtVec3
95 // Access: Public
96 // Description: Converts from LPoint3f to NxExtendedVec3.
97 ////////////////////////////////////////////////////////////////////
98 INLINE NxExtendedVec3 PhysxManager::
100 
101  return NxExtendedVec3(p.get_x(), p.get_y(), p.get_z());
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: PhysxManager::nxExtVec3_to_point3
106 // Access: Public
107 // Description: Converts from NxExtendedVec3 to LPoint3f.
108 ////////////////////////////////////////////////////////////////////
110 nxExtVec3_to_point3(const NxExtendedVec3 &p) {
111 
112  return LPoint3f(p.x, p.y, p.z);
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: PhysxManager::quat_to_nxQuat
117 // Access: Public
118 // Description: Converts from LQuaternionf to NxQuat.
119 ////////////////////////////////////////////////////////////////////
120 INLINE NxQuat PhysxManager::
122 
123  NxQuat nxq;
124  nxq.setXYZW(q.get_i(), q.get_j(), q.get_k(), q.get_r());
125  return nxq;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: PhysxManager::nxQuat_to_quat
130 // Access: Public
131 // Description: Converts from NxQuat to LQuaternionf.
132 ////////////////////////////////////////////////////////////////////
134 nxQuat_to_quat(const NxQuat &q) {
135 
136  return LQuaternionf(q.w, q.x, q.y, q.z);
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: PhysxManager::mat4_to_nxMat34
141 // Access: Public
142 // Description: Converts from LMatrix4f to NxMat34.
143 ////////////////////////////////////////////////////////////////////
144 INLINE NxMat34 PhysxManager::
146 
147  NxMat33 mat = mat3_to_nxMat33(m.get_upper_3());
148  NxVec3 v = vec3_to_nxVec3(m.get_row3(3));
149  return NxMat34(mat, v);
150 }
151 
152 ////////////////////////////////////////////////////////////////////
153 // Function: PhysxManager::nxMat34_to_mat4
154 // Access: Public
155 // Description: Converts from NxMat34 to LMatrix4f.
156 ////////////////////////////////////////////////////////////////////
158 nxMat34_to_mat4(const NxMat34 &m) {
159 
160  return LMatrix4f(nxMat33_to_mat3(m.M), nxVec3_to_vec3(m.t));
161 }
162 
163 ////////////////////////////////////////////////////////////////////
164 // Function: PhysxManager::mat3_to_nxMat33
165 // Access: Public
166 // Description: Converts from LMatrix3f to NxMat33.
167 ////////////////////////////////////////////////////////////////////
168 INLINE NxMat33 PhysxManager::
170 
171  NxMat33 mat;
172  mat.setColumnMajor(m.get_data());
173  return mat;
174 }
175 
176 ////////////////////////////////////////////////////////////////////
177 // Function: PhysxManager::nxMat33_to_mat3
178 // Access: Public
179 // Description: Converts from NxMat33 to LMatrix3f.
180 ////////////////////////////////////////////////////////////////////
182 nxMat33_to_mat3(const NxMat33 &m) {
183 
184  float cells[9];
185  m.getColumnMajor(cells);
186  return LMatrix3f(cells[0], cells[1], cells[2],
187  cells[3], cells[4], cells[5],
188  cells[6], cells[7], cells[8]);
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function: PhysxManager::update_vec3_from_nxVec3
193 // Access: Public
194 // Description:
195 ////////////////////////////////////////////////////////////////////
196 INLINE void PhysxManager::
197 update_vec3_from_nxVec3(LVector3f &v, const NxVec3 &nVec) {
198 
199  v.set_x(nVec.x);
200  v.set_y(nVec.y);
201  v.set_z(nVec.z);
202 }
203 
204 ////////////////////////////////////////////////////////////////////
205 // Function: PhysxManager::update_point3_from_nxVec3
206 // Access: Public
207 // Description:
208 ////////////////////////////////////////////////////////////////////
209 INLINE void PhysxManager::
210 update_point3_from_nxVec3(LPoint3f &p, const NxVec3 &nVec) {
211 
212  p.set_x(nVec.x);
213  p.set_y(nVec.y);
214  p.set_z(nVec.z);
215 }
216 
217 
218 ////////////////////////////////////////////////////////////////////
219 // Function: PhysxManager::ls
220 // Access: Published
221 // Description:
222 ////////////////////////////////////////////////////////////////////
223 INLINE void PhysxManager::
224 ls() const {
225 
226  ls(nout);
227 }
228 
229 ////////////////////////////////////////////////////////////////////
230 // Function: PhysxManager::ls
231 // Access: Published
232 // Description:
233 ////////////////////////////////////////////////////////////////////
234 INLINE void PhysxManager::
235 ls(ostream &out, int indent_level) const {
236 
237  indent(out, indent_level) << "PhysxManager\n";
238 
239  _scenes.ls(out, indent_level);
240  _heightfields.ls(out, indent_level);
241  _convex_meshes.ls(out, indent_level);
242  _triangle_meshes.ls(out, indent_level);
243 }
244 
LMatrix3f get_upper_3() const
Retrieves the upper 3x3 submatrix.
Definition: lmatrix.h:1169
NxPhysicsSDK * get_sdk() const
Returns a pointer to the NxPhysicsSDK.
Definition: physxManager.I:22
static NxQuat quat_to_nxQuat(const LQuaternionf &q)
Converts from LQuaternionf to NxQuat.
Definition: physxManager.I:121
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:77
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:145
static NxExtendedVec3 point3_to_nxExtVec3(const LPoint3f &p)
Converts from LPoint3f to NxExtendedVec3.
Definition: physxManager.I:99
static LPoint3f nxExtVec3_to_point3(const NxExtendedVec3 &p)
Converts from NxExtendedVec3 to LPoint3f.
Definition: physxManager.I:110
static NxExtendedVec3 vec3_to_nxExtVec3(const LVector3f &v)
Converts from LVector3f to NxExtendedVec3.
Definition: physxManager.I:55
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
static LQuaternionf nxQuat_to_quat(const NxQuat &q)
Converts from NxQuat to LQuaternionf.
Definition: physxManager.I:134
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition: physxManager.I:169
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:44
This is the base quaternion class.
Definition: lquaternion.h:96
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:88
const float * get_data() const
Returns the address of the first of the nine data elements in the matrix.
Definition: lmatrix.h:3196
LVecBase3f get_row3(int row) const
Retrieves the row column of the matrix as a 3-component vector, ignoring the last column...
Definition: lmatrix.h:1312
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition: physxManager.I:158
static LMatrix3f nxMat33_to_mat3(const NxMat33 &m)
Converts from NxMat33 to LMatrix3f.
Definition: physxManager.I:182
static LVector3f nxExtVec3_to_vec3(const NxExtendedVec3 &v)
Converts from NxExtendedVec3 to LVector3f.
Definition: physxManager.I:66