Main Page   Class Hierarchy   Compound List   File List   Compound Members  

freecloth::SimSimulator Class Reference

An implementation of Baraff & Witkin's cloth simulation algorithm. More...

#include <freecloth/simulator/simSimulator.h>

Inheritance diagram for freecloth::SimSimulator:

freecloth::RCBase List of all members.

Public Types

enum  ForceType {
  F_STRETCH, F_SHEAR, F_BEND, F_GRAVITY,
  F_DRAG, NB_FORCES
}
 The individual classes of forces.


Public Member Functions

 SimSimulator (const GeMesh &initialMesh)
const GeMeshgetMesh () const
const RCShdPtr< GeMesh > & getMeshPtr () const
void rewind ()
void step ()
BaTime::Instant getTime () const
 Retrieve the current simulation time.

void removeAllConstraints ()
 Remove all constraints on all vertices.

void setPosConstraintPlane (GeMesh::VertexId, const GeVector &)
void setPosConstraintLine (GeMesh::VertexId, const GeVector &)
 Constrain movement of the vertex to the given line.

void setPosConstraintFull (GeMesh::VertexId)
 Completely constrain the vertex, allowing no movement.

void setVelConstraint (GeMesh::VertexId, const GeVector &)
bool subStepsDone () const
void preSubSteps ()
void subStep ()
void postSubSteps ()
void setTimestep (Float)
 Mutator.

void setParams (const Params &)
 Mutator.

void setDensity (Float rho)
 Mutator.

void setPCGTolerance (Float)
 Mutator.

Float getTimestep () const
 Accessor.

const ParamsgetParams () const
 Accessor.

Float getDensity () const
 Accessor.

Float getPCGTolerance () const
 Accessor.

GeVector getVelocity (GeMesh::VertexId vid) const
 Only exposed for debugging purposes.

GeVector getForce (GeMesh::VertexId vid) const
 Only exposed for debugging purposes.

Float getEnergy (ForceType) const
 Only exposed for debugging purposes.

Float getTriEnergy (ForceType, GeMesh::FaceId) const
 Only exposed for debugging purposes.

GeVector getForce (ForceType type, GeMesh::VertexId vid) const
 Only exposed for debugging purposes.

GeVector getDampingForce (ForceType type, GeMesh::VertexId vid) const
 Only exposed for debugging purposes.

void setMesh (const GeMesh &)
 Only exposed for debugging purposes.


Detailed Description

An implementation of Baraff & Witkin's cloth simulation algorithm.

Using the simulation is fairly straightforward. The client supplies an initial mesh, which must have disc topology. The client also specifies the density of the cloth, which indirectly defines the mass of each triangle of the mesh. The client can also specify constraints on the cloth motion, constraining both the position and the velocity of individual nodes of the mesh.

Time starts at zero, and is advanced by a fixed timestep by calls to step(). The client can retrieve the mesh after each timestep. The simulation can be rewound to the beginning by calling rewind().

There are many parameters for the simulation algorithm. See [BarWit98] or the description in SimSimulator::Params for details.

References:

Definition at line 104 of file simSimulator.h.


Member Function Documentation

void freecloth::SimSimulator::postSubSteps  
 

Finer grained simulation control - allows the client more control over the computation. See step() for details.

Definition at line 608 of file simSimulator.cpp.

Referenced by step().

void freecloth::SimSimulator::preSubSteps  
 

Finer grained simulation control - allows the client more control over the computation. See step() for details.

Definition at line 482 of file simSimulator.cpp.

References freecloth::SimSimulator::Params::_g, freecloth::SimSimulator::Params::_k_drag, freecloth::SimVector::clear(), and freecloth::SimVector::dot().

Referenced by step().

void freecloth::SimSimulator::rewind  
 

Rewind simulation time to zero, and return the mesh to its initial state.

Definition at line 318 of file simSimulator.cpp.

References ForceType.

void freecloth::SimSimulator::setPosConstraintPlane GeMesh::VertexId   ,
const GeVector  
 

Constrain movement of the vertex to the plane defined by the given normal.

Definition at line 409 of file simSimulator.cpp.

References freecloth::GeVector::getUnit().

void freecloth::SimSimulator::setVelConstraint GeMesh::VertexId   ,
const GeVector  
 

Force the vertex to move with the specified velocity. This overrides any position constraints.

Definition at line 463 of file simSimulator.cpp.

References freecloth::SimVector::size().

void freecloth::SimSimulator::step  
 

Advance the simulation by one timestep. step() is equivalent to calling

Definition at line 471 of file simSimulator.cpp.

References postSubSteps(), preSubSteps(), subStep(), and subStepsDone().

void freecloth::SimSimulator::subStep  
 

Finer grained simulation control - allows the client more control over the computation. See step() for details.

Definition at line 601 of file simSimulator.cpp.

Referenced by step().

bool freecloth::SimSimulator::subStepsDone   const
 

Finer grained simulation control - allows the client more control over the computation. See step() for details.

Definition at line 594 of file simSimulator.cpp.

Referenced by step().


The documentation for this class was generated from the following files:
Generated on Wed Apr 23 15:58:47 2003 for Freecloth by doxygen1.3-rc3