Download presentation
Presentation is loading. Please wait.
Published byAlison Spencer Modified over 9 years ago
1
© TMC Computer School HC20203 VRML 2 - 1 HIGHER DIPLOMA IN COMPUTING Chapter 2 – Basic VRML
2
© TMC Computer School HC20203 VRML 2 - 2 HIGHER DIPLOMA IN COMPUTING Structure of VRML File A VRML file consists of the following major functional components the VRML header the scene graph which includes Shapes Interpolators sensors and scripts the prototypes event routing
3
© TMC Computer School HC20203 VRML 2 - 3 HIGHER DIPLOMA IN COMPUTING #VRML V2.0 utf8 # A brown hut Group { children [ # Draw the hut walls Shape { appearance DEF Brown Appearance { material Material { diffuseColor 0.6 0.4 0.0 } geometry Cylinder { height 2.0 radius 2.0 } },
4
© TMC Computer School HC20203 VRML 2 - 4 HIGHER DIPLOMA IN COMPUTING # Draw the hut roof Transform { translation 0.0 2.0 0.0 children Shape { appearance USE Brown geometry Cone { height 2.0 bottomRadius 2.5 } ] }
5
© TMC Computer School HC20203 VRML 2 - 5 HIGHER DIPLOMA IN COMPUTING VRML Header For easy identification of VRML files, every VRML file shall begin with #VRML V2.0 The is either " utf8 " or any other authorized values defined in other parts of ISO/IEC 14772 In this course, we are using " utf8" which indicates a clear text encoding that allows for international characters to be displayed in VRML
6
© TMC Computer School HC20203 VRML 2 - 6 HIGHER DIPLOMA IN COMPUTING UTF-8 File Format # character begins a comment Only the first comment (the file header) has semantic meaning The only exception is within double-quoted SFString and MFString fields where the # character is defined to be part of the string Commas, spaces, tabs, linefeeds, and carriage-returns are separator characters wherever they appear outside of string fields One or more separator characters separate the syntactical entities in VRML The separator characters collectively are termed whitespace
7
© TMC Computer School HC20203 VRML 2 - 7 HIGHER DIPLOMA IN COMPUTING VRML Statements VRML file may contain any combination of the following : Any number of PROTO or EXTERNPROTO statements Any number of root children node statements Any number of USE statements Any number of ROUTE statements
8
© TMC Computer School HC20203 VRML 2 - 8 HIGHER DIPLOMA IN COMPUTING Scene Graph The scene graph contains nodes, which describe objects and their properties It contains hierarchically grouped geometry to provide an audio-visual representation of objects It also provides a means for nodes to participate in the event generation and routing mechanism
9
© TMC Computer School HC20203 VRML 2 - 9 HIGHER DIPLOMA IN COMPUTING Nodes Nodes are used to describe shapes and properties of the world such as: shapes colors lights viewpoints, how to position and orient shapes animation times, sensors and interpolators
10
© TMC Computer School HC20203 VRML 2 - 10 HIGHER DIPLOMA IN COMPUTING Nodes A node contains the following information: type of nodes a set of curly brackets fields For example, a cylinder node could be described: cylinder { height 2.0 radius 2.0 }
11
© TMC Computer School HC20203 VRML 2 - 11 HIGHER DIPLOMA IN COMPUTING Fields and Field Values Fields define the attributes of a node In the above example, the height field defines the height of the cylinder Fields are optional within the nodes If the values are not given, then a default value would be assigned For example, the default values of cylinder have radius = 1.0 units and height = 2.0 units Field values defines the attributes like color, size or position
12
© TMC Computer School HC20203 VRML 2 - 12 HIGHER DIPLOMA IN COMPUTING Defining and Using Node Name Any node can be defined in the world The name of the node must begin with a letter, followed by any combination of characters and/or digits DEF node_name name_type Once a node has a name, we could reuse the node. The node with defined name is called original node while the reuse nodes are called instances USE node_name Note that the node names are case-sensitive
13
© TMC Computer School HC20203 VRML 2 - 13 HIGHER DIPLOMA IN COMPUTING Describing Shapes A VRML shape has appearance (based on material), color and surface texture These attributes are specified by the field values within a shape node VRML supports several primitives shape geometries that include boxes, cylinders, cones, and shapes VRML also supports advanced shape geometries like extruded shapes and elevation grids Using these primitive shapes, we could group them and build more complex shapes Shapes can be grouped by the Group node
14
© TMC Computer School HC20203 VRML 2 - 14 HIGHER DIPLOMA IN COMPUTING Event Routing Some VRML nodes generate events in response to environmental changes or user interaction Event routing provides a mechanism, which allow events to be propagated to effect changes in other nodes Once generated, events are sent to their routed destinations in time order and processed by the receiving node This processing can change the state of the node, generate additional events, or change the structure of the scene graph
15
© TMC Computer School HC20203 VRML 2 - 15 HIGHER DIPLOMA IN COMPUTING Event Routing In order to build a dynamic world and propagate events based on environmental changes, we need “wiring instructions” This process involves a pair of nodes to wire together a wiring route or path between these two nodes Once the nodes are wired, messages could be sent along that route Such message is called events which contains communicating values
16
© TMC Computer School HC20203 VRML 2 - 16 HIGHER DIPLOMA IN COMPUTING Event Routing For a successful routing, nodes must have eventIn and the corresponding eventOut An eventIn receives events when it is connected to a route and a message is being sent to it An eventOut sends the events out along the connected route VRML “wiring” architecture is built by describing a route from one node’s eventOut to another node’s eventIn
17
© TMC Computer School HC20203 VRML 2 - 17 HIGHER DIPLOMA IN COMPUTING Event Routing The receiving node reacts based on the event depends on the following: type of node receiving the event node input jack to which the route is wired values contained in the event current activities of the node
18
© TMC Computer School HC20203 VRML 2 - 18 HIGHER DIPLOMA IN COMPUTING Presentation and Interaction The interpretation, execution, and presentation of VRML files will typically be undertaken a browser, which displays the shapes and sounds in the scene graph This presentation is known as a virtual world and is navigated in the browser by a human or mechanical entity, known as a user The world is displayed as if experienced from a particular location; that position and orientation in the world is known as the viewer
19
© TMC Computer School HC20203 VRML 2 - 19 HIGHER DIPLOMA IN COMPUTING Presentation and Interaction The browser may define navigation paradigms (such as walking or flying) that enables the user to move the viewer through the virtual world The browser may provide a mechanism allowing the user to interact with the world through sensor nodes in the scene graph hierarchy Sensors respond to user interaction with geometric objects in the world, the movement of the user through the world, or the passage of time
20
© TMC Computer School HC20203 VRML 2 - 20 HIGHER DIPLOMA IN COMPUTING Presentation and Interaction The visual presentation of geometric objects in a VRML world follows a conceptual model designed to resemble the physical characteristics of light The VRML lighting model describes how appearance properties and lights in the world are combined to produce displayed colours Refer to the diagram for the conceptual model of the VRML browser
21
© TMC Computer School HC20203 VRML 2 - 21 HIGHER DIPLOMA IN COMPUTING Presentation and Interaction Conceptual Model of VRML Browser
22
© TMC Computer School HC20203 VRML 2 - 22 HIGHER DIPLOMA IN COMPUTING USE Statement The USE statement enables us to reuse all the objects that we have defined earlier in the scene graph A USE statement consists of the USE keyword followed by a node name as follows: USE
23
© TMC Computer School HC20203 VRML 2 - 23 HIGHER DIPLOMA IN COMPUTING ROUTE Statement A ROUTE statement provides the message passing mechanism from one node to another A ROUTE statement consists of the ROUTE keyword followed in order by a node name, a period character, a field name, the TO keyword, a node name, a period character, and a field name. Whitespace is allowed but not required before or after the period characters: ROUTE. TO. All these commands will be covered in more details as the course proceeds
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.