• Advertisement

Archived

This topic is now archived and is closed to further replies.

Transformations problem

This topic is 5128 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 problem with seperating various transformations from different objects (so that they affect only objects I want and leave the rest in piece). My OpenGL main rendering loop looks something like this: { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //some initial stuff //position the camera: glRotatef(lookupdown,1.0f,0,0); //left/right glRotatef(sceneroty,0,1.0f,0); //up/down glTranslatef(xp, yp, zp); //forward/backward //draw the level glScalef(...) //i need to scale my model glTranslatef(...) //try to move my model DrawModel1(); glScalef(...) //scaling 2nd model glTrsnslatef(...) //moving 2nd object DrawModel2(); } The problem is that transformations for the first model affect also the second model and rest of stuff. I tried to put glPushMatrix(), glPopMatrix() and glLoadIdentity() and it didn''t work also, but maybe I didn''t do it right way. If someone know solution to this I would be gratefuk. Thanks in advance, Olek

Share this post


Link to post
Share on other sites
Advertisement
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//some initial stuff
//position the camera:
glRotatef(lookupdown,1.0f,0,0); //left/right
glRotatef(sceneroty,0,1.0f,0); //up/down
glTranslatef(xp, yp, zp); //forward/backward

glPushMatrix();

//draw the level
glScalef(...) //i need to scale my model
glTranslatef(...) //try to move my model
DrawModel1();

glPopMatrix();
glPushMatrix();

glScalef(...) //scaling 2nd model
glTrsnslatef(...) //moving 2nd object
DrawModel2();

glPopMatrix();
}


i put spaces between the parts that i changed

"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

[edited by - ncsu121978 on February 6, 2004 6:59:30 AM]

Share this post


Link to post
Share on other sites

  • Advertisement