Lab 5

 

 

Adding event driven messages

 

Start yg and load your scene from the last lab, lab4b.yg.

 

Open a browser window and find the documentation for ygSelector in the section labeled selection.

 

1. Create a ygSelector node and place it at the bulb frame of reference.

 

What messages are available in yg that are also listed in the documentation for ygSelector?

 

2. Replace the two ygSwitch nodes with the new ygSelector node.

 

3. Select editType -> ygSelector from the world menu.

 

4. Find the ygSelector node in the scene view and select it by clicking on it.

 

What value of selectNum turns the light on?

What value of selectNum turns the light off?

What happens when you send the forward message with the value true?

 

3. Create a wandTrigger node under the localroot node.

 

4. Add a when message to the wandTrigger node to send a message when button1 is pressed as follows:

 

when -> button1 -> add -> ”selector1.forward”

 

What happens to the selector each time the left mouse button is pressed?

 

5. Remove the when message as follows:

 

when -> button1 -> remove -> ”selector1.forward”

 

6. Add a ygTransform node above the wandTrigger node.

 

7. Select editType -> wandTrigger from the world menu.

 

What does the edit display of the wand trigger look like?

 

8. Find the transform above the wand trigger and set edit to true.

 

9. Select the wand trigger and change the volume to box.

 

What happened to the edit display of the wand trigger?

 

10. Adjust the transform so that the wand trigger volume is located on the wall of the house at shoulder level.

 

11. Add the when message to the wand trigger again as you did in step 4.

 

What happens to the selector each time the left mouse button is pressed?

 

12. Add a ygObject node under the wand trigger transform and load the file block1.pfb.

 

13. Turn off the edit display for both the transform and wand trigger nodes.

 

14. Save the scene as lab5.yg.

 

15. Run yg in simulator mode by executing:

 

yg lab5.yg

 

Use the F5 button to display the simulator help in the shell window.

Move the avatar hand into the box.

The hand will disappear when it is completely inside the box.

What happens when the left mouse button is pressed?

 

Where in the world does the wandTrigger node detect the button1 event when the volume is infinite?

Where in the world does the wandTrigger node detect the button1 event when the volume is box?