Hierarchical Modeling CS418 Computer Graphics John C. Hart.

38
Hierarchical Modeling CS418 Computer Graphics John C. Hart

Transcript of Hierarchical Modeling CS418 Computer Graphics John C. Hart.

Page 1: Hierarchical Modeling CS418 Computer Graphics John C. Hart.

Hierarchical Modeling

CS418 Computer Graphics

John C. Hart

Page 2: 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();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();

Page 3: 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();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();

Page 4: 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();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

Page 5: 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();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();

Page 6: 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();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();

14

14

1

1

Page 7: 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();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();

14

14

1

1 1 1

1

1 1

Page 8: 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();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();

14

14

c s 1

s c 1 1 1

1 1

1 1 1

Page 9: 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();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();

1144

14

1 1 c s 1

s c 1 1 11 21 11

1 11 1

Page 10: 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();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

Page 11: 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();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();

Page 12: 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();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();

Page 13: 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();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();

Page 14: 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();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();

Page 15: 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();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();

Page 16: 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();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

Page 17: 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();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();

Page 18: 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();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();

Page 19: 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();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();

Page 20: 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();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

Page 21: 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();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

Page 22: 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();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

Page 23: 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();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

Page 24: 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();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

14

1 1

1 2

1

1

Page 25: 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();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

14

1 1 c s

s c1 211

11

Page 26: 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();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:14

c s 1 1

1s c 2 ,11

11

14

1 1 c s

s c1 211

11

Page 27: 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();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:14

c s 1 1

1s c 2 ,11

11

14

c s 1 1

1 1s c 211

11

Page 28: 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();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:14

c s 1 1

1s c 2 ,11

11

1144

14

c s 1

1s c 2 c

1

1 1

Page 29: 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();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

14

c s 1

s c 2

1

1

Page 30: 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();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

14

c s 1 1

1 2s c 211

11

Page 31: 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();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

14

c s 1 c' s'

s' c's c 2 2c11

11

Page 32: 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();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

14

cc' ss' cs' c's 1 1

1 1c's cs' cc' ss' 2 2c11

11

Page 33: 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();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

1144

14

cc' ss' cs' c's 1 c's cs'

1c's cs' cc' ss' 2 2c cc' ss'

1

1 1

Page 34: 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();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

Page 35: Hierarchical Modeling CS418 Computer Graphics John C. Hart.

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 of 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(…)

}

Page 36: Hierarchical Modeling CS418 Computer Graphics John C. Hart.

Solar System

Page 37: Hierarchical Modeling CS418 Computer Graphics John C. Hart.

Solar System

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

Page 38: Hierarchical Modeling CS418 Computer Graphics John C. Hart.

Solar System

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

PushMatrixRotate 360*days/27,(0,1,0)Translate 238856,0,0Rotate -360*days/29,(0,1,0)drawmoonPopMatrix