My first object is originally at the origin. But once i pan it, its no longer at the origin. yet when I rotate the model, it rotates around the origin of the first object.
i’ll give it one more try and see if i’m doing something wrong…
O.k here is the process it goes through.
I am makinng the framewok for a piping application. All the components (pipes, bend etc) have global coordinates. When I am loading a model, it loads each and every component(pipe, bend, valve etc.) into a inked list. In the main draw loop
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFER_BIT)
gluLookAt(0+origin.x, 0.origin.y,20, origin.x, origin.y,0,0,1,0);
// rotate the eye
// here we traverse the linked list and get the pointer to each object and call its draw function
// Draw is a derived virtual function which calls corresponding draw of cylinder, bend etc.
//heres the code for clinder…
void DrawCylinder(const RGFW3f *startPoint, float angleXY, float angleXZ, float length, float baseRadius, float topRadius)
// move to the starting position of the pipe
glTranslatef(startPoint->x, startPoint->y, startPoint->z);
// draw the pipe
gluCylinder(cylinder, baseRadius, topRadius, length, 18, 1);
//so what effectively am I doing is…
gluLookAt(…// for panning
glRotate(…// for rotation
DrawObject1();// which calls the corresponding draw of cylinder or bend…
glPopMatrix();// actually these push and pos are in the drawobject function but i’m showing here for understanding
and so on until the end of the list.
sorry if i’m hgetting you confused.
from the above its obvious that since my model will be panned first through gluLookAt, thus shifting the local coordinate system, the whole system will start to rotate around the new position of the local coordinate system.
If on the other hand I switch the gluLookat and rotate calls in the the beginnig, then it rotates around the center of the screen but then once I rotate the model by 90 degrees along y axis and pan the model, now the x axis is facing outside the screen so instead of panning left right, its panning in and out of the screen…
i’m again sorry if i’m confusing you. This is probably my longest post ever on these forums and my worst problem ever with opengl.
or should I say my logic…
thanx for your time.