Panda3D

physxControllerDesc.cxx

00001 // Filename: physxControllerDesc.cxx
00002 // Created by:  enn0x (22Sep09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "physxControllerDesc.h"
00016 #include "physxManager.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: PhysxControllerDesc::set_pos
00020 //       Access: Published
00021 //  Description: Set the position of the character.
00022 ////////////////////////////////////////////////////////////////////
00023 void PhysxControllerDesc::
00024 set_pos(const LPoint3f &pos) {
00025 
00026   ptr()->position = PhysxManager::point3_to_nxExtVec3(pos);
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: PhysxControllerDesc::set_slope_limit
00031 //       Access: Published
00032 //  Description: Sets the maximum slope which the character can walk
00033 //               up. In general it is desirable to limit where the
00034 //               character can walk, in particular it is unrealistic
00035 //               for the character to be able to climb arbitary
00036 //               slopes.
00037 //               The value is expressed in degrees.
00038 //               Default: 45.0 degrees.
00039 ////////////////////////////////////////////////////////////////////
00040 void PhysxControllerDesc::
00041 set_slope_limit(float slopeLimit) {
00042 
00043   ptr()->slopeLimit = cosf(NxMath::degToRad(slopeLimit));
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: PhysxControllerDesc::set_skin_width
00048 //       Access: Published
00049 //  Description: Sets the skin width used by the controller. 
00050 //               A "skin" around the controller is necessary to
00051 //               avoid numerical precision issues.
00052 //               This is dependant on the scale of the users world,
00053 //               but should be a small, positive non zero value.
00054 //               Default: 0.1 
00055 ////////////////////////////////////////////////////////////////////
00056 void PhysxControllerDesc::
00057 set_skin_width(float skinWidth) {
00058 
00059   ptr()->skinWidth = skinWidth;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: PhysxControllerDesc::set_step_offset
00064 //       Access: Published
00065 //  Description: Defines the maximum height of an obstacle which the
00066 //               character can climb. 
00067 //               A small value will mean that the character gets
00068 //               stuck and cannot walk up stairs etc, a value which
00069 //               is too large will mean that the character can climb
00070 //               over unrealistically high obstacles.
00071 //               Default: 0.5
00072 ////////////////////////////////////////////////////////////////////
00073 void PhysxControllerDesc::
00074 set_step_offset(float stepOffset) {
00075 
00076   ptr()->stepOffset = stepOffset;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: PhysxControllerDesc::set_interaction_flag
00081 //       Access: Published
00082 //  Description: The interaction flag controls if a character
00083 //               controller collides with other controllers.
00084 //               The default is to collide with other controllers.
00085 ////////////////////////////////////////////////////////////////////
00086 void PhysxControllerDesc::
00087 set_interaction_flag(bool interactionFlag) {
00088 
00089   ptr()->interactionFlag = (NxCCTInteractionFlag)interactionFlag;
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: PhysxControllerDesc::get_pos
00094 //       Access: Published
00095 //  Description: Returns the position of the character.
00096 ////////////////////////////////////////////////////////////////////
00097 LPoint3f PhysxControllerDesc::
00098 get_pos() const {
00099 
00100   return PhysxManager::nxExtVec3_to_point3(ptr()->position);
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: PhysxControllerDesc::get_slope_limit
00105 //       Access: Published
00106 //  Description: Returns the maximum slope which the character can
00107 //               walk up.
00108 ////////////////////////////////////////////////////////////////////
00109 float PhysxControllerDesc::
00110 get_slope_limit() const {
00111 
00112   return NxMath::radToDeg(acosf(ptr()->slopeLimit));
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: PhysxControllerDesc::get_skin_width
00117 //       Access: Published
00118 //  Description: Returns the skin width used by the controller. 
00119 ////////////////////////////////////////////////////////////////////
00120 float PhysxControllerDesc::
00121 get_skin_width() const {
00122 
00123   return ptr()->skinWidth;
00124 }
00125 
00126 ////////////////////////////////////////////////////////////////////
00127 //     Function: PhysxControllerDesc::get_step_offset
00128 //       Access: Published
00129 //  Description: Returns the maximum height of an obstacle which the
00130 //               character can climb. 
00131 ////////////////////////////////////////////////////////////////////
00132 float PhysxControllerDesc::
00133 get_step_offset() const {
00134 
00135   return ptr()->stepOffset;
00136 }
00137 
00138 ////////////////////////////////////////////////////////////////////
00139 //     Function: PhysxControllerDesc::get_interaction_flag
00140 //       Access: Published
00141 //  Description: Returns the interaction flag.
00142 ////////////////////////////////////////////////////////////////////
00143 bool PhysxControllerDesc::
00144 get_interaction_flag() const {
00145 
00146   return (ptr()->interactionFlag) ? true : false;
00147 }
00148 
 All Classes Functions Variables Enumerations