PxController.h
Go to the documentation of this file.00001 // This code contains NVIDIA Confidential Information and is disclosed to you 00002 // under a form of NVIDIA software license agreement provided separately to you. 00003 // 00004 // Notice 00005 // NVIDIA Corporation and its licensors retain all intellectual property and 00006 // proprietary rights in and to this software and related documentation and 00007 // any modifications thereto. Any use, reproduction, disclosure, or 00008 // distribution of this software and related documentation without an express 00009 // license agreement from NVIDIA Corporation is strictly prohibited. 00010 // 00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES 00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, 00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. 00015 // 00016 // Information and code furnished is believed to be accurate and reliable. 00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such 00018 // information or for any infringement of patents or other rights of third parties that may 00019 // result from its use. No license is granted by implication or otherwise under any patent 00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice. 00021 // This code supersedes and replaces all information previously supplied. 00022 // NVIDIA Corporation products are not authorized for use as critical 00023 // components in life support devices or systems without express written approval of 00024 // NVIDIA Corporation. 00025 // 00026 // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved. 00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. 00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. 00029 00030 00031 00032 #ifndef PX_PHYSICS_CCT_CONTROLLER 00033 #define PX_PHYSICS_CCT_CONTROLLER 00034 00038 #include "characterkinematic/PxCharacter.h" 00039 #include "characterkinematic/PxExtended.h" 00040 #include "PxSceneQueryFiltering.h" 00041 00042 #ifndef PX_DOXYGEN 00043 namespace physx 00044 { 00045 #endif 00046 00050 struct PxControllerShapeType 00051 { 00052 enum Enum 00053 { 00059 eBOX, 00060 00066 eCAPSULE, 00067 00068 eFORCE_DWORD = 0x7fffffff 00069 }; 00070 }; 00071 00072 class PxShape; 00073 class PxScene; 00074 class PxController; 00075 class PxRigidDynamic; 00076 class PxMaterial; 00077 struct PxFilterData; 00078 class PxSceneQueryFilterCallback; 00079 class PxControllerBehaviorCallback; 00080 class PxObstacleContext; 00081 class PxObstacle; 00082 00091 struct PxCCTInteractionMode 00092 { 00093 enum Enum 00094 { 00095 eINCLUDE, 00096 eEXCLUDE, 00097 00109 eUSE_FILTER, 00110 }; 00111 }; 00112 00119 struct PxCCTNonWalkableMode 00120 { 00121 enum Enum 00122 { 00123 ePREVENT_CLIMBING, 00124 eFORCE_SLIDING, 00125 }; 00126 }; 00127 00131 struct PxControllerFlag 00132 { 00133 enum Enum 00134 { 00135 eCOLLISION_SIDES = (1<<0), 00136 eCOLLISION_UP = (1<<1), 00137 eCOLLISION_DOWN = (1<<2), 00138 }; 00139 }; 00140 00144 struct PxControllerState 00145 { 00146 PxVec3 deltaXP; 00147 PxShape* touchedShape; // Shape on which the CCT is standing 00148 PxObstacle* touchedObstacle; // Obstacle on which the CCT is standing 00149 PxU32 collisionFlags; // Last known collision flags (PxControllerFlag) 00150 bool standOnAnotherCCT; // Are we standing on another CCT? 00151 bool standOnObstacle; // Are we standing on a user-defined obstacle? 00152 bool isMovingUp; // is CCT moving up or not? (i.e. explicit jumping) 00153 }; 00154 00158 struct PxControllerStats 00159 { 00160 PxU16 nbIterations; 00161 PxU16 nbFullUpdates; 00162 PxU16 nbPartialUpdates; 00163 }; 00164 00168 struct PxCCTHit 00169 { 00170 PxController* controller; 00171 PxExtendedVec3 worldPos; 00172 PxVec3 worldNormal; 00173 PxVec3 dir; 00174 PxF32 length; 00175 }; 00176 00182 struct PxControllerShapeHit : PxCCTHit 00183 { 00184 PxShape* shape; 00185 PxU32 triangleIndex; 00186 }; 00187 00193 struct PxControllersHit : PxCCTHit 00194 { 00195 PxController* other; 00196 }; 00197 00203 struct PxControllerObstacleHit : PxCCTHit 00204 { 00205 const void* userData; 00206 }; 00207 00215 class PxUserControllerHitReport 00216 { 00217 public: 00218 00226 virtual void onShapeHit(const PxControllerShapeHit& hit) = 0; 00227 00235 virtual void onControllerHit(const PxControllersHit& hit) = 0; 00236 00244 virtual void onObstacleHit(const PxControllerObstacleHit& hit) = 0; 00245 00246 protected: 00247 virtual ~PxUserControllerHitReport(){} 00248 }; 00249 00250 00256 class PxControllerFilters 00257 { 00258 public: 00259 PX_INLINE PxControllerFilters(PxU32 groups=0xffffffff, const PxFilterData* filterData=NULL, PxSceneQueryFilterCallback* cb=NULL) : 00260 mActiveGroups (groups), 00261 mFilterData (filterData), 00262 mFilterCallback (cb), 00263 mFilterFlags (PxSceneQueryFilterFlag::eSTATIC|PxSceneQueryFilterFlag::eDYNAMIC|PxSceneQueryFilterFlag::ePREFILTER) 00264 {} 00265 00266 PxU32 mActiveGroups; 00267 const PxFilterData* mFilterData; 00268 PxSceneQueryFilterCallback* mFilterCallback; 00269 PxSceneQueryFilterFlags mFilterFlags; 00270 }; 00271 00272 00278 class PxControllerDesc 00279 { 00280 protected: 00281 00282 PxControllerShapeType::Enum type; 00283 00287 PX_INLINE PxControllerDesc(PxControllerShapeType::Enum); 00288 PX_INLINE virtual ~PxControllerDesc(); 00289 public: 00290 00296 PX_INLINE virtual bool isValid() const; 00297 00305 PX_INLINE PxControllerShapeType::Enum getType() const { return type; } 00306 00312 PxExtendedVec3 position; 00313 00322 PxVec3 upDirection; 00323 00336 PxF32 slopeLimit; 00337 00349 PxF32 invisibleWallHeight; 00350 00374 PxF32 maxJumpHeight; 00375 00387 PxF32 contactOffset; 00388 00400 PxF32 stepOffset; 00401 00409 PxF32 density; 00410 00419 PxF32 scaleCoeff; 00420 00429 PxF32 volumeGrowth; 00430 00442 PxUserControllerHitReport* callback; 00443 00455 PxControllerBehaviorCallback* behaviorCallback; 00456 00466 PxCCTInteractionMode::Enum interactionMode; 00467 00477 PxCCTNonWalkableMode::Enum nonWalkableMode; 00478 00486 PxU32 groupsBitmask; 00487 00497 PxMaterial* material; 00498 00504 void* userData; 00505 }; 00506 00507 PX_INLINE PxControllerDesc::PxControllerDesc(PxControllerShapeType::Enum t) : type(t) 00508 { 00509 upDirection = PxVec3(0.0f, 1.0f, 0.0f); 00510 slopeLimit = 0.707f; 00511 contactOffset = 0.1f; 00512 stepOffset = 0.5f; 00513 density = 10.0f; 00514 scaleCoeff = 0.8f; 00515 volumeGrowth = 1.5f; 00516 callback = NULL; 00517 behaviorCallback = NULL; 00518 userData = NULL; 00519 interactionMode = PxCCTInteractionMode::eINCLUDE; 00520 nonWalkableMode = PxCCTNonWalkableMode::ePREVENT_CLIMBING; 00521 groupsBitmask = 0xffffffff; 00522 position.x = PxExtended(0.0); 00523 position.y = PxExtended(0.0); 00524 position.z = PxExtended(0.0); 00525 material = NULL; 00526 invisibleWallHeight = 0.0f; 00527 maxJumpHeight = 0.0f; 00528 } 00529 00530 PX_INLINE PxControllerDesc::~PxControllerDesc() 00531 { 00532 } 00533 00534 PX_INLINE bool PxControllerDesc::isValid() const 00535 { 00536 if(scaleCoeff<0.0f) return false; 00537 if(volumeGrowth<1.0f) return false; 00538 if(density<0.0f) return false; 00539 if(slopeLimit<0.0f) return false; 00540 if(stepOffset<0.0f) return false; 00541 if(contactOffset<0.0f) return false; 00542 if(!material) return false; 00543 return true; 00544 } 00545 00546 00552 class PxController 00553 { 00554 protected: 00555 PX_INLINE PxController() {} 00556 virtual ~PxController() {} 00557 00558 public: 00559 00565 virtual PxControllerShapeType::Enum getType() = 0; 00566 00570 virtual void release() = 0; 00571 00583 virtual PxU32 move(const PxVec3& disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters& filters, const PxObstacleContext* obstacles=NULL) = 0; 00584 00599 virtual bool setPosition(const PxExtendedVec3& position) = 0; 00600 00614 virtual const PxExtendedVec3& getPosition() const = 0; 00615 00630 virtual bool setFootPosition(const PxExtendedVec3& position) = 0; 00631 00639 virtual PxExtendedVec3 getFootPosition() const = 0; 00640 00648 virtual PxRigidDynamic* getActor() const = 0; 00649 00657 virtual void setStepOffset(const PxF32 offset) =0; 00658 00666 virtual PxF32 getStepOffset() const =0; 00667 00675 virtual void setInteraction(PxCCTInteractionMode::Enum flag) = 0; 00676 00684 virtual PxCCTInteractionMode::Enum getInteraction() const = 0; 00685 00693 virtual void setNonWalkableMode(PxCCTNonWalkableMode::Enum flag) = 0; 00694 00702 virtual PxCCTNonWalkableMode::Enum getNonWalkableMode() const = 0; 00703 00711 virtual void setGroupsBitmask(PxU32 bitmask) = 0; 00712 00720 virtual PxU32 getGroupsBitmask() const = 0; 00721 00729 virtual PxF32 getContactOffset() const =0; 00730 00738 virtual PxVec3 getUpDirection() const =0; 00739 00747 virtual void setUpDirection(const PxVec3& up) =0; 00748 00756 virtual PxF32 getSlopeLimit() const =0; 00757 00771 virtual void invalidateCache() = 0; 00772 00778 virtual PxScene* getScene() = 0; 00779 00787 virtual void* getUserData() const = 0; 00788 00796 virtual void getState(PxControllerState& state) const = 0; 00797 00805 virtual void getStats(PxControllerStats& stats) const = 0; 00806 00817 virtual void resize(PxReal height) = 0; 00818 }; 00819 00820 #ifndef PX_DOXYGEN 00821 } // namespace physx 00822 #endif 00823 00825 #endif
Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com