class MClothSystem

Jump to documentation

Interface for cloth solver system.

public members:

MClothSystem ()
virtual ~MClothSystem ()
virtual MStatus addCloth ( MClothHandle handle, int nParticles, int nTriangles, int vertexList[][3], const MDoubleArray & uArray, const MDoubleArray & vArray, MSeamInfo *seam = NULL, int nSeam = 0 )
virtual MStatus addCloth ( MClothHandle handle, int nParticles, int nTriangles, int vertexList[][3], const MPointArray & particles, MSeamInfo *seam = NULL, int nSeam = 0, const MPointArray *uvs=NULL)
virtual MStatus removeCloth ( MClothHandle handle )
virtual MClothMaterial * getNewMaterialInstance ( MStatus *ReturnStatus = NULL )
virtual void setMaterial ( MClothHandle handle, MClothMaterial *material, int triIndex = 0, MStatus * ReturnStatus = NULL )
virtual void updateMaterial ( MClothHandle handle, MStatus * ReturnStatus = NULL )
virtual unsigned numTriangles ( MClothHandle handle, MStatus * ReturnStatus = NULL ) const
virtual unsigned numParticles ( MClothHandle handle, MStatus * ReturnStatus = NULL ) const
virtual MClothParticle * getParticle ( MClothHandle handle, unsigned index, MStatus * ReturnStatus = NULL ) const
virtual MClothTriangle * getTriangle ( MClothHandle handle, unsigned index, MStatus * ReturnStatus = NULL ) const
virtual MStatus getClothNeighbours ( MClothHandle handle, MIntArray & result, int index = -1 )
virtual MStatus getClothContacts ( MClothHandle handle, MIntArray & result, int index = -1 )
virtual MStatus getClothForces ( MClothHandle handle, MDoubleArray & result, int index = -1 )
virtual MStatus getStress ( MClothHandle handle, MDoubleArray & result, int index = -1 )
virtual MStatus getStress_scaled ( MClothHandle handle, double stress[] )
virtual double getBendingForce ( MClothHandle handle, int triangleNo, int edgeNo, MStatus * ReturnStatus = NULL )
virtual void setBendingForce ( MClothHandle handle, int triangleNo, int edgeNo, double theta, double weight, MStatus * ReturnStatus = NULL )
virtual void setBendResistance ( MClothHandle handle, int triangleNo, int edgeNo, double resistance, MStatus * ReturnStatus = NULL )
virtual void getPosition ( MClothHandle handle, MPointArray & position, MStatus * ReturnStatus = NULL ) const
virtual void setPosition ( MClothHandle handle, MPointArray & position, MStatus * ReturnStatus = NULL )
virtual void getVelocity ( MClothHandle handle, MVectorArray & velocity, MStatus * ReturnStatus = NULL ) const
virtual void setVelocity ( MClothHandle handle, MVectorArray & velocity, MStatus * ReturnStatus = NULL )
virtual unsigned numTriangles ( MStatus * ReturnStatus = NULL ) const
virtual unsigned numParticles ( MStatus * ReturnStatus = NULL ) const
virtual bool preSolve ()
virtual bool postSolve ()
virtual void interpolate ( double frameTime, MStatus * ReturnStatus = NULL )
virtual double step_forward ( double stepSize , MStatus * ReturnStatus = NULL )
virtual void restart ( double frameTime, MStatus * ReturnStatus = NULL)
virtual double frameSize ( MStatus * ReturnStatus = NULL ) const
virtual void setFrameSize ( const double frameSize , MStatus * ReturnStatus = NULL )
virtual double currentTime ( MStatus * ReturnStatus = NULL ) const
virtual void setCurrentTime ( const double currTime, MStatus * ReturnStatus = NULL )
virtual double lastTime ( MStatus * ReturnStatus = NULL ) const
virtual double stepSize ( MStatus * ReturnStatus = NULL ) const
virtual MClothConstraint * lockParticle ( MClothParticle *particle, MClothPolyhedron *poly, int triIndex, MStatus * ReturnStatus = NULL )
virtual void unlockParticle ( MClothParticle *particle, MStatus * ReturnStatus = NULL )
virtual void unlockParticle ( MClothConstraint *constaint, MStatus * ReturnStatus = NULL )
virtual void addCommand ( MClothConstraintCmd *command, MStatus * ReturnStatus = NULL )
virtual void removeCommand ( MClothConstraintCmd *command, MStatus * ReturnStatus = NULL )
virtual MClothForce * addSpring ( MClothParticle * particle1, MClothParticle * particle2, double ks, double kd, MStatus * ReturnStatus = NULL)
virtual MClothForce * addSpring ( MClothParticle * particle1, MClothTriangle *clothTriangle, MPoint bary, double ks, double kd, MStatus * ReturnStatus = NULL)
virtual void removeSpring ( MClothForce *springForce, MStatus * ReturnStatus = NULL)
virtual MClothPolyhedron * createRigidbody ( int numVertices, int indices[][3], int numTriangles , double triDepthMap[], double triCollisionOffsetMap[], char *name = NULL, unsigned numRampSamples = 0, float* offsetVelIncrement = NULL, float* depthVelIncrement = NULL, bool collisionEnable = true, MStatus * ReturnStatus = NULL )
virtual MStatus addRigidbody ( MClothPolyhedron * body )
virtual MStatus removeRigidbody ( MClothPolyhedron * body )
virtual void setVelocity_CutOff ( const double min, const double max, const double damping, MStatus * ReturnStatus = NULL )
virtual void setPinchMethod ( const short method, MStatus * ReturnStatus = NULL )
virtual void setIgnoreCollisions ( const bool ignore, MStatus * ReturnStatus = NULL )
virtual int getRecoilWidth ( MStatus * ReturnStatus = NULL ) const
virtual void setRecoilWidth ( int width, MStatus * ReturnStatus = NULL )
virtual int getRecoilDuration ( MStatus * ReturnStatus = NULL ) const
virtual void setRecoilDuration ( int duration, MStatus * ReturnStatus = NULL )
virtual int findClosestPolyhedron ( MClothPolyhedron *spAry[], int spCount, MPoint x, double maxd, MStatus * ReturnStatus = NULL )
virtual int findTriangle ( MClothPolyhedron *sp, MPoint x, double maxd, double *closestDist = NULL, MStatus * ReturnStatus = NULL )
virtual int findClothTriangle ( MClothHandle handle, MPoint x, MPoint &barycentric, MStatus * ReturnStatus = NULL )
virtual int findClothTriangle ( MClothHandle handle, MPoint x, const MIntArray & excludedTriangles, MPoint &barycentric, MStatus * ReturnStatus = NULL )
virtual int findClothTriangle ( const MPointArray & clothPositions, MPoint x, MPoint &barycentric, MStatus * ReturnStatus = NULL )
virtual MStatus findNeighborTriangles ( MClothHandle handle, int vertexIndex, int neighborhood, MIntArray & neighborTriangles )
MObject solverNode ()
void setUserdata ( void* userPtr )
void* getUserdata ()

