Panda3D
physxForceFieldShapeDesc.cxx
1 // Filename: physxForceFieldShapeDesc.cxx
2 // Created by: enn0x (06Nov09)
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 #include "physxForceFieldShapeDesc.h"
16 #include "physxManager.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: PhysxForceFieldShapeDesc::set_name
20 // Access: Published
21 // Description: Sets a possible debug name.
22 ////////////////////////////////////////////////////////////////////
24 set_name(const char *name) {
25 
26  _name = name ? name : "";
27  ptr()->name = _name.c_str();
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: PhysxForceFieldShapeDesc::set_pos
32 // Access: Published
33 // Description:
34 ////////////////////////////////////////////////////////////////////
35 void PhysxForceFieldShapeDesc::
36 set_pos(const LPoint3f &pos) {
37 
38  nassertv(!pos.is_nan());
39  ptr()->pose.t = PhysxManager::point3_to_nxVec3(pos);
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PhysxForceFieldShapeDesc::set_mat
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 void PhysxForceFieldShapeDesc::
48 set_mat(const LMatrix4f &mat) {
49 
50  nassertv(!mat.is_nan());
51  ptr()->pose = PhysxManager::mat4_to_nxMat34(mat);
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: PhysxForceFieldShapeDesc::set_hpr
56 // Access: Published
57 // Description:
58 ////////////////////////////////////////////////////////////////////
59 void PhysxForceFieldShapeDesc::
60 set_hpr(float h, float p, float r) {
61 
62  LQuaternionf q;
63  LMatrix3f rot;
64  NxMat34 m;
65 
66  q.set_hpr(LVector3f(h, p, r));
67  q.extract_to_matrix(rot);
68 
69  ptr()->pose.M = PhysxManager::mat3_to_nxMat33(rot);
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: PhysxForceFieldShapeDesc::get_name
74 // Access: Published
75 // Description:
76 ////////////////////////////////////////////////////////////////////
77 const char *PhysxForceFieldShapeDesc::
78 get_name() const {
79 
80  return ptr()->name;
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: PhysxForceFieldShapeDesc::get_pos
85 // Access: Published
86 // Description:
87 ////////////////////////////////////////////////////////////////////
88 LPoint3f PhysxForceFieldShapeDesc::
89 get_pos() const {
90 
91  return PhysxManager::nxVec3_to_point3(ptr()->pose.t);
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: PhysxForceFieldShapeDesc::get_mat
96 // Access: Published
97 // Description:
98 ////////////////////////////////////////////////////////////////////
99 LMatrix4f PhysxForceFieldShapeDesc::
100 get_mat() const {
101 
102  return PhysxManager::nxMat34_to_mat4(ptr()->pose);
103 }
104 
void set_name(const char *name)
Sets a possible debug name.
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
void extract_to_matrix(LMatrix3f &m) const
Based on the quat lib from VRPN.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:464
bool is_nan() const
Returns true if any component of the matrix is not-a-number, false otherwise.
Definition: lmatrix.h:1417
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:145
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition: physxManager.I:169
void set_hpr(const LVecBase3f &hpr, CoordinateSystem cs=CS_default)
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
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
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