27
Sep 30, 2005 1 I3I3DG&VR CE00539-m Interactive 3D Graphics and Virtual Reality Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire University

I3I3DG&VR CE00539-m

Embed Size (px)

DESCRIPTION

Interactive 3D Graphics and Virtual Reality. Faculty of Computing, Engineering and Technology Staffordshire University. I3I3DG&VR CE00539-m. Bob Hobbs. Module Details What is 3D programming? Typical Processing Steps Modelling and Rendering Applications Summary. Outline. - PowerPoint PPT Presentation

Citation preview

Page 1: I3I3DG&VR CE00539-m

Sep 30, 2005 1

I3I3DG&VRCE00539-m

Interactive 3D Graphics and Virtual Reality

Bob Hobbs

Faculty of Computing, Engineering and Technology

Staffordshire University

Page 2: I3I3DG&VR CE00539-m

Sep 30, 2005 2

OutlineOutline

Module DetailsModule Details

What is 3D programming?What is 3D programming?

Typical Processing StepsTypical Processing Steps

Modelling and RenderingModelling and Rendering

ApplicationsApplications

SummarySummary

Page 3: I3I3DG&VR CE00539-m

Sep 30, 2005 3

Module DetailsModule Details Teaching TeamTeaching Team

– Bob HobbsBob Hobbs [email protected]– Dr. Len Noriega Dr. Len Noriega [email protected]

Semester 2Semester 2 15 cats15 cats 4 Hours per week4 Hours per week

– 2 Hours Lecture 2 Hours Lecture Tues 2pm (C321) & Tue 4pm (BLUE)Tues 2pm (C321) & Tue 4pm (BLUE)– 2 Hours Practical 2 Hours Practical Monday 1pm-3pm (K106)Monday 1pm-3pm (K106)

Page 4: I3I3DG&VR CE00539-m

Sep 30, 2005 4

Module DetailsModule Details

Course Handbook & Lecture NotesCourse Handbook & Lecture Notes http://www.soc.staffs.ac.uk/rgh11

Assignment DetailsAssignment Details 50% assignment work50% assignment work 50% two hour exam50% two hour exam

Page 5: I3I3DG&VR CE00539-m

Sep 30, 2005 5

Program of StudyProgram of Study Week 01 RGH Week 01 RGH Introduction, OpenGL and general 3D conceptsIntroduction, OpenGL and general 3D concepts Week 02 RGH Week 02 RGH Virtual Reality Concepts, Semantic cues and Virtual Reality Concepts, Semantic cues and

HCIHCI Week 03 LANWeek 03 LAN Lighting, Shading and TexturingLighting, Shading and Texturing Week 04 LAN Week 04 LAN Physics and Collision DetectionPhysics and Collision Detection Week 05 LAN Week 05 LAN Matrix Operations for MechanicsMatrix Operations for Mechanics Week 06 LAN Week 06 LAN Cognitive Agents and AI conceptsCognitive Agents and AI concepts Week 07 RGH Week 07 RGH Interaction Metaphors, Immersion and Interaction Metaphors, Immersion and

PresencePresence Week 08 RGH Week 08 RGH Human movement, Bio-Mechanics and Human movement, Bio-Mechanics and

KinematicsKinematics Week 09 LAN Week 09 LAN Quaternion Operations for MechanicsQuaternion Operations for Mechanics Week 10 RGHWeek 10 RGH Quaternion Operations for Mechanics IIQuaternion Operations for Mechanics II Week 11 BOTH Week 11 BOTH Assignment surgeryAssignment surgery Week 12 BOTH Week 12 BOTH Assessment demo in exam weekAssessment demo in exam week

Page 6: I3I3DG&VR CE00539-m

Sep 30, 2005 6

Hierarchy of ModelsHierarchy of Models

Geometry

Physics

Bio-Mechanics

Behaviour

Page 7: I3I3DG&VR CE00539-m

Sep 30, 2005 7

How does this work ?How does this work ?

Simulation LoopSimulation Loop– read input sensorsread input sensors– update objectsupdate objects– render scene in displayrender scene in display

Uses traditional 3D graphics Uses traditional 3D graphics methods to render or ‘draw’ the methods to render or ‘draw’ the scenescene

