Professional Documents
Culture Documents
Richard Nordhaus
Tin Toy
School of Architecture and Planning
Copyright Pixar Animation Studios
University of New Mexico
Interactive Graphical Systems: Structure
What is Interactive Computer Graphics ?
Example : Interactive Computer Graphics
Computer-
simulation
Real world
Design and Simulation of a Robot Cell
Copyright Sandia National Libraries Replication
definition of O, y, and z
y
r x2 y2 z2 x = r cosM cosO
a xb a x b x a y b y a z bz y
.
~v N
b
a P. .
ba O
a axa a x2 a y2 a z2
V´ x
a xb D= ab
D cos 1
a b z .V
Used for
ba a xb a 1 a) calculation of length and distances Solution: The polygon is facing towards the observer if the normal vector of that face is facing towards
the observer. This is the case, if the length of the projection of the vector V’ onto N is
b) angle measurements
greater than zero. See next slide for two examples.
Application of the dot product - Backface Culling Vector algebra (quick rehearsal of useful formulas)
§ 1· §2 3·
¨ ¸ ¨ ¸ 2. Vector product or cross product of two vectors
Let: P ¨ 1¸ ; N ¨1 3¸ ; N 4 9 1 9 4 9 9 9 1
¨ ¸ ¨ ¸
© 0¹ ©2 3¹ aub c
§ 10· § 5·
a y
b z b y a z i a z b x b z a x j a x b y b x a y k
¨ ¸ ¨ ¸
Case1: Let V ¨ 7¸ Case2: Let V ¨ 7 ¸ § a y bz b y a z ·
¨ ¸ ¨ ¸ ¨ ¸
© 15¹ © 9¹ ¨ a z b x bz a x ¸
¨ ¸
© a x by bx a y ¹ c
§ 10 1· § 9· § 5 1· § 6·
¨ ¸ ¨ ¸ ¨ ¸ ¨ ¸
V' V P ¨ 7 1¸ ¨ 6¸ V' V P ¨ 7 1 ¸ ¨ 6 ¸ c is a vector perpendicular to a and b.
¨ ¸ ¨ ¸
¨ ¸
© 15 0¹
¨ ¸
© 15¹ © 9 0¹ © 9¹ b
.
Used for .
v~ N x V ' 2 3 9 1 3 6 2 3 15 v~ N x V ' 2 3 6 1 3 6 2 3 9 a) calculation of surface normal vectors
6 2 10 18 4 2 6 8 b) test for collinearity of two vectors (c = 0)
a
c) calculation of reference frames
18>0 -> The polygon is facing towards V. -8<0 -> The polygon is not facing towards V.
0.5 1 k
N ab u ac
1
1
1
0
§ 0.5 ( 1) ·
¨
¨ 0 ( 1) ¸
¸
§ 0.5·
¨ ¸
¨ 1¸
c ij ¦a
s 1
is b sj ;1 i n ,1 j l
0.5 1 ¨ ¸ ¨ ¸
© 1 0 ¹ © 1¹
1 1
Transformation of Points : Matrix-Vector Multiplication Matrix representation of basic geometric transforms
Scale Translation Rotations
Transformation represented as a Mn,k where n=4, k=4.
§sx 0 0 0· §1 0 0 tx · §cos- sin- 0 0·
¨ ¸ ¨ ¸ ¨ ¸
Point represented by homogeneous coordinates { x, y, z, 1 } as column vector P ¨0
S ¨
sy 0 0¸ ¨0 1 0 ty¸ ¨sin- cos- 0 0¸
T Rz (-) ¨
where k = 4, l = 1. 0 0 sz 0¸ ¨0 0 1 tz ¸ 0 0 1 0¸
¨ ¸ ¨ ¸ ¨ ¸
©0 0 0 1¹ ©0 0 0 1¹ © 0 0 0 1¹
The resulting matrix has n=4 rows and l=1 columns
§1 0 0 0·
¨ ¸
¨0 cos- sin- 0¸
Rx (-) ¨
0 sin- cos- 0¸
¨ ¸
m11 m12 m13 m14 x m11x + m12y + m13Z + m14 ©0 0 0 1¹
m21 m22 m23 m24 y m21x + m22y + m23Z + m24
P’ = M.P = m31 m32 m33 m34 z = m31x + m32y + m33Z + m34
m41 m42 m43 m44 1 m41x + m42y + m43Z + m44
§ cos- 0 sin- 0·
¨ ¸
¨ 0 1 0 0¸
Ry (-) ¨
sin- 0 cos- 0¸
¨ ¸
© 0 0 0 1¹
B)
1. Rotate about X, 25 deg.
Example : A = RzT Example : A = TRz
2. Translate along X, 0.5
3. Rotate about Z, 50 deg.
y Z X
y y y y
x x x x x x
Calculation of Reference Frames (Attitude Matrix) Calculation of Reference Frames (Attitude Matrix)
Given: Three points in space identify the spatial attitude of an object´s reference frame
ªt11 t12 t12 t14 º ª1º ªt11 1 t12 0 t12 0 t14 1º ªax º ªa x ? ? 0º
«t t 24 »» «0» «t 1 t 24 1»» «a » «a 0»»
Txa * x « 21 t 22 t 23
« » « 21 t 22 0 t 23 0
« y» Hence: Txa « x ? ?
y «t31 t32 t33 t34 » «0» «t31 1 t32 0 t33 0 t34 1» «az » «a x ? ? 0»
« » « » « » « » « »
¬t 41 t 42 t 43 t 44 ¼ ¬1¼ ¬t 41 1 t 42 0 t 43 0 t 44 1¼ ¬1¼ ¬0 0 0 1¼
y b C b
a . a ay
A. .B O ax
az
ªt11 t12 t12 t14 º ª0º ªt11 0 t12 1 t12 0 t14 1º ªbx º ª? bx ? 0º
c «t t 24 »» «1» «t 0 t 24 1»» «b » «? b ? 0»»
O c Tyb * y « 21 t 22 t 23
« » « 21 t 22 1 t 23 0
« y» Hence: Tyb « y
x «t31 t32 t33 t34 » «0» «t31 0 t32 1 t33 0 t34 1» «bz » «? bz ? 0»
« » « » « » « » « »
x z ¬t 41 t 42 t 43 t 44 ¼ ¬1¼ ¬t 41 0 t 42 1 t 43 0 t 44 1¼ ¬1¼ ¬0 0 0 1¼
z
A, B, and C can be used to calculate A transformation matrix Txa rotates the unit vector
(1,0,0,1) into the new base vector a=(ax,ay,az,1) ªt11 t12 t12 t14 º ª0º ªt11 0 t12 0 t12 1 t14 1º ªcx º ª? ? cx 0º
a new orthonormal basis {A;a,b,c} «t
« 21 t 22 t 23 t 24 »» «0» «t 0
« 21 t 22 0 t 23 1 t 24 1»» «c » «? ? cy 0»»
Tzc * z « » « y» Hence: Tzc «
a CA ªt11 t12 t12 t14 º ª1º ªt11 1 t12 0 t12 0 t14 1º ªax º «t31 t32 t33 t34 » «1» «t31 0 t32 0 t33 1 t34 1» «cz » «? ? cz 0»
«t t 24 »» ««0»» «t 1 t 22 0 t 23 0 t 24 1»» «a » « » « » « » « » « »
b ( B A) u a « 21 t 22 t 23
Txa * x
«t31 t32 t33
t34 » «0»
« 21
«t31 1 t32 0 t33 0 t34 1»
« y»
«az » ¬t 41 t 42 t 43 t 44 ¼ ¬1¼ ¬t 41 0 t 42 0 t 43 1 t 44 1¼ ¬1¼ ¬0 0 0 1¼
c aub « » « » « » « »
¬t 41 t 42 t 43 t 44 ¼ ¬1¼ ¬t 41 1 t 42 0 t 43 0 t 44 1¼ ¬1¼
Note: a,b, and c must be normalized!
ªt11 t12 t12 t14 º ª0º ªt11 0 t12 0 t12 0 t14 1º ª Ax º ª? ? ? Ax º Quantitative Models
«t t 24 »» «0» «t 0 t 22 0 t 23 0 t 24 1»» «A » «?
« 21 t 22 t 23 « 21 « y » Hence: T ? ? Ay »» Mathematical, physical, chemical... function define vertex data
TOA * O « » OA
«
«t31 t32 t33 t34 » «0» «t31 0 t32 0 t33 0 t34 1» « Az » «? ? ? Az »
« » « » « » « » « »
¬t 41 t 42 t 43 t 44 ¼ ¬1¼ ¬t 41 0 t 42 0 t 43 0 t 44 1¼ ¬1¼ ¬0 0 0 1¼
Procedural Models
Since Tax,Tby, and Tcz operate independantly on the respective base vectors, they can be Declarative or procedural system describes vertex data and connectivity
combined into on single transformation matrix, that rotates a all base vectors simultaneously. (rule based, language based, recursive and fractal functions)
The translation matix operates independently on to trnaslate the origin, regardles of the
rotational components. Hence, the combined transformation matrix can be denoted as:
Hierarchical Geometric Models
ªax bx cx Ax º Explicit definition of objects by vertex data and connectivity
«a Ay »»
T « y by cy Re-Usage of geometric prototypes
«az bz cz Az » Defining hierarchies and geometric relations between instances
« »
¬0 0 0 1¼
How are graphical objects defined ?
How are graphical objects defined ?
Finite set of volume points (voxels) : Voxelviewer
Mathematical functions : Example MATLAB
x,y,z,...u,v
Polygon List
n
p4 v6 1 4 { 1, 2, 3, 4 } { ......... }
y
v2 2 3 { 6, 4, 3 } { ......... }
Vertex Index Vertex Data
v3 Cartesian Coordinates 3 3 { 5, 4, 6 } { ......... }
p2 Normal Vectors 4 4 { 3, 2, 7, 6 } { ......... }
Texture Coordinates
p1 p3 Color Values
v5
v1 k 3 { l, m, n } { ......... }
v4
x Polygon Index
Number of Vertices
z
Pictures: Copyright (c) 1990 Pixar Objects reference frame List of Vertex Indices
Other data e.g. Texture Reference
• Point Clouds • Object vertices are drawn as singular pixels • Wire Frames • Edges of object polygons are drawn as lines
• Color of the pixels can be constant (object color) • Color of the lines can be constant (object color)
or be shaded (depending on lights and object colors) or be shaded (depending on lights and object colors)
• Determination of discrete screen-coordinates from • Determination of discrete screen-coordinates for
model vertex coordinates model vertices
• Very fast rendering method • 2D line drawing (scan conversion) between the vertices
• Very fast rendering method if used without hidden
surface removal
Examples: Examples:
Rendering Methods
Surface Shading Models
• Surface Shading • Object polygons are drawn as filled areas
• Color of the polygons can be constant (object color) • Constant / Flat Shading
or be shaded (depending on lights and object colors) ) one shading value is calculated per polygon
(constant or ambient shading, diffuse shading) ) entire polygon is filled only with that color value
• Determination of discrete screen-coordinates for model vertices ) fast but not nice looking
• 2D line drawing (scan conversion) of the edges
• 2D area fill inside the polygon • Gouraud Shading (Color Interpolation)
• Can be very slow depending on shading method ) shading values are calculated for each vertex
Examples: ) color values for each pixel inside polygon
are linearly interpolated
) good visual appearance at cost of reduced rendering speed
Example: Flat Shading vs. Gouraud Shading Requirements: Flat Shading vs. Gouraud Shading
Flat-Shading:
n1
One surface normal n2
vector per face/polygon.
n3 n4
n4
Phong-Shading:
n1
fn1 n2
Surface normal vectors fn2
per vertex.
Usually calculated from n1
n2
surrounding polygon
normal vectors. fn3
fn4
I(n)
15,00 1,25 4,00 0,13 -0,95638 0,956382 0,90 0,6
16,00 1,40 4,00 0,20 -0,95668 0,956681 0,91 I(gouraud)
C2 (n2 x l) O [
17,00 1,55 4,00 0,28 -0,95564 0,955645 0,92
C2 (n2 x l) O [ 18,00 1,70 4,00 0,35 -0,95338 0,953379 0,93
19,00 1,85 4,00 0,43 -0,95 0,949997 0,94 0,4
Color calculation between vertices by (bi)linear 20,00 2,00 4,00 0,50 -0,94561 0,945611 0,945611
z
Number of Vertices
Allow for easier animation of behavior
Objects reference frame List of Vertex Indices
Other data e.g. Texture Reference
Hierarchical modeling Simple Robot : Modeling Hierarchy
Base
Trunk
Base VRT_NodeScale(base,0.1,0.2,0.1);
base = VRT_NodeNew(root,"Robot Base");
Trunk trunk = VRT_NodeNew(base,"Robot Trunk"); VRT_NodeTranslate(trunk,0.0,2.0,0.0);
head = VRT_NodeNew(trunk,"Robot Head"); VRT_NodeScale(trunk,1.5,1.0,1.5);
left_arm = VRT_NodeNew(trunk,"Left Arm");
Head Left_Arm Right_Arm
right_arm = VRT_NodeNew(trunk,"Right Arm"); VRT_NodeTranslate(head,0.0,1.2,0.0);
Tree of involved instances VRT_NodeScale(head,0.5,0.5,0.5);
cylinder = VRT_Cone(1.0,1.0,1.0,20);
cube = VRT_Cube(1); VRT_NodeTranslate(right_arm,-1.4,0.8,-0.2)
box = VRT_Box(0.2,1.0,0.2); VRT_NodeScale(right_arm,2.0,2.0,2.0);
VRT_NodeRotate(right_arm,180,0,0);
VRT_NodeSetGeometry(base,cylinder);
VRT_NodeSetGeometry(trunk,cube); VRT_NodeTranslate(left_arm,1.0,0.8,-0.2);
VRT_NodeSetGeometry(head,cube); VRT_NodeScale(left_arm,2.0,2.0,2.0);
Generic objects VRT_NodeSetGeometry(left_arm,box); VRT_NodeRotate(left_arm,180,0,0);
VRT_NodeSetGeometry(right_arm,box);
Simple Robot : The Scene Graph
“base”
nnn
nnn
nnn
Start robot.exe
“trunk”
nnn
nnn
nnn