wandTrigger

The wandTrigger works like the userTrigger, but reacts to the wand instead of the user's head.
The location, shape, and size of the wandTrigger is defined using the volumemessage.
It generates enter and exit events, and also button events when the wand buttons are pressed.

In this example, the cube gets a little larger when you touch it, and returns to its normal size when you move your hand away.
When you press button 1 while touching it it will double in size, and when you release it shrinks again.
This is analogous to the 3-state button idea used in HTML, Flash, Director, and many other programs. When making interactive objects in VR, it can be particularly useful to let the user know which objects can be grabbed or clicked on by giving some sort of visual cue.

#include "User0"

object cube (file("cube.pfb"),position(0 5 3),size(1))

wandTrigger (volume(sphere 0 5 3 2),
		when(enter,cube.size(1.1)),
		when(exit,cube.size(1)),
		when(button1,cube.size(2)),
		when(buttonUp1,cube,size(1.1))
		)

Node Reference

Derived from: ygSpace

Messages

MessageParametersDefaultDescription
volume string volumeShape, float coordinates ...

sphere x y z radius
box x1 y1 z1 x2 y2 z2
cylinder x1 y1 z1 x2 y2 z2 radius
point x y z
infinite
infinite defines the shape of the trigger's active area. the volumeShape can be one of the following:
  • infinite: the trigger is active throughout the world
  • sphere: x y z is the location of the trigger; radius is the radius of the sphere.
  • box: x1 y1 z1 and x2 y2 z2 define two opposite corners of a box
  • cylinder: x1 y1 z1 and x2 y2 z2 are centers of the ends of the cylinder; radius is the radius of the cylinder.
  • point: x y z is the location of the trigger.

Events

EventVariablesDescription
enter$user, $wand a wand has entered the space.
$wand is the wand node that has entered.
$user is the user node that owns it.
exit$user, $wandwand has left the space.
button1, button2, button3 ... a button has been pressed.
buttonUp1, buttonUp2, buttonUp3 ... a button has been released.

(c) Ben Chang