08/06/09 13:29
1
VRML 2.0 Scene Graph Structure Nodes Group
Transformation
Shape
UML
08/06/09 13:29
2
Shape Node: Contained Nodes
Shape appea rance
col or
c
norm
d coor r olo
rd coo
al
Indexed Face Set
Indexed Line Set lor
coo rd
Point Set
Coordinate
Color
Normal
ran
sfo
rm
Texture Transform
Elevation Grid r colo
te xC al
rm no
FontStyle
reT
Image, Movie PixelTexture
Material
co
fon tSty le
Text
m
tex tu
oo rd
texCo ord
Box Cone Cylinder Sphere Extrusion
l ria e t a
texture
ge om et ry
Appearance
Texture Coordinate
UML
08/06/09 13:29
3
Text Node Definition fontStyle Node Definition Text {
}
exposedField exposedField exposedField exposedField
FontStyle { field field field field field field field field field }
MFString SFNode MFFloat SFFloat
MFString SFBool MFString SFSring SFFloat SFFloat SFString SFBool SFBool
string fontStyle length maxExtent
[] NULL [] 0.0
family “SERIF” horizontal TRUE justify “BEGIN” language ““ size 1.0 spacing 1.0 style “PLAIN” topToBottom TRUE leftToRight TRUE UML
08/06/09 13:29
4
Appearance & Material Nodes
Appearance { exposedField SFNode exposedField SFNode exposedField SFNode } Material { exposedField exposedField exposedField exposedField exposedField exposedField }
SFFloat SFColor SFColor SFFloat SFColor SFFloat
material NULL texture NULL textureTransform NULL
ambientIntensity 0.2 diffuseColor 0.8 0.8 0.8 emissiveColor 0 0 0 shininess 0.2 specularColor 0 0 0 transparency 0
UML
08/06/09 13:29
5
Texture Node Definitions ImageTexture { exposedField field feild }
MFString SFBool SFBool
url repeatS repeatT
[] TRUE TRUE
PixelTexture { exposedField field feild }
SFImage SFBool SFBool
image repeatS repeatT
0 0 0 TRUE TRUE
UML
08/06/09 13:29
6
Texture Node Definitions, Continued
MovieTexture { exposedField exposedField exposedField exposedField exposedField field field eventOut eventOut }
SFBool SFFloat SFTime SFTime MFString SFBool SFBool SFFloat SFBool
loop FALSE speed 1 startTime 0 stopTime 0 url [] repeatS TRUE repeatT TRUE duration_changed isActive
UML
08/06/09 13:29
7
Lighting in VRML 2.0 Directional Light Source DirectionalLight { exposedField exposedField exposedField exposedField exposedField }
SFFloat SFColor SFVec3f SFFloat SFBool
ambientIntensity color direction intensity on
0 1 1 1 0 0 -1 1 TRUE
Directional lights are “scoped” to illuminate only objects in their group.
UML
08/06/09 13:29
8
Lighting in VRML 2.0 Point Light Sources PointLight { exposedField exposedField exposedField exposedField exposedField exposedField exposedField }
SFFloat SFVec3f SFColor SFFloat SFVec3f SFBool SFFloat
ambientIntensity attenuation color intensity location on radius
0 1 0 0 1 1 1 1 0 0 0 TRUE 100
Scoping for the PointLight is given by the radius field, beyond which no objects are illuminated
UML
08/06/09 13:29
9
Lighting in VRML 2.0 Spotlights
SpotLight { exposedField exposedField exposedField exposedField exposedField exposedField exposedField exposedField exposedField exposedField }
SFFloat SFVec3f SFFloat SFColor SFFloat SFVec3f SFFloat SFVec3f SFBool SFFloat
ambientIntensity 0 attenuation 1 0 0 beamwidth 1.570796 color 1 1 1 cutOffAngle 0.785398 direction 0 0 -1 intensity 1 location 0 0 0 on TRUE radius 100
UML
08/06/09 13:29
10
Transform Node Definition Transform { enventIn eventIn exposedField exposedField exposedField exposedField exposedField exposedField field field }
MFNode MFNode SFVec3f MFNode SFRotation SFVec3f SFRotation SFVec3f SFVec3f SFVec3f
addChildren removeChildren center children rotation scale scaleOrientation translation bboxCenter bboxSize
0 0 0 [] 0 0 1 0 1 1 1 0 0 1 0 0 0 0 0 0 0 -1 -1 -1
Order of application: T(translation) • T(rotation) • T(scale) {children}
UML
08/06/09 13:29
11
GroupNode Definition Transform { enventIn eventIn exposedField field field }
MFNode MFNode MFNode SFVec3f SFVec3f
addChildren removeChildren children bboxCenter bboxSize
[] 0 0 0 -1 -1 -1
UML
08/06/09 13:29
12
Viewing in VRML 2.0 Viewpoint { eventIn exposedField exposedField exposedField exposedField field eventOut eventOut }
SFBool SFFloat SFBool SFRotation SFVec3f SFString SFTime SFBool
set_bind fieldOfView jump orientation position description bindTime isBound
0.785396 TRUE 0 0 1 0 0 0 10 ““
UML
08/06/09 13:29
13
Sound in VRML 2.0 Definition of Sound Node Sound { exposedField exposedField exposedField exposedField exposedField exposedField exposedField exposedField exposedField field }
SFVec3f SFFloat SFVec3f SFFloat SFFloat SFFloat SFFloat SFFloat SFNode SFBool
direction intensity location maxBack maxFront minBack minFront priority source spatialize
0 0 1 1 0 0 0 10 10 1 1 0 NULL TRUE
UML
08/06/09 13:29
14
Sound in VRML2.0 Definition of AudioClip Node AudioClip { exposedField exposedField exposedField exposedField exposedField exposedField eventOut eventOut }
SFString description SFBool loop SFFloat pitch SFTime startTime SFTime stopTime MFString url duration_changed isActive
““ FALSE 1.0 0 0 []
UML
08/06/09 13:29
15
Spatial Sound Pattern in VRML 2.0 Constant intensity location
Linear Attenuation
direction
minBack
minFront maxFront
maxBack
UML
08/06/09 13:29
16
Internode Communication: Events
eventOut Node A
Node B
Node C eventIn Connection by a ROUTE
UML
08/06/09 13:29
17
Internode Communication Node Field Classes field
Private node member
exposedField
Public node member
eventIn
Event received by node
eventOut
Event sent by node
set_ _changed
Event received by node Event sent by node
Type and value of events correspond to type and value of node fields.
UML
08/06/09 13:29
18
Internode Communication Route Syntax DEF T1 Transform { . . . } DEF T2 Transform { . . . } DEF T3 Transform { . . . } . . . ROUTE T1.translation_changed TO T2.set_translation ROUTE T2.translation_changed TO T3.set_translation
T1
T2
T3
translation
translation
translation
UML
08/06/09 13:29
19
Event Generators: Touch Sensor
= Shapes Sensed
UML
08/06/09 13:29
20
Event Generators: Touch Sensor TouchSensor { exposedField eventOut eventOut eventOut eventOut eventOut eventOut }
SFBool SFVec3f SFVec3f SFVec2f SFBool SFBool SFTime
enabled TRUE hitNormal_changed hitPoint_changed hitTexCoord_changed isActive isOver touchTime
UML
08/06/09 13:29
21
Touch Sensor Example Group {
}
children [ DEF TS TouchSensor { } Shape { appearance Appearance { material Material { diffuseColor 0 0.5 0 } } geometry Sphere {} } DEF Highlight DirectionalLight { color 1 0 0 on FALSE } DEF ActiveLight DirectionalLight { color 0 0 1 on FALSE } ] ROUTE TS.isOver TO Highlight.set_on ROUTE TS.isActive TO ActiveLight.set_on
UML
08/06/09 13:29
22
Touch Sensor Example Group {
}
children [ DEF TS TouchSensor { } Shape { appearance Appearance { material Material { diffuseColor 0 0.5 0 } } geometry Sphere {} } Sound { maxBack 1000 maxFront 1000 source DEF Audio AudioClip { url “horse.wav” } } ] ROUTE TS.touchTime TO Audio.startTime
UML
08/06/09 13:29
23
Adding Behavior to Objects
TimeSensor
Interpolator
Generates time varying scalar in range [0,1]
Maps [0,1] to field data type values.
[0,1]
General Node
ScalarInterpolator PositionInterpolator OrientationInterpolator CoordinateInterpolator ColorInterpolator
UML
08/06/09 13:29
24
Time Sensor TimeSensor { exposedField exposedField exposedField exposedField exposedField eventOut eventOut eventOut eventOut }
SFTime SFBool SFBool SFTime SFTime SFTime SFFloat SFBool SFTime
cycleInterval 1 enabled TRUE loop FALSE startTime 0 stopTime 0 cycleTime fraction_changed isActive time
loop=TRUE
loop=FALSE startTime
cycleInterval
stopTime
UML
08/06/09 13:29
25
Position Interpolator PositionInterpolator eventIn exposedField exposedField eventOut }
{ SFFloat MFFloat MFVec3f SFVec3f
set_fraction key [] keyValue [] value_changed
y
x
Input: [ 0
1]
z
UML
08/06/09 13:29
26
Position Animation Example Def T Transform { translation 0 5 0 children [ Shape { geometry Cone {} appearance Appearance { material Material { diffuseColor 1 0 0 } } } ] } Def P PositionInterpolator { key [0, 0.5, 1] keyValue [ 0 0 0, 4 0 0, 0 0 0] } Def TS TimeSensor { stopTime -1 loop TRUE } ROUTE TS.fraction_changed TO P.set_fraction ROUTE P.value_changed TO T.set_translation
UML
08/06/09 13:29
27
Java 3D: Class Hierarchy
UML
08/06/09 13:29
28
Java 3D: Viewing Classes
Contains information about physical screen Contains most of view state Locates a view within scene
3D version of Abstract Windowing Toolkit
UML
08/06/09 13:29
29
Java 3D: Sample Code to Build Scene Graph Shape3D myShape1 = new Shape3D(myGeometry1, myAppearance1); Shape3D myShape2 = new Shape3D(myGeometry2, myAppearance2); BranchGroup myBranch = new BranchGroup(); myBranch.addChild(myShape1); myBranch.addChild(myShape2); myBranch.compile(); VirtualUniverse myUniverse = new VirtualUniverse(); Locale myLocale = new Locale(myUniverse); myLocale.addBranchGraph(myBranch);
UML
08/06/09 13:29
30
Java 3D: Scene Graph Built
UML
08/06/09 13:29
31
Java 3D; Node Class Hierarchy
UML
08/06/09 13:29
32
Java 3D “Hello Universe” Program public class HelloUniverse extends Applet { public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // // // //
Create the TransformGroup node and initialize it to the identity. Enable the TRANSFORM_WRITE capability so that our behavior code can modify it at run time. Add it to the root of the subgraph.
TransformGroup objTrans = new TransformGroup(); objTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans); // Create a simple Shape3D node; add it to the scene graph. objTrans.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the // desired operation on the specified transform and add // it into the scene graph.
UML
08/06/09 13:29
33
Java 3D “Hello Universe” Program, contd. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator( rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI*2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); rotator.setSchedulingBounds(bounds); objRoot.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; } public HelloUniverse() { <set layout of applet, construct canvas3d, add canvas3d> // Create the scene; attach it to the virtual universe BranchGroup scene = createSceneGraph(); SimpleUniverse u = new SimpleUniverse(canvas3d); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); } }
UML