hierarchical modeling cs418 computer graphics john c. hart
TRANSCRIPT
![Page 1: Hierarchical Modeling CS418 Computer Graphics John C. Hart](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/1.jpg)
Hierarchical Modeling
CS418 Computer Graphics
John C. Hart
![Page 2: Hierarchical Modeling CS418 Computer Graphics John C. Hart](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/5.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/6.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/7.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/8.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/10.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/11.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/12.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/13.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/14.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/15.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/16.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/17.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/18.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/19.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/20.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/21.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/22.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/23.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/24.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/25.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/26.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/27.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/28.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/29.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/30.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/31.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/32.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/33.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/34.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/35.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/36.jpg)
Solar System
![Page 37: Hierarchical Modeling CS418 Computer Graphics John C. Hart](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/37.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022081511/56649ede5503460f94beee54/html5/thumbnails/38.jpg)
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