Panda3D
Loading...
Searching...
No Matches
physxPulleyJointDesc.cxx
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 physxPulleyJointDesc.cxx
10 * @author enn0x
11 * @date 2009-09-28
12 */
13
15#include "physxMotorDesc.h"
16#include "physxManager.h"
17
18/**
19 * Sets the rest length of the rope connecting the two objects.
20 */
22set_distance(float distance) {
23
24 _desc.distance = distance;
25}
26
27/**
28 * Sets how stiff the constraint is, between 0 and 1 (stiffest)
29 */
31set_stiffness(float stiffness) {
32
33 _desc.stiffness = stiffness;
34}
35
36/**
37 * Sets the transmission ratio.
38 */
40set_ratio(float ratio) {
41
42 _desc.ratio = ratio;
43}
44
45/**
46 * Sets or clears a single PulleyJointFlag flag.
47 */
49set_flag(PhysxPulleyJointFlag flag, bool value) {
50
51 if (value == true) {
52 _desc.flags |= flag;
53 }
54 else {
55 _desc.flags &= ~(flag);
56 }
57}
58
59/**
60 * Sets the suspension points of two bodies in world space.
61 */
63set_pulley(unsigned int idx, const LPoint3f pos) {
64
65 nassertv_always(idx < 2);
66 _desc.pulley[idx] = PhysxManager::point3_to_nxVec3(pos);
67}
68
69/**
70 * Sets an optional joint motor.
71 */
73set_motor(const PhysxMotorDesc &motor) {
74
75 _desc.motor = motor._desc;
76}
77
78/**
79 *
80 */
81float PhysxPulleyJointDesc::
82get_distance() const {
83
84 return _desc.distance;
85}
86
87/**
88 *
89 */
90float PhysxPulleyJointDesc::
91get_stiffness() const {
92
93 return _desc.stiffness;
94}
95
96/**
97 *
98 */
99float PhysxPulleyJointDesc::
100get_ratio() const {
101
102 return _desc.ratio;
103}
104
105/**
106 *
107 */
108bool PhysxPulleyJointDesc::
109get_flag(PhysxPulleyJointFlag flag) const {
110
111 return (_desc.flags & flag) ? true : false;
112}
113
114/**
115 *
116 */
117LPoint3f PhysxPulleyJointDesc::
118get_pulley(unsigned int idx) const {
119
120 nassertr_always(idx < 2, LPoint3f::zero());
121 return PhysxManager::nxVec3_to_point3(_desc.pulley[idx]);
122}
123
124/**
125 *
126 */
127PhysxMotorDesc PhysxPulleyJointDesc::
128get_motor() const {
129
130 PhysxMotorDesc value;
131 value._desc = _desc.motor;
132 return value;
133}
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Describes a joint motor.
void set_distance(float distance)
Sets the rest length of the rope connecting the two objects.
void set_pulley(unsigned int idx, const LPoint3f pos)
Sets the suspension points of two bodies in world space.
void set_ratio(float ration)
Sets the transmission ratio.
void set_flag(PhysxPulleyJointFlag flag, bool value)
Sets or clears a single PulleyJointFlag flag.
void set_motor(const PhysxMotorDesc &motor)
Sets an optional joint motor.
void set_stiffness(float stiffness)
Sets how stiff the constraint is, between 0 and 1 (stiffest)
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.