Panda3D
Loading...
Searching...
No Matches
physxControllerDesc.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 physxControllerDesc.cxx
10 * @author enn0x
11 * @date 2009-09-22
12 */
13
14#include "physxControllerDesc.h"
15#include "physxManager.h"
16
17/**
18 * Set the position of the character.
19 */
21set_pos(const LPoint3f &pos) {
22
23 ptr()->position = PhysxManager::point3_to_nxExtVec3(pos);
24}
25
26/**
27 * Sets the maximum slope which the character can walk up. In general it is
28 * desirable to limit where the character can walk, in particular it is
29 * unrealistic for the character to be able to climb arbitary slopes. The
30 * value is expressed in degrees. Default: 45.0 degrees.
31 */
33set_slope_limit(float slopeLimit) {
34
35 ptr()->slopeLimit = cosf(NxMath::degToRad(slopeLimit));
36}
37
38/**
39 * Sets the skin width used by the controller. A "skin" around the controller
40 * is necessary to avoid numerical precision issues. This is dependant on the
41 * scale of the users world, but should be a small, positive non zero value.
42 * Default: 0.1
43 */
45set_skin_width(float skinWidth) {
46
47 ptr()->skinWidth = skinWidth;
48}
49
50/**
51 * Defines the maximum height of an obstacle which the character can climb. A
52 * small value will mean that the character gets stuck and cannot walk up
53 * stairs etc, a value which is too large will mean that the character can
54 * climb over unrealistically high obstacles. Default: 0.5
55 */
57set_step_offset(float stepOffset) {
58
59 ptr()->stepOffset = stepOffset;
60}
61
62/**
63 * The interaction flag controls if a character controller collides with other
64 * controllers. The default is to collide with other controllers.
65 */
67set_interaction_flag(bool interactionFlag) {
68
69 ptr()->interactionFlag = (NxCCTInteractionFlag)interactionFlag;
70}
71
72/**
73 * Returns the position of the character.
74 */
76get_pos() const {
77
78 return PhysxManager::nxExtVec3_to_point3(ptr()->position);
79}
80
81/**
82 * Returns the maximum slope which the character can walk up.
83 */
85get_slope_limit() const {
86
87 return NxMath::radToDeg(acosf(ptr()->slopeLimit));
88}
89
90/**
91 * Returns the skin width used by the controller.
92 */
94get_skin_width() const {
95
96 return ptr()->skinWidth;
97}
98
99/**
100 * Returns the maximum height of an obstacle which the character can climb.
101 */
103get_step_offset() const {
104
105 return ptr()->stepOffset;
106}
107
108/**
109 * Returns the interaction flag.
110 */
112get_interaction_flag() const {
113
114 return (ptr()->interactionFlag) ? true : false;
115}
void set_step_offset(float setpOffset)
Defines the maximum height of an obstacle which the character can climb.
void set_skin_width(float skinWidth)
Sets the skin width used by the controller.
void set_pos(const LPoint3f &pos)
Set the position of the character.
bool get_interaction_flag() const
Returns the interaction flag.
float get_skin_width() const
Returns the skin width used by the controller.
void set_interaction_flag(bool interactionFlag)
The interaction flag controls if a character controller collides with other controllers.
float get_slope_limit() const
Returns the maximum slope which the character can walk up.
void set_slope_limit(float slopeLimit)
Sets the maximum slope which the character can walk up.
float get_step_offset() const
Returns the maximum height of an obstacle which the character can climb.
LPoint3f get_pos() const
Returns the position of the character.
static NxExtendedVec3 point3_to_nxExtVec3(const LPoint3f &p)
Converts from LPoint3f to NxExtendedVec3.
static LPoint3f nxExtVec3_to_point3(const NxExtendedVec3 &p)
Converts from NxExtendedVec3 to LPoint3f.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.