0

I want to follow a object in negative Y-axis. Here is my look-at function:

gluLookAt(0,Y,0,    0,0,0,  0,0,1);

I am increasing the value by pressing pageUp key which is also increasing the translating value of my object in negative Y-axis. Y's initial value was 100. Until Y=0 it works fine to follow the object but when it become negative the camera is now looking towards the positive Y-axis. But I want to follow or look at in the negative axis.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • The line of sight is determined from eye pos. (the first triple) to center pos. (the second triple). If `Y` becomes negative this is, of course, looking towards positive Y-axis. To prevent this, you could e.g. set center to eye - (0, 1, 0). Try `0, Y - 1, 0` for the 2nd triple of [`gluLookAt()`](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml). – Scheff's Cat Jun 18 '18 at 15:17
  • Is `Y` the y-coordinate of the object? Do you use orthographic projection?. Try `gluLookAt(0,Y,0, 0,Y-1.0,0, 0,0,1);` But note, the position of the camera and the object are the same in this case. – Rabbid76 Jun 18 '18 at 15:27
  • Thank's @Rabbid76. Problem solved. – MD. Noor Uddin Jun 19 '18 at 03:25

0 Answers0