Documentation

Interface for cloth solver system.
Description

This class provides interface to cloth system. Cloth solver writers should derive their solver class from this class. Common convenience methods are available.

Note on Terminology: The following terms are used interchangeably:

This class provides interface to complete cloth solver system. Cloth solver plugins should override this class and it should get registered through MClothSolverRegister::registerClothSolver.

There can be multiple cloth mesh objects attached to one solver. Each cloth mesh can be identified uniquely by MClothHandle in solver.

MClothHandle is defined as: typedef unsigned int MClothHandle;

MClothHandle is essentilly plugIndex of outMesh attribute for each cloth mesh. CpClothPlugin maintains the list of cloth mesh objects connected with the solver.

Typically, solver will represent the different cloth mesh objects as one complete mesh in their internal data structures. This helps in linerly indexing the particle simulation.

Some of the simulation related methods for example interpolate, step_forward and restart work independent of MClothHandle.

ClothSystem also has interface methods to add/remove Constraint, Forces and Collision objects into solver.

Functions

MClothSystem:: MClothSystem ()

Description

Class constructor.

MClothSystem:: ~MClothSystem ()

Description

Class destructor.

MStatus MClothSystem:: addCloth ( MClothHandle handle, int nParticles, int nTriangles, int vertexList[][3], const MDoubleArray & uArray, const MDoubleArray & vArray, MSeamInfo *seam, int nSeam )

