21btVector3 LVecBase3_to_btVector3(
const LVecBase3 &v) {
23 return btVector3((btScalar)v.get_x(),
31LVecBase3 btVector3_to_LVecBase3(
const btVector3 &v) {
33 return LVecBase3((PN_stdfloat)v.getX(),
34 (PN_stdfloat)v.getY(),
35 (PN_stdfloat)v.getZ());
41LVector3 btVector3_to_LVector3(
const btVector3 &v) {
43 return LVector3((PN_stdfloat)v.getX(),
44 (PN_stdfloat)v.getY(),
45 (PN_stdfloat)v.getZ());
51LPoint3 btVector3_to_LPoint3(
const btVector3 &p) {
53 return LPoint3((PN_stdfloat)p.getX(),
54 (PN_stdfloat)p.getY(),
55 (PN_stdfloat)p.getZ());
61btMatrix3x3 LMatrix3_to_btMatrix3x3(
const LMatrix3 &m) {
65 result.setFromOpenGLSubMatrix((
const btScalar *)m4.get_data());
72LMatrix3 btMatrix3x3_to_LMatrix3(
const btMatrix3x3 &m) {
75 m.getOpenGLSubMatrix(cells);
76 return LMatrix3((PN_stdfloat)cells[0], (PN_stdfloat)cells[1], (PN_stdfloat)cells[2],
77 (PN_stdfloat)cells[4], (PN_stdfloat)cells[5], (PN_stdfloat)cells[6],
78 (PN_stdfloat)cells[8], (PN_stdfloat)cells[9], (PN_stdfloat)cells[10]);
84btQuaternion LQuaternion_to_btQuat(
const LQuaternion &q) {
86 return btQuaternion((btScalar)q.get_i(),
95LQuaternion btQuat_to_LQuaternion(
const btQuaternion &q) {
97 return LQuaternion((PN_stdfloat)q.getW(),
98 (PN_stdfloat)q.getX(),
99 (PN_stdfloat)q.getY(),
100 (PN_stdfloat)q.getZ());
106btTransform LMatrix4_to_btTrans(
const LMatrix4 &m) {
109 quat.set_from_matrix(m.get_upper_3());
111 btQuaternion btq = LQuaternion_to_btQuat(quat);
112 btVector3 btv = LVecBase3_to_btVector3(m.get_row3(3));
114 return btTransform(btq, btv);
120LMatrix4 btTrans_to_LMatrix4(
const btTransform &trans) {
122 return TransformState::make_pos_quat_scale(
123 btVector3_to_LVector3(trans.getOrigin()),
124 btQuat_to_LQuaternion(trans.getRotation()),
125 LVector3(1.0f, 1.0f, 1.0f))->get_mat();
131CPT(
TransformState) btTrans_to_TransformState(
const btTransform &trans,
const LVecBase3 &scale) {
133 LVecBase3 pos = btVector3_to_LVector3(trans.getOrigin());
134 LQuaternion quat = btQuat_to_LQuaternion(trans.getRotation());
136 return TransformState::make_pos_quat_scale(pos, quat, scale);
144 ts = ts->set_scale(1.0);
149 quat.set_from_matrix(m.get_upper_3());
151 btQuaternion btq = LQuaternion_to_btQuat(quat);
152 btVector3 btv = LVecBase3_to_btVector3(m.get_row3(3));
154 return btTransform(btq, btv);
160BulletUpAxis get_default_up_axis() {
162 switch (get_default_coordinate_system()) {
180void get_node_transform(btTransform &trans,
PandaNode *node) {
185 ts = node->get_transform();
189 ts = np.get_net_transform();
193 ts = ts->set_scale(1.0);
199 quat.set_from_matrix(m.get_upper_3());
201 btQuaternion btq = LQuaternion_to_btQuat(quat);
202 btVector3 btv = LVecBase3_to_btVector3(m.get_row3(3));
204 trans.setRotation(btq);
205 trans.setOrigin(btv);
213 return BT_BULLET_VERSION;
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...
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.
A basic node of the scene graph or data graph.
get_num_parents
Returns the number of parent nodes this node has.