The code relative to this example is located in :
sofa/applications/tutorials/oneTetrahedron
There is just a Main.cpp with less than 100 lines. Open and observe it.
sofa::simulation::tree::GNode* groot = new sofa::simulation::tree::GNode; ...
sofa::component::odesolver::CGImplicitSolver* solver =
new sofa::component::odesolver::CGImplicitSolver;
...
sofa::component::context::Gravity* gravity =
new sofa::component::context::Gravity;
...
sofa::component::MechanicalObject<MyTypes>* DOF =
new sofa::component::MechanicalObject<MyTypes>;
...
sofa::component::mass::UniformMass<MyTypes,double>* mass =
new sofa::component::mass::UniformMass<MyTypes,double>;
...
sofa::component::topology::MeshTopology* topology =
new sofa::component::topology::MeshTopology;
...
sofa::component::constraint::FixedConstraint<MyTypes>*
constraints =
new sofa::component::constraint::FixedConstraint<MyTypes>;
...
sofa::component::forcefield::TetrahedronFEMForceField<MyTypes>* fem =
new sofa::component::forcefield::TetrahedronFEMForceField<MyTypes>;
...
sofa::simulation::tree::GNode* skin = new sofa::simulation::tree::GNode; ...
sofa::component::visualmodel::OglModel* visual
= new sofa::component::visualmodelOglModel;
visual->load("../../../scenes/VisualModels/liver-smooth.obj", "", "");
MyMapping* mapping = new MyMapping(DOF, visual); ...
Here a BarycentricMapping is used to map the visual model to the animation model.
This type is templated and you can find some examples of uses at the end of the file sofa/modules/sofa/component/mapping/BarycentricMapping.cpp
By analogy, we have built MyMapping type :
typedef sofa::component::mapping::BarycentricMapping<
sofa::core::Mapping<
sofa::core::componentmodel::behavior::MechanicalModel<MyTypes>,
sofa::core::componentmodel::behavior::MappedModel<
sofa::defaulttype::ExtVectorTypes<
sofa::defaulttype::Vec<3,GLfloat>,
sofa::defaulttype::Vec<3,GLfloat>
>
>
>
> MyMapping;