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
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).