# stuck with 360 camera loop

• 08-10-2013, 08:14 AM
uwi2k2
stuck with 360 camera loop
hi all,

sorry , but i just got stuck with a free 360 camera movement.
right now i can move left / right at full 360 .. but the up and down holds at -90 / + 90 degree.
here is what i do right now:

Code :

``` this.Control.yrotrad = (this.Control.yrot / 180.0 * 3.141592654 ); this.Control.xrotrad = (this.Control.xrot / 180.0 * 3.141592654 );   // up vector this.up[0] = 0.0; this.up[1] = 1.0; this.up[2] = 0.0;   // eye this.eye[0] = this.Control.xpos; this.eye[1] = this.Control.ypos; this.eye[2] = this.Control.zpos ;   // center point this.center[0] = this.Control.xpos+(Math.sin(this.Control.yrotrad)*1.0); this.center[1] = (this.Control.ypos-(Math.sin(this.Control.xrotrad)*1.0)); this.center[2] = this.Control.zpos-(Math.cos(this.Control.yrotrad)*1.0) ;   this.myWGL.CameraView = M4x4.makeLookAt ( this.eye, this.center, this.up );```

i guess its all about the up vector .. but i just canīt figure out what to do ...
can someone complete the code ? or am i going the wrong way ?

thanx
uwi
• 08-10-2013, 07:09 PM
GClements
Quote:

Originally Posted by uwi2k2
i guess its all about the up vector .. but i just canīt figure out what to do ...
can someone complete the code ? or am i going the wrong way ?

If you want direct control over the view direction, using a "look-at" function is probably the wrong way to go about it. It's simpler to concatenate a translation, a rotation about the vertical axis and a rotation about the left-right axis. Also, the look-at approach has undefined behaviour if you're looking directly up or down.

A pitch angle of more than +/- 90 degrees will make the view upside down, which is impossible to achieve with a fixed up vector (it will combine a 180-degree rotation about the vertical axis with a pitch wrapped to the -90..+90 range).

But if you're committed to the look-at approach, you can just invert the up vector when the pitch is outside of that range.