#VRML++ draft utf8 WorldInfo { title "Walking Man Example" info [ "Author: Stephan Diehl", "1997" ] } Background { groundColor [ 0.3 0.5 0.3 , 0.1 0.4 0.1 ] groundAngle 1.57 skyColor 0 0 0.6 } PROTO ArmPart [exposedField SFColor color 1 0 0] { Transform { children [ Transform { children Shape { appearance Appearance { material DEF ARMMATERIAL Material { diffuseColor IS color } } geometry Cone { bottomRadius 0.07 height .20 } } translation 0 0.30 0 }, Transform { children Shape { appearance Appearance { material USE ARMMATERIAL } geometry Cone { bottomRadius 0.07 height .20 } } translation 0 0.10 0 rotation 0 0 1 3.14 } ] } } PROTO Arm [ exposedField SFRotation toprotation 0 0 0 0 exposedField SFRotation botrotation 0 0 0 0 exposedField SFColor color 1 0 0 ] { Transform { children [ ArmPart { color IS color } Transform { children ArmPart { color IS color } translation 0 0.40 0 rotation IS toprotation } ] rotation IS botrotation } } PROTO BodyPart [ exposedField SFColor color 1 1 0 ] { Transform { children [ Transform { children Shape { appearance Appearance { material DEF BODYMATERIAL Material { diffuseColor IS color } } geometry Sphere { radius 0.10 } } scale 1 1.5 1 }, Transform { children Shape { appearance Appearance { material USE BODYMATERIAL } geometry Cone { bottomRadius 0.15 height .35 } } translation 0 0.175 0 rotation 0 0 1 3.14 }, Transform { children Shape { appearance Appearance { material USE BODYMATERIAL } geometry Cone { bottomRadius 0.15 height .35 } } translation 0 -0.175 0 } ] } } PROTO Head [ exposedField SFColor color 0 0 1 exposedField SFColor hatColor 1 0.5 0.5 ] { Transform { children [ Shape { appearance Appearance { material Material { diffuseColor IS color } } geometry Sphere { radius 0.12 } }, Transform { children Shape { appearance Appearance { material Material { diffuseColor IS hatColor } } geometry Cone { bottomRadius 0.14 height 0.10 } } translation 0 0.115 0 } ] translation 0 0.12 0 } } ### WALKMAN CLASS JointInterpolator [ eventIn SFFloat set_fraction eventOut SFRotation value_changed ] EXTENDS SFNode { } # abstract class CLASS Walkman [ field TimeSensor clock NULL field TimeSensor slowclock NULL field ScalarInterpolator leftphase NULL field ScalarInterpolator rightphase NULL field JointInterpolator legleftinttop NULL field JointInterpolator legrightinttop NULL field JointInterpolator legleftintbot NULL field JointInterpolator legrightintbot NULL field JointInterpolator armleftinttop NULL field JointInterpolator armrightinttop NULL field JointInterpolator armleftintbot NULL field JointInterpolator armrightintbot NULL field PositionInterpolator heightint NULL field PositionInterpolator posint NULL ] EXTENDS SFNode { DEF BODY Transform { children DEF BODYheight Transform { children [ BodyPart { color .14 .14 .15 }, Transform { children DEF HEAD Head { color 0.4 0.4 0.5 hatColor 0.6 0.4 0.5 } translation 0 0.35 0 }, Transform { children DEF ARMright Arm { color 0.4 0.4 0.45 } translation 0.15 0.30 0 rotation 0 0 1 3.14 }, Transform { children DEF ARMleft Arm { color 0.4 0.4 0.45 } translation -0.15 0.30 0 rotation 0 0 1 3.14 }, Transform { children DEF LEGright Arm { color 0.5 0.5 0.55 } translation 0.12 -0.35 0 rotation 0 0 1 3.14 }, Transform { children DEF LEGleft Arm { color 0.5 0.5 0.55 } translation -0.12 -0.35 0 rotation 0 0 1 3.14 } ] } } ROUTE clock.fraction_changed TO rightphase.set_fraction ROUTE clock.fraction_changed TO leftphase.set_fraction # MOVE RIGHT ARMS ROUTE rightphase.value_changed TO armrightinttop.set_fraction ROUTE rightphase.value_changed TO armrightintbot.set_fraction ROUTE armrightinttop.value_changed TO ARMright.set_toprotation ROUTE armrightintbot.value_changed TO ARMright.set_botrotation # MOVE LEFT ARMS ROUTE leftphase.value_changed TO armleftinttop.set_fraction ROUTE leftphase.value_changed TO armleftintbot.set_fraction ROUTE armleftinttop.value_changed TO ARMleft.set_toprotation ROUTE armleftintbot.value_changed TO ARMleft.set_botrotation # MOVE RIGHT LEG ROUTE leftphase.value_changed TO legrightinttop.set_fraction ROUTE leftphase.value_changed TO legrightintbot.set_fraction ROUTE legrightinttop.value_changed TO LEGright.set_toprotation ROUTE legrightintbot.value_changed TO LEGright.set_botrotation # MOVE LEFT LEG ROUTE rightphase.value_changed TO legleftinttop.set_fraction ROUTE rightphase.value_changed TO legleftintbot.set_fraction ROUTE legleftinttop.value_changed TO LEGleft.set_toprotation ROUTE legleftintbot.value_changed TO LEGleft.set_botrotation # MOVE BODY ROUTE slowclock.fraction_changed TO posint.set_fraction ROUTE posint.value_changed TO BODY.set_translation ROUTE clock.fraction_changed TO heightint.set_fraction ROUTE heightint.value_changed TO BODYheight.set_translation } # ViewPoints DEF BestView Viewpoint { description "Best View" position 20 5 10 orientation 0 1 0.2 1.57 } # Interpolators # Orientation of Arm CLASS ArmIntBot [ eventIn SFFloat set_fraction eventOut SFRotation value_changed ] EXTENDS JointInterpolator { OrientationInterpolator { set_fraction IS set_fraction value_changed IS value_changed key [ 0 , 0.2, 0.8, 1 ] keyValue [ 0 0 0 0, 1 0 0 1.4, 1 0 0 -1.4, 0 0 0 0 ] } } CLASS ArmIntTop [ eventIn SFFloat set_fraction eventOut SFRotation value_changed ] EXTENDS JointInterpolator { OrientationInterpolator { set_fraction IS set_fraction value_changed IS value_changed key [ 0 , 0.5, 1 ] keyValue [ 0 0 0 0, 1 0 0 1.0, 0 0 0 0 ] } } DEF ArmRightIntBot ArmIntBot { } DEF ArmLeftIntBot ArmIntBot { } DEF ArmRightIntTop ArmIntTop { } DEF ArmLeftIntTop ArmIntTop { } # Orientation of Right Leg CLASS LegIntBot [ eventIn SFFloat set_fraction eventOut SFRotation value_changed ] EXTENDS JointInterpolator { OrientationInterpolator { set_fraction IS set_fraction value_changed IS value_changed key [ 0 , 0.2, 0.8, 1 ] keyValue [ 0 0 0 0, 1 0 0 1.5, 1 0 0 -0.3, 0 0 0 0 ] } } CLASS LegIntTop [ eventIn SFFloat set_fraction eventOut SFRotation value_changed ] EXTENDS JointInterpolator { OrientationInterpolator { set_fraction IS set_fraction value_changed IS value_changed key [ 0 , 0.2, 0.8, 1 ] keyValue [ 0 0 0 0, 1 0 0 -1.5, 1 0 0 -0.3, 0 0 0 0 ] } } DEF LegRightIntBot LegIntBot { } DEF LegLeftIntBot LegIntBot { } DEF LegRightIntTop LegIntTop { } DEF LegLeftIntTop LegIntTop { } # Position of BODY DEF PosInt PositionInterpolator { # run 10 meters key [ 0, 1 ] keyValue [ 0 0 0, 0 0 20 ] } # Height of BODY DEF HeightInt PositionInterpolator { key [ 0 , 0.5, 1 ] keyValue [ 0 0 0, 0 -0.2 0, 0 0 0 ] } # CLOCKS DEF CLOCK TimeSensor { loop TRUE # cycleInterval 2 } DEF SLOWCLOCK TimeSensor { cycleInterval 20 loop TRUE } DEF RIGHTPHASE ScalarInterpolator { key [ 0, 1 ] keyValue [ 1, 0 ] } DEF LEFTPHASE ScalarInterpolator { key [ 0, 1 ] keyValue [ 0, 1 ] } # DANCER # DEF CLOCK TimeSensor { loop TRUE cycleInterval 3 } # DEF RIGHTPHASE ScalarInterpolator { key [ 0, 0.5, 1 ] keyValue [ 1, 0, 1 ] } # DEF LEFTPHASE ScalarInterpolator { key [ 0, 0.5, 1 ] keyValue [ 0, 1, 0 ] } ### INSTANTIATION DEF WALKER Walkman { clock USE CLOCK slowclock USE SLOWCLOCK leftphase USE LEFTPHASE rightphase USE RIGHTPHASE legleftinttop USE LegLeftIntTop legleftintbot USE LegLeftIntBot legrightinttop USE LegRightIntTop legrightintbot USE LegRightIntBot armleftinttop USE ArmLeftIntTop armleftintbot USE ArmLeftIntBot armrightinttop USE ArmRightIntTop armrightintbot USE ArmRightIntBot heightint USE HeightInt posint USE PosInt } Transform { children USE WALKER translation 0 0 20 rotation 0 1 0 3.14 } Transform { children USE WALKER translation -10 0 10 rotation 0 1 0 1.57 } Transform { children USE WALKER translation 10 0 10 rotation 0 1 0 -1.57 }