Title: VRML Basic Syntax
1VRML Basic Syntax
- Lee, Chan Su
- chansu_at_caip.rutgers.edu
2File Syntax and Structure(I)
- prototypesPROTO, EXTERNPROTO
Floops.wrl
Floops.txt
3File Syntax and Structure(II)
- Syntax Basics
- illegal character
- First Character - 0-9 , . \
0x-0x20 - All other Character , . \ 0x-0x20
- Reserved Keywords DEF, PROTO,..
4Head
- Head
- VRML V2.0 ltencoding typegt comment ltline
terminatorgt - VRML V2.0 utf8
utf8Universal Character Set Transform Format
Comment to the end of the line is comment
5Node(I)
- Node
- analogous to object , or function
- If you make a scene with node, it makes object in
the virtual environment
DEF ltnamegt ltnodeTypegt ltbodygt
6Node(II)
- Nodes Body consists of any number of
- PROTO statements or EXTERNPROTO statements
in any order
7Node(III)
- Nodes are commonly supplied to fields of other
nodes.
Node1 fieldName Node2 Node2
fields set here
8Node(IV)
- Group NodeAnchor, Billboard, Collision, Group,
Inline, LOD(Level of Detail), Switch, Transform
- nodes that can contain and manage other nodes
9Node(V)
Group children Nodename1 node1
., Nodename2 node2 .,
...
10Field(I)
- field A private member of the nodeno access to
and from other node
- eventIn An event received by the Nodeother node
can set this field
- eventOut An event sent by the nodeother nodes
can receive values form this field, but not set
them
11Field(II)
- A public member of the nodeother nodes are free
to set this field and also receive them
- in general set_nodeName for eventIn
- nodeName_changed for eventOut
12Field(III)
- -Bool/ -Int32/ -Float/ -Color/ -Node/ -String/
-Time/ -Vec2f/ -Vec3f/ -IMage
SFFloat/ MFFloat SFString, MFVec3f
13Field(IV)
- class_specifier data_type field_name default
range - field SFFloat radius
1 0 to ?
- Exception of name in exposedField
- Boolean eventOuts isNodeName
- SFTime exitTime, startTime
14DEF/USE statement
- A node given a name using DEF keyword may later
be referenced by name with USE or ROUTE
statements
- The USE statement does not create a copy of the
node
DEF ltnamegt ltnodeTypegt ltbodygt
DEF Red Material diffuseColor 1 0 0
USE ltnamegt
15Example of Node Definition
Transform eventIn MFNode
addChildren eventIn MFNode
removeChildren exposedField SFVec3f center
0 0 0 (-,) exposedField MFNode
children exposedField
SFRotation rotation 0 0 1 0
-1,1,(-,) exposedField SFVec3f scale
1 1 1 (0,) exposedField SFRotation
scaleOrientation 0 0 1 0 -1,1,(-,)
exposedField SFVec3f translation 0 0 0
(-,) field SFVec3f bboxCenter
0 0 0 (-,) field SFVec3f
bboxSize -1 -1 -1 (0,) or -1,-1,-1
16Coordinate System
- Cartesian, right-handed, 3D coordinate System
- Viewing Model-Viewport
- define specific location of viewer
17Building Predefined Shapes(I)
Shape exposedField SFNode appearance NULL
exposedField SFNode geometry NULL
18Building Predefined Shapes(II)
Appearance exposedField SFNode material
NULL exposedField SFNode texture
NULL exposedField SFNode textureTransform
NULL
19Building Predefined Shapes(III)
Material exposedField SFFloat
ambientIntensity 0.2 0,1
exposedField SFColor diffuseColor 0.8 0.8
0.8 0,1 exposedField SFColor emissiveColor
0 0 0 0,1 exposedField SFFloat
shininess 0.2 0,1
exposedField SFColor specularColor 0 0 0
0,1 exposedField SFFloat transparency
0 0,1
20Building Predefined Shapes(IV)
- Box, Cone, Cylinder, Sphere
Box field SFVec3f size 2 2 2
(0, )
21Building Predefined Shapes(V)
Cone field SFFloat bottomRadius 1
(0,) field SFFloat height 2
(0,) field SFBool side
TRUE field SFBool bottom TRUE
22Building Predefined Shapes(VI)
Cylinder field SFBool bottom TRUE
field SFFloat height 2 (0,)
field SFFloat radius 1 (0,)
field SFBool side TRUE field SFBool
top TRUE
23Example of VRML File(I)
- Simple VRML File
- Cone.txt
- Cone.wrl
- If you change the field, the scene will be changed
24Route/Sensors
- Lee, Chan Su
- chansu_at_caip.rutgers.edu
25Event Route(I)
- Event
- allow objects to have and express
- more realistic and life like virtual experience
26Event Route(II)
- Route
- The connection between the node generating the
event and the node receiving the event
- Routes are not nodes, but merely a syntactic
construct to field naming conventions
Type Matching In eventIn and eventOut
27Event Route(III)
ROUTE NodeName.eventOutName TO NodeName.eventInNam
e
28Sensor Nodes(I)
- Change of the State of an Input Device
29Sensor Nodes(II)
- Change of Viewer or Object
30Execution Model
ROUTE A.touchTime TO B.toggleNow ROUTE
A.touchTime TO C.set_startTime ROUTE
B.toggle_changed TO C.set_enabled
Event Cascade, Fan-in and Fan-out
31Sensing Viewer Actions(I)
TouchSensor exposedField SFBool enabled
TRUE eventOut SFVec3f hitNormal_changed
eventOut SFVec3f hitPoint_changed eventOut
SFVec2f hitTexCoord_changed eventOut
SFBool isActive eventOut SFBool isOver
eventOut SFTime touchTime
32Sensing Viewer Actions(I)
TouchSensor exposedField SFBool enabled
TRUE eventOut SFVec3f hitNormal_changed
eventOut SFVec3f hitPoint_changed eventOut
SFVec2f hitTexCoord_changed eventOut
SFBool isActive eventOut SFBool isOver
eventOut SFTime touchTime
33Sensing Viewer Actions(II)
PlaneSensor exposedField SFBool autoOffset
TRUE exposedField SFBool enabled
TRUE exposedField SFVec2f maxPosition
-1 -1 (-,) exposedField SFVec2f
minPosition 0 0 (-,)
exposedField SFVec3f offset 0 0 0
(-,) eventOut SFBool isActive
eventOut SFVec3f trackPoint_changed
eventOut SFVec3f translation_changed
34Sensing Viewer Actions(III)
SphereSensor exposedField SFBool
autoOffset TRUE exposedField SFBool
enabled TRUE exposedField SFRotation
offset 0 1 0 0 -1,1,(-,)
eventOut SFBool isActive eventOut
SFRotation rotation_changed eventOut
SFVec3f trackPoint_changed
35Sensing Viewer Actions(IV)
CylinderSensor exposedField SFBool
autoOffset TRUE exposedField SFFloat
diskAngle 0.262 (0,/2) exposedField
SFBool enabled TRUE exposedField SFFloat
maxAngle -1 -2,2 exposedField
SFFloat minAngle 0 -2,2
exposedField SFFloat offset 0
(-,) eventOut SFBool isActive
eventOut SFRotation rotation_changed
eventOut SFVec3f trackPoint_changed
36Sensor Route Example
route_test.txt
route_test.wrl
ROUTE Shape1Sensor.rotation_changed TO
Shape1.set_rotation ROUTE Shape2Sensor.rotation_ch
anged TO Shape2.set_rotation
37Program Project I
- interaction in VRML
- using Sensor
- using ROUTE
- using primitive geometry
- changing according to user action