定義
Collision {
eventIn MFNode addChildren
eventIn MFNode removeChildren
exposedField MFNode children []
exposedField SFBool collide TRUE
field SFVec3f bboxCenter 0 0 0 # (-,)
field SFVec3f bboxSize -1 -1 -1 # (0,) or -1,-1,-1
field SFNode proxy NULL
eventOut SFTime collideTime
}
サンプル
衝突したときに球の色の変化が始まる例です。
#VRML V2.0 utf8
DEF Obj Transform { children Viewpoint {description "move"}}
Viewpoint {description "still"}
DEF Polator PositionInterpolator {
key [0, .5, 1]
keyValue [0 0 0, 0 0 -8.8,0 0 0]
}
DEF Senser TimeSensor {
loop TRUE
cycleInterval 10
stopTime -1
}
DEF Col Collision {
children Transform {
children [Shape { geometry Sphere {}
appearance Appearance {
material DEF Mat Material {}}}
]
}
}
DEF Sensor2 TimeSensor {
loop FALSE
cycleInterval 5
}
DEF Polator2 ColorInterpolator {
key [0, .25, .5, .75, 1]
keyValue [1 1 1, 1 0 0, 0 1 0, 0 0 1, 1 1 1]
}
ROUTE Senser.fraction_changed TO Polator.set_fraction
ROUTE Polator.value_changed TO Obj.set_translation
ROUTE Col.collideTime TO Sensor2.set_startTime
ROUTE Sensor2.fraction_changed TO Polator2.set_fraction
ROUTE Polator2.value_changed TO Mat.set_diffuseColor