Lab 4
Using ygSwitch in
the Scene Graph
Start yg
but do not load a scene:
Open a web browser to the
following location:
Find the link for ygObject.
What section is it in?
Create a
ygObject
node.
Follow the link for ygObject and
compare the messages in yg with those listed in the documentation.
What messages listed in the
documentation are also available for ygObject in yg?
Follow the link at the top of
the ygObject
page to ygGeometry.
What messages listed in the
documentation for ygGeometry
are also available for ygObject in yg?
Create a
ygGeometry
node in your scene.
Notice that ygObject and ygGeometry have
the same messages except those that are specific to ygObject.
ygObject is said to be derived from ygGeometry, it inherits
all of the functionality of ygGeometry and includes some of its own.
Follow the link at the top of
the ygGeometry
page to ygNode.
What messages listed in the
documentation for ygNode
are also available for ygGeometry in yg?
Create a
ygNode
node in your scene.
Notice that ygGeometry and ygNode have the
same messages except those that are specific to ygGeometry.
ygGeometry is derived from ygNode, and ygNode is called a base
node because it is not derived from any other node.
All nodes in Ygdrasil are derived from ygNode.
Delete your existing nodes
and load the scene from lab 3.
Notice that you cannot see
the inside walls of the house model.
1. Adjust the cull message so that you can only see
the inside of the house.
2. Adjust the cull message so that you can see both
the outside and inside of the house.
3. Set the wireframe message to true
on both the house object and the lamp object.
4. Create a
ygSwitch
object as a child of the bulb frame of reference.
5. Place the spotLight and ygTransform siblings
under the ygSwitch
object.
Turn off any other ygLight in the
scene.
Turn the ygSwitch node off by setting the
off message to true.
What happened to the light
and bulb?
6. Set the ygSwitch reset message to true.
What happened to the ygSwitch node?
Look at the documentation for
ygSwitch.
What is the default state for
the ygSwitch
node?
7. Bring up the world menu and set reset to true.
What happened to the house
and lamp objects?
8. Turn off the ygSwitch node
again.
9. Save your lab as lab4.yg.
Open lab4.yg in the kate
editor and find your ygSwitch
node.
Notice that it includes the
message off in between the
parenthesis.
Also, notice that each ygObject node
includes the file message in between
the parenthesis.
The messages saved to the
file are called initial messages.
They will establish the initial
state of each node when the file is loaded.
And, they will establish the initial
state that the world returns to when it is reset.
10. Use the replace function
in the editor to replace each instance of object1 with terrain.
11. Replace each other object
with its appropriate model name.
12. Copy and paste the lines
of code that includes the ygSwitch and all of its children so that it appears twice.
13. Replace bulb
with bulb_on in the newly added
code (including the file name).
14. Save the new scene as
lab4b.yg.
Reload the new scene into yg by deleting the existing scene and loading lab4b.yg.
15. Delete the spotLight node
associated with the bulb model but leave the one with the bulb_on
model.
What do we have to do to make
the “light turn on”?
What do we have to do to make
the “light turn off”?
16. Save your modified scene.