Any one reading "Interactive Computer Graphics: A Top-Down Approach with OpenGL"?

Hey, I am using Edward Angel’s famous book - “Interactive Computer Graphics: A Top-Down Approach with OpenGL”, and encounters a problem in Chapter 9 - “Hierarcical Modeling”

The problem is that in “dynamic.c”, Angel uses a new presentation of tree structure. It was Ok to use “glLoadIndentity” and “MultiMatrix”, but when I want to move the camara away from the torso, the torso doesn’t become smaller. It seems as if the torso just moves together with the camera.

Does anybody know the reason?

are you using orthogonal projection? if you want objects to become smaller with bigger distance, you have to use glFrustum or gluPerspective.

Originally posted by RigidBody:
are you using orthogonal projection? if you want objects to become smaller with bigger distance, you have to use glFrustum or gluPerspective.
Well, Angel was using glOrtho, but I have replaced it with glFrustum. Still, moving the camera cannot change the torso size …

can you post some code?

source code is here
http://rapidshare.de/files/10311480/torso.c.html web page

some useful code is following:
/* tree node definination */
typedef struct treenode
{
GLfloat m[16];
void (*f)();
struct treenode *sibling;
struct treenode *child;
}treenode;

/* torso node */
treenode torso_node, head_node, lua_node, rua_node, lll_node, rll_node,lla_node, rla_node, rul_node, lul_node;

void traverse(treenode* root)
{
if(root==NULL) return;
glPushMatrix();
glMultMatrixf(root->m);
root->f();
if(root->child!=NULL) traverse(root->child);
glPopMatrix();
if(root->sibling!=NULL) traverse(root->sibling);

}

void torso()
{
glPushMatrix();
glRotatef(-90.0, 1.0, 0.0, 0.0);
gluCylinder(t,TORSO_RADIUS, TORSO_RADIUS, TORSO_HEIGHT,10,10);
glPopMatrix();
}

void head()
{
glPushMatrix();
glTranslatef(0.0, 0.5*HEAD_HEIGHT,0.0);
glScalef(HEAD_RADIUS, HEAD_HEIGHT, HEAD_RADIUS);
gluSphere(h,1.0,10,10);
glPopMatrix();
}

void
display(void)
{

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);

gluLookAt(x,y,z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

traverse(&torso_node);

glutSwapBuffers();

}

void myInit(void)
{/* set up tree structure */
glLoadIdentity();

   glRotatef(theta[0], 0.0, 1.0, 0.0);
	glGetFloatv(GL_MODELVIEW_MATRIX,torso_node.m);
	torso_node.f = torso;
	torso_node.sibling = NULL;
	torso_node.child =  &head_node;

	glLoadIdentity();
    glTranslatef(0.0, TORSO_HEIGHT+0.5*HEAD_HEIGHT, 0.0);

// glTranslatef(x+0.0, y+TORSO_HEIGHT+0.5*HEAD_HEIGHT, z+0.0);

    glRotatef(theta[1], 1.0, 0.0, 0.0);
    glRotatef(theta[2], 0.0, 1.0, 0.0);
    glTranslatef(0.0, -0.5*HEAD_HEIGHT, 0.0);

// glTranslatef(x+0.0, y-0.5*HEAD_HEIGHT, z+0.0);
glGetFloatv(GL_MODELVIEW_MATRIX,head_node.m);
head_node.f = head;
head_node.sibling = &lua_node;
head_node.child = NULL;
}

In my book, this topic has been discussed in chapter 8.
You need to write a code to change the X, Y, and Z variables of the function gluLookAt(). Edward has used from the gluLookAt() to simulate the camera.
-Ehsan-