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 NV_CLOTH_EXTENSIONS_CLOTH_FABRIC_COOKER_H
00032 #define NV_CLOTH_EXTENSIONS_CLOTH_FABRIC_COOKER_H
00033
00038 #include "ClothMeshDesc.h"
00039 #include "NvCloth/Fabric.h"
00040 #include "NvCloth/Factory.h"
00041
00042 namespace nv
00043 {
00044 namespace cloth
00045 {
00046
00047 struct CookedData
00048 {
00049 uint32_t mNumParticles;
00050 Range<const uint32_t> mPhaseIndices;
00051 Range<const int32_t> mPhaseTypes;
00052 Range<const uint32_t> mSets;
00053 Range<const float> mRestvalues;
00054 Range<const float> mStiffnessValues;
00055 Range<const uint32_t> mIndices;
00056 Range<const uint32_t> mAnchors;
00057 Range<const float> mTetherLengths;
00058 Range<const uint32_t> mTriangles;
00059 };
00060
00065 struct ClothFabricPhaseType
00066 {
00067 enum Enum
00068 {
00069 eINVALID,
00070 eVERTICAL,
00071 eHORIZONTAL,
00072 eBENDING,
00073 eSHEARING,
00074 eCOUNT
00075 };
00076 };
00077
00082 struct ClothFabricPhase
00083 {
00084 ClothFabricPhase(ClothFabricPhaseType::Enum type =
00085 ClothFabricPhaseType::eINVALID, physx::PxU32 index = 0);
00086
00090 ClothFabricPhaseType::Enum phaseType;
00091
00095 physx::PxU32 setIndex;
00096 };
00097
00098 PX_INLINE ClothFabricPhase::ClothFabricPhase(
00099 ClothFabricPhaseType::Enum type, physx::PxU32 index)
00100 : phaseType(type)
00101 , setIndex(index)
00102 {}
00103
00108 class ClothFabricDesc
00109 {
00110 public:
00112 physx::PxU32 nbParticles;
00113
00115 physx::PxU32 nbPhases;
00117 const ClothFabricPhase* phases;
00118
00120 physx::PxU32 nbSets;
00122 const physx::PxU32* sets;
00123
00125 const physx::PxU32* indices;
00127 const physx::PxReal* restvalues;
00128
00130 physx::PxU32 nbTethers;
00132 const physx::PxU32* tetherAnchors;
00134 const physx::PxReal* tetherLengths;
00135
00136 physx::PxU32 nbTriangles;
00137 const physx::PxU32* triangles;
00138
00142 PX_INLINE ClothFabricDesc();
00143
00147 PX_INLINE void setToDefault();
00148
00153 PX_INLINE bool isValid() const;
00154 };
00155
00156 PX_INLINE ClothFabricDesc::ClothFabricDesc()
00157 {
00158 setToDefault();
00159 }
00160
00161 PX_INLINE void ClothFabricDesc::setToDefault()
00162 {
00163 memset(this, 0, sizeof(ClothFabricDesc));
00164 }
00165
00166 PX_INLINE bool ClothFabricDesc::isValid() const
00167 {
00168 return nbParticles && nbPhases && phases && restvalues && nbSets
00169 && sets && indices && (!nbTethers || (tetherAnchors && tetherLengths))
00170 && (!nbTriangles || triangles);
00171 }
00172
00174 class NV_CLOTH_IMPORT ClothFabricCooker : public UserAllocated
00175 {
00176 public:
00177 virtual ~ClothFabricCooker(){}
00178
00190 virtual bool cook(const ClothMeshDesc& desc, physx::PxVec3 gravity, bool useGeodesicTether = true) = 0;
00191
00193 virtual CookedData getCookedData() const = 0;
00194
00196 virtual ClothFabricDesc getDescriptor() const = 0;
00198 virtual void save(physx::PxOutputStream& stream, bool platformMismatch) const = 0;
00199 };
00200
00203 }
00204 }
00205
00206
00207 NV_CLOTH_API(nv::cloth::ClothFabricCooker*) NvClothCreateFabricCooker();
00208
00220 NV_CLOTH_API(nv::cloth::Fabric*) NvClothCookFabricFromMesh(nv::cloth::Factory* factory,
00221 const nv::cloth::ClothMeshDesc& desc, const physx::PxVec3& gravity,
00222 nv::cloth::Vector<int32_t>::Type* phaseTypes = nullptr, bool useGeodesicTether = true);
00223
00224 #endif // NV_CLOTH_EXTENSIONS_CLOTH_FABRIC_COOKER_H