PDA

View Full Version : Transformations



Balu
11-01-2003, 01:44 AM
How to rotate the object itself? And when i scale the object the position of the object also moved; I want to place the object at same positio.

mikael_aronsson
11-01-2003, 03:53 AM
glRotate... is used to rotate.

An object is scaled around the origin so if you for example center a cube around the origin and then scale it, it will not move.

It is important to do scaling/rotation/translation in correct order.

Mikael


[This message has been edited by mikael_aronsson (edited 11-03-2003).]

Balu
11-02-2003, 06:24 PM
Can you give the code, Please.

cwc36
11-02-2003, 10:28 PM
Hi,

Try some simple opengl examples here... http://myopendemo.hypermart.net

Balu
11-03-2003, 02:15 AM
Here i have placed my code. I tried to rotate the object around itself. But it won't work. Please modify the code.

glLoadIdentity();
glRotatef(gfAngle, 0.0f, 0.0f, 10.0f);

glBegin(GL_LINE_LOOP);
glVertex3f(10.0f, 10.0f, 0.0f);
glVertex3f(60.0f, 10.0f, 0.0f);
glVertex3f(60.0f, 60.0f, 0.0f);
glVertex3f(10.0f, 60.0f, 0.0f);
glVertex3f(10.0f, 10.0f, 0.0f);
glEnd();

glLoadIdentity();

glFinish();




[This message has been edited by Balu (edited 11-03-2003).]

Deiussum
11-03-2003, 04:52 AM
Ok, if my calculations are right, the center of that line loop is about 35,35.

So... do this:

glTranslatef(35, 35, 0); // translate back to position
glRotatef(gfAngle, 0.0f, 0.0f, 1.0f);
glTranslatef(-35, -35, 0); // translate to origin

Balu
11-03-2003, 08:31 PM
Thank you, it is very helpful for me.