#VRML V2.0 utf8
# blaxxunCC3D avatar PROTO test

EXTERNPROTO MyAvatar [
exposedField SFTime gesture1
exposedField SFTime gesture2
exposedField SFTime gesture3
exposedField SFTime gesture4
exposedField SFTime gesture5
exposedField SFTime gesture6
exposedField SFTime gesture7
exposedField SFTime gesture8
exposedField SFBool isAvatar
#exposedField MFString gestureNames
eventIn SFVec3f set_position
exposedField SFRotation rotation
exposedField SFInt32 whichChoice
exposedField SFBool isOver
exposedField SFTime touchTime
#eventIn SFString set_nickname
#eventIn MFString set_chatGesture
#exposedField SFBool isPilot
#eventIn SFString set_url
#eventOut SFInt32 gesture_changed
#eventIn SFNode set_sharedZone
#eventIn SFInt32 set_gesture
#field SFFloat avatarHeight
] 
["flamingo.wrl#Avatar" ]

## with guesture test buttons
PROTO Button [
 eventOut SFTime click
 field SFVec3f translation 0 0 0
]
{
 Transform {
  translation IS translation
  children [
   DEF BClick TouchSensor { enabled TRUE touchTime IS click }
   DEF BShape Shape {
    appearance Appearance { material Material {} }
    geometry Box { size 0.06 0.06 0.06 }
   }
  ]
 }
}

NavigationInfo {  
type ["EXAMINE", "ANY"]
avatarSize      [0.25, 1.75, 0.75] 
visibilityLimit 50 
}

Viewpoint {
 position 3 2.75 3
 orientation -0.26855 0.95682 0.11124 0.8171
 description "Perspective"
}
Viewpoint {
 position 0 7.75 0
 orientation 0 -.707 -.707 3.14
 description "Above"
}
Viewpoint {
 position 0 0.8 4 
 description "Buttons"
}
Viewpoint {
 position 0 1.75 1.7 
 description "Eyes"
}

Background {
groundAngle [ 0.9, 1.5, 1.57 ]
groundColor [
0 0.333 0,
0 0.4 0,
0 0.5 0,
0.62 0.67 0.60
]
skyAngle [ 0.9, 1.5, 1.57 ]
skyColor [
0.21 0.18 0.66,
0.2 0.44 0.85,
0.51 0.81 0.95,
0.77 0.8 0.82
]
}

DEF MyPS ProximitySensor {
 size 100 100 100
}
Transform {
 translation 0 1.75 0 # translate avatar to a right position 
 children [
  Inline { url "axes.wrl" }
  DEF A MyAvatar { }

# Guesture test buttons
  DEF Buttons Transform {
   translation 0 0.2 0.5
   center 0 -1.55 -0.5
   children [
    DEF B1 Button { translation -0.35 -1.75 0.0 }
    DEF B2 Button { translation -0.25 -1.75  0.0 }
    DEF B3 Button { translation -0.15 -1.75 0.0 }
    DEF B4 Button { translation -0.05 -1.75 0.0 }
    DEF B5 Button { translation  0.05 -1.75 0.0 }
    DEF B6 Button { translation  0.15 -1.75 0.0 }
    DEF B7 Button { translation  0.25 -1.75 0.0 }
    DEF B8 Button { translation  0.35 -1.75 0.0 }
    Transform {
      children [
      Shape {
       appearance Appearance { material Material { diffuseColor 1 0 0 } }
       geometry IndexedFaceSet {
        coord Coordinate { point [
         0.4 -1.925 0,
         0.7 -1.925 0,
         0.7 -1.625 0,
         0.4 -1.625 0
        ] }
        coordIndex [ 0 1 2 3 -1 ]
       }
      }
      DEF PS PlaneSensor {
       minPosition -1 -1
       maxPosition 1 1
      }
      DEF PositionDriver Script {
       eventIn SFVec3f set_translation
       eventOut SFVec3f position_changed
       url ["javascript:
	function set_translation(value) {
	 position_changed = new SFVec3f(value.x,0,value.y);
	}
       "]
      }
     ]
     ROUTE PS.translation_changed TO PositionDriver.set_translation
    }
    Transform {
      children [
      Shape {
       appearance Appearance { material Material { diffuseColor 1 0 0 } }
       geometry IndexedFaceSet {
        coord Coordinate { point [
         -0.8 -1.8 0,
         -0.4 -1.8 0,
         -0.4 -1.7 0,
         -0.8 -1.7 0
        ] }
        coordIndex [ 0 1 2 3 -1 ]
       }
      }
      DEF PS2 PlaneSensor {
       minPosition -3.14 -3.14
       maxPosition 3.14 3.14
      }
      DEF RotationDriver Script {
       eventIn SFVec3f set_translation
       eventOut SFRotation rotation_changed
       url ["javascript:
	function set_translation(value) {
	 rotation_changed = new SFRotation(0,1,0,value.x);
	}
       "]
      }
     ]
     ROUTE PS2.translation_changed TO RotationDriver.set_translation
    }
   ]
   ROUTE MyPS.orientation_changed TO Buttons.set_rotation
  }
 ]
 ROUTE B1.click TO A.gesture1
 ROUTE B2.click TO A.gesture2
 ROUTE B3.click TO A.gesture3
 ROUTE B4.click TO A.gesture4
 ROUTE B5.click TO A.gesture5
 ROUTE B6.click TO A.gesture6
 ROUTE B7.click TO A.gesture7
 ROUTE B8.click TO A.gesture8
 ROUTE RotationDriver.rotation_changed TO A.set_rotation
 ROUTE PositionDriver.position_changed TO A.set_position
}