Toggle group

From H3D.org

Jump to: navigation, search

The ToggleGroup node allows users enable or disable the graphics and/or haptics rendering of its children nodes. It contains the fields graphicsOn and hapticsOn for this purpose.


Learning objective:

  • Using the ToggleGroup node


 
<Scene>
  <ToggleGroup DEF="T">
    <Shape>
      <Appearance>
        <Material diffuseColor="0.5 0.7 0" />
        <FrictionalSurface />
      </Appearance>
      <Box size="0.1 0.1 0.05"/>
    </Shape>
  </ToggleGroup>
  <MouseSensor DEF="M" />
  <ROUTE fromNode="M" fromField="rightButton" toNode="T" toField="hapticsOn" />
  <ROUTE fromNode="M" fromField="leftButton" toNode="T" toField="graphicsOn" />
</Scene>
 

In the example above, we enclose our shape in a ToggleGroup. We also add a MouseSensor to the scene. rightButton is routed to hapticsOn, while leftButton is routed to graphicsOn. Now when the left mouse button is clicked, the shape is rendered, when the right button is clicked the haptics of the geometry is rendered.

References

Personal tools
go to