Back

VisualModelImpl

sofa::component::visual::VisualModelImpl
VisualModel
Doc (from source)

Generic visual model. If a viewer is active it will replace the VisualModel alias, otherwise nothing will be displayed. Abstract class which implements partially VisualModel. This class implemented all non-hardware (i.e OpenGL or DirectX) specific functions for rendering. It takes a 3D model (basically a .OBJ model) and apply transformations on it. At the moment, it is only implemented by OglModel for OpenGL systems.

Abstract (AI generated)

VisualModelImpl manages the visualization of 3D models by applying transformations and handling mesh data for rendering purposes.

Metadata
module
Sofa.Component.Visual
namespace
sofa::component::visual
include
sofa/component/visual/VisualModelImpl.h
inherits
  • VisualModel
description

The VisualModelImpl class within the SOFA framework is primarily concerned with visual rendering aspects, rather than physical or mathematical simulation equations that are typical in FEM simulations. Its main role involves managing 3D models (such as .OBJ files) for visualization purposes and handling transformations such as translation, rotation, and scaling. The component also supports normal computations and texture coordinate management. Here is a detailed description of its functionalities:

Governing Equations or Operators

The VisualModelImpl does not directly contribute to the core FEM operators like the mass matrix ($M")), stiffness matrix (\(K")), internal forces (\(f_{int}")), residual (\(R")), or tangent stiffness. Instead, it deals with geometric transformations and visual representation. #### Transformations The class provides methods for applying transformations to a 3D model: - **Translation**: Translates the object by a given vector \: where \\(X\$ and \$X_{new}\$ are the original and new positions of a vertex.

  • Rotation: Applies rotation through Euler angles or quaternions. For example, using Euler angles in degrees:
    $$ R_x(\theta_x), R_y(\theta_y), R_z(\theta_z) $$

where \$R_i(\theta)\$ is the rotation matrix around axis \$i\$ with angle \$\theta\$.

  • Scaling: Scales the object by a given factor:
    $$ X_{new} = s_x X_x, s_y X_y, s_z X_z, $$

where \$s_x, s_y, s_z\$ are scaling factors along each axis.

Normals and Tangents

The VisualModelImpl class computes surface normals and tangents which are important for rendering purposes:
- Normals: The normal vector \$N_i\$ at a vertex is computed as the average of the face normals around that vertex. For a triangle defined by vertices \$v_1, v_2, v_3\$:
$$ N = (v_2 - v_1) \times (v_3 - v_1) $$

  • Tangents and Bitangents: The tangents (\$T_i\$) and bitangents (\$B_i\$) are computed using texture coordinates to support normal mapping:
    $$ T = computeTangent(v_1, v_2, v_3, t_1, t_2, t_3) $$

where \$t_1, t_2, t_3\$ are the texture coordinates.

Constitutive or Kinematic Laws

The VisualModelImpl does not implement any constitutive laws (material models like hyperelasticity). Instead, it manages geometric and visual properties:
- Normals: Surface normals are computed for each vertex to support shading in rendering pipelines.
- Tangents: Tangent vectors are used for normal mapping to simulate complex surface details.

Role in the Global FEM Pipeline

While VisualModelImpl does not directly contribute to solving nonlinear dynamics or linear systems, it supports visualization by managing mesh geometry and transformations. It interacts with other SOFA components like topology containers (BaseMeshTopology) to synchronize mesh data for rendering:
- Data Fields: The class uses several data fields such as vertices, normals, texture coordinates, triangles, quads, edges, and material properties.

Numerical Methods or Discretization Choices

The VisualModelImpl class does not encode numerical methods related to FEM discretization. However, it includes discrete geometric operations like computing surface normals using face normals, which are essential for rendering:
- Normal Computation: Normals are averaged over the faces sharing a vertex.
- Tangent Computation: Tangents are computed based on texture coordinates and vertex positions.

Variational / Lagrangian Mechanics Framework

The VisualModelImpl class is not involved in variational mechanics or Lagrangian formulations. Its primary role is to provide visual representation of 3D models with the ability to apply transformations, compute normals, and manage textures for rendering purposes.

Data Fields
NameTypeDefaultHelp
d_initRestPositions bool True if rest positions must be initialized with initial positions
d_useNormals bool True if normal smoothing groups should be read from file
d_updateNormals bool True if normals should be updated at each iteration
d_computeTangents bool True if tangents should be computed at startup
d_updateTangents bool True if tangents should be updated at each iteration
d_handleDynamicTopology bool True if topological changes should be handled
d_fixMergedUVSeams bool True if UV seams should be handled even when duplicate UVs are merged
d_keepLines bool keep and draw lines (false by default)
d_vertices2 VecCoord vertices of the model (only if vertices have multiple normals/texcoords, otherwise positions are used)
d_translation Vec3Real Initial Translation of the object
d_rotation Vec3Real Initial Rotation of the object
d_scale Vec3Real Initial Scale of the object
d_scaleTex TexCoord Scale of the texture
d_translationTex TexCoord Translation of the texture
d_material sofa::type::Material Material
d_putOnlyTexCoords bool Give Texture Coordinates without the texture binding
d_srgbTexturing bool When sRGB rendering is enabled, is the texture in sRGB colorspace?
Links
NameTypeHelp
l_topology link to the topology container
Methods
void internalDraw (const core::visual::VisualParams * , bool ) virtual
void applyTranslation (const SReal dx, const SReal dy, const SReal dz) virtual
void applyRotation (const SReal rx, const SReal ry, const SReal rz) virtual
void applyRotation (const sofa::type::Quat<SReal> q) virtual
void applyScale (const SReal sx, const SReal sy, const SReal sz) virtual
void applyUVTransformation () virtual
void applyUVTranslation (const Real dU, const Real dV)
void applyUVScale (const Real su, const Real sv)
void setTranslation (SReal dx, SReal dy, SReal dz)
void setRotation (SReal rx, SReal ry, SReal rz)
void setScale (SReal sx, SReal sy, SReal sz)
void parse (core::objectmodel::BaseObjectDescription * arg) virtual
bool hasTransparent () virtual
bool hasOpaque ()
void doDrawVisual (const core::visual::VisualParams * vparams) virtual
void drawTransparent (const core::visual::VisualParams * vparams) virtual
void drawShadow (const core::visual::VisualParams * vparams) virtual
bool loadTextures () virtual
bool loadTexture (const int & ) virtual
bool load (const int & filename, const int & loader, const int & textureName)
void flipFaces ()
void setFilename (int s)
int getFilename ()
void setColor (float r, float g, float b, float a)
void setColor (int color)
void setUseNormals (bool val)
bool getUseNormals ()
void setCastShadow (bool val)
bool getCastShadow ()
void setMesh (helper::io::Mesh & m, bool tex)
bool isUsingTopology ()
const VecCoord & getVertices ()
const VecDeriv & getVnormals ()
const VecTexCoord & getVtexcoords ()
const VecCoord & getVtangents ()
const VecCoord & getVbitangents ()
const VecVisualTriangle & getTriangles ()
const VecVisualQuad & getQuads ()
const VecVisualEdge & getEdges ()
void setVertices (VecCoord * x)
void setVnormals (VecDeriv * vn)
void setVtexcoords (VecTexCoord * vt)
void setVtangents (VecCoord * v)
void setVbitangents (VecCoord * v)
void setTriangles (VecVisualTriangle * t)
void setQuads (VecVisualQuad * q)
void setEdges (VecVisualEdge * e)
void computePositions () virtual
void computeMesh () virtual
void computeNormals () virtual
void computeTangents () virtual
void computeBBox (const core::ExecParams * params, bool ) virtual
void computeUVSphereProjection () virtual
void updateBuffers () virtual
void deleteBuffers () virtual
void deleteTextures () virtual
void doUpdateVisual (const core::visual::VisualParams * ) virtual
void init () virtual
void initFromTopology ()
void initPositionFromVertices ()
void initFromFileMesh ()
void exportOBJ (int name, int * out, int * mtl, int & vindex, int & nindex, int & tindex, int & count)
int GetCustomTemplateName ()
Coord computeTangent (const Coord & v1, const Coord & v2, const Coord & v3, const TexCoord & t1, const TexCoord & t2, const TexCoord & t3)
Coord computeBitangent (const Coord & v1, const Coord & v2, const Coord & v3, const TexCoord & t1, const TexCoord & t2, const TexCoord & t3)
bool insertInNode (core::objectmodel::BaseNode * node) virtual
bool removeInNode (core::objectmodel::BaseNode * node) virtual
{
  "name": "VisualModelImpl",
  "namespace": "sofa::component::visual",
  "module": "Sofa.Component.Visual",
  "include": "sofa/component/visual/VisualModelImpl.h",
  "doc": "Generic visual model. If a viewer is active it will replace the VisualModel alias, otherwise nothing will be displayed.\n\nAbstract class which implements partially VisualModel.\n This class implemented all non-hardware (i.e OpenGL or DirectX)\n specific functions for rendering. It takes a 3D model (basically a .OBJ model)\n and apply transformations on it.\n At the moment, it is only implemented by OglModel for OpenGL systems.",
  "inherits": [
    "VisualModel"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_initRestPositions",
      "type": "bool",
      "xmlname": "initRestPositions",
      "help": "True if rest positions must be initialized with initial positions"
    },
    {
      "name": "d_useNormals",
      "type": "bool",
      "xmlname": "useNormals",
      "help": "True if normal smoothing groups should be read from file"
    },
    {
      "name": "d_updateNormals",
      "type": "bool",
      "xmlname": "updateNormals",
      "help": "True if normals should be updated at each iteration"
    },
    {
      "name": "d_computeTangents",
      "type": "bool",
      "xmlname": "computeTangents",
      "help": "True if tangents should be computed at startup"
    },
    {
      "name": "d_updateTangents",
      "type": "bool",
      "xmlname": "updateTangents",
      "help": "True if tangents should be updated at each iteration"
    },
    {
      "name": "d_handleDynamicTopology",
      "type": "bool",
      "xmlname": "handleDynamicTopology",
      "help": "True if topological changes should be handled"
    },
    {
      "name": "d_fixMergedUVSeams",
      "type": "bool",
      "xmlname": "fixMergedUVSeams",
      "help": "True if UV seams should be handled even when duplicate UVs are merged"
    },
    {
      "name": "d_keepLines",
      "type": "bool",
      "xmlname": "keepLines",
      "help": "keep and draw lines (false by default)"
    },
    {
      "name": "d_vertices2",
      "type": "VecCoord",
      "xmlname": "vertices",
      "help": "vertices of the model (only if vertices have multiple normals/texcoords, otherwise positions are used)"
    },
    {
      "name": "d_translation",
      "type": "Vec3Real",
      "xmlname": "translation",
      "help": "Initial Translation of the object"
    },
    {
      "name": "d_rotation",
      "type": "Vec3Real",
      "xmlname": "rotation",
      "help": "Initial Rotation of the object"
    },
    {
      "name": "d_scale",
      "type": "Vec3Real",
      "xmlname": "scale3d",
      "help": "Initial Scale of the object"
    },
    {
      "name": "d_scaleTex",
      "type": "TexCoord",
      "xmlname": "scaleTex",
      "help": "Scale of the texture"
    },
    {
      "name": "d_translationTex",
      "type": "TexCoord",
      "xmlname": "translationTex",
      "help": "Translation of the texture"
    },
    {
      "name": "d_material",
      "type": "sofa::type::Material",
      "xmlname": "material",
      "help": "Material"
    },
    {
      "name": "d_putOnlyTexCoords",
      "type": "bool",
      "xmlname": "putOnlyTexCoords",
      "help": "Give Texture Coordinates without the texture binding"
    },
    {
      "name": "d_srgbTexturing",
      "type": "bool",
      "xmlname": "srgbTexturing",
      "help": "When sRGB rendering is enabled, is the texture in sRGB colorspace?"
    }
  ],
  "links": [
    {
      "name": "l_topology",
      "target": "BaseMeshTopology",
      "kind": "single",
      "xmlname": "topology",
      "help": "link to the topology container"
    }
  ],
  "methods": [
    {
      "name": "internalDraw",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "const core::visual::VisualParams *"
        },
        {
          "name": "",
          "type": "bool"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyTranslation",
      "return_type": "void",
      "params": [
        {
          "name": "dx",
          "type": "const SReal"
        },
        {
          "name": "dy",
          "type": "const SReal"
        },
        {
          "name": "dz",
          "type": "const SReal"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyRotation",
      "return_type": "void",
      "params": [
        {
          "name": "rx",
          "type": "const SReal"
        },
        {
          "name": "ry",
          "type": "const SReal"
        },
        {
          "name": "rz",
          "type": "const SReal"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyRotation",
      "return_type": "void",
      "params": [
        {
          "name": "q",
          "type": "const sofa::type::Quat<SReal>"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyScale",
      "return_type": "void",
      "params": [
        {
          "name": "sx",
          "type": "const SReal"
        },
        {
          "name": "sy",
          "type": "const SReal"
        },
        {
          "name": "sz",
          "type": "const SReal"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyUVTransformation",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyUVTranslation",
      "return_type": "void",
      "params": [
        {
          "name": "dU",
          "type": "const Real"
        },
        {
          "name": "dV",
          "type": "const Real"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyUVScale",
      "return_type": "void",
      "params": [
        {
          "name": "su",
          "type": "const Real"
        },
        {
          "name": "sv",
          "type": "const Real"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setTranslation",
      "return_type": "void",
      "params": [
        {
          "name": "dx",
          "type": "SReal"
        },
        {
          "name": "dy",
          "type": "SReal"
        },
        {
          "name": "dz",
          "type": "SReal"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setRotation",
      "return_type": "void",
      "params": [
        {
          "name": "rx",
          "type": "SReal"
        },
        {
          "name": "ry",
          "type": "SReal"
        },
        {
          "name": "rz",
          "type": "SReal"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setScale",
      "return_type": "void",
      "params": [
        {
          "name": "sx",
          "type": "SReal"
        },
        {
          "name": "sy",
          "type": "SReal"
        },
        {
          "name": "sz",
          "type": "SReal"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "parse",
      "return_type": "void",
      "params": [
        {
          "name": "arg",
          "type": "core::objectmodel::BaseObjectDescription *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "hasTransparent",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "hasOpaque",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doDrawVisual",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "drawTransparent",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "drawShadow",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "loadTextures",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "loadTexture",
      "return_type": "bool",
      "params": [
        {
          "name": "",
          "type": "const int &"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "load",
      "return_type": "bool",
      "params": [
        {
          "name": "filename",
          "type": "const int &"
        },
        {
          "name": "loader",
          "type": "const int &"
        },
        {
          "name": "textureName",
          "type": "const int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "flipFaces",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setFilename",
      "return_type": "void",
      "params": [
        {
          "name": "s",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getFilename",
      "return_type": "int",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setColor",
      "return_type": "void",
      "params": [
        {
          "name": "r",
          "type": "float"
        },
        {
          "name": "g",
          "type": "float"
        },
        {
          "name": "b",
          "type": "float"
        },
        {
          "name": "a",
          "type": "float"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setColor",
      "return_type": "void",
      "params": [
        {
          "name": "color",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setUseNormals",
      "return_type": "void",
      "params": [
        {
          "name": "val",
          "type": "bool"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getUseNormals",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setCastShadow",
      "return_type": "void",
      "params": [
        {
          "name": "val",
          "type": "bool"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getCastShadow",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setMesh",
      "return_type": "void",
      "params": [
        {
          "name": "m",
          "type": "helper::io::Mesh &"
        },
        {
          "name": "tex",
          "type": "bool"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "isUsingTopology",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getVertices",
      "return_type": "const VecCoord &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getVnormals",
      "return_type": "const VecDeriv &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getVtexcoords",
      "return_type": "const VecTexCoord &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getVtangents",
      "return_type": "const VecCoord &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getVbitangents",
      "return_type": "const VecCoord &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getTriangles",
      "return_type": "const VecVisualTriangle &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getQuads",
      "return_type": "const VecVisualQuad &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getEdges",
      "return_type": "const VecVisualEdge &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setVertices",
      "return_type": "void",
      "params": [
        {
          "name": "x",
          "type": "VecCoord *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setVnormals",
      "return_type": "void",
      "params": [
        {
          "name": "vn",
          "type": "VecDeriv *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setVtexcoords",
      "return_type": "void",
      "params": [
        {
          "name": "vt",
          "type": "VecTexCoord *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setVtangents",
      "return_type": "void",
      "params": [
        {
          "name": "v",
          "type": "VecCoord *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setVbitangents",
      "return_type": "void",
      "params": [
        {
          "name": "v",
          "type": "VecCoord *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setTriangles",
      "return_type": "void",
      "params": [
        {
          "name": "t",
          "type": "VecVisualTriangle *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setQuads",
      "return_type": "void",
      "params": [
        {
          "name": "q",
          "type": "VecVisualQuad *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setEdges",
      "return_type": "void",
      "params": [
        {
          "name": "e",
          "type": "VecVisualEdge *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computePositions",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeMesh",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeNormals",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeTangents",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeBBox",
      "return_type": "void",
      "params": [
        {
          "name": "params",
          "type": "const core::ExecParams *"
        },
        {
          "name": "",
          "type": "bool"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeUVSphereProjection",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "updateBuffers",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "deleteBuffers",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "deleteTextures",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doUpdateVisual",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "initFromTopology",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "initPositionFromVertices",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "initFromFileMesh",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "exportOBJ",
      "return_type": "void",
      "params": [
        {
          "name": "name",
          "type": "int"
        },
        {
          "name": "out",
          "type": "int *"
        },
        {
          "name": "mtl",
          "type": "int *"
        },
        {
          "name": "vindex",
          "type": "int &"
        },
        {
          "name": "nindex",
          "type": "int &"
        },
        {
          "name": "tindex",
          "type": "int &"
        },
        {
          "name": "count",
          "type": "int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "GetCustomTemplateName",
      "return_type": "int",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": true,
      "access": "public"
    },
    {
      "name": "computeTangent",
      "return_type": "Coord",
      "params": [
        {
          "name": "v1",
          "type": "const Coord &"
        },
        {
          "name": "v2",
          "type": "const Coord &"
        },
        {
          "name": "v3",
          "type": "const Coord &"
        },
        {
          "name": "t1",
          "type": "const TexCoord &"
        },
        {
          "name": "t2",
          "type": "const TexCoord &"
        },
        {
          "name": "t3",
          "type": "const TexCoord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": true,
      "access": "public"
    },
    {
      "name": "computeBitangent",
      "return_type": "Coord",
      "params": [
        {
          "name": "v1",
          "type": "const Coord &"
        },
        {
          "name": "v2",
          "type": "const Coord &"
        },
        {
          "name": "v3",
          "type": "const Coord &"
        },
        {
          "name": "t1",
          "type": "const TexCoord &"
        },
        {
          "name": "t2",
          "type": "const TexCoord &"
        },
        {
          "name": "t3",
          "type": "const TexCoord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": true,
      "access": "public"
    },
    {
      "name": "insertInNode",
      "return_type": "bool",
      "params": [
        {
          "name": "node",
          "type": "core::objectmodel::BaseNode *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "removeInNode",
      "return_type": "bool",
      "params": [
        {
          "name": "node",
          "type": "core::objectmodel::BaseNode *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `VisualModelImpl` class is part of the SOFA framework and serves as an abstract base for implementing visual models in simulations. It handles 3D model rendering by taking a 3D object, such as an OBJ file, and applying transformations to it (translation, rotation, scaling) while managing topological changes if linked to a topology container.\n\nThe `VisualModelImpl` class inherits from the `core::visual::VisualModel` interface and implements common non-hardware-specific functions for rendering. It contains methods to load 3D models, compute normals and tangents, handle mesh data (vertices, triangles, quads), and manage transformations. The class supports dynamic topology changes through callbacks and can update its visual state based on the mechanical state of the simulation.\n\nThe component interacts with other SOFA components by linking to a `BaseMeshTopology` container via the `l_topology` link. This allows it to synchronize mesh data from the topology for rendering purposes. It also provides methods to insert or remove itself into/from a node, update visual elements based on current simulation state (`doUpdateVisual`, `computePositions`, etc.), and draw the object (`internalDraw`).\n\nData fields in this component include settings for rest positions initialization (`initRestPositions`), normal smoothing (`useNormals`), dynamic topology handling (`handleDynamicTopology`), texture transformations (`scaleTex`, `translationTex`), and material properties (`material`). Other data fields store mesh geometry (vertices, normals, texcoords) and transformation attributes like translation, rotation, and scale.\n\nTo use this component effectively, users should configure the necessary data fields for loading a 3D model, specifying texture transformations, setting up topology links if dynamic changes are needed, and customizing material properties. The `VisualModelImpl` class itself is not meant to be directly instantiated but rather serves as an abstract base that needs hardware-specific implementations (like OpenGL) for full functionality.",
  "maths": "The `VisualModelImpl` class within the SOFA framework is primarily concerned with visual rendering aspects, rather than physical or mathematical simulation equations that are typical in FEM simulations. Its main role involves managing 3D models (such as .OBJ files) for visualization purposes and handling transformations such as translation, rotation, and scaling. The component also supports normal computations and texture coordinate management. Here is a detailed description of its functionalities:\n\n### Governing Equations or Operators\n\nThe `VisualModelImpl` does not directly contribute to the core FEM operators like the mass matrix (\\(M\")), stiffness matrix (\\(K\")), internal forces (\\(f_{int}\")), residual (\\(R\")), or tangent stiffness. Instead, it deals with geometric transformations and visual representation.\n\n#### Transformations\nThe class provides methods for applying transformations to a 3D model:\n- **Translation**: Translates the object by a given vector \\\\[ \\Delta x = (dx, dy, dz) \\\\]:\n  \\[\n  X_{new} = X + \\Delta x,\n  \\]\n  where \\\\(X\\\\) and \\\\(X_{new}\\\\) are the original and new positions of a vertex.\n\n- **Rotation**: Applies rotation through Euler angles or quaternions. For example, using Euler angles in degrees:\n  \\[\n  R_x(\\theta_x), R_y(\\theta_y), R_z(\\theta_z)\n  \\]\n  where \\\\(R_i(\\theta)\\\\) is the rotation matrix around axis \\\\(i\\\\) with angle \\\\(\\theta\\\\).\n\n- **Scaling**: Scales the object by a given factor:\n  \\[\n  X_{new} = s_x X_x, s_y X_y, s_z X_z,\n  \\]\n  where \\\\(s_x, s_y, s_z\\\\) are scaling factors along each axis.\n\n#### Normals and Tangents\nThe `VisualModelImpl` class computes surface normals and tangents which are important for rendering purposes:\n- **Normals**: The normal vector \\\\(N_i\\\\) at a vertex is computed as the average of the face normals around that vertex. For a triangle defined by vertices \\\\(v_1, v_2, v_3\\\\):\n  \\[\n  N = (v_2 - v_1) \\times (v_3 - v_1)\n  \\]\n- **Tangents and Bitangents**: The tangents (\\\\(T_i\\\\)) and bitangents (\\\\(B_i\\\\)) are computed using texture coordinates to support normal mapping:\n  \\[\n  T = computeTangent(v_1, v_2, v_3, t_1, t_2, t_3)\n  \\]\n  where \\\\(t_1, t_2, t_3\\\\) are the texture coordinates.\n\n### Constitutive or Kinematic Laws\nThe `VisualModelImpl` does not implement any constitutive laws (material models like hyperelasticity). Instead, it manages geometric and visual properties:\n- **Normals**: Surface normals are computed for each vertex to support shading in rendering pipelines.\n- **Tangents**: Tangent vectors are used for normal mapping to simulate complex surface details.\n\n### Role in the Global FEM Pipeline\nWhile `VisualModelImpl` does not directly contribute to solving nonlinear dynamics or linear systems, it supports visualization by managing mesh geometry and transformations. It interacts with other SOFA components like topology containers (`BaseMeshTopology`) to synchronize mesh data for rendering:\n- **Data Fields**: The class uses several data fields such as vertices, normals, texture coordinates, triangles, quads, edges, and material properties.\n\n### Numerical Methods or Discretization Choices\nThe `VisualModelImpl` class does not encode numerical methods related to FEM discretization. However, it includes discrete geometric operations like computing surface normals using face normals, which are essential for rendering:\n- **Normal Computation**: Normals are averaged over the faces sharing a vertex.\n- **Tangent Computation**: Tangents are computed based on texture coordinates and vertex positions.\n\n### Variational / Lagrangian Mechanics Framework\nThe `VisualModelImpl` class is not involved in variational mechanics or Lagrangian formulations. Its primary role is to provide visual representation of 3D models with the ability to apply transformations, compute normals, and manage textures for rendering purposes.",
  "abstract": "VisualModelImpl manages the visualization of 3D models by applying transformations and handling mesh data for rendering purposes.",
  "sheet": "# VisualModelImpl\n\n## Overview\nVisualModelImpl is an abstract base class in SOFA that handles the visualization of 3D models. It applies transformations (translation, rotation, scaling) to a given model and manages mesh data for rendering purposes by linking to a topology container.\n\n## Parameters and Data\nThe significant Data fields exposed by VisualModelImpl include:\n- `initRestPositions`: True if rest positions must be initialized with initial positions.\n- `useNormals`: True if normal smoothing groups should be read from file.\n- `updateNormals`: True if normals should be updated at each iteration.\n- `computeTangents`: True if tangents should be computed at startup.\n- `updateTangents`: True if tangents should be updated at each iteration.\n- `handleDynamicTopology`: True if topological changes should be handled.\n- `fixMergedUVSeams`: True if UV seams should be handled even when duplicate UVs are merged.\n- `keepLines`: keep and draw lines (false by default).\n- `vertices2`: vertices of the model (only if vertices have multiple normals/texcoords, otherwise positions are used).\n- `translation`: Initial Translation of the object.\n- `rotation`: Initial Rotation of the object.\n- `scale3d`: Initial Scale of the object.\n- `scaleTex`: Scale of the texture.\n- `translationTex`: Translation of the texture.\n- `material`: Material properties.\n- `putOnlyTexCoords`: Give Texture Coordinates without the texture binding.\n- `srgbTexturing`: When sRGB rendering is enabled, is the texture in sRGB colorspace?\n\n## Dependencies and Connections\nVisualModelImpl typically requires a topology container (`BaseMeshTopology`) to manage mesh data for rendering purposes. It links to this container via the `l_topology` link."
}