Panda3D
 All Classes Functions Variables Enumerations
physxPulleyJointDesc.cxx
1 // Filename: physxPulleyJointDesc.cxx
2 // Created by: enn0x (28Sep09)
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 "physxPulleyJointDesc.h"
16 #include "physxMotorDesc.h"
17 #include "physxManager.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: PhysxPulleyJointDesc::set_distance
21 // Access: Published
22 // Description: Sets the rest length of the rope connecting the
23 // two objects.
24 ////////////////////////////////////////////////////////////////////
26 set_distance(float distance) {
27 
28  _desc.distance = distance;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: PhysxPulleyJointDesc::set_stiffness
33 // Access: Published
34 // Description: Sets how stiff the constraint is, between 0 and 1
35 // (stiffest)
36 ////////////////////////////////////////////////////////////////////
38 set_stiffness(float stiffness) {
39 
40  _desc.stiffness = stiffness;
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: PhysxPulleyJointDesc::set_ratio
45 // Access: Published
46 // Description: Sets the transmission ratio.
47 ////////////////////////////////////////////////////////////////////
49 set_ratio(float ratio) {
50 
51  _desc.ratio = ratio;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: PhysxPulleyJointDesc::set_flag
56 // Access: Published
57 // Description: Sets or clears a single PulleyJointFlag flag.
58 ////////////////////////////////////////////////////////////////////
60 set_flag(PhysxPulleyJointFlag flag, bool value) {
61 
62  if (value == true) {
63  _desc.flags |= flag;
64  }
65  else {
66  _desc.flags &= ~(flag);
67  }
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: PhysxPulleyJointDesc::set_pulley
72 // Access: Published
73 // Description: Sets the suspension points of two bodies in world
74 // space.
75 ////////////////////////////////////////////////////////////////////
77 set_pulley(unsigned int idx, const LPoint3f pos) {
78 
79  nassertv_always(idx < 2);
80  _desc.pulley[idx] = PhysxManager::point3_to_nxVec3(pos);
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: PhysxPulleyJointDesc::set_motor
85 // Access: Published
86 // Description: Sets an optional joint motor.
87 ////////////////////////////////////////////////////////////////////
89 set_motor(const PhysxMotorDesc &motor) {
90 
91  _desc.motor = motor._desc;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: PhysxPulleyJointDesc::get_distance
96 // Access: Published
97 // Description:
98 ////////////////////////////////////////////////////////////////////
99 float PhysxPulleyJointDesc::
100 get_distance() const {
101 
102  return _desc.distance;
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: PhysxPulleyJointDesc::get_stiffness
107 // Access: Published
108 // Description:
109 ////////////////////////////////////////////////////////////////////
110 float PhysxPulleyJointDesc::
111 get_stiffness() const {
112 
113  return _desc.stiffness;
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: PhysxPulleyJointDesc::get_ratio
118 // Access: Published
119 // Description:
120 ////////////////////////////////////////////////////////////////////
121 float PhysxPulleyJointDesc::
122 get_ratio() const {
123 
124  return _desc.ratio;
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: PhysxPulleyJointDesc::get_flag
129 // Access: Published
130 // Description:
131 ////////////////////////////////////////////////////////////////////
132 bool PhysxPulleyJointDesc::
133 get_flag(PhysxPulleyJointFlag flag) const {
134 
135  return (_desc.flags & flag) ? true : false;
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: PhysxPulleyJointDesc::get_pulley
140 // Access: Published
141 // Description:
142 ////////////////////////////////////////////////////////////////////
143 LPoint3f PhysxPulleyJointDesc::
144 get_pulley(unsigned int idx) const {
145 
146  nassertr_always(idx < 2, LPoint3f::zero());
147  return PhysxManager::nxVec3_to_point3(_desc.pulley[idx]);
148 }
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: PhysxPulleyJointDesc::get_motor
152 // Access: Published
153 // Description:
154 ////////////////////////////////////////////////////////////////////
155 PhysxMotorDesc PhysxPulleyJointDesc::
156 get_motor() const {
157 
158  PhysxMotorDesc value;
159  value._desc = _desc.motor;
160  return value;
161 }
162 
void set_motor(const PhysxMotorDesc &motor)
Sets an optional joint motor.
Describes a joint motor.
void set_pulley(unsigned int idx, const LPoint3f pos)
Sets the suspension points of two bodies in world space.
static const LPoint3f & zero()
Returns a zero-length point.
Definition: lpoint3.h:258
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:77
void set_distance(float distance)
Sets the rest length of the rope connecting the two objects.
void set_ratio(float ration)
Sets the transmission ratio.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
void set_stiffness(float stiffness)
Sets how stiff the constraint is, between 0 and 1 (stiffest)
void set_flag(PhysxPulleyJointFlag flag, bool value)
Sets or clears a single PulleyJointFlag flag.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:88