Panda3D
Loading...
Searching...
No Matches
physxSphericalJointDesc.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 physxSphericalJointDesc.cxx
10 * @author enn0x
11 * @date 2009-09-28
12 */
13
15#include "physxManager.h"
16#include "physxSpringDesc.h"
17#include "physxJointLimitDesc.h"
18
19/**
20 * Set the distance above which to project joint.
21 */
23set_projection_distance(float distance) {
24
25 _desc.projectionDistance = distance;
26}
27
28/**
29 * Sets or clears a single SphericalJointFlag flag.
30 */
32set_flag(PhysxSphericalJointFlag flag, bool value) {
33
34 if (value == true) {
35 _desc.flags |= flag;
36 }
37 else {
38 _desc.flags &= ~(flag);
39 }
40}
41
42/**
43 * Sets a spring that works against twisting.
44 */
46set_twist_spring(const PhysxSpringDesc &spring) {
47
48 _desc.twistSpring = spring._desc;
49}
50
51/**
52 * Sets a spring that works against swinging.
53 */
55set_swing_spring(const PhysxSpringDesc &spring) {
56
57 _desc.swingSpring = spring._desc;
58}
59
60/**
61 * Sets a spring that lets the joint get pulled apart.
62 */
64set_joint_spring(const PhysxSpringDesc &spring) {
65
66 _desc.jointSpring = spring._desc;
67}
68
69/**
70 * Set the swing limit axis defined in the joint space of actor 0.
71 */
73set_swing_axis(const LVector3f &axis) {
74
75 nassertv( !axis.is_nan() );
76 _desc.swingAxis = PhysxManager::vec3_to_nxVec3(axis);
77}
78
79/**
80 * Use this to enable joint projection. Default is PM_none.
81 */
83set_projection_mode(PhysxProjectionMode mode) {
84
85 _desc.projectionMode = (NxJointProjectionMode)mode;
86}
87
88/**
89 * Limits rotation around twist axis.
90 */
93
94 _desc.twistLimit.low = low._desc;
95}
96
97/**
98 * Limits rotation around twist axis.
99 */
102
103 _desc.twistLimit.high = high._desc;
104}
105
106/**
107 * Limits swing of twist axis.
108 */
111
112 _desc.swingLimit = limit._desc;
113}
114
115/**
116 *
117 */
118float PhysxSphericalJointDesc::
119get_projection_distance() const {
120
121 return _desc.projectionDistance;
122}
123
124/**
125 *
126 */
127bool PhysxSphericalJointDesc::
128get_flag(PhysxSphericalJointFlag flag) const {
129
130 return (_desc.flags & flag) ? true : false;
131}
132
133/**
134 *
135 */
136PhysxSpringDesc PhysxSphericalJointDesc::
137get_twist_spring() const {
138
139 PhysxSpringDesc value;
140 value._desc = _desc.twistSpring;
141 return value;
142}
143
144/**
145 *
146 */
147PhysxSpringDesc PhysxSphericalJointDesc::
148get_swing_spring() const {
149
150 PhysxSpringDesc value;
151 value._desc = _desc.swingSpring;
152 return value;
153}
154
155/**
156 *
157 */
158PhysxSpringDesc PhysxSphericalJointDesc::
159get_joint_spring() const {
160
161 PhysxSpringDesc value;
162 value._desc = _desc.jointSpring;
163 return value;
164}
165
166/**
167 *
168 */
169LVector3f PhysxSphericalJointDesc::
170get_swing_axis() const {
171
172 return PhysxManager::nxVec3_to_vec3(_desc.swingAxis);
173}
174
175/**
176 *
177 */
178PhysxEnums::PhysxProjectionMode PhysxSphericalJointDesc::
179get_projection_mode() const {
180
181 return (PhysxProjectionMode)_desc.projectionMode;
182}
183
184/**
185 *
186 */
187PhysxJointLimitDesc PhysxSphericalJointDesc::
188get_twist_limit_low() const {
189
191 value._desc = _desc.twistLimit.low;
192 return value;
193}
194
195/**
196 *
197 */
198PhysxJointLimitDesc PhysxSphericalJointDesc::
199get_twist_limit_high() const {
200
202 value._desc = _desc.twistLimit.high;
203 return value;
204}
205
206/**
207 * Limits swing of twist axis.
208 */
210get_swing_limit() const {
211
213 value._desc = _desc.swingLimit;
214 return value;
215}
Describes a joint limit.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
void set_twist_limit_low(const PhysxJointLimitDesc &low)
Limits rotation around twist axis.
void set_swing_limit(const PhysxJointLimitDesc &limit)
Limits swing of twist axis.
void set_projection_distance(float distance)
Set the distance above which to project joint.
void set_projection_mode(PhysxProjectionMode mode)
Use this to enable joint projection.
void set_joint_spring(const PhysxSpringDesc &spring)
Sets a spring that lets the joint get pulled apart.
void set_swing_spring(const PhysxSpringDesc &spring)
Sets a spring that works against swinging.
void set_twist_spring(const PhysxSpringDesc &spring)
Sets a spring that works against twisting.
void set_swing_axis(const LVector3f &axis)
Set the swing limit axis defined in the joint space of actor 0.
void set_twist_limit_high(const PhysxJointLimitDesc &high)
Limits rotation around twist axis.
void set_flag(PhysxSphericalJointFlag flag, bool value)
Sets or clears a single SphericalJointFlag flag.
PhysxJointLimitDesc get_swing_limit() const
Limits swing of twist axis.
Describes a joint spring.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.