Description

Add a new seamed cloth mesh to this solver at given handle. MSeamInfo structure is defined as follows... struct MSeamInfo { int particleIndex, // particle index triangleIndex; // triangle index double u, // texture values v; };

Arguments

  • handle handle to uniquely identify the cloth mesh.
  • nParticles number of particles.
  • nTriangles number of triangles.
  • vertexList vertex indices for the polygons.
  • uArray texture u array.
  • vArray texture v array.
  • seams array of MSeamInfo structure.
  • nSeams number of seams in MSeamInfo structure.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: addCloth ( MClothHandle handle, int nParticles, int nTriangles,int vertexList[][3], const MPointArray & particles, MSeamInfo *seam, int nSeam, const MPointArray *uvs)

Description

Add a new cloth object mesh to this solver at given handle.

Arguments

  • handle handle to uniquely identify the cloth mesh.
  • nParticles number of particles.
  • nTriangles number of triangles.
  • vertexList vertex indices for the polygons.
  • particles point (vertex) array. This includes all the particles in the mesh, and no extras.
  • seams array of MSeamInfo structure.
  • nSeams number of seams in MSeamInfo structure.
  • uvs Uvs to apply.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: removeCloth ( MClothHandle handle )

Description

Add a new seamed cloth mesh to this solver at given handle.

Arguments

  • handle handle to uniquely identify the cloth mesh.
  • nParticles number of particles.
  • nTriangles number of triangles.
  • vertexList vertex indices for the polygons.
  • uArray texture u array.
  • vArray texture v array.
  • seams array of MSeamInfo structure.
  • nSeams number of seams in MSeamInfo structure.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothMaterial * MClothSystem:: getNewMaterialInstance ( MStatus *ReturnStatus )

Description

This method returns a new material instance. Cloth plugin maintains the list of material instance. This method needs to allocate the cloth material object using new and return the pointer. (This is necessary because delete is called on the returned pointer by cloth plugin when work is done.)

Arguments

  • ReturnStatus Status code.

Return Value

  • MClothMaterial A new cloth material instance.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setMaterial ( MClothHandle handle, MClothMaterial *material, int triIndex, MStatus * ReturnStatus )

Description

This method sets material at given triangle index.

Arguments

  • handle handle to of cloth mesh.
  • material cloth material to set.
  • triIndex index of triangle.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: updateMaterial ( MClothHandle handle, MStatus * ReturnStatus )

Description

This method updates material in internal data structure by recalculating values of mass from updated and triangular area and density values.

Arguments

  • handle handle to of cloth mesh.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

unsigned MClothSystem:: numTriangles ( MClothHandle handle, MStatus * ReturnStatus ) const

Description

This method returns number of cloth triangles in a cloth mesh.

Arguments

  • handle handle to of cloth mesh.
  • ReturnStatus Status code.

Return Value

  • unsigned number of cloth triangles.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

unsigned MClothSystem:: numParticles ( MClothHandle handle, MStatus * ReturnStatus) const

Description

This method returns number of cloth particles in a cloth mesh.

Arguments

  • handle handle to of cloth mesh.
  • ReturnStatus Status code.

Return Value

  • unsigned number of cloth particles.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothParticle * MClothSystem:: getParticle ( MClothHandle handle, unsigned index, MStatus * ReturnStatus ) const

Description

This method returns cloth particle at given index.

Arguments

  • handle handle to of cloth mesh.
  • index index of particle.
  • ReturnStatus Status code.

Return Value

  • MClothParticle* cloth particle instance.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothTriangle * MClothSystem:: getTriangle ( MClothHandle handle, unsigned index, MStatus * ReturnStatus ) const

Description

This method returns cloth triangle at given index.

Arguments

  • handle handle to of cloth mesh.
  • index index of triangle.
  • ReturnStatus Status code.

Return Value

  • MClothTriangle* cloth triangle instance.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: getClothNeighbours ( MClothHandle handle, MIntArray & result, int index )

Description

This method returns neighboring cloth particle indices.

Arguments

  • handle handle to of cloth mesh.
  • result neighboring cloth particles indices array.
  • index index of particle. If index == -1 then return indices for all particles else return the neighboring indices for particle at given index only.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: getClothContacts ( MClothHandle handle, MIntArray & result, int index )

Description

This method returns cloth particle contacts indices.

Arguments

  • handle handle to of cloth mesh.
  • result cloth particles contacts indices array.
  • index index of particle. If index == -1 then return indices for all particles else return the indices for particle at given index only.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: getClothForces ( MClothHandle handle, MDoubleArray & result, int index )

Description

This method returns cloth particle contact forces.

Arguments

  • handle handle to of cloth mesh.
  • result cloth particles contacts forces array.
  • index index of particle. If index == -1 then return forces for all particles else return the forces for particle at given index only.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: getStress ( MClothHandle handle, MDoubleArray & result, int index )

Description

This method returns vertex stress of particle.

Arguments

  • handle handle to of cloth mesh.
  • result particle stress array.
  • index index of particle. If index == -1 then return stress value for all particles else return the stress value for particle at given index only.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: getStress_scaled ( MClothHandle handle, double stress[] )

Description

This method returns scaled vertex stress of particles. This method needs to scale the stress, exaggerating those closer to 1, but keeping them in the 0..1 range before returning the values.

A simple method to scale is to apply a SIN function on normalized stress values and then clamping them in between 0...1

Arguments

  • handle handle to of cloth mesh.
  • stress stress array.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

double MClothSystem:: getBendingForce ( MClothHandle handle, int triangleNo, int edgeNo, MStatus * ReturnStatus )

Description

This method gets crease angle for given triangle and edge pair.

Arguments

  • handle handle to of cloth mesh.
  • triangleNo triangle index of cloth mesh.
  • edgeNo edge index of given triangle.
  • ReturnStatus Status code.

Return Value

  • theta crease angle value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setBendResistance ( MClothHandle handle, int triangleNo, int edgeNo, double resistance, MStatus * ReturnStatus )

Description

This method sets bend resistance for given triangle and edge pair.

Arguments

  • handle handle to of cloth mesh.
  • triangleNo triangle index of cloth mesh.
  • edgeNo edge index of given triangle.
  • theta bend resistance.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setBendingForce ( MClothHandle handle, int triangleNo, int edgeNo, double theta, double weight, MStatus * ReturnStatus )

Description

This method sets crease angle and updates the values of bend angle for given triangle and edge pair.

Arguments

  • handle handle to of cloth mesh.
  • triangleNo triangle index of cloth mesh.
  • edgeNo edge index of given triangle.
  • theta crease angle value.
  • weight weight value.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: getPosition ( MClothHandle handle, MPointArray & position, MStatus * ReturnStatus ) const

Description

This method returns vertex positions of all the particles for given cloth mesh.

Arguments

  • handle handle to of cloth mesh.
  • position particles position array.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setPosition ( MClothHandle handle, MPointArray & position, MStatus * ReturnStatus )

Description

This method sets vertex positions of all the particles for given cloth mesh.

Arguments

  • handle handle to of cloth mesh.
  • position particles position array.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: getVelocity ( MClothHandle handle, MVectorArray & velocity, MStatus * ReturnStatus ) const

Description

This method returns vertex velocity of all the particles for given cloth mesh.

Arguments

  • handle handle to of cloth mesh.
  • velocity particles velocity array.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setVelocity ( MClothHandle handle, MVectorArray & velocity, MStatus * ReturnStatus )

Description

This method sets vertex velocities of all the particles for given cloth mesh.

Arguments

  • handle handle to of cloth mesh.
  • velocity particles velocity array.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

unsigned MClothSystem:: numTriangles ( MStatus * ReturnStatus) const

Description

This method returns number of cloth triangles in complete cloth system. This is essentially sum all of the triangles for each individual cloth mesh.

Arguments

  • ReturnStatus Status code.

Return Value

  • unsigned number of cloth triangles in cloth system.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

unsigned MClothSystem:: numParticles ( MStatus * ReturnStatus) const

Description

This method returns number of cloth particles in complete cloth system. This is essentially sum all of the particles for each individual cloth mesh.

Arguments

  • ReturnStatus Status code.

Return Value

  • unsigned number of cloth particles in cloth system.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

bool MClothSystem:: preSolve ( )
Description

This method is called prior to the calls to step_forward.

Arguments

None.

ReturnCodes

The API user should return true if preSolve methods succeed.

bool MClothSystem:: postSolve ( )
Description

This method is called after the calls to step_forward.

Arguments

None.

ReturnCodes

The API user should return true if postSolve methods succeed.

void MClothSystem:: interpolate ( double frameTime, MStatus * ReturnStatus )

Description

This method interpolates cloth at given frameTime.

Arguments

  • frameTime frame time.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

double MClothSystem:: step_forward ( double stepSize , MStatus * ReturnStatus )

Description

This method increments the cloth simulation by stepSize.

Arguments

  • stepSize incremental step size.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: restart ( double frameTime, MStatus * ReturnStatus )

Description

This method resets/restarts cloth simulation to given frameTime.

Arguments

  • frameTime frame time.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

double MClothSystem:: frameSize ( MStatus * ReturnStatus ) const

Description

This method returns frame size value from solver.

Arguments

  • ReturnStatus Status code.

Return Value

  • double The framesize value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setFrameSize ( const double frameSize , MStatus * ReturnStatus )

Description

This method sets frame size for simulation.

Arguments

  • frameSize The frame size value.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

double MClothSystem:: currentTime ( MStatus * ReturnStatus ) const

Description

This method returns current time value from solver.

Arguments

  • ReturnStatus Status code.

Return Value

  • double The current time value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setCurrentTime ( const double currTime, MStatus * ReturnStatus )

Description

This method sets current time for simulation.

Arguments

  • currTime The current time value in double.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

double MClothSystem:: lastTime ( MStatus * ReturnStatus ) const

Description

This method returns last time value from solver.

Arguments

  • ReturnStatus Status code.

Return Value

  • double The last time value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

double MClothSystem:: stepSize ( MStatus * ReturnStatus ) const

Description

This method returns step size increment value from solver.

Arguments

  • ReturnStatus Status code.

Return Value

  • double The step size increment value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothConstraint * MClothSystem:: lockParticle ( MClothParticle *particle, MClothPolyhedron *poly, int triIndex, MStatus * ReturnStatus )

Description

This method adds and returns a new cloth constraint. The newly created constraint should lock the supplied particle with triangle of a given poly.

Arguments

  • particle particle that needs to be locked.
  • poly The cloth collision mesh.
  • triIndex triangle index of collision mesh.
  • ReturnStatus Status code.

Return Value

  • MClothConstraint* The cloth constraint object.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: unlockParticle ( MClothParticle *particle, MStatus * ReturnStatus )

Description

This method removes cloth constraint attached to given particle.

Arguments

  • particle particle that needs to be unlocked/removed.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: unlockParticle ( MClothConstraint *constaint, MStatus * ReturnStatus )

Description

This method removes cloth constraint.

Arguments

  • constraint constraint that needs to be unlocked/removed.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: addCommand ( MClothConstraintCmd *command, MStatus * ReturnStatus )

Description

This method adds cloth constraint command object. For example : Cloth Pin Constraint.

Arguments

  • command cloth constraint command that needs to be added.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: removeCommand ( MClothConstraintCmd *command, MStatus * ReturnStatus )

Description

This method removes cloth constraint command object.

Arguments

  • command cloth constraint command that needs to be removed.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothForce * MClothSystem:: addSpring ( MClothParticle * particle1, MClothParticle * particle2, double shear, double damp, MStatus * ReturnStatus)

Description

This method adds and returns a new cloth force constraint. The newly created constraint should create a spring force between supplied particles. For example : Cloth Force Constraint.

Arguments

  • particle1 first cloth particle.
  • particle2 second cloth particle.
  • shear shear value.
  • damp damp value.
  • ReturnStatus Status code.

Return Value

  • MClothForce* The cloth force constraint object.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothForce * MClothSystem:: addSpring ( MClothParticle * particle1, MClothTriangle *clothTriangle, MPoint bary, double shear, double damp, MStatus * ReturnStatus )

Description

This method adds and returns a new cloth force constraint. The newly created constraint should create a spring force between supplied particles. For example : Cloth Force Constraint.

Arguments

  • particle1 first cloth particle.
  • clothtriangle cloth triangle.
  • bary barycentric value for cloth triangle.
  • shear shear value.
  • damp damp value.
  • ReturnStatus Status code.

Return Value

  • MClothForce* The cloth force constraint object.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: removeSpring ( MClothForce *springForce, MStatus * ReturnStatus )

Description

This method removes cloth force constraint.

Arguments

  • springForce cloth spring force constraint object to be removed.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MClothPolyhedron * MClothSystem:: createRigidbody ( int numVertices, int indices[][3], int numTriangles , double triDepthMap[], double triCollisionOffsetMap[], char *name, unsigned numRampSamples, float* offsetVelIncrement, float* depthVelIncrement, bool collisionEnable, MStatus * ReturnStatus )

Description

This method creates and returns a new cloth collision object. Note: This method should not automatically add the newly created collision object.

Arguments

  • nVertices number of vertices.
  • indices vertex indices for the polygons.
  • numTriangles number of triangles.
  • triDepthMap triangle depth map.
  • triCollisionOffsetMap triangle collision offset map.
  • name name of this collision object.
  • numRampSamples number of ramp samples.
  • offsetVelIncrement array of offset velocity increment values.
  • depthVelIncrement array of depth velocity increment values.
  • collisionEnable toggle the collision status of this object
  • ReturnStatus Status code.

Return Value

  • MClothPolyhedron* The cloth polyhedron object.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: addRigidbody ( MClothPolyhedron * body )

Description

This method adds cloth collision object.

Arguments

  • body cloth collision object.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: removeRigidbody ( MClothPolyhedron * body )

Description

This method removes cloth collision object.

Arguments

  • body cloth collision object to be removed.

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setVelocity_CutOff ( const double min, const double max, const double damping, MStatus * ReturnStatus )

Description

This method sets minimum, maximum and damping velocity cut off values.

Arguments

  • min minimum velocity cut off value.
  • max maximum velocity cut off value.
  • damping damping velocity cut off value.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setPinchMethod ( const short method, MStatus * ReturnStatus )

Description

This method sets cloth pinch method. Set the pinch method in the solver. The choices are: PinchMethodClosestDistance : When, cloth is pinched by 2 triangles, pick the closer triangle. PinchMethodFirstContact : When, cloth is pinched by 2 triangles, pick the 1st triangle in contact.

Arguments

  • method The pinch method. If method = 0 then PinchMethodClosestDistance i.e. When, cloth is pinched by 2 triangles, pick the closer triangle. If method = 1 then PinchMethodFirstContact i.e. When, cloth is pinched by 2 triangles, pick the 1st triangle in contact.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setIgnoreCollisions ( const bool ignore, MStatus * ReturnStatus )

Description

This method sets whether the Cloth to Cloth collision can be ignored for complete cloth system.

Arguments

  • isIgnored If true then then cloth to cloth collision must be ignored.
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: getRecoilWidth ( MStatus * ReturnStatus ) const

Description

This method returns recoil width value from solver. Recoil scale represents number of rows of neighbor particles to dampen.

Arguments

  • ReturnStatus Status code.

Return Value

  • double The recoil width value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setRecoilWidth ( int width, MStatus * ReturnStatus )

Description

This method sets recoil width value into solver. Recoil scale represents number of rows of neighbor particles to dampen.

Arguments

  • width Recoil width value.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: getRecoilDuration ( MStatus * ReturnStatus ) const

Description

This method returns recoil duration value from solver. Recoil scale represents time length until mass is restored after collision.

Arguments

  • ReturnStatus Status code.

Return Value

  • double The recoil duration value.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setRecoilDuration ( int duration, MStatus * ReturnStatus )

Description

This method sets recoil duration value into solver. Recoil scale represents time length until mass is restored after collision.

Arguments

  • duration Recoil duration value.
  • ReturnStatus Status code.

Return Value

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: findClosestPolyhedron ( MClothPolyhedron *spAry[], int spCount, MPoint x, double maxd, MStatus * ReturnStatus )

Description

This method returns closest collision object given an array of collision objects (MClothPolyhedron) and a cloth point.

Arguments

  • spAry MClothPolyhedron array.
  • spCount number of objects in spAry.
  • x cloth point.
  • maxd maximum range to look for a collision object. This is usually set to FLT_MAX.
  • ReturnStatus Status code.

Return Value

  • closestPoly Returns index of closest collision obejct.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: findTriangle ( MClothPolyhedron *sp, MPoint x, double maxd, double *closestDist, MStatus * ReturnStatus)

Description

This method takes a cloth-vertex location, x, and an MClothPolyhedron, sp, and returns the index of the triangle in sp that is the most suitable place to pin the vertex at x to. If no suitable triangle can be found, findTriangle returns -1.

The parameter maxd is the farthest away from the surface of sp that we look in finding a pin. Thus, if x is maxd or more from a triangle of sp, that triangle cannot be returned as the place we should pin to.

Note that sp should be checked in its current transformed state.

Arguments

  • sp MClothPolyhedron object.
  • x cloth point.
  • maxd maximum range. This is usually set to FLT_MAX.
  • closestDist The minimum distance.
  • ReturnStatus Status code.

Return Value

  • closestTri Returns index of closest triangle.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: findClothTriangle ( MClothHandle handle, MPoint x, MPoint &barycentric, MStatus * ReturnStatus )

Description

This method finds the relative triangle index of the closest triangle to a world space point.

Arguments

  • handle handle to uniquely identify the cloth mesh.
  • x cloth point.
  • barycentric barycentric point.
  • ReturnStatus Status code.

Return Value

  • closestTri Returns index of closest triangle.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: findClothTriangle ( MClothHandle handle, MPoint x, const MIntArray & excludedTriangles, MPoint &barycentric, MStatus * ReturnStatus )

Description

This method finds the relative triangle index of the closest triangle to a world space point.

Arguments

  • handle handle to uniquely identify the cloth mesh.
  • x cloth point.
  • excludetriangles Exclude the given triangles from being looked at. The triangle indices are relative (starting with 0 for each new garment).
  • barycentric barycentric point.
  • ReturnStatus Status code.

Return Value

  • closestTri Returns index of closest triangle.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

int MClothSystem:: findClothTriangle ( const MPointArray & clothPositions, MPoint x, MPoint &barycentric, MStatus * ReturnStatus )

Description

This method finds the relative triangle index of the closest triangle to a world space point given all the cloth positions.

Arguments

  • clothPositions This is a specially ordered array of points. It is ordered in triangle order and then point order [0,1,2] Example: Triangle[0] = Vert 0 5 6 Triangle[1] = Vert 5 6 7 Triangle[2] = Vert 7 9 10

    Then the array contains these points: 0 5 6 5 7 7 9 10.

  • x cloth point.
  • barycentric barycentric point.
  • ReturnStatus Status code.

Return Value

  • closestTri Returns index of closest triangle.

Status Codes

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

MStatus MClothSystem:: findNeighborTriangles ( MClothHandle handle, int vertexIndex, int neighborhood, MIntArray & neighborTriangles )

Description

This method finds the triangle index that are "close" to this vertex given an absolute vertex index of a cloth particle. These vertices will be excluded in the process of making a cloth-to-cloth constraint.

The returned triangles should be in Maya facet index (relative to each garment).

Arguments

  • handle handle to uniquely identify the cloth mesh.
  • vertexIndex vertex index.
  • neighborhood This is the topological walking distance as you trace from a triangle to it's surrounding neighbors. For example a neighborhood of 1 means 1 layer of surrounding triangles. 2 means 2 layers of surrounding triangles. Clamp the neighborhood between 1 and 6
  • neighborTrianglesTriangles that are neighbors to the output

Return Value

  • MS::kSuccess The method was successful.
  • MS::kFailure An object error has occurred.

void MClothSystem:: setUserdata (void* userDataPtr)

Description

Internal use only Set user data for MayaCloth plugin.

Arguments

  • userDataPtr The userDataPtr to set.

Return Value

void* MClothSystem:: getUserdata ()

Description

Internal use only Return user data to MayaCloth plugin.

Return Value

  • userDataPtr The userDataPtr associated with this object.

MObject MClothSystem:: solverNode ()
Description

Returns an MObject which represents the solver node that this cloth system belongs.

Arguments

None.

ReturnCodes

MObject::kNullObj if no solver node was found.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright