PROTOs for Dummies IV | |
|
Dateline: 5/11/98
Now that we have some PROTOs for eye balls, clearly we have to start
poking it! To review from the previous features, still available as Dummies
I, Dummies
II and Dummies
III, there several PROTOs that we now have. PROTOs for single and multiple
eyeballs. We can also move the cursor over these eyes to see the colors
change.
It was my distinct hope to simply plug these eyes into a sound PROTO...but alas 'twas not to be (in the time I have). So as a semi cop out, here is an explanation of the use of Braden's AudibleButtonTemplate which can be found in his VRML97 PROTO collection. One would like to be able to simply plug-and-play PROTOs to create reusable pieces of content, and in fact this is possible, however the data types of the nodes must be clearly specified. In this case the AudibleButtonTemplate requires the use of various Geometry nodes and the EyeBall protos developed so far are Transform or Group nodes. I will leave the proper completion of these PROTOs to the talented hackers out there.
The use of the AudibleButtonTemplate is however quite instructive. The
interface to the PROTO looks like:
EXTERNPROTO AudibleButtonTemplate [
eventIn
SFBool set_enabled
field
SFNode activeAppearance
field
SFNode activeGeometry
field
SFNode activeOverAppearance
field
SFNode activeOverGeometry
field
MFString activeSoundUrl
field
SFNode appearance
field
SFString description
field
SFNode disabledAppearance
field
SFNode disabledGeometry
field
SFBool enabled
field
SFNode geometry
field
SFNode overAppearance
field
SFNode overGeometry
field
MFString pressedSoundUrl
eventOut
SFBool enabled_changed
eventOut
SFBool isActive
eventOut
SFBool isOver
eventOut
SFTime pressedTime
] [ "widgets.wrl#AudibleButtonTemplate" ]
To see it in action check out the wrl linked to by this image.
The actual use of the PROTO requires that it be placed as one of the
nodes as the children of a Group node. So it's use in this case is as follows:
Group {
children [
NavigationInfo {
headlight FALSE
type
[ "NONE" ]
},
Background {
skyColor [ 0.75 0.7 0.6 ]
},
DirectionalLight {
direction 1 -1 -1
},
Viewpoint {
position 0 0 3
},
AudibleButtonTemplate {
description "DOH"
enabled TRUE
geometry DEF GEOMETRY
Sphere { radius 0.5}
activeGeometry DEF ACTIVE-GEOMETRY
Sphere { radius 0.3 }
overGeometry USE GEOMETRY
activeOverGeometry USE
ACTIVE-GEOMETRY
disabledGeometry USE
GEOMETRY
appearance DEF NORMAL_APPEARANCE
Appearance {
material Material {
diffuseColor 0.2 0.2 0.2 #color of the pupil
}
}
overAppearance DEF RED_APPEARANCE
Appearance {
material Material {
diffuseColor 0.8 0.2 0.2
}
}
activeAppearance
USE RED_APPEARANCE
activeOverAppearance
Appearance {
material Material {
diffuseColor 0.2 0.8 0.2 #color of the pupil
}
}
disabledAppearance USE
NORMAL_APPEARANCE
activeSoundUrl [ "hey.wav"
]
pressedSoundUrl [ "doh.wav"
]
}
]
}
There are five distinct possible states each of which can be visually
represented with it's own unique geometry and appearance node.
State 1: no user action, the default.
State 2 (over): the user has moved the cursor on top of the
object.
State 3 (over active): the user has the cursor over the object
AND is pressing a mouse button.
State 4 (active): the user has pressed down and is holding the
mouse button. [this state can only be reached after the over-active state
and the user has moved the cursor away from the object but is still holding
the mouse button.
State 5: (disabled): the proto has been disabled with a FALSE
state in the enabled field.
One of the difficult issues in creating a library of reusable PROTOs is to ensure that the inputs and outputs are compatible. There are no simple magic solutions just good programming style (of which my PROTOs are clearly NOT!). As usual in most programming tasks, find examples of good PROTOs and "borrow" them. Happy PROTO building.
Got any burning issues, post it on the board.