PxCloth.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 #ifndef PX_PHYSICS_NX_CLOTH
15 #define PX_PHYSICS_NX_CLOTH
16 
20 #include "PxPhysXConfig.h"
21 #include "PxActor.h"
22 #include "PxLockedData.h"
23 #include "PxFiltering.h"
24 #include "cloth/PxClothFabric.h"
25 #include "cloth/PxClothTypes.h"
27 
28 #ifndef PX_DOXYGEN
29 namespace physx
30 {
31 #endif
32 
33 class PxScene;
34 
41 {
50 
57 
65 
73 
78  PxReal stiffnessMultiplier_=1.0f, PxReal compressionLimit_=1.0f, PxReal stretchLimit_=1.0f)
79  : stiffness(stiffness_)
80  , stiffnessMultiplier(stiffnessMultiplier_)
81  , compressionLimit(compressionLimit_)
82  , stretchLimit(stretchLimit_)
83  {}
84 };
85 
92 {
101 
109 
113  PX_INLINE PxClothTetherConfig(PxReal stiffness_ = 1.0f, PxReal stretchLimit_ = 1.0f)
114  : stiffness(stiffness_), stretchLimit(stretchLimit_)
115  {}
116 };
117 
124 {
132 
140 
149 
153  PX_INLINE PxClothMotionConstraintConfig(PxReal radiiScale = 1.0f, PxReal radiiBias = 0.0f, PxReal consStiffness = 1.0f)
154  : scale(radiiScale), bias(radiiBias), stiffness(consStiffness)
155  {}
156 };
157 
172 class PxCloth : public PxActor
173 {
174 public:
179  virtual void release() = 0;
180 
185  virtual PxClothFabric* getFabric() const = 0;
186 
192  virtual PxBounds3 getWorldBounds(float inflation=1.01f) const = 0;
193 
198  virtual PxU32 getNbParticles() const = 0;
199 
220  virtual PxClothParticleData* lockParticleData(PxDataAccessFlags flags) = 0;
226  virtual PxClothParticleData* lockParticleData() const = 0;
227 
238  virtual void setParticles(const PxClothParticle* currentParticles, const PxClothParticle* previousParticles) = 0;
239 
245  virtual void setClothFlag(PxClothFlag::Enum flag, bool value) = 0;
250  virtual void setClothFlags(PxClothFlags inFlags) = 0;
255  virtual PxClothFlags getClothFlags() const = 0;
256 
260 
261 
269  virtual void setTargetPose(const PxTransform& pose) = 0;
278  virtual void setGlobalPose(const PxTransform& pose) = 0;
283  virtual PxTransform getGlobalPose() const = 0;
284 
292  virtual void setSolverFrequency(PxReal frequency) = 0;
297  virtual PxReal getSolverFrequency() const = 0;
298 
304  virtual PxReal getPreviousTimeStep() const = 0;
305 
317  virtual void setStiffnessFrequency(PxReal frequency) = 0;
323  virtual PxReal getStiffnessFrequency() const = 0;
324 
332  virtual void setLinearInertiaScale(PxVec3 scale) = 0;
337  virtual PxVec3 getLinearInertiaScale() const = 0;
345  virtual void setAngularInertiaScale(PxVec3 scale) = 0;
350  virtual PxVec3 getAngularInertiaScale() const = 0;
358  virtual void setCentrifugalInertiaScale(PxVec3 scale) = 0;
363  virtual PxVec3 getCentrifugalInertiaScale() const = 0;
368  virtual void setInertiaScale(PxReal scale) = 0;
369 
377  virtual void setDampingCoefficient(PxVec3 dampingCoefficient) = 0;
382  virtual PxVec3 getDampingCoefficient() const = 0;
383 
392  virtual void setLinearDragCoefficient(PxVec3 dragCoefficient) = 0;
397  virtual PxVec3 getLinearDragCoefficient() const = 0;
406  virtual void setAngularDragCoefficient(PxVec3 dragCoefficient) = 0;
411  virtual PxVec3 getAngularDragCoefficient() const = 0;
416  virtual void setDragCoefficient(PxReal scale) = 0;
417 
423  virtual void setExternalAcceleration(PxVec3 acceleration) = 0;
428  virtual PxVec3 getExternalAcceleration() const = 0;
429 
436  virtual void setParticleAccelerations(const PxVec4* particleAccelerations) = 0;
442  virtual bool getParticleAccelerations(PxVec4* particleAccelerationsBuffer) const = 0;
447  virtual PxU32 getNbParticleAccelerations() const = 0;
448 
450 
454 
455 
463  virtual void setMotionConstraints(const PxClothParticleMotionConstraint* motionConstraints) = 0;
469  virtual bool getMotionConstraints(PxClothParticleMotionConstraint* motionConstraintsBuffer) const = 0;
474  virtual PxU32 getNbMotionConstraints() const = 0;
479  virtual void setMotionConstraintConfig(const PxClothMotionConstraintConfig& config) = 0;
484  virtual PxClothMotionConstraintConfig getMotionConstraintConfig() const = 0;
485 
493  virtual void setSeparationConstraints(const PxClothParticleSeparationConstraint* separationConstraints) = 0;
499  virtual bool getSeparationConstraints(PxClothParticleSeparationConstraint* separationConstraintsBuffer) const = 0;
504  virtual PxU32 getNbSeparationConstraints() const = 0;
505 
512  virtual void clearInterpolation() = 0;
513 
519  virtual void setStretchConfig(PxClothFabricPhaseType::Enum type, const PxClothStretchConfig& config) = 0;
525  virtual PxClothStretchConfig getStretchConfig(PxClothFabricPhaseType::Enum type) const = 0;
530  virtual void setTetherConfig(const PxClothTetherConfig& config) = 0;
535  virtual PxClothTetherConfig getTetherConfig() const = 0;
536 
538 
542 
543 
549  virtual void addCollisionSphere(const PxClothCollisionSphere& sphere) = 0;
556  virtual void removeCollisionSphere(PxU32 index) = 0;
565  virtual void setCollisionSpheres(const PxClothCollisionSphere* spheresBuffer, PxU32 count) = 0;
570  virtual PxU32 getNbCollisionSpheres() const = 0;
571 
581  virtual void addCollisionCapsule(PxU32 first, PxU32 second) = 0;
587  virtual void removeCollisionCapsule(PxU32 index) = 0;
592  virtual PxU32 getNbCollisionCapsules() const = 0;
593 
600  virtual void addCollisionPlane(const PxClothCollisionPlane& plane) = 0;
608  virtual void removeCollisionPlane(PxU32 index) = 0;
617  virtual void setCollisionPlanes(const PxClothCollisionPlane* planesBuffer, PxU32 count) = 0;
622  virtual PxU32 getNbCollisionPlanes() const = 0;
623 
631  virtual void addCollisionConvex(PxU32 mask) = 0;
638  virtual void removeCollisionConvex(PxU32 index) = 0;
643  virtual PxU32 getNbCollisionConvexes() const = 0;
644 
650  virtual void addCollisionTriangle(const PxClothCollisionTriangle& triangle) = 0;
656  virtual void removeCollisionTriangle(PxU32 index) = 0;
665  virtual void setCollisionTriangles(const PxClothCollisionTriangle* trianglesBuffer, PxU32 count) = 0;
670  virtual PxU32 getNbCollisionTriangles() const = 0;
671 
683  virtual void getCollisionData(PxClothCollisionSphere* spheresBuffer, PxU32* capsulesBuffer,
684  PxClothCollisionPlane* planesBuffer, PxU32* convexesBuffer, PxClothCollisionTriangle* trianglesBuffer) const = 0;
685 
702  virtual void setVirtualParticles(PxU32 numVirtualParticles, const PxU32* indices, PxU32 numWeights, const PxVec3* weights) = 0;
707  virtual PxU32 getNbVirtualParticles() const = 0;
713  virtual void getVirtualParticles(PxU32* indicesBuffer) const = 0;
718  virtual PxU32 getNbVirtualParticleWeights() const = 0;
723  virtual void getVirtualParticleWeights(PxVec3* weightsBuffer) const = 0;
724 
730  virtual void setFrictionCoefficient(PxReal frictionCoefficient) = 0;
735  virtual PxReal getFrictionCoefficient() const = 0;
736 
745  virtual void setCollisionMassScale(PxReal scalingCoefficient) = 0;
750  virtual PxReal getCollisionMassScale() const = 0;
751 
753 
757 
758 
764  virtual void setSelfCollisionDistance(PxReal distance) = 0;
769  virtual PxReal getSelfCollisionDistance() const = 0;
776  virtual void setSelfCollisionStiffness(PxReal stiffness) = 0;
781  virtual PxReal getSelfCollisionStiffness() const = 0;
782 
793  virtual void setSelfCollisionIndices(const PxU32* indices, PxU32 nbIndices) = 0;
799  virtual bool getSelfCollisionIndices(PxU32* indices) const = 0;
800 
805  virtual PxU32 getNbSelfCollisionIndices() const = 0;
806 
818  virtual void setRestPositions(const PxVec4* restPositions) = 0;
824  virtual bool getRestPositions(PxVec4* restPositions) const = 0;
829  virtual PxU32 getNbRestPositions() const = 0;
830 
832 
836 
837 
845  virtual void setSimulationFilterData(const PxFilterData& data) = 0;
846 
852  virtual PxFilterData getSimulationFilterData() const = 0;
853 
855 
859 
860 
868  virtual void setContactOffset(PxReal offset) = 0;
869 
874  virtual PxReal getContactOffset() const = 0;
875 
883  virtual void setRestOffset(PxReal offset) = 0;
884 
889  virtual PxReal getRestOffset() const = 0;
890 
892 
896 
897 
905  virtual void setSleepLinearVelocity(PxReal threshold) = 0;
910  virtual PxReal getSleepLinearVelocity() const = 0;
920  virtual void setWakeCounter(PxReal wakeCounterValue) = 0;
926  virtual PxReal getWakeCounter() const = 0;
933  virtual void wakeUp() = 0;
938  virtual void putToSleep() = 0;
944  virtual bool isSleeping() const = 0;
945 
947 
948  virtual const char* getConcreteTypeName() const { return "PxCloth"; }
949 
950 protected:
951  PX_INLINE PxCloth(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
952  PX_INLINE PxCloth(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
953  virtual ~PxCloth() {}
954  virtual bool isKindOf(const char* name) const { return !strcmp("PxCloth", name) || PxActor::isKindOf(name); }
955 };
956 
957 PX_DEPRECATED PX_INLINE PxCloth* PxActor::isCloth() { return is<PxCloth>(); }
958 PX_DEPRECATED PX_INLINE const PxCloth* PxActor::isCloth() const { return is<PxCloth>(); }
959 
960 #ifndef PX_DOXYGEN
961 } // namespace physx
962 #endif
963 
965 #endif


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