|
rotating primitives? |
sensmaster
Member #14,767
December 2012
|
What is the best way to rotate a primitive? Please help me |
William Labbett
Member #4,486
March 2004
|
Take a look at this :- https://www.allegro.cc/manual/5/al_draw_rotated_bitmap Is it what you need ? You could make a bitmap of the rectangle first and then rotate it.
|
SiegeLord
Member #7,827
October 2006
|
/* Setup the transformation */ ALLEGRO_TRANSFORM trans; al_identity_transform(&trans); al_translate_transform(&trans, -ref_x, -ref_y); al_rotate_transform(&trans, angle_in_radians); al_translate_transform(&trans, ref_x, ref_y); al_use_transform(&trans); /* Draw whatevs here */ /* Turn off the rotation */ al_identity_transform(&trans); al_use_transform(&trans);
"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
sensmaster
Member #14,767
December 2012
|
First of all, I am not asking for the bitmap to rotate, any ideas? |
SiegeLord
Member #7,827
October 2006
|
Quote: any ideas? Did I post in invisible ink or something? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Arthur Kalliokoski
Second in Command
February 2005
|
SiegeLord said: Did I post in invisible ink or something? It's all geek to him... They all watch too much MSNBC... they get ideas. |
sensmaster
Member #14,767
December 2012
|
I have seen your code, but doesn't that rotate the whole screen? For instance, I have a circle and a rectangle. |
Arthur Kalliokoski
Second in Command
February 2005
|
It rotates whatever's drawn next until the al_identity_transform() and al_use_transform() resets it to normal. They all watch too much MSNBC... they get ideas. |
sensmaster
Member #14,767
December 2012
|
oh thanks... Thanks so much. I got it working now. I have one more question. al_translate_transform(&trans, - ref_x, - ref_y); I do not understand those 3 steps... |
Arthur Kalliokoski
Second in Command
February 2005
|
SiegeLord said: al_translate_transform(&trans, - ref_x, - ref_y); al_translate_transform() moves it across/updown to set position on the screen. The reason the minus signs are stuck in there is because you don't move the camera, you move the world (think about that a minute). al_rotate_transform() twists it around to rotate it. al_translate_transform() moves it once again on screen to re-adjust position because al_rotate_transform() moved it from the rotation point. They all watch too much MSNBC... they get ideas. |
Thomas Fjellstrom
Member #476
June 2000
|
The main reason for the two transforms is it makes it so your origin is the center of the object you're trying to rotate. If you didn't transform like that, you'd end up rotating around a different center, and not actually just rotating your object. -- |
|