00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef PX_PHYSICS_NX_CLOTH_FABRIC
00032 #define PX_PHYSICS_NX_CLOTH_FABRIC
00033 
00038 #include "common/PxBase.h"
00039 
00040 #if !PX_DOXYGEN
00041 namespace physx
00042 {
00043 #endif
00044 
00049 struct PxClothFabricPhaseType
00050 {
00051     enum Enum
00052     {
00053         eINVALID,     
00054         eVERTICAL,    
00055         eHORIZONTAL,  
00056         eBENDING,     
00057         eSHEARING,    
00058         eCOUNT        
00059     };
00060 };
00061 
00066 struct PxClothFabricPhase
00067 {
00068     PxClothFabricPhase(PxClothFabricPhaseType::Enum type = 
00069         PxClothFabricPhaseType::eINVALID, PxU32 index = 0);
00070 
00074     PxClothFabricPhaseType::Enum phaseType;
00075 
00079     PxU32 setIndex;
00080 };
00081 
00082 PX_INLINE PxClothFabricPhase::PxClothFabricPhase(
00083     PxClothFabricPhaseType::Enum type, PxU32 index)
00084     : phaseType(type)
00085     , setIndex(index)
00086 {}
00087 
00092 class PxClothFabricDesc
00093 {
00094 public:
00096     PxU32 nbParticles;
00097 
00099     PxU32 nbPhases;
00101     const PxClothFabricPhase* phases;
00102 
00104     PxU32 nbSets;
00106     const PxU32* sets;
00107 
00109     const PxU32* indices;
00111     const PxReal* restvalues;
00112 
00114     PxU32 nbTethers;
00116     const PxU32* tetherAnchors;
00118     const PxReal* tetherLengths;
00119 
00121     const PxU32* triangles;
00123     PxU32 nbTriangles;
00124 
00128     PX_INLINE PxClothFabricDesc();
00129 
00133     PX_INLINE void setToDefault();
00134 
00139     PX_INLINE bool isValid() const;
00140 };
00141 
00142 PX_INLINE PxClothFabricDesc::PxClothFabricDesc()
00143 {
00144     setToDefault();
00145 }
00146 
00147 PX_INLINE void PxClothFabricDesc::setToDefault()
00148 {
00149     memset(this, 0, sizeof(PxClothFabricDesc));
00150 }
00151 
00152 PX_INLINE bool PxClothFabricDesc::isValid() const
00153 {
00154     return nbParticles && nbPhases && phases && restvalues && nbSets 
00155         && sets && indices && (!nbTethers || (tetherAnchors && tetherLengths))
00156         && (!nbTriangles || triangles);
00157 }
00158 
00159 
00180 class PxClothFabric : public PxBase
00181 {
00182 public:
00188     virtual void release() = 0;
00189 
00194     virtual PxU32 getNbParticles() const = 0;
00195 
00200     virtual PxU32 getNbPhases() const = 0;
00201 
00206     virtual PxU32 getNbRestvalues() const = 0;
00207 
00212     virtual PxU32 getNbSets() const = 0;
00213 
00218     virtual PxU32 getNbParticleIndices() const = 0;
00219 
00224     virtual PxU32 getNbTethers() const = 0;
00225 
00236     virtual PxU32 getPhases(PxClothFabricPhase* userPhaseBuffer, PxU32 bufferSize) const = 0;
00237 
00249     virtual PxU32 getSets(PxU32* userSetBuffer, PxU32 bufferSize) const = 0;
00250 
00261     virtual PxU32 getParticleIndices(PxU32* userParticleIndexBuffer, PxU32 bufferSize) const = 0;
00262 
00276     virtual PxU32 getRestvalues(PxReal* userRestvalueBuffer, PxU32 bufferSize) const = 0;
00277 
00290     virtual PxU32 getTetherAnchors(PxU32* userAnchorBuffer, PxU32 bufferSize) const = 0;
00291 
00303     virtual PxU32 getTetherLengths(PxReal* userLengthBuffer, PxU32 bufferSize) const = 0;
00304 
00305 
00310     virtual void scaleRestlengths(PxReal scale) = 0;
00311 
00318     virtual PxU32 getReferenceCount() const = 0;
00319 
00325     virtual void acquireReference() = 0;
00326 
00327 
00328     virtual const char* getConcreteTypeName() const { return "PxClothFabric";   }
00329 
00330 protected:
00331 
00332     PX_INLINE PxClothFabric(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
00333     PX_INLINE PxClothFabric(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
00334     virtual ~PxClothFabric() {}
00335     virtual bool isKindOf(const char* name) const { return !::strcmp("PxClothFabric", name) || PxBase::isKindOf(name); }
00336 };
00337 
00338 #if !PX_DOXYGEN
00339 } 
00340 #endif
00341 
00343 #endif