# hierarchical modeling in "Interactive Computer Graphics"

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a problem with hierarchical modeling in Chapter 9 of Edward Angel's famous book "Interactive Computer Graphics". It was quite OK to use Mutilplying Matrix for tree structure, but when I want to move the camera, it seems as if the torso always keeps a fixed distance from my camera, no matter where my camera is. I have already tried several ways, including, 1, keep the camera fixed, move the torso, by adding (x,y,z) to all components of the torso: his code: glTranslatef(-(TORSO_RADIUS+UPPER_ARM_RADIUS), 0.9*TORSO_HEIGHT, 0.0); my code: glTranslatef(x-(TORSO_RADIUS+UPPER_ARM_RADIUS), y+0.9*TORSO_HEIGHT, z+0.0); 2, keep the torso fixed, move the camera, by updating gluLookAt gluLookAt(x, y, z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); But these don't work at all. Would anybody please tell me the solution of how to keep the torso at a fixed position (x,y,z), while camera moves?

##### Share on other sites
I don't know the book you mentioned, but in general you have to performs these steps to render a forward hierarchy of co-ordinate frames (your problem description sound like you do such thing) and your camera is given in world space:

(1) switch to MODELVIEW matrix stack
(3) glMultMatrix or glRotate with inverse camera orientation in world
(4) glMultMatrix or glTranslate with inverse camera position in world
[BTW: (3) and (4) is made by gluLookAt if used]
(5) for each model in the hierarchy do
(5a) glMultMatrix or glTranslate of model local position
(5b) glMultMatrix or glRotate of model local orientation
(5c) glMultMatrix or glScale of model local size (if not standard 1)
(5d) push model geometry (normals, vertices, ...)
(6) continue w/ (5) if more models

You have to insert push/pop of matrix at appripriate places of (5x), of course.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634102
• Total Posts
3015536
×