Panda3D
physxControllerDesc.cxx
1 // Filename: physxControllerDesc.cxx
2 // Created by: enn0x (22Sep09)
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 "physxControllerDesc.h"
16 #include "physxManager.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: PhysxControllerDesc::set_pos
20 // Access: Published
21 // Description: Set the position of the character.
22 ////////////////////////////////////////////////////////////////////
24 set_pos(const LPoint3f &pos) {
25 
26  ptr()->position = PhysxManager::point3_to_nxExtVec3(pos);
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: PhysxControllerDesc::set_slope_limit
31 // Access: Published
32 // Description: Sets the maximum slope which the character can walk
33 // up. In general it is desirable to limit where the
34 // character can walk, in particular it is unrealistic
35 // for the character to be able to climb arbitary
36 // slopes.
37 // The value is expressed in degrees.
38 // Default: 45.0 degrees.
39 ////////////////////////////////////////////////////////////////////
41 set_slope_limit(float slopeLimit) {
42 
43  ptr()->slopeLimit = cosf(NxMath::degToRad(slopeLimit));
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: PhysxControllerDesc::set_skin_width
48 // Access: Published
49 // Description: Sets the skin width used by the controller.
50 // A "skin" around the controller is necessary to
51 // avoid numerical precision issues.
52 // This is dependant on the scale of the users world,
53 // but should be a small, positive non zero value.
54 // Default: 0.1
55 ////////////////////////////////////////////////////////////////////
57 set_skin_width(float skinWidth) {
58 
59  ptr()->skinWidth = skinWidth;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: PhysxControllerDesc::set_step_offset
64 // Access: Published
65 // Description: Defines the maximum height of an obstacle which the
66 // character can climb.
67 // A small value will mean that the character gets
68 // stuck and cannot walk up stairs etc, a value which
69 // is too large will mean that the character can climb
70 // over unrealistically high obstacles.
71 // Default: 0.5
72 ////////////////////////////////////////////////////////////////////
74 set_step_offset(float stepOffset) {
75 
76  ptr()->stepOffset = stepOffset;
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: PhysxControllerDesc::set_interaction_flag
81 // Access: Published
82 // Description: The interaction flag controls if a character
83 // controller collides with other controllers.
84 // The default is to collide with other controllers.
85 ////////////////////////////////////////////////////////////////////
87 set_interaction_flag(bool interactionFlag) {
88 
89  ptr()->interactionFlag = (NxCCTInteractionFlag)interactionFlag;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: PhysxControllerDesc::get_pos
94 // Access: Published
95 // Description: Returns the position of the character.
96 ////////////////////////////////////////////////////////////////////
98 get_pos() const {
99 
100  return PhysxManager::nxExtVec3_to_point3(ptr()->position);
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: PhysxControllerDesc::get_slope_limit
105 // Access: Published
106 // Description: Returns the maximum slope which the character can
107 // walk up.
108 ////////////////////////////////////////////////////////////////////
111 
112  return NxMath::radToDeg(acosf(ptr()->slopeLimit));
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: PhysxControllerDesc::get_skin_width
117 // Access: Published
118 // Description: Returns the skin width used by the controller.
119 ////////////////////////////////////////////////////////////////////
121 get_skin_width() const {
122 
123  return ptr()->skinWidth;
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: PhysxControllerDesc::get_step_offset
128 // Access: Published
129 // Description: Returns the maximum height of an obstacle which the
130 // character can climb.
131 ////////////////////////////////////////////////////////////////////
134 
135  return ptr()->stepOffset;
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: PhysxControllerDesc::get_interaction_flag
140 // Access: Published
141 // Description: Returns the interaction flag.
142 ////////////////////////////////////////////////////////////////////
145 
146  return (ptr()->interactionFlag) ? true : false;
147 }
148 
float get_slope_limit() const
Returns the maximum slope which the character can walk up.
bool get_interaction_flag() const
Returns the interaction flag.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
void set_pos(const LPoint3f &pos)
Set the position of the character.
static NxExtendedVec3 point3_to_nxExtVec3(const LPoint3f &p)
Converts from LPoint3f to NxExtendedVec3.
Definition: physxManager.I:99
void set_slope_limit(float slopeLimit)
Sets the maximum slope which the character can walk up.
float get_skin_width() const
Returns the skin width used by the controller.
static LPoint3f nxExtVec3_to_point3(const NxExtendedVec3 &p)
Converts from NxExtendedVec3 to LPoint3f.
Definition: physxManager.I:110
LPoint3f get_pos() const
Returns the position of the character.
void set_step_offset(float setpOffset)
Defines the maximum height of an obstacle which the character can climb.
void set_interaction_flag(bool interactionFlag)
The interaction flag controls if a character controller collides with other controllers.
void set_skin_width(float skinWidth)
Sets the skin width used by the controller.
float get_step_offset() const
Returns the maximum height of an obstacle which the character can climb.