CS 378: Computer Game Technology

14
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012

description

CS 378: Computer Game Technology. 3D Engines and Scene Graphs Spring 2012. What’s a 3d engine. OGRE Core Class Structure. What are the objects?. Geometry - polygon (triangle, quad) meshes. Hierarchical Modeling. How can you make articulated characters move in the world? - PowerPoint PPT Presentation

Transcript of CS 378: Computer Game Technology

Page 1: CS  378:  Computer Game Technology

University of Texas at Austin CS 378 – Game Technology Don Fussell

CS 378: Computer Game Technology

3D Engines and Scene GraphsSpring 2012

Page 2: CS  378:  Computer Game Technology

What’s a 3d engine

OGRE Core Class Structure

University of Texas at Austin CS 378 – Game Technology Don Fussell 2

Page 3: CS  378:  Computer Game Technology

What are the objects?

Geometry - polygon (triangle, quad) meshes

University of Texas at Austin CS 378 – Game Technology Don Fussell 3

Page 4: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 4

Hierarchical Modeling

How can you make articulated characters move in the world?

Move the whole character wrt the worldMove legs, arms, head wrt bodyMove hands wrt armsMove upper vs. lower armSame for legs

Page 5: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 5

Symbols and instances

Most graphics APIs support a few geometric primitives:

spherescubestriangles

These symbols are instanced using an instance transformation.

Page 6: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 6

Use a series of transformationsUltimately, a particular geometric instance istransformed by one combined transformation matrix:

But it’s convenient to build this single matrixfrom a series of simpler transformations:

We have to be careful about how we thinkabout composing these transformations.

(Mathematical reason: Transformation matrices don’t commute under matrix multiplication)

Page 7: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 7

Connecting primitives

Page 8: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 8

3D Example: A robot armConsider this robot arm with 3 degrees of freedom:

Base rotates about its vertical axis by Upper arm rotates in its xy-plane by Lower arm rotates in its xy-plane by

Q: What matrix do we use to transform the base?Q: What matrix for the upper arm?Q: What matrix for the lower arm?

h1h2 h3Base

Upper armLower arm

Page 9: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 9

Hierarchical modeling

Hierarchical models can be composed of instances using trees or DAGs:

edges contain geometric transformationsnodes contain geometry (and possibly drawing attributes) How might we draw

the tree for the robot arm?

Page 10: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 10

A complex example: human figure

Q: What’s the most sensible way to traverse this tree?

Page 11: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 11

Human figure implementation, OpenGL

figure(){ torso(); glPushMatrix(); glTranslate( ... ); glRotate( ... ); head(); glPopMatrix(); glPushMatrix(); glTranslate( ... ); glRotate( ... ); left_upper_arm(); glPushMatrix(); glTranslate( ... ); glRotate( ... ); left_lower_arm(); glPopMatrix(); glPopMatrix(); . . .}

Page 12: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 12

Animation

The above examples are called articulated models:rigid partsconnected by joints

They can be animated by specifying the joint angles (or other display parameters) as functions of time.

Page 13: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 13

Key-frame animationThe most common method for character animation in production is key-frame animation.

Each joint specified at various key frames (not necessarily the same as other joints)System does interpolation or in-betweening

Doing this well requires:A way of smoothly interpolating key frames: splinesA good interactive systemA lot of skill on the part of the animator

Page 14: CS  378:  Computer Game Technology

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 14

Scene graphsThe idea of hierarchical modeling can be extended to an entire scene, encompassing:

many different objectslightscamera position

This is called a scene tree or scene graph.

CameraLight1 Light2 Object2 Object3

Scene

Object1