Advertisement Jump to content
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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
(2) glLoadIdentity
(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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!