Hierarchical Modeling CS418 Computer Graphics John C. Hart Build a - - PowerPoint PPT Presentation

hierarchical modeling
SMART_READER_LITE
LIVE PREVIEW

Hierarchical Modeling CS418 Computer Graphics John C. Hart Build a - - PowerPoint PPT Presentation

Hierarchical Modeling CS418 Computer Graphics John C. Hart Build a Robot glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix();


slide-1
SLIDE 1

Hierarchical Modeling

CS418 Computer Graphics John C. Hart

slide-2
SLIDE 2

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-3
SLIDE 3

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-4
SLIDE 4

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 2 1 1              

slide-5
SLIDE 5

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-6
SLIDE 6

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 4 1 4

1 1              

slide-7
SLIDE 7

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 4 1 4

1 1 1 1 1 1 1                           

slide-8
SLIDE 8

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 4 1 4

c s 1 s c 1 1 1 1 1 1 1 1                                        

slide-9
SLIDE 9

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 1 4 4 1 4

1 1 c s 1 s c 1 1 1 1 2 1 1 1 1 1 1 1                                                      

slide-10
SLIDE 10

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

push/pop matrix keeps body scale from affecting shoulder

slide-11
SLIDE 11

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-12
SLIDE 12

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-13
SLIDE 13

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-14
SLIDE 14

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-15
SLIDE 15

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-16
SLIDE 16

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

push/pop allows the forearm to ignore these

slide-17
SLIDE 17

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-18
SLIDE 18

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-19
SLIDE 19

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

slide-20
SLIDE 20

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 1 1 1            

Modelview: Stack:

1 1 1 1            

slide-21
SLIDE 21

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 1 1 1            

Modelview: Stack:

1 1 1 1 , 1 1 1 1                        

slide-22
SLIDE 22

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 2 1 1            

Modelview: Stack:

1 1 1 1 , 1 1 1 1                        

slide-23
SLIDE 23

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

1 1 1 1            

Modelview: Stack:

1 1 1 1            

slide-24
SLIDE 24

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 4

1 1 1 2 1 1              

slide-25
SLIDE 25

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 4

1 1 c s s c 1 2 1 1 1 1                           

slide-26
SLIDE 26

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 4

c s 1 1 1 s c 2 , 1 1 1 1                           

1 4

1 1 c s s c 1 2 1 1 1 1                           

slide-27
SLIDE 27

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 4

c s 1 1 1 s c 2 , 1 1 1 1                           

1 4

c s 1 1 1 1 s c 2 1 1 1 1                            

slide-28
SLIDE 28

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 4

c s 1 1 1 s c 2 , 1 1 1 1                           

1 1 4 4 1 4

c s 1 1 s c 2 c 1 1 1                              

slide-29
SLIDE 29

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 4

c s 1 s c 2 1 1               

slide-30
SLIDE 30

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 4

c s 1 1 1 2 s c 2 1 1 1 1                            

slide-31
SLIDE 31

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 4

c s 1 c' s' s' c' s c 2 2c 1 1 1 1                            

slide-32
SLIDE 32

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 4

cc' ss' cs' c's 1 1 1 1 c's cs' cc' ss' 2 2c 1 1 1 1                                

slide-33
SLIDE 33

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

1 1 4 4 1 4

cc' ss' cs' c's 1 c's cs' 1 c's cs' cc' ss' 2 2c cc' ss' 1 1 1                                     

slide-34
SLIDE 34

Build a Robot

glPushMatrix(); glPushMatrix(); glScalef(1.0,2.0,1.0); glutSolidCube(2.0); glPopMatrix(); glTranslatef(1.25,2,0.0); glRotatef(shoulder,0,0,1); glPushMatrix(); glTranslatef(0,-1,0.0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix(); glTranslatef(0,-2,0); glRotatef(elbow,0,0,1); glTranslatef(0,-1,0); glScalef(0.25,1.0,0.25); glutSolidCube(2.0); glPopMatrix();

Modelview: Stack:

1 1 1 1            

slide-35
SLIDE 35

Hierarchical Modeling

  • Use glPushMatrix() to save a copy of

the current coordinate system

  • Use glPopMatrix() to return to that

coordinate system

  • Surround drawing routines with

Push/PopMatrix for reusability – Better (more reusable) than calling glIdentityMatrix() at the beginning

  • f the display routine, which

destroys the current view

display() { glPushMatrix() … establish coordinates … glPushMatrix() … go off on a tangent … glPopMatrix() … return to coordinates … glPopMatrix() } reshape() { gluLookat(…) }

slide-36
SLIDE 36

Solar System

slide-37
SLIDE 37

Solar System

PushMatrix Rotate 360*days/365,(0,1,0) Translate (AU,0,0) Rotate 23,(1,0,0) Rotate 360*hours/24,(0,1,0) drawearth … PopMatrix

slide-38
SLIDE 38

Solar System

PushMatrix Rotate 360*days/365,(0,1,0) Translate (AU,0,0) Rotate 23,(1,0,0) Rotate 360*hours/24,(0,1,0) drawearth … PopMatrix PushMatrix Rotate 360*days/27,(0,1,0) Translate 238856,0,0 Rotate -360*days/29,(0,1,0) drawmoon PopMatrix