View Full Version : glRotatef (a pivot?)
02-26-2003, 10:34 AM
is there somekind of setting up a pivot when rotating the object?
I want to rotate the cube but the object isn't rotating "around himself", but around some place on the scene.
I am using:
What is going on?
regards for your help.
02-26-2003, 11:40 AM
You are rotating about the y-axis instead of the origin of the object.
02-26-2003, 11:48 AM
Could you help me with solving the problem?
02-26-2003, 12:45 PM
This is what you kinda want to do:
// Put all your standard glClear(...) and what not functions here
// Transform the scene back a certain amount
// Push an identity matrix on the matrix stack
// Rotate the object about it's center
// Draw the object
// Pull that temporrary matrix out
This code is under the assumption that you are defining the cube's vertices so that it is centered about to the global space origin.
If it isn't, just do this inside the glPushMatrix()/glPopMatrix() pair:
// let's say the position of the cube in world/global space is (x, y, z).
// Translate the point to the center
// Now rotate the object (this will be about the origin of world space AND the cube's center
// Translate the object back
glTranslatef(x, y, z);
// then draw the object
And that should do it.
02-27-2003, 02:18 AM
Now the object dissapeared ;(
02-27-2003, 02:19 AM
Maybe i'll throw the code:
gluLookAt( XP-5, CAMUP, ZP,XP, 0.5f, ZP,XP, 1, ZP);
podloga(); //draw the floor.
glRotatef(g_RotationSpeed, 0.0f, 1.0f, 0.0f);
g_RotateX += g_RotationSpeed; // Increase the speed of rotation
02-27-2003, 02:48 AM
Ok i have made it, - modyfing the render function for 3ds files.
Big thanks for help to all of you.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.