Adding Lights to the User
You can add lights to the user file, to create the effect of a headlamp, a lantern, or a flashlight. It's pretty easy - since the Head and Hand nodes are basically just transform nodes, you can group any other node under them.
// headlamp
user User0 ()
{
caveNavigator navigatorUser0 ()
{
object (file("body.pfb"))
}
caveHead headUser0 ()
{
object (file("head.pfb"))
spotlight headlight (spread(45),falloff(10),
orientation(90 0 0),attenuation(0 .2 0))
}
caveTracker wandTrackerUser0 (sensor(1))
{
caveWand wandUser0 ()
{
object(file("hand.pfb"))
}
}
}
// flashlight
user User0 ()
{
caveNavigator navigatorUser0 ()
{
object (file("body.pfb"))
}
caveHead headUser0 ()
{
object (file("head.pfb"))
}
caveTracker wandTrackerUser0 (sensor(1))
{
caveWand wandUser0 ()
{
object(file("hand.pfb"))
spotlight wandlight (spread(45),falloff(10),
orientation(90 0 0),attenuation(0 .2 0))
}
}
}
// flickering flashlight with on/off switch
user User0 ()
{
caveNavigator navigatorUser0 ()
{
object (file("body.pfb"))
}
caveHead headUser0 ()
{
object (file("head.pfb"))
}
caveTracker wandTrackerUser0 (sensor(1))
{
caveWand wandUser0 (when(button1,wandlight.toggle))
{
object(file("hand.pfb"))
mathematics (rand,when(changed,rand+.05,
wandlight.diffuse($value $value $value)))
spotlight wandlight (spread(45),falloff(10),
orientation(90 0 0),attenuation(0 .2 0),off)
}
}
}
(c) Ben Chang