#include <freecloth/simulator/simSimulator.h>
Inheritance diagram for SimSimulator:
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 GeMesh & | getMesh () 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 Params & | getParams () 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. | |
Private Types | |
typedef SimMatrix | Matrix |
typedef SimMatrix | SymMatrix |
typedef SimMatrix | TridiagMatrix |
Private Member Functions | |
void | setupMass () |
void | calcStretchShear (const GeMesh::FaceWrapper &face) |
Calculate values common to the stretch and shear conditions. | |
void | calcStretch (const GeMesh::FaceWrapper &face, const CommonVars &cv, const GePoint x[3], const GePoint tp[3], const GeVector v0[3]) |
Calculate the stretch condition and its derivatives. | |
void | calcShear (const GeMesh::FaceWrapper &face, const CommonVars &cv, const GePoint x[3], const GePoint tp[3], const GeVector v0[3]) |
Calculate the shear condition and its derivatives. | |
void | calcBend (const GeMeshWingedEdge::HalfEdgeWrapper &edge) |
Calculate the bend condition and its derivatives. | |
Private Attributes | |
RCShdPtr< GeMesh > | _initialMesh |
RCShdPtr< GeMeshWingedEdge > | _initialMeshWingedEdge |
RCShdPtr< GeMesh > | _mesh |
Params | _params |
Float | _rho |
Density of cloth ( kg / m^2 ). | |
Float | _h |
Timestep. | |
Float | _time |
Current time. | |
TridiagMatrix | _M |
Variables from the [BarWit98], as defined in equations (6) and (14). | |
Float | _totalMass |
Sum of diagonals of _M. | |
SimVector | _f0 |
SymMatrix | _df_dx |
SymMatrix | _df_dv |
SimVector | _v0 |
SimVector | _z0 |
ModPCGSolver | _modPCG |
SimVector | _f0i [NB_FORCES] |
For debugging. | |
SimVector | _d0i [NB_FORCES] |
For debugging. | |
SymMatrix | _df_dxi [NB_FORCES] |
For debugging. | |
SymMatrix | _dd_dvi [NB_FORCES] |
For debugging. | |
SymMatrix | _dd_dxi [NB_FORCES] |
For debugging. | |
Float | _fenergy [NB_FORCES] |
Total energy of cloth. | |
Float | _venergy |
Total energy of cloth. | |
Float | _energy |
Total energy of cloth. | |
std::vector< Float > | _trienergy [NB_FORCES] |
Total energy of cloth. |
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.
|
Finer grained simulation control - allows the client more control over the computation. See step() for details. Definition at line 608 of file simSimulator.cpp. References SimSimulator::ModPCGSolver::_A, _d0i, _energy, _f0i, _fenergy, _h, _time, SimSimulator::ModPCGSolver::result(), GeMeshTypes::VertexConstIterator, and GeMeshTypes::VertexIterator. Referenced by step(). |
|
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 SimSimulator::ModPCGSolver::_A, SimSimulator::ModPCGSolver::_b, _d0i, _dd_dvi, _dd_dxi, _df_dxi, _energy, _f0i, _fenergy, SimSimulator::Params::_g, _h, SimSimulator::Params::_k_drag, _M, _time, _venergy, SimSimulator::ModPCGSolver::_z, calcBend(), calcStretchShear(), SimVector::clear(), SimVector::dot(), GeMeshWingedEdge::EdgeIterator, GeMeshTypes::FaceVertexId, and SimSimulator::ModPCGSolver::preStep(). Referenced by step(). |
|
Rewind simulation time to zero, and return the mesh to its initial state. Definition at line 318 of file simSimulator.cpp. References SimSimulator::ModPCGSolver::_A, SimSimulator::ModPCGSolver::_b, _d0i, _dd_dvi, _dd_dxi, _df_dxi, _energy, _f0i, _fenergy, _time, _trienergy, _venergy, and ForceType. |
|
Constrain movement of the vertex to the plane defined by the given normal. Definition at line 409 of file simSimulator.cpp. References SimSimulator::ModPCGSolver::_S, GeVector::getUnit(), and GeMatrix3::outerProduct(). |
|
Fill the mass matrix (_M) using the initial mesh's triangles areas and the density parameter, as per [BarWit98] section 2.2. Definition at line 361 of file simSimulator.cpp. References _M, _rho, _totalMass, and GeMeshTypes::VertexId. Referenced by setDensity(). |
|
Force the vertex to move with the specified velocity. This overrides any position constraints. Definition at line 463 of file simSimulator.cpp. References SimVector::size(). |
|
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(). |
|
Finer grained simulation control - allows the client more control over the computation. See step() for details. Definition at line 601 of file simSimulator.cpp. References SimSimulator::ModPCGSolver::step(). Referenced by step(). |
|
Finer grained simulation control - allows the client more control over the computation. See step() for details. Definition at line 594 of file simSimulator.cpp. References SimSimulator::ModPCGSolver::done(). Referenced by step(). |