chapter 11: hierarchical modeling

45
Chapter 11 Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 11: Hierarchical Modeling

Upload: zarita

Post on 19-Jan-2016

57 views

Category:

Documents


0 download

DESCRIPTION

Chapter 11: Hierarchical Modeling. This Chapter: we will learn about. Building Hierarchical Models Controlling components in a Hierarchical Model Object Coordinate System Scene Graphs/Trees/Nodes. Review of D3D …. We wish to draw a vertex V i What is being drawn is V o , where For D3D - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Chapter 11: Hierarchical Modeling

Page 2: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

This Chapter: we will learn about

Building Hierarchical Models

Controlling components in a Hierarchical Model

Object Coordinate System

Scene Graphs/Trees/Nodes

Page 3: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

We wish to draw a vertex Vi

What is being drawn is Vo, where

For D3D

We have see: MV = Mw2n

This chapter, we examine what to do with MW

MP = I4 will not change until 3D

Review of D3D …

Page 4: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Motivation …

A circle at Vi = (xi, yi) with radius r Define a triangle fan

Either: centered at Vi with radius r Or: at origin (0,0), with radius 1.0 AND

Load: MW = S(r,, r) T(xi,, yi)

XformInfo class: to compute/load MW = T(-px, -py)S(sy, sy)R(θ)T(px,, py)T(tx,, ty) A general operator to transform primitives

Page 5: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Now, a simple Arm …

Rectangle:

Circle:

Want to: Rotate the entire Arm about Pivot:

EASY to accomplish with xformInfo!

Page 6: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.1: Controlling Simple Arm

Controls

Page 7: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.1: some details …

Label C: Sets top of Stack to Identity: I4

Label D: On the stack computes

Ma = T(-px, -py)S(sy, sy)R(θ)T(px,, py)T(tx,, ty) AND

Loads top of stack to: WORLD matrix (MW = Ma)

Page 8: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.1: more detilas

MW = Ma where … Ma = T(-px, -py)S(sy, sy)R(θ)T(px,, py)T(tx,, ty)

Arm movement is accomplished … With no changes to any of the vertices

Ra0 and Cp0 vertices are not altered!

With xformInfo class Load Ma from top of stack to MW

Then draw

Page 9: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Generalize the idea …

Control the Palm on the arm Palm is the circle (Cp0) pivoted at (Pp)

Observe (intuition) Palm follows the arm xform

i.e., when rotate arm, palm must follow Palm has additional xform …

i.e., palm can be rotated independent from arm

Page 10: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.2: Parent/Child Xform Note:

Label A: one moreXformInfo object

Page 11: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.2: Some details …

Label B: Computes Ma from m_ArmXform Draws Ra0 rectangle with MW= Ma

Label C: Computes Mp from m_PalmXform and

concatenates with Ma to compute: MpMa

Draws Cp0 rectangle with MW= MpMa

Page 12: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Observations:

Graphical Objects Geometric Primitives Once defined, do not alter

Interactive control Accomplished via computing/setting

transformations Components

By strategically defining/concatenating separate transforms

Accomplish intuitive group/component control

Page 13: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib 11: SceneNode class

Design to support convenient concatenation of XformInfo

Page 14: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

SceneNode Details

Page 15: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.3: SceneNode

Look/Feel: identical to Tut 11.2

Page 16: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.4: Subclass from SceneNodeLook/Feel: identical to Tut 11.2/11.3

Page 17: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.5: SceneTreeControl (GUI support)

SceneTreeControl

Page 18: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

SceneTreeControl: some details

Page 19: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

SceneTreeControl: Implementation

Page 20: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.6: Hierarchy of SceneNodes

Page 21: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.6: Implementation

Page 22: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 12.6: Details …

Body xformed by:

Left Arm by:

Left Palm by:

Page 23: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Instancing: sharing …

Notice … left and right arm/palm

are identical! How can we re-use?!

Page 24: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Instancing: Sharing of hierarchy

Arm hierarchy shared byseparate left/righttransforms

See: two separate arms: left

Arm palm

Right Arm palm

Page 25: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Sharing Hierarchy: Problem Transforms:

Left Arm/Palm

Right Arm/Palm

Notice: Ma and Mp in both left and right When change these two transforms

Left/right arm/palm will change in identical manner!

In this case: no way to control left/right separately!

Page 26: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Instancing: Sharing Geometry

Problem: complexity!

Page 27: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Instancing: Discussion …

Commercial System: Sharing of geometry

Memory management is tricky! reference count

Sharing of hierarchy Typically not used because of restricted

control

UWBGL_LIB: DO NOT support any form of instancing

Page 28: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Object Coordinate (OC) System

Page 29: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Left Arm/Palm to WC Transform

Page 30: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Object Coordinate and Transforms

Drawing: XformInfo in SceneNode Computes/loads MW to transform node OC to WC WindowHandler (DrawOnlyHandler::DrawGraphics()):

Computes load Mw2n to MV to transform form WC to NDC

Mouse click selection Positions are given to us in HC space! Our program represent graphical objects in OC!

Collision: we must decide! Perform computation in WC? Or Perform computation in OC?

Page 31: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Mouse Click Selection

Two Tasks: Coordinate Space: From DC to OC Proximity Test:

when in OC determine if mouse click is close to object

Page 32: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Mouse click position in OCs

Page 33: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

DC to OC Transforms …

Mouse click:

In Body OC:

In Left Arm OC:

In Left Palm OC:

Page 34: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Proximity Test:

Close-enough test In general: expensive!

In our case: Use point in

bounding volume

Page 35: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib12: SceneNode bound support

Bound: in WC Velocity: for moving the

entire node (by changing XformInfo)

Page 36: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Lib12: Transformation support

DrawHelper::TransformPoint() Transforms a point based Using the top of matrix stack

Usage: Push matrix stack Compute transform

on the matrix stack Transform points Pop matrix stack

Page 37: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Compute SceneNode BBox

Page 38: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

SceneNode: Bound implementation

A: BBox of all primitives for this node B: OC to WC matrix C: Transform BBOX to WC D: Compute/Merge with Children BBOX

Page 39: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

SceneNode::GetNodeBound()

A: If specific scene node found: compute bound starting from this node

B: if not found, Set OC to WC xform and B1: continue traversing down the hierarchy (looking for

given node) C: Restore Xfrom Stack

Page 40: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.7: Mouse Hit Detection

LMB click in bound tosee component selected

Page 41: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut: 11.7: some details

Page 42: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.8: Collision

CPrimitiveArm: is a primitive Can be used as bullets In the CModel m_bullets array

Page 43: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.8: UpdateSimulation()

B: Keeps references to colliding parts (Palms) C: Collide all bullets (balls and PrimitiveArm)

With Left/Right Palms D: Randomly create new bullets

Page 44: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.8: Lesson …

Rough Approximation: Proximity tests are simple Bbox Many false positives!

Multiple collisions: A bullet can intersect with a palm

multiple times! Resulting in multiple hitCount for the

same palm/bullet collisions

Page 45: Chapter 11:  Hierarchical Modeling

Chapter 11

Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer

Tut 11.9: Simple Animation …

Continuously change

the xform of a SceneNode (palm)