Page 8: I3I3DG&VR CE00539-m

Sep 30, 2005 8

Simulation LoopSimulation Loop

Check any defined actions

Read Sensors

Update objects with sensor input

Objects perform tasks

Step along any defined paths

Render universe

Page 9: I3I3DG&VR CE00539-m

Sep 30, 2005 9

Introducing OpenGLIntroducing OpenGL Graphics basics:Graphics basics:

– Transform geometry (object Transform geometry (object world, world world, world eye)eye)– Apply perspective projection (eye Apply perspective projection (eye screen)screen)– Clip to the view frustumClip to the view frustum– Perform visible-surface processing (Z-buffer)Perform visible-surface processing (Z-buffer)– Calculate surface lighting etc.Calculate surface lighting etc.

Implementing all this is a lot of work Implementing all this is a lot of work (surprise)(surprise)

OpenGLOpenGL provides a standard provides a standard implementation implementation

Page 10: I3I3DG&VR CE00539-m

Sep 30, 2005 10

OpenGL Design GoalsOpenGL Design Goals SGI’s design goals for OpenGL:SGI’s design goals for OpenGL:

– Hardware independence without sacrificing Hardware independence without sacrificing performance performance

– Natural, concise API with some built-in Natural, concise API with some built-in extensibilityextensibility

OpenGL has become a standard because:OpenGL has become a standard because:– It doesn’t try to do too muchIt doesn’t try to do too much

Only renders the image, doesn’t manage windows, Only renders the image, doesn’t manage windows, etc.etc.

No high-level animation, modeling, sound (!), etc.No high-level animation, modeling, sound (!), etc.

– It does enoughIt does enough Useful rendering effects + high performanceUseful rendering effects + high performance

– It is promoted by SGI (& Microsoft, half-It is promoted by SGI (& Microsoft, half-heartedly)heartedly)

Page 11: I3I3DG&VR CE00539-m

Sep 30, 2005 11

OpenGL: ConventionsOpenGL: Conventions Functions in OpenGL start with Functions in OpenGL start with glgl

– Functions starting with Functions starting with gluglu are utility are utility functions (i.e., functions (i.e., gluLookAt()gluLookAt()))

– Functions starting with Functions starting with glxglx are for interfacing are for interfacing with the X Windows system (i.e., in gfx.c)with the X Windows system (i.e., in gfx.c)

Function names indicate argument type/#Function names indicate argument type/#– Functions ending with Functions ending with ff take floats take floats– Functions ending with Functions ending with ii take ints, functions take ints, functions

that end with that end with vv take an array, with take an array, with bb take byte, take byte, etc.etc.

– Ex: Ex: glColor3f()glColor3f() takes 3 floats, but takes 3 floats, but glColor4fv() glColor4fv() takes an array of 4 floatstakes an array of 4 floats

Page 12: I3I3DG&VR CE00539-m

Sep 30, 2005 12

OpenGL: Specifying OpenGL: Specifying GeometryGeometry

Geometry in OpenGL consists of a list of Geometry in OpenGL consists of a list of vertices in between calls to vertices in between calls to glBegin()glBegin() and and glEnd()glEnd()– A simple example: telling GL to render a triangleA simple example: telling GL to render a triangle

glBegin(GL_POLYGON);glBegin(GL_POLYGON);glVertex3f(x1, y1, z1);glVertex3f(x1, y1, z1);glVertex3f(x2, y2, z2);glVertex3f(x2, y2, z2);glVertex3f(x3, y3, z3);glVertex3f(x3, y3, z3);glEnd();glEnd();

– Usage: Usage: glBegin(glBegin(geomtypegeomtype)) where geomtype is: where geomtype is: Points, lines, polygons, triangles, quadrilaterals, etc...Points, lines, polygons, triangles, quadrilaterals, etc...

Page 13: I3I3DG&VR CE00539-m

Sep 30, 2005 13

What is 3D rendering?What is 3D rendering?

Object

Viewer

Generally deals with graphical display of 3D objects as seen by viewer

Synthetic image will vary according to: viewing direction, viewer position, illumination, object

properties, ...

Projection onto 2D surface

Page 14: I3I3DG&VR CE00539-m

Sep 30, 2005 14

What is 3D Computer What is 3D Computer Graphics?Graphics?

3D graphics: generation of 3D graphics: generation of graphical display (graphical display (renderingrendering) ) of 3D object(s) from of 3D object(s) from specification (specification (model(s)model(s)))

Specification Modelling

Graphical display

Rendering

such as

Page 15: I3I3DG&VR CE00539-m

Sep 30, 2005 15

Wireframe polygonal model Solid object

Vertices

Viewpoint

Typical Processing StepsTypical Processing Steps

Facets

Transformation

Hidden surface removal

Light source

Shading

Page 16: I3I3DG&VR CE00539-m

Sep 30, 2005 16

Object model(s)

Illumination model

Viewing and projection

specification

Graphics engine

Graphical display

Rendering: operations that produce view of scene projected onto view surface

Modelling: numerical description of scene objects, illumination, and viewer

Typical Processing StepsTypical Processing Steps

Page 17: I3I3DG&VR CE00539-m

Sep 30, 2005 17

ModellingModelling

Human Head Model

1438 facets

Page 18: I3I3DG&VR CE00539-m

Sep 30, 2005 18

ModellingModelling

Human Head Model

7258 facets

Page 19: I3I3DG&VR CE00539-m

Sep 30, 2005 19

ModellingModelling

Teacher and Board Model

2074 facets

Page 20: I3I3DG&VR CE00539-m

Sep 30, 2005 20

RenderingRendering

Shaded Human Head

1438 facets

Page 21: I3I3DG&VR CE00539-m

Sep 30, 2005 22

RenderingRendering

Shaded Teacher and Board

Page 22: I3I3DG&VR CE00539-m

Sep 30, 2005 23

Scene GraphsScene Graphs In VR programming the structure In VR programming the structure

used is a scene graph which is used is a scene graph which is special tree structure designed to special tree structure designed to store information about a scene.store information about a scene.

Typical elements includeTypical elements include– geometriesgeometries– positional informationpositional information– lightslights– fogfog

Page 23: I3I3DG&VR CE00539-m

Sep 30, 2005 24

Simple scene graphSimple scene graph

Fognode

Lightnode

Rootnode

Groupnode

Xformnode

Geomnode

Page 24: I3I3DG&VR CE00539-m

Sep 30, 2005 25

Scene Graph NodesScene Graph Nodes Content NodesContent Nodes

– contain basic elements contain basic elements of a sceneof a scene

geometrygeometry lightlight positionposition fogfog

Group NodesGroup Nodes– no contentno content– link the hierarchylink the hierarchy– allow grouping of allow grouping of

nodes sharing a nodes sharing a common statecommon state

Parent

Child #1

Parent

Child #2

Page 25: I3I3DG&VR CE00539-m

Sep 30, 2005 26

Example HierarchyExample Hierarchy

Geom

Lampost

Xform

T2

Geom

Dog

Xform

T1

Group

“Dog”

Group

“Lampost”Light

Root

Page 26: I3I3DG&VR CE00539-m

Sep 30, 2005 27

ApplicationsApplications VR programming is used in VR programming is used in many many

applicationsapplications, e.g., e.g.– EntertainmentEntertainment (computer games, ‘movie’ special (computer games, ‘movie’ special

effects, ...)effects, ...)– Human computer interactionHuman computer interaction (GUI, ...) (GUI, ...)– ScienceScience, , educationeducation, , medicinemedicine (visualisation …) (visualisation …) – BusinessBusiness (marketing, ...) (marketing, ...)– ArtArt

Page 27: I3I3DG&VR CE00539-m

Sep 30, 2005 28

SummarySummary Simulation consists of a series of scenesSimulation consists of a series of scenes Objects defined as Scenes in a scene graph which Objects defined as Scenes in a scene graph which

may be one object or a related collection of objectsmay be one object or a related collection of objects Each iteration of the simulation loop determines Each iteration of the simulation loop determines

actions, translations(along paths) and other inputs actions, translations(along paths) and other inputs which affect properties of the objectswhich affect properties of the objects

NOT animation !!!NOT animation !!! The world is redrawn using rendering processThe world is redrawn using rendering process