(from The Annotated VRML 2.0 Reference Manual)
#VRML V2.0 utf8 Group { children [ # The target object to be rotated needs three extra Transforms. # Two are used to rotate the local coordinate system, and # two are used as the targets for the sensors (T1 and T3). DEF T1 Transform { children Transform { rotation 0 0 1 -1.57 children DEF T2 Transform { children Transform { rotation 0 0 1 1.57 children Shape { appearance DEF A1 Appearance { material Material { diffuseColor 1 1 1 } } geometry Cone { bottomRadius 2 height 4 } } } } } } Transform { # left crank - rotates about Y axis => T1 translation -1 0 3 rotation 0 0 1 -1.57 children [ DEF T3 Transform { children DEF G1 Group { children [ Transform { rotation 0 0 1 1.57 translation -.5 0 0 children Shape { appearance USE A1 geometry Cylinder { radius .1 height 1 } } } Transform { rotation 0 0 1 1.57 translation -1 0 0 children Shape { geometry Sphere { radius .2 } appearance USE A1 } } ]} # end Group } DEF CS1 CylinderSensor { maxAngle 1.57 minAngle 0 } ] } Transform { # right crank - rotates about X-axis => T2 translation 1 0 3 rotation 0 0 1 -1.57 children [ DEF T4 Transform { children USE G1 } DEF CS2 CylinderSensor { maxAngle 1.57 minAngle 0 } ] } Transform { # housing to hold cranks translation 0 0 3 children Shape { geometry Box { size 3 0.5 0.5 } appearance USE A1 } } Background { skyColor 1 1 1 } ] } ROUTE CS1.rotation_changed TO T1.rotation # rotates about Y-axis ROUTE CS1.rotation_changed TO T3.rotation # rotates the crank handle ROUTE CS2.rotation_changed TO T2.rotation # rotates about local X-axis ROUTE CS2.rotation_changed TO T4.rotation # rotates the crank handle
mrl