Panda3D
physxManager.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxManager.I
10  * @author enn0x
11  * @date 2009-09-01
12  */
13 
14 /**
15  * Returns a pointer to the NxPhysicsSDK.
16  */
17 INLINE NxPhysicsSDK *PhysxManager::
18 get_sdk() const {
19 
20  return _sdk;
21 }
22 
23 /**
24  * Converts from LVector3f to NxVec3.
25  */
26 INLINE NxVec3 PhysxManager::
27 vec3_to_nxVec3(const LVector3f &v) {
28 
29  return NxVec3(v.get_x(), v.get_y(), v.get_z());
30 }
31 
32 /**
33  * Converts from NxVec3 to LVector3f.
34  */
35 INLINE LVector3f PhysxManager::
36 nxVec3_to_vec3(const NxVec3 &v) {
37 
38  return LVector3f(v.x, v.y, v.z);
39 }
40 
41 /**
42  * Converts from LVector3f to NxExtendedVec3.
43  */
44 INLINE NxExtendedVec3 PhysxManager::
45 vec3_to_nxExtVec3(const LVector3f &v) {
46 
47  return NxExtendedVec3(v.get_x(), v.get_y(), v.get_z());
48 }
49 
50 /**
51  * Converts from NxExtendedVec3 to LVector3f.
52  */
53 INLINE LVector3f PhysxManager::
54 nxExtVec3_to_vec3(const NxExtendedVec3 &v) {
55 
56  return LVector3f(v.x, v.y, v.z);
57 }
58 
59 /**
60  * Converts from LPoint3f to NxVec3.
61  */
62 INLINE NxVec3 PhysxManager::
63 point3_to_nxVec3(const LPoint3f &p) {
64 
65  return NxVec3(p.get_x(), p.get_y(), p.get_z());
66 }
67 
68 /**
69  * Converts from NxVec3 to LPoint3f.
70  */
71 INLINE LPoint3f PhysxManager::
72 nxVec3_to_point3(const NxVec3 &p) {
73 
74  return LPoint3f(p.x, p.y, p.z);
75 }
76 
77 /**
78  * Converts from LPoint3f to NxExtendedVec3.
79  */
80 INLINE NxExtendedVec3 PhysxManager::
81 point3_to_nxExtVec3(const LPoint3f &p) {
82 
83  return NxExtendedVec3(p.get_x(), p.get_y(), p.get_z());
84 }
85 
86 /**
87  * Converts from NxExtendedVec3 to LPoint3f.
88  */
89 INLINE LPoint3f PhysxManager::
90 nxExtVec3_to_point3(const NxExtendedVec3 &p) {
91 
92  return LPoint3f(p.x, p.y, p.z);
93 }
94 
95 /**
96  * Converts from LQuaternionf to NxQuat.
97  */
98 INLINE NxQuat PhysxManager::
99 quat_to_nxQuat(const LQuaternionf &q) {
100 
101  NxQuat nxq;
102  nxq.setXYZW(q.get_i(), q.get_j(), q.get_k(), q.get_r());
103  return nxq;
104 }
105 
106 /**
107  * Converts from NxQuat to LQuaternionf.
108  */
109 INLINE LQuaternionf PhysxManager::
110 nxQuat_to_quat(const NxQuat &q) {
111 
112  return LQuaternionf(q.w, q.x, q.y, q.z);
113 }
114 
115 /**
116  * Converts from LMatrix4f to NxMat34.
117  */
118 INLINE NxMat34 PhysxManager::
119 mat4_to_nxMat34(const LMatrix4f &m) {
120 
121  NxMat33 mat = mat3_to_nxMat33(m.get_upper_3());
122  NxVec3 v = vec3_to_nxVec3(m.get_row3(3));
123  return NxMat34(mat, v);
124 }
125 
126 /**
127  * Converts from NxMat34 to LMatrix4f.
128  */
129 INLINE LMatrix4f PhysxManager::
130 nxMat34_to_mat4(const NxMat34 &m) {
131 
132  return LMatrix4f(nxMat33_to_mat3(m.M), nxVec3_to_vec3(m.t));
133 }
134 
135 /**
136  * Converts from LMatrix3f to NxMat33.
137  */
138 INLINE NxMat33 PhysxManager::
139 mat3_to_nxMat33(const LMatrix3f &m) {
140 
141  NxMat33 mat;
142  mat.setColumnMajor(m.get_data());
143  return mat;
144 }
145 
146 /**
147  * Converts from NxMat33 to LMatrix3f.
148  */
149 INLINE LMatrix3f PhysxManager::
150 nxMat33_to_mat3(const NxMat33 &m) {
151 
152  float cells[9];
153  m.getColumnMajor(cells);
154  return LMatrix3f(cells[0], cells[1], cells[2],
155  cells[3], cells[4], cells[5],
156  cells[6], cells[7], cells[8]);
157 }
158 
159 /**
160  *
161  */
162 INLINE void PhysxManager::
163 update_vec3_from_nxVec3(LVector3f &v, const NxVec3 &nVec) {
164 
165  v.set_x(nVec.x);
166  v.set_y(nVec.y);
167  v.set_z(nVec.z);
168 }
169 
170 /**
171  *
172  */
173 INLINE void PhysxManager::
174 update_point3_from_nxVec3(LPoint3f &p, const NxVec3 &nVec) {
175 
176  p.set_x(nVec.x);
177  p.set_y(nVec.y);
178  p.set_z(nVec.z);
179 }
180 
181 
182 /**
183  *
184  */
185 INLINE void PhysxManager::
186 ls() const {
187 
188  ls(nout);
189 }
190 
191 /**
192  *
193  */
194 INLINE void PhysxManager::
195 ls(std::ostream &out, int indent_level) const {
196 
197  indent(out, indent_level) << "PhysxManager\n";
198 
199  _scenes.ls(out, indent_level);
200  _heightfields.ls(out, indent_level);
201  _convex_meshes.ls(out, indent_level);
202  _triangle_meshes.ls(out, indent_level);
203 }
NxPhysicsSDK * get_sdk() const
Returns a pointer to the NxPhysicsSDK.
Definition: physxManager.I:18
static NxQuat quat_to_nxQuat(const LQuaternionf &q)
Converts from LQuaternionf to NxQuat.
Definition: physxManager.I:99
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:63
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:119
static NxExtendedVec3 point3_to_nxExtVec3(const LPoint3f &p)
Converts from LPoint3f to NxExtendedVec3.
Definition: physxManager.I:81
static LPoint3f nxExtVec3_to_point3(const NxExtendedVec3 &p)
Converts from NxExtendedVec3 to LPoint3f.
Definition: physxManager.I:90
static NxExtendedVec3 vec3_to_nxExtVec3(const LVector3f &v)
Converts from LVector3f to NxExtendedVec3.
Definition: physxManager.I:45
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LQuaternionf nxQuat_to_quat(const NxQuat &q)
Converts from NxQuat to LQuaternionf.
Definition: physxManager.I:110
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition: physxManager.I:139
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:72
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition: physxManager.I:130
static LMatrix3f nxMat33_to_mat3(const NxMat33 &m)
Converts from NxMat33 to LMatrix3f.
Definition: physxManager.I:150
static LVector3f nxExtVec3_to_vec3(const NxExtendedVec3 &v)
Converts from NxExtendedVec3 to LVector3f.
Definition: physxManager.I:54