Skip to content

TextureInterpolation

This component belongs to the category of Engines. This engine creates texture coordinate in 1D according to an input state vector. Coordinate can be interpolated either from min and max value of input states (default behavior) or on a manual define scale.

Input Data

  • input_states: input array of state values
  • input_coordinates: input array of coordinates values (not mandatory)

Output Data

  • output_coordinates: output array of texture coordinates

Additional Parameter

For manual scale :

  • min_value: minimum value of state value for interpolation
  • max_value: maximum value of state value for interpolation
  • manual_scale: compute texture interpolation on manually scale defined above

Examples

An example scene involving the TextureInterpolation engine is available in examples/Component/Engine/GL/TextureInterpolation.scn

Target: Sofa.GL.Component.Engine

namespace: sofa::gl::component::engine

parents:

  • DataEngine

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
input_coordinates input array of coordinates values.
scalarField To interpolate only the first dimension of input field (useful if this component need to be templated in higher dimension). 1
min_value minimum value of state value for interpolation. 0
max_value maximum value of state value for interpolation. 0
manual_scale compute texture interpolation on manually scale defined above. 0
vertexPloted Vertex index of values display in graph for each iteration. 0
graph Vertex state value per iteration
Inputs
input_states input array of state values.
Outputs
output_coordinates output array of texture coordinates.
Visualization
drawPotentiels Debug: view state values. 0
showIndicesScale Debug : scale of state values displayed. 0.0001

Links:

Name Description
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used)
slaves Sub-objects used internally by this object
master nullptr for regular objects, or master object for which this object is one sub-objects

Examples

Component/Engine/GL/TextureInterpolation.scn

<Node name="Root" gravity="0 0 0" dt="0.02">
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase BruteForceBroadPhase CollisionPipeline] -->
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
    <RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshGmshLoader] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TriangleSetTopologyContainer] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Engine"/> <!-- Needed to use components [TextureInterpolation] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->

    <DefaultAnimationLoop/>
    <VisualStyle displayFlags="showVisual showBehaviorModels showForceFields showCollision showMapping" />
    <CollisionPipeline name="DefaultCollisionPipeline" verbose="0" draw="0" depth="6" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <MinProximityIntersection name="Proximity" alarmDistance="0.3" contactDistance="0.2" />
    <CollisionResponse name="Response" response="PenalityContactForceField" />
    <Node name="MecaNode" gravity="0 0 0">
        <MeshGmshLoader name="loader" tags="meca" filename="mesh/square3.msh" />
        <MechanicalObject src="@loader" template="Vec3" name="mecaObj" tags="meca" scale="10" />
        <TriangleSetTopologyContainer src="@loader" name="topo" tags="meca" />
        <Node name="ElecNode" gravity="0 0 0">
            <EulerImplicitSolver name="euler" tags="elec"  rayleighStiffness="0.1" rayleighMass="0.1" />
            <CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" tags="elec" />
            <MechanicalObject template="Vec1" name="ElecObj" position="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&#x0A;&#x09;&#x09;&#x09;&#x09;  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" tags="elec" />
            <!-- Components used in heat diffusion, still in work in Sophia. the potentiel
    evolve and interpolation is computed at the same time to display the diffusion. -->
            <!--   <TriangularDiffusionForceField template="Vec1" name="ffDiffusion" tags="elec"/>
             <MeshMatrixMass template="Vec1" name="mass" tags="elec" />   -->
        </Node>
        <Node name="visu" gravity="0 0 0">
            <TextureInterpolation template="Vec1" name="EngineInterpolation" input_states="@../ElecNode/ElecObj.position" input_coordinates="@../mecaObj.position" min_value="0.0" max_value="10.0" manual_scale="1" drawPotentiels="1" />
            <OglModel template="Vec3" name="oglPotentiel" texcoords="@EngineInterpolation.output_coordinates" texturename="textures/heatColor.bmp" handleDynamicTopology="0" />
        </Node>
    </Node>
</Node>
def createScene(rootNode):

    Root = rootNode.addChild('Root', gravity="0 0 0", dt="0.02")
    Root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Algorithm")
    Root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Intersection")
    Root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
    Root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
    Root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
    Root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
    Root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
    Root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Dynamic")
    Root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
    Root.addObject('RequiredPlugin', name="Sofa.GL.Component.Engine")
    Root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
    Root.addObject('DefaultAnimationLoop')
    Root.addObject('VisualStyle', displayFlags="showVisual showBehaviorModels showForceFields showCollision showMapping")
    Root.addObject('CollisionPipeline', name="DefaultCollisionPipeline", verbose="0", draw="0", depth="6")
    Root.addObject('BruteForceBroadPhase')
    Root.addObject('BVHNarrowPhase')
    Root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="0.3", contactDistance="0.2")
    Root.addObject('CollisionResponse', name="Response", response="PenalityContactForceField")

    MecaNode = Root.addChild('MecaNode', gravity="0 0 0")
    MecaNode.addObject('MeshGmshLoader', name="loader", tags="meca", filename="mesh/square3.msh")
    MecaNode.addObject('MechanicalObject', src="@loader", template="Vec3", name="mecaObj", tags="meca", scale="10")
    MecaNode.addObject('TriangleSetTopologyContainer', src="@loader", name="topo", tags="meca")

    ElecNode = MecaNode.addChild('ElecNode', gravity="0 0 0")
    ElecNode.addObject('EulerImplicitSolver', name="euler", tags="elec", rayleighStiffness="0.1", rayleighMass="0.1")
    ElecNode.addObject('CGLinearSolver', iterations="25", name="linear solver", tolerance="1.0e-9", threshold="1.0e-9", tags="elec")
    ElecNode.addObject('MechanicalObject', template="Vec1", name="ElecObj", position="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 10 10 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", tags="elec")

    visu = MecaNode.addChild('visu', gravity="0 0 0")
    visu.addObject('TextureInterpolation', template="Vec1", name="EngineInterpolation", input_states="@../ElecNode/ElecObj.position", input_coordinates="@../mecaObj.position", min_value="0.0", max_value="10.0", manual_scale="1", drawPotentiels="1")
    visu.addObject('OglModel', template="Vec3", name="oglPotentiel", texcoords="@EngineInterpolation.output_coordinates", texturename="textures/heatColor.bmp", handleDynamicTopology="0")