SEARCH
TOOLBOX
LANGUAGES
VisualStyle

VisualStyle

From SOFAWiki

Jump to: navigation, search

Contents

Description

VisualStyle component controls the DisplayFlags state embedded in the VisualParams for the current subgraph. It merges the DisplayFlags conveyed by the VisualParams with its own DisplayFlags.

Example

Taken from

examples/Components/visualmodel/VisualStyle.scn 
<Node 	name="root" gravity="0 -9.81 0" dt="0.02"   >
  <VisualStyle displayFlags="showBehavior" />
	<Node 	name="Liver" gravity="0 -9.81 0" depend="topo dofs"  >
                <MeshGmshLoader name="meshLoader"  filename="mesh/liver.msh" />
		<TetrahedronSetTopologyContainer name="topo" src="@meshLoader" />
		<MechanicalObject  name="dofs"   src="@meshLoader" />
		<TetrahedronSetGeometryAlgorithms  name="GeomAlgo" />
		<DiagonalMass name="computed using mass density"  massDensity="1" />
		<TetrahedralCorotationalFEMForceField template="Vec3d" name="FEM"  method="large"  poissonRatio="0.3"  youngModulus="3000"  computeGlobalMatrix="0" />
		<FixedConstraint  name="FixedConstraint"  indices="3 39 64" />
		<Node 	name="Visu" tags="Visual" gravity="0 -9.81 0"  showVisualModels="0" >
                        <VisualStyle displayFlags="showVisual showWireframe" /> 
			<OglModel  name="VisualModel"  fileMesh="mesh/liver-smooth.obj" />
			<BarycentricMapping name="visual mapping"  input="@../dofs"  output="@VisualModel" />
		</Node>
		<Node 	name="Surf" gravity="0 -9.81 0"  >
                        <VisualStyle displayFlags="hideBehavior showCollision showWireframe"/>
			<MechanicalObject  name="spheres"  />
			<TSphereModel name="CollisionModel"  fileSphere="mesh/liver.sph" />
			<BarycentricMapping  name="sphere mapping" input="@../dofs" output="@spheres"/>
		</Node>
	</Node>
</Node>


Image:VisualStyle.jpg

XML Usage

<VisualStyle displayFlags="hideVisual showCollision showWireframe" />

allowed values for displayFlags data are a combination of the following:

showAll, hideAll,
  showVisual, hideVisual,
   showVisualModels, hideVisualModels,
  showBehavior, hideBehavior,
    showBehaviorModels, hideBehaviorModels,
    showForceFields, hideForceFields,
    showInteractionForceFields, hideInteractionForceFields
  showMapping, hideMapping
    showMappings, hideMappings
    showMechanicalMappings, hideMechanicalMappings
  showCollision, hideCollision
     showCollisionModels, hideCollisionModels
     showBoundingCollisionModels, hideBoundingCollisionModels
showOptions hideOptions
  showNormals hideNormals
  showWireframe hideWireframe


C++ Usage

In C++, to set the visual style in a node, you have to create a VisualStyle component, attach it to the node, create and tune a !DisplayFlags object and set the !VisualStyle with it, as shown in the following example:

  VisualStyle::SPtr visualStyle = New<sofa::component::visualmodel::VisualStyle>();
  root->addObject(visualStyle);
  VisualStyle::DisplayFlags displayFlags;
  displayFlags.setShowAll();
  visualStyle->displayFlags.setValue(displayFlags);

You can also use method component::visualmodel::addVisualStyle( simulation::Node::SPtr ) to insert a VisualStyle component at the given node and return a WriteAccessor on the display flags:

  addVisualStyle(root)->setShowVisual().setShowBehavior().setShowMapping(false);