How to solve DIsplay problems using gluLookat() ??

hi all

I displayed a 3D object in a MFC window using gluLookAt().
gluLookAt(0,0,4,0,0,0,0,1,0);
I have increment/decrement the z value of eyez for zoom in/out.I have the following problems…

1.The object partially vanishes after 5 or 6 levels of zoom in and zoom out.
2. When zoom in the object looses it’s centre point and shift to left/right of the screen.
3.When ia m rotating,the rotation is not depend on the centre point.

Can anybody please help me to sort out these troubles.

Thanks for any input,
Jerry

Jerry,

  1. This depends on the factors you use for zooming in and out. It is also possible that the object gets clipped by either the near (zoom in) or far (zoom out) clipping plane. What projection parameters are you using (gluPerspective…)?

  2. This depends on where you draw your 3D object (centered at <0, 0, 0>, which is where your looking at or elsewhere)

  3. Again, rotation takes place around coordinate <0, 0, 0>, not around the centre of your window (unless of course <0, 0, 0> happens to be in the centre of your window

I suggest you try to read up on the model-view transformations of OpenGL and the projection matrix to get a better understanding of the way OpenGL performs these operations. Please refer to the FAQ or other resources like the Red Book.

HTH

Jean-Marc

Hi,

First, sorry for late reply…

1.gluPerspective(50, (GLdouble)cx/(GLdouble)cy, 0.001f, 1000.0f);

2.I want to position the object in centre always.But when i am rotating the object is not rotate cenre based.If any change is required in the gluUlookAt() centre point argument x,y and z when rotating ?
Help me if u can…

Thanks,
Jerry