the best way to animate

I guys i’m new around were and i’m doing a project similiar like this game here http://miniclip.sapo.pt/games/bloxorz/pt/ the game is almost done but now i need do animate the moves, i’m rotating the block by it’s center, the block it’s made with

glScalef(BLOCO_W,BLOCO_H,BLOCO_W);
glEnable(GL_DEPTH_TEST);
glutSolidCube(1.0f);

and i need to make the block go from this position

to this one

with some soft moviment, can someone help, i need to make this until tuesday

On every frame, you vary a glRotatef param. That’s it.

Do not double-post, as we visit all sub-forums. This thread doesn’t belong to the Advanced section.

that’s why i put them is two sections, because i didn’t now where it belong, sorry and thanks

but it have to rotate from it’s base not from is middle, just with glrotate it won’t give the desired efect

then do a glTranslate around it :slight_smile:

Addendum:
To change the center of rotation of an object, first translate it so that (0,0,0) is the center, then do the rotation, and finally make the inverse translation of that first one. Something like


glTranslatef(0,-1,0); // un-translates
glRotatef(angle,1,0,0);
glTranslatef(0,1,0); // translates to position center

yes thanks a lot, i made the first move well, but now i wanto to rotate again, from the last positon and not from the start position? The problem is that after make the first move, when you want to make the second move, the object will rotate, centered in the start/initial position? how to change that??

It will not be as easy as few glRotate/glTranslate calls.

After you rotate a block, two axes are swapped. You should delete it and create a new one in it’s place.

What I mean is, if you have 2x1x1 block and rotate it - you’ll get a “rotated 2x1x1 block” - remove it and place “unrotated 1x2x1 block” in it’s place.
You do that after each move (not after each frame).