21 btVector3 LVecBase3_to_btVector3(
const LVecBase3 &v) {
23 return btVector3((btScalar)v.get_x(),
31 LVecBase3 btVector3_to_LVecBase3(
const btVector3 &v) {
33 return LVecBase3((PN_stdfloat)v.getX(),
34 (PN_stdfloat)v.getY(),
35 (PN_stdfloat)v.getZ());
41 LVector3 btVector3_to_LVector3(
const btVector3 &v) {
43 return LVector3((PN_stdfloat)v.getX(),
44 (PN_stdfloat)v.getY(),
45 (PN_stdfloat)v.getZ());
51 LPoint3 btVector3_to_LPoint3(
const btVector3 &p) {
53 return LPoint3((PN_stdfloat)p.getX(),
54 (PN_stdfloat)p.getY(),
55 (PN_stdfloat)p.getZ());
61 btMatrix3x3 LMatrix3_to_btMatrix3x3(
const LMatrix3 &m) {
64 result.setFromOpenGLSubMatrix((
const btScalar *)m.get_data());
71 LMatrix3 btMatrix3x3_to_LMatrix3(
const btMatrix3x3 &m) {
74 m.getOpenGLSubMatrix(cells);
75 return LMatrix3((PN_stdfloat)cells[0], (PN_stdfloat)cells[1], (PN_stdfloat)cells[2],
76 (PN_stdfloat)cells[3], (PN_stdfloat)cells[4], (PN_stdfloat)cells[5],
77 (PN_stdfloat)cells[6], (PN_stdfloat)cells[7], (PN_stdfloat)cells[8]);
83 btQuaternion LQuaternion_to_btQuat(
const LQuaternion &q) {
85 return btQuaternion((btScalar)q.get_i(),
94 LQuaternion btQuat_to_LQuaternion(
const btQuaternion &q) {
96 return LQuaternion((PN_stdfloat)q.getW(),
97 (PN_stdfloat)q.getX(),
98 (PN_stdfloat)q.getY(),
99 (PN_stdfloat)q.getZ());
105 btTransform LMatrix4_to_btTrans(
const LMatrix4 &m) {
108 quat.set_from_matrix(m.get_upper_3());
110 btQuaternion btq = LQuaternion_to_btQuat(quat);
111 btVector3 btv = LVecBase3_to_btVector3(m.get_row3(3));
113 return btTransform(btq, btv);
119 LMatrix4 btTrans_to_LMatrix4(
const btTransform &trans) {
121 return TransformState::make_pos_quat_scale(
122 btVector3_to_LVector3(trans.getOrigin()),
123 btQuat_to_LQuaternion(trans.getRotation()),
124 LVector3(1.0f, 1.0f, 1.0f))->get_mat();
130 CPT(
TransformState) btTrans_to_TransformState(
const btTransform &trans,
const LVecBase3 &scale) {
132 LVecBase3 pos = btVector3_to_LVector3(trans.getOrigin());
133 LQuaternion quat = btQuat_to_LQuaternion(trans.getRotation());
135 return TransformState::make_pos_quat_scale(pos, quat, scale);
143 ts = ts->set_scale(1.0);
148 quat.set_from_matrix(m.get_upper_3());
150 btQuaternion btq = LQuaternion_to_btQuat(quat);
151 btVector3 btv = LVecBase3_to_btVector3(m.get_row3(3));
153 return btTransform(btq, btv);
159 BulletUpAxis get_default_up_axis() {
161 switch (get_default_coordinate_system()) {
179 void get_node_transform(btTransform &trans,
PandaNode *node) {
184 ts = node->get_transform();
188 ts = np.get_net_transform();
192 ts = ts->set_scale(1.0);
198 quat.set_from_matrix(m.get_upper_3());
200 btQuaternion btq = LQuaternion_to_btQuat(quat);
201 btVector3 btv = LVecBase3_to_btVector3(m.get_row3(3));
203 trans.setRotation(btq);
204 trans.setOrigin(btv);
212 return BT_BULLET_VERSION;
A basic node of the scene graph or data graph.
get_num_parents
Returns the number of parent nodes this node has.
static NodePath any_path(PandaNode *node, Thread *current_thread=Thread::get_current_thread())
Returns a new NodePath that represents any arbitrary path from the root to the indicated node.
int get_bullet_version()
Returns the version of the linked Bullet library.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...