Main Page   Class List   Class Members  

  • Main Page
  • Modules
  • Classes
  • Files
  • File List

ClothFabricCooker.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-2017 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 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        // internal use only
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 } // namespace cloth
00204 } // namespace nv
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
Copyright © 2016-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com