1 / 23

Chapter 2 – Basic VRML

Chapter 2 – Basic VRML. 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. #VRML V2.0 utf8 # A brown hut Group {

Télécharger la présentation

Chapter 2 – Basic VRML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. Chapter 2 – Basic VRML

  2. 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. #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. # 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. VRML Header • For easy identification of VRML files, every VRML file shall begin with • #VRML V2.0 <encoding type> • The <encoding type> 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Presentation and Interaction Conceptual Model of VRML Browser

  22. 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 <name>

  23. 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 <name>.<field/eventName> TO <name>.<field/eventName> • All these commands will be covered in more details as the course proceeds

More Related