Where We Are Static Models Our models are static sets of polygons We can only move them via transformations translate scale rotate or any other 4x4 matrix This does not allow us to simulate very realistic motion So how do we fix this A Multitude of Spaces Recall that transformations move us between different coordinate spaces e2 e 2 Object Space Model Transform e 1 World Space View Transform Eye Space e1 Vertices move through many spaces We change spaces for convenience as with the view transform Projection Clip Space Perspective Division Normalized Device Coordinates Viewport Transform Window Coordinates 1 First Step Break the thing Apart Model object as hierarchy of components each one can move and they move relative to parent How do they move with transformations Body L Arm Upper Head Torso R Arm Lower Introduce Transformation Nodes Traverse hierarchy during draw object nodes draw them transform nodes Current Matrix Mbody multiply into current matrix on way down remove from current matrix on way up M Mbody Body Constantly changing local coordinate system Mupper Allows changes at different scales apply rotation above Body vs rotation above L Arm M Mbody Mupper Upper Mlarm M Mbody Mupper Mlarm L Arm 2 Parameterizing Movement So how do we control the movement of parts We have all these transformation nodes 4x4 matrix 16 coefficients obviously don t want to specify manually Could just specify sets of rotate translate scale much handier but still lacks one crucial thing things might fall apart Parameterizing Movement We want to link things with joints Example for a shoulder specify corresponding points that remain together provide a joint angle parameter just like building people with cardboard cut outs Construct transform from parameters 3 Building Hierarchies We need some good way to build them manual manipulation select objects and hit Group button graph layout draw graphs directly textual description of hierarchy write scripts to generate hierarchy And we need to manipulate the transformations type in rotate scale translate values attach parameters to GUI elements e g sliders write little procedural controllers for instance increment angle every 1 3 seconds acts sort of like a motor Matrix Stacks Instead of a current matrix we need a matrix stack current matrix is just the top of the stack Stack operations PUSH duplicate matrix on top POP remove matrix on top glPushMatrix glPopMatrix When traversing hierarchies PUSH on entering transformation node multiply transformation into current matrix descend to children POP when returning up the tree A Push A A Mult B AB A Pop A 4 Implementing Transformation Nodes Be careful about transformation order usually want to scale before rotation usually want to rotate before translation Simple 2 D Case glPushMatrix glTranslatef dx dy Further translation glTranslatef cx cy Back to center glRotatef angle 0 0 1 glScalef s t glTranslatef cx cy Center to origin descend to children glPopMatrix Example Building a Simple Arm We want to model this arm as a hierarchy Out of these basic components s t e1 L e2 U L U U upper arm L lower arm forearm w User Control Parameters shoulder joint angle t where shoulder meets torso elbow joint angle 5 Positioning the Forearm Initially segments in same position s e1 e 2 shoulder joint location elbow joint locations w wrist joint location e2 w First perform elbow rotation translate elbow joint to origin rotate by given angle 1 translate e 2 2 rotate w U L L e1 U e2 Attaching Forearm to Upper Arm w Second align corresponding elbows 3 translate e1 L s e1 e 2 U w Third perform shoulder rotation must operate on whole arm 4 translate s L 5 rotate e1 e 2 s U 6 Placing the Shoulder w Fourth put shoulder in right spot 6 translate t L And we re done e1 e 2 Important things to notice presents limited control knobs automatically handle interconnection s t U e g elbow joint Exercise Converting to Hierarchy trans t 1 translate e 2 2 rotate What s the hierarchy to put in here 3 translate e1 U 4 translate s 5 rotate 6 translate t L 7 Converting to Transformation Hierarchy trans t 1 translate e 2 rotate 2 rotate trans s 3 translate e1 U trans e1 4 translate s 5 rotate rotate 6 translate t trans e2 L Notable Properties of Transform Hierarchy Geometry is always at the leaves internal nodes are transforms trans t rotate There are 2 types of transforms structural shown in gray trans s trans e1 rotate U fixed at design time keeps things together control knobs shown in blue variable parameters controlled by user trans e2 L 8 Scene Graphs This idea can be extended to the whole scene collect every object into a single hierarchy Provides several nice advantages natural way of defining bounding volumes for culling can instance same model in many places but graph is no longer a tree it s a more general DAG Parking Lot Street can introduce new node types also light nodes material nodes Truck OpenGL State Stack In OpenGL you can also push pop state variables glPushAttrib glPopAttrib Pass to glPushAttrib a bitfield describing what to push GL ALL ATTRIB BITS GL ENABLE BIT everything set by glEnable GL LIGHTING BIT light position colors materials GL CURRENT BIT current color normal and several others 9 How to Generate Animation We can create parameterize models now design the geometry set up a bunch of control knobs e g joint angles But how do we animate these models don t want to manually tweak transformation parameters We ll specify parameters as functions of time but we need to do this conveniently no writing out explicit polynomial functions Recall How We Display Animation We create animated behavior just like movie projectors display a sequence of still images in rapid succession creates the illusion of continuous motion typically want 30 frames sec and definitely higher than 10 Given some parameterized hierarchical model for every frame we calculate the correct parameter values we set our hierarchy control knobs appropriately and we draw the scene in its current state We re going to need to figure out how to control parameters key framing specify poses and automatically interpolate physically based motion simulate physical laws 10
View Full Document
Unlocking...