PxJoint.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_JOINTCONSTRAINT_H
00032 #define PX_JOINTCONSTRAINT_H
00033 
00037 #include "foundation/PxTransform.h"
00038 #include "PxRigidActor.h"
00039 #include "PxConstraint.h"
00040 #include "common/PxBase.h"
00041 
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046 
00047 class PxRigidActor;
00048 class PxScene;
00049 class PxPhysics;
00050 class PxConstraint;
00051 
00057 struct PxJointConcreteType
00058 {
00059     enum Enum
00060     {
00061         eSPHERICAL = PxConcreteType::eFIRST_PHYSX_EXTENSION,
00062         eREVOLUTE,
00063         ePRISMATIC,
00064         eFIXED,
00065         eDISTANCE,
00066         eD6,
00067         eLast
00068     };
00069 };
00070 
00071 PX_DEFINE_TYPEINFO(PxJoint,             PxConcreteType::eUNDEFINED)
00072 PX_DEFINE_TYPEINFO(PxD6Joint,           PxJointConcreteType::eD6)
00073 PX_DEFINE_TYPEINFO(PxDistanceJoint,     PxJointConcreteType::eDISTANCE)
00074 PX_DEFINE_TYPEINFO(PxFixedJoint,        PxJointConcreteType::eFIXED)
00075 PX_DEFINE_TYPEINFO(PxPrismaticJoint,    PxJointConcreteType::ePRISMATIC)
00076 PX_DEFINE_TYPEINFO(PxRevoluteJoint,     PxJointConcreteType::eREVOLUTE)
00077 PX_DEFINE_TYPEINFO(PxSphericalJoint,    PxJointConcreteType::eSPHERICAL)
00078 
00085 struct PxJointActorIndex
00086 {
00087     enum Enum
00088     {
00089         eACTOR0,
00090         eACTOR1,
00091         COUNT
00092     };
00093 };
00094 
00099 class PxJoint : public PxBase
00100 {
00101 //= ATTENTION! =====================================================================================
00102 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00103 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00104 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00105 // accordingly.
00106 //==================================================================================================
00107 public:
00108 
00120     virtual void                setActors(PxRigidActor* actor0, PxRigidActor* actor1)           = 0;
00121 
00131     virtual void                getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const   = 0;
00132 
00144     virtual void                setLocalPose(PxJointActorIndex::Enum actor, const PxTransform& localPose) = 0;
00145 
00156     virtual PxTransform         getLocalPose(PxJointActorIndex::Enum actor) const = 0;
00157 
00158 
00166     virtual PxTransform         getRelativeTransform()              const   = 0;
00167 
00175     virtual PxVec3              getRelativeLinearVelocity()         const   = 0;
00176 
00183     virtual PxVec3              getRelativeAngularVelocity()        const   = 0;
00184 
00185 
00198     virtual void                setBreakForce(PxReal force, PxReal torque)                      = 0;
00199 
00208     virtual void                getBreakForce(PxReal& force, PxReal& torque)            const   = 0;
00209 
00217     virtual void                setConstraintFlags(PxConstraintFlags flags)                     = 0;
00218 
00227     virtual void                setConstraintFlag(PxConstraintFlag::Enum flag, bool value)      = 0;
00228 
00229 
00237     virtual PxConstraintFlags   getConstraintFlags()                                    const   = 0;
00238 
00239 
00240 
00248     virtual void                setInvMassScale0(PxReal invMassScale)                           = 0;
00249 
00258     virtual PxReal              getInvMassScale0() const                                        = 0;
00259 
00268     virtual void                setInvInertiaScale0(PxReal invInertiaScale)                     = 0;
00269 
00277     virtual PxReal              getInvInertiaScale0() const                                     = 0;
00278 
00279 
00287     virtual void                setInvMassScale1(PxReal invMassScale)                           = 0;
00288 
00297     virtual PxReal              getInvMassScale1() const                                        = 0;
00298 
00307     virtual void                setInvInertiaScale1(PxReal invInertiaScale)                     = 0;
00308 
00316     virtual PxReal              getInvInertiaScale1() const                                     = 0;
00317 
00318 
00327     virtual PxConstraint*       getConstraint()                                         const   = 0;
00328 
00340     virtual void                setName(const char* name)                                       = 0;
00341 
00350     virtual const char*         getName()                                               const   = 0;
00351 
00358     virtual void                release()                                                       = 0;
00359 
00360 
00361 
00369     virtual PxScene*            getScene()                                              const   = 0;
00370 
00371     void*                       userData;   
00372 
00373     //serialization
00374 
00378     static  void                getBinaryMetaData(PxOutputStream& stream);
00379 
00380     //~serialization
00381                     
00382 protected:
00383     virtual                     ~PxJoint() {}
00384 
00385     //serialization
00386 
00390     PX_INLINE                   PxJoint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
00391     
00395     PX_INLINE                   PxJoint(PxBaseFlags baseFlags)  : PxBase(baseFlags) {}
00396 
00400     virtual bool                isKindOf(const char* name) const { return !::strcmp("PxJoint", name) || PxBase::isKindOf(name); }
00401 
00402     //~serialization
00403 };
00404 
00405 class PxSpring
00406 {
00407 //= ATTENTION! =====================================================================================
00408 // Changing the data layout of this class breaks the binary serialization format.  See comments for 
00409 // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData 
00410 // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
00411 // accordingly.
00412 //==================================================================================================
00413 public:
00414 
00415     PxReal                  stiffness;          
00416     PxReal                  damping;            
00417 
00418     PxSpring(PxReal stiffness_, PxReal damping_): stiffness(stiffness_), damping(damping_) {}
00419 };
00420 
00421 
00422 #if !PX_DOXYGEN
00423 } // namespace physx
00424 #endif
00425 
00440 PX_C_EXPORT void PX_CALL_CONV PxSetJointGlobalFrame(physx::PxJoint& joint, const physx::PxVec3* wsAnchor, const physx::PxVec3* wsAxis);
00441 
00443 #endif


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