View Full Version : a simple question on glTranslate
godhand
05-10-2004, 02:00 AM
Hi, I have drawn a cube resting on a 3 dimensional rectangle and I want to use glTranslate to move the whole object(cube+rectangle) via keyboard presses, how do I make it so that the cube doesn't move and only the whole object moves? thanks.
mikael_aronsson
05-10-2004, 03:03 AM
Hi !
You use glPushMatrix and glPopMatrix to do hierarchical transformations.
glPushMatrix();
transform entire object here
glPushMatrix();
transform before cube
render cube
glPopMatrix();
glPushMatrix();
transform before rectangle
render rectangle
glPopMatrix();
glPopMatrix();
This way you save do local transformations to modify a single triangle or whatever and also transform the entire shape if you want to.
Mikael
godhand
05-11-2004, 01:10 AM
Hi, they moved uniformly for awhile but doesn't not always stay together when moving. For example, the cube would just be couple of points behind the rectange after a long movement down the plain.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.