PxD6Joint.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2008-2018 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 #ifndef PX_D6JOINT_H
00032 #define PX_D6JOINT_H
00033 
00037 #include "extensions/PxJoint.h"
00038 #include "extensions/PxJointLimit.h"
00039 #include "foundation/PxFlags.h"
00040 
00041 #if !PX_DOXYGEN
00042 namespace physx
00043 {
00044 #endif
00045 
00046 class PxD6Joint;
00047 
00060 PxD6Joint*          PxD6JointCreate(PxPhysics& physics, 
00061                                     PxRigidActor* actor0, const PxTransform& localFrame0, 
00062                                     PxRigidActor* actor1, const PxTransform& localFrame1);
00063 
00064 
00065 
00066 
00073 struct PxD6Axis
00074 {
00075     enum Enum
00076     {
00077         eX      = 0,    
00078         eY      = 1,    
00079         eZ      = 2,    
00080         eTWIST  = 3,    
00081         eSWING1 = 4,    
00082         eSWING2 = 5,    
00083         eCOUNT  = 6
00084     };
00085 };
00086 
00087 
00093 struct PxD6Motion
00094 {
00095     enum Enum
00096     {
00097         eLOCKED,    
00098         eLIMITED,   
00099         eFREE       
00100     };
00101 };
00102 
00103 
00120 struct PxD6Drive
00121 {
00122     enum Enum
00123     {
00124         eX          = 0,        
00125         eY          = 1,        
00126         eZ          = 2,        
00127         eSWING      = 3,        
00128         eTWIST      = 4,        
00129         eSLERP      = 5,        
00130         eCOUNT      = 6
00131     };
00132 };
00133 
00140 struct PxD6JointDriveFlag
00141 {
00142     enum Enum
00143     {
00144         eACCELERATION   = 1 
00145     };
00146 };
00147 typedef PxFlags<PxD6JointDriveFlag::Enum, PxU32> PxD6JointDriveFlags;
00148 PX_FLAGS_OPERATORS(PxD6JointDriveFlag::Enum, PxU32)
00149 
00150 
00151 
00157 class PxD6JointDrive : public PxSpring
00158 {
00159 //= ATTENTION! =====================================================================================
00160 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00161 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00162 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00163 // accordingly.
00164 //==================================================================================================
00165 
00166 public:
00167     PxReal                  forceLimit;         
00168     PxD6JointDriveFlags     flags;              
00169 
00170 
00175     PxD6JointDrive(): PxSpring(0,0), forceLimit(PX_MAX_F32), flags(0) {}
00176 
00187     PxD6JointDrive(PxReal driveStiffness, PxReal driveDamping, PxReal driveForceLimit, bool isAcceleration = false)
00188     : PxSpring(driveStiffness, driveDamping)
00189     , forceLimit(driveForceLimit)
00190     , flags(isAcceleration?PxU32(PxD6JointDriveFlag::eACCELERATION) : 0) 
00191     {}
00192 
00197     bool isValid() const
00198     {
00199         return PxIsFinite(stiffness) && stiffness>=0 &&
00200                PxIsFinite(damping) && damping >=0 &&
00201                PxIsFinite(forceLimit) && forceLimit >=0;
00202     }
00203 };
00204 
00205 
00238 class PxD6Joint : public PxJoint
00239 {
00240 public:
00241 
00256     virtual void                setMotion(PxD6Axis::Enum axis, PxD6Motion::Enum type)           = 0;
00257 
00268     virtual PxD6Motion::Enum    getMotion(PxD6Axis::Enum axis)          const                   = 0;
00269 
00274     virtual PxReal              getTwist()                              const                   = 0;
00275 
00280     virtual PxReal              getSwingYAngle()                        const                   = 0;
00281 
00286     virtual PxReal              getSwingZAngle()                        const                   = 0;
00287 
00288 
00299     virtual void                setLinearLimit(const PxJointLinearLimit& limit)                     = 0;
00300 
00309     virtual PxJointLinearLimit  getLinearLimit()                        const                   = 0;
00310 
00311 
00323     virtual void                setTwistLimit(const PxJointAngularLimitPair& limit)             = 0;
00324 
00325 
00333     virtual PxJointAngularLimitPair getTwistLimit()                         const                   = 0;
00334 
00346     virtual void                setSwingLimit(const PxJointLimitCone& limit)                        = 0;
00347 
00355     virtual PxJointLimitCone    getSwingLimit()                         const                   = 0;
00356 
00368     virtual void                setDrive(PxD6Drive::Enum index, const PxD6JointDrive& drive)        = 0;
00369 
00377     virtual PxD6JointDrive      getDrive(PxD6Drive::Enum index) const                           = 0;
00378 
00390     virtual void                setDrivePosition(const PxTransform& pose)                       = 0;
00391 
00398     virtual PxTransform         getDrivePosition()                      const                   = 0;
00399 
00400 
00412     virtual void                setDriveVelocity(const PxVec3& linear,
00413                                                  const PxVec3& angular)                         = 0;
00414 
00424     virtual void                getDriveVelocity(PxVec3& linear,
00425                                                  PxVec3& angular)       const                   = 0;
00426     
00427 
00447     virtual void                setProjectionLinearTolerance(PxReal tolerance)                  = 0;
00448 
00449 
00458     virtual PxReal              getProjectionLinearTolerance()          const                   = 0;
00459 
00482     virtual void                setProjectionAngularTolerance(PxReal tolerance)                         = 0;
00483 
00492     virtual PxReal              getProjectionAngularTolerance()         const                   = 0;
00493 
00497     virtual const char*         getConcreteTypeName() const { return "PxD6Joint"; }
00498 
00499 
00500 protected:
00501 
00502     //serialization
00503 
00507     PX_INLINE                   PxD6Joint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
00508 
00512     PX_INLINE                   PxD6Joint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
00513 
00517     virtual bool                isKindOf(const char* name) const { return !::strcmp("PxD6Joint", name) || PxJoint::isKindOf(name); }
00518 
00519     //~serialization
00520 };
00521 
00522 #if !PX_DOXYGEN
00523 } // namespace physx
00524 #endif
00525 
00527 #endif


Copyright © 2008-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com