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
14#include "physxPulleyJointDesc.h"
15#include "physxMotorDesc.h"
16#include "physxManager.h"
17
18/**
19 * Sets the rest length of the rope connecting the two objects.
20 */
21 void PhysxPulleyJointDesc::
22 set_distance(float distance) {
23
24 _desc.distance = distance;
25}
26
27/**
28 * Sets how stiff the constraint is, between 0 and 1 (stiffest)
29 */
30 void PhysxPulleyJointDesc::
31 set_stiffness(float stiffness) {
32
33 _desc.stiffness = stiffness;
34}
35
36/**
37 * Sets the transmission ratio.
38 */
39 void PhysxPulleyJointDesc::
40 set_ratio(float ratio) {
41
42 _desc.ratio = ratio;
43}
44
45/**
46 * Sets or clears a single PulleyJointFlag flag.
47 */
48 void PhysxPulleyJointDesc::
49 set_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 */
62 void PhysxPulleyJointDesc::
63 set_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 */
72 void PhysxPulleyJointDesc::
73 set_motor(const PhysxMotorDesc &motor) {
74
75 _desc.motor = motor._desc;
76}
77
78/**
79 *
80 */
81 float PhysxPulleyJointDesc::
82get_distance() const {
83
84 return _desc.distance;
85}
86
87/**
88 *
89 */
90 float PhysxPulleyJointDesc::
91get_stiffness() const {
92
93 return _desc.stiffness;
94}
95
96/**
97 *
98 */
99 float PhysxPulleyJointDesc::
100get_ratio() const {
101
102 return _desc.ratio;
103}
104
105/**
106 *
107 */
108 bool 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 */
127 PhysxMotorDesc PhysxPulleyJointDesc::
128get_motor() const {
129
130 PhysxMotorDesc value;
131 value._desc = _desc.motor;
132 return value;
133}
PhysxManager::point3_to_nxVec3
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition physxManager.I:63
PhysxManager::nxVec3_to_point3
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition physxManager.I:72
PhysxMotorDesc
Describes a joint motor.
Definition physxMotorDesc.h:26
PhysxPulleyJointDesc::set_distance
void set_distance(float distance)
Sets the rest length of the rope connecting the two objects.
Definition physxPulleyJointDesc.cxx:22
PhysxPulleyJointDesc::set_pulley
void set_pulley(unsigned int idx, const LPoint3f pos)
Sets the suspension points of two bodies in world space.
Definition physxPulleyJointDesc.cxx:63
PhysxPulleyJointDesc::set_ratio
void set_ratio(float ration)
Sets the transmission ratio.
Definition physxPulleyJointDesc.cxx:40
PhysxPulleyJointDesc::set_flag
void set_flag(PhysxPulleyJointFlag flag, bool value)
Sets or clears a single PulleyJointFlag flag.
Definition physxPulleyJointDesc.cxx:49
PhysxPulleyJointDesc::set_motor
void set_motor(const PhysxMotorDesc &motor)
Sets an optional joint motor.
Definition physxPulleyJointDesc.cxx:73
PhysxPulleyJointDesc::set_stiffness
void set_stiffness(float stiffness)
Sets how stiff the constraint is, between 0 and 1 (stiffest)
Definition physxPulleyJointDesc.cxx:31
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxMotorDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxPulleyJointDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.