transforms correct

Note!!!
The problem is that I have to rotate with respect of each object’s middle point (local
coordinate system) ,and it changes.I should also be able to translate with respect of the currect location(local coord.) of each object.

Hi,

i am not sure if i understand you right? if your problem is : how to rotate a object (which does not have it’s center in the “middle point”) around it’s own center, i can tell you how to handle this problem, if your problem is something else, please tell a little more about it.

greetings

thorsten

The problem goes like that:

Rotation - Pressing and dragging the right mouse button, all objects in the scene will rotate around their center . This means that if initially the object was not centered at (0, 0), you will have to calculate its center (by averaging the x and y coordinates) and make the appropriate transformation before rotating the object.

All directions are in the local object coordinate system. This means that initially, before any rotations are applied, moving the mouse to the right will make the objects move to the right as well. Once the objects are rotated, their coordinate system is rotated as well. This means that making a translation in the X coordinate, for example, will not cause the object to move to the right. Instead it will move in the direction of its own X direction.

For one object in the scene it is easy:
each time I call display() I do

glTranslatef(midpoint_x,midpoint_y,0.0);
glRotatef(…)
glTranslate(…)
glTranslatef(-midpoint_x,-midpoint_y,0.0);
draw_object();

But the problem is that I have many objects
in my scene and thay have different mid_points.