© De Montfort University, D Graphics and VRML Howell Istance and Chris Hand* De Montfort University * now at
© De Montfort University, D COMPUTER GRAPHICS Co-ordinates, Lines and Polygons Specify a point in space using (x,y,z) co-ordinates Lines join points Lines form polygons Polygons are shaded with a colour Scenes may include lights – effect on shading needs to be calculated Virtual Camera (user’s “eye”) has a position in space
© De Montfort University, D Scene…
© De Montfort University, Web 3D Describes any programming or descriptive language that can be used to deliver interactive 3D objects and worlds across the internet Consortium Includes open languages –VRML –Java3D –X3D (under development) Includes proprietary (closed) languages as well
© De Montfort University, VIRTUAL REALITY MODELLING LANGUAGE - VRML Born in 1994, intended to allow 3D and Virtual Worlds over the Internet Specification of a file-format as an open standard –VRML 1.0 spec - May 1995 –VRML August 1996 –VRML97 (ISO/IEC ) - October 1997
© De Montfort University, USES OF VRML 1.Specifying 3D Objects and Worlds in a platform independent way – useful as an open interchange format (cf. Proprietary standards such as.DXF) …many 3D modelling packages (e.g 3D Studio) will export to VRML format 2.Creating interactive 3D content for delivery over the Internet, intranets or CD-ROM etc. Pure 3D applications: interactive 3D maps, training, games… 3D user interfaces to web sites, databases… Web advertising - lightweight, interactive 2D/3D banner ads Multi-user 3D worlds (via VRML extension mechanisms)
© De Montfort University, Building a VRML World Collection of objects arranged in a particular order Objects correspond to something physical that has shape, various surface properties (colour, smoothness, shininess) and a position in 3D space other objects include sounds, lights, viewpoints, all of which have a location in 3D space
© De Montfort University, Nodes Fundamental building blocks, some nodes are objects, some nodes are containers to hold nodes which are related –e.g. Shape node contains geometry node and appearance node Geometry - definition of shape, predefined nodes include Cylinder, Box, Sphere, user defined shape represented as an indexed faceset (collection of numbered coordinates and specification of connectivity) Appearance - contains Material node - definition of surface properties of an object, colour, texture, shininess
© De Montfort University, Grouping Nodes Transform - specifies how a group of children nodes may be translated, rotated or scaled –translation field takes a single vector as its value, showing the amount to move in the x, y and z direction VRML coordinate system +x points to the right +y points up +z points out of the screen
© De Montfort University, Scene Graph hierarchical data structure containing nodes, built by browser as the file is loaded, enables groups of nodes to be manipulated by applying transforms to parent nodes which affect all children nodes
© De Montfort University, Fields and Data types Single Value Field Types - prefixed with SF(SFColor, SFFloat, SFString) - spec shows field, data type, identifier, default value Transform { …. exposedField SFVec3f translation … } Material{ …. ExposedField SFColor diffuseColor 0.8, 0.8, 0.8 … } Multiple-valued Field types - prefixed with MF (MFColor, MFFloat, MFString) - essentially arrays of values
© De Montfort University, MULTIMEDIA SUPPORT Text –Use Text and fontStyle nodes –Control over font face,size, spacing, horizontal/vertical alignment and direction Bitmapped images –Support for Texture maps via ImageTexture node –Mono/Greyscale/RGB/RGB+Alpha (opacity) –Plug-ins/Browsers generally support PNG, JPEG and (usually) GIF formats
© De Montfort University, MULTIMEDIA SUPPORT Audio –Sound node with AudioClip node –Digital Audio - support for.WAV (uncompressed PCM) required by spec –MIDI type 1 file support recommended (general MIDI) –Audio is spatialised in 3D Video –MPEG-1 files (video or video+sound) supported as texture maps using MovieTexture node Animation –Extensive support for keyframe animation in 2D and 3D using timers (TimeSensor) and various “interpolators” –Properties of objects that may be animated include Position, Orientation, Colour and Transparency
© De Montfort University, Responding to user actions - events, sensors and scripts In addition to data fields, nodes can contain event fields Events typically used to change things –object position or orientation –material properties (colour, transparency) –switching things on/off EventIn - events which the node can respond to EventOut - events which the node can generate
© De Montfort University, Event Routing nodes are 'wired' together with ROUTE statements (i.e cause the event generated by node1 to trigger a response in node2 ) eventOut and eventIn must be of the same type (e.g.SFBool)
© De Montfort University, Event Graphs Nodes and routes form an Event Graph Each event has a time-stamp and a value, which depends on the type of the event e.g. SFVec3f: (time format is number of seconds since 1-Jan-70) x0.0 y32.5 z10.5 time
© De Montfort University, SENSOR NODES Events usually originate from sensors Environmental sensors Collision ProximitySensor TimeSensor VisibilitySensor Pointing Device Sensors Anchor TouchSensor Drag Sensors CylinderSensor PlaneSensor SphereSensor
© De Montfort University, Example of a Sensor The code in World3.wrl defines a box located 5 units to the right of the origin, which is equipped with a touchsensor the DEF reserved word allows a node to named, for reference in other nodes or statements The generated event from touchBox can be routed another node for processing ROUTE touchBox.isActive TO node2.eventIn
© De Montfort University, Typical Uses TimeSensor – Animations Drag Sensors – manipulating objects (translate, rotate) ProximitySensor, VisibilitySensor – Efficiency, reacting to user presence Anchor, TouchSensor – buttons, signposts Nodes (often grouped with other nodes) which generate events in response to user behaviour –ProximitySensor defines an area which generates an IsActive event when the user enters the area –TouchSensor generates an IsActive event when 'touched' by a mouse-click