PDA

View Full Version : Tetrahedron



Mukund
05-25-2010, 06:27 AM
Hello everyone.
Im not able to understand how the following is happening:


void Tetrahedron()
{
glClear(GL_COLOR_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(scale, scale, scale);

Draw_Tetrahedron();
glFlush();

}

void Draw_Tetrahedron()
{
glPushMatrix();
glTranslatef(Tx, 0, 0);
glutWireTetrahedron();
glPopMatrix();


glPushMatrix();
glTranslatef(3.3 * Tx, 0, 0);
glutWireTetrahedron();
glPopMatrix();

}

Now when i continuosly increase "scale" and redraw the tetrahedron,should'nt they overlap? Because im changing the scale factor, so how is that the same translation factor sufficing?

The tetrahedrons are not overlapping.They maintain the same distance between them in whatever way i change the size(i mean scale them).How is this happening?

Should i not give a larger translating factor when the objects are scaled to a larger extent?

Can anyone please explain?

Thanks in advance.

ZbuffeR
05-25-2010, 06:34 AM
"Should i not give a larger translating factor when the objects are scaled to a larger extent?"

this would be true if you did no scale on Tetrahedron and this in Draw_Tetrahedron :

void Draw_Tetrahedron()
{
glPushMatrix();
glTranslatef(Tx, 0, 0);
glScalef(scale, scale, scale);
glutWireTetrahedron();
glPopMatrix();


glPushMatrix();
glTranslatef(3.3 * Tx, 0, 0);
glScalef(scale, scale, scale);
glutWireTetrahedron();
glPopMatrix();

}

Mukund
05-26-2010, 01:19 AM
Thanks for the reply Zbuffer.
i got it.

One more thing.Is there any way we can get the Current Transformation Matrix?
ie since its a 4x4 matrix, can we retrive that matrix in any way?

Yomboprime
05-26-2010, 03:14 PM
Use glGetDoublev with parameter GL_MODELVIEW_MATRIX