Skip to content

OglModel

Generic visual model for OpenGL display

Vec3d

Templates:

  • Vec3d

Target: Sofa.GL.Component.Rendering3D

namespace: sofa::gl::component::rendering3d

parents:

  • VisualModelImpl

Data

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the objet belongs to
bbox this object bounding box
componentState The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). Undefined
listening if true, handle the events, otherwise ignore the events 0
enable Display the object or not 1
initRestPositions True if rest positions must be initialized with initial positions 0
useNormals True if normal smoothing groups should be read from file 1
updateNormals True if normals should be updated at each iteration 1
computeTangents True if tangents should be computed at startup 0
updateTangents True if tangents should be updated at each iteration 1
handleDynamicTopology True if topological changes should be handled 1
fixMergedUVSeams True if UV seams should be handled even when duplicate UVs are merged 1
keepLines keep and draw lines (false by default) 0
vertPosIdx If vertices have multiple normals/texcoords stores vertices position indices
vertNormIdx If vertices have multiple normals/texcoords stores vertices normal indices
filename Path to an ogl model
texturename Name of the Texture
scaleTex Scale of the texture 1 1
translationTex Translation of the texture 0 0
material Material
putOnlyTexCoords Give Texture Coordinates without the texture binding 0
srgbTexturing When sRGB rendering is enabled, is the texture in sRGB colorspace? 0
materials List of materials
groups Groups of triangles and quads using a given material
blendTranslucency Blend transparent parts 1
premultipliedAlpha is alpha premultiplied ? 0
writeZTransparent Write into Z Buffer for Transparent Object 0
alphaBlend Enable alpha blending 0
depthTest Enable depth testing 1
cullFace Face culling (0 = no culling, 1 = cull back faces, 2 = cull front faces) 0
lineWidth Line width (set if != 1, only for lines rendering) 1
pointSize Point size (set if != 1, only for points rendering) 1
lineSmooth Enable smooth line rendering 0
pointSmooth Enable smooth point rendering 0
primitiveType Select types of primitives to send (necessary for some shader types such as geometry or tesselation)
blendEquation if alpha blending is enabled this specifies how source and destination colors are combined
sfactor if alpha blending is enabled this specifies how the red, green, blue, and alpha source blending factors are computed
dfactor if alpha blending is enabled this specifies how the red, green, blue, and alpha destination blending factors are computed
Vector
position Vertices coordinates
restPosition Vertices rest coordinates
normal Normals of the model
vertices vertices of the model (only if vertices have multiple normals/texcoords, otherwise positions are used)
texcoords coordinates of the texture
tangents tangents for normal mapping
bitangents tangents for normal mapping
edges edges of the model
triangles triangles of the model
quads quads of the model
Transformation
translation Initial Translation of the object 0 0 0
rotation Initial Rotation of the object 0 0 0
scale3d Initial Scale of the object 1 1 1
Name Description Destination type name
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used) BaseContext
slaves Sub-objects used internally by this object BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject
topology link to the topology container BaseMeshTopology

Examples

OglModel.scn

<?xml version="1.0"?>
<Node name="root" dt="0.01">
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
    <DefaultAnimationLoop/>

    <MeshOBJLoader name="meshLoader_0" filename="mesh/snake_body.obj" translation="30 0 0" handleSeams="1" />
    <OglModel name="VisualModel" src="@meshLoader_0" useNormals="0"/>

    <MeshOBJLoader name="loader" filename="mesh/snake_body.obj" translation="0 0 0"/>    
    <OglModel name="VisualModel2"  src="@loader" color="red"/>

</Node>
def createScene(root_node):

   root = root_node.addChild('root', dt="0.01")

   root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('DefaultAnimationLoop', )
   root.addObject('MeshOBJLoader', name="meshLoader_0", filename="mesh/snake_body.obj", translation="30 0 0", handleSeams="1")
   root.addObject('OglModel', name="VisualModel", src="@meshLoader_0", useNormals="0")
   root.addObject('MeshOBJLoader', name="loader", filename="mesh/snake_body.obj", translation="0 0 0")
   root.addObject('OglModel', name="VisualModel2", src="@loader", color="red")