Home > Software engineering >  OpenGL gluLookAt the up direction
OpenGL gluLookAt the up direction

Time:09-18

Opengl gluLookAt function need nine parameters, of which the first three eye position is set to point E, middle three for target location is set to point A, so reverse view vector for A - E; The last three parameters for the up vector, namely the head in the direction; As far as I am understand head up and gaze direction vertical direction, so the vector (A - E) up and vector inner product should be 0, but his conclusion on https://blog.csdn.net/yangzhiloveyou/article/details/20299759 is vertical (A -) of the up and up, and http://www.it1352.com/501532.html said the up direction and the line of sight direction does not need to be vertical, don't understand is what set itself up vertical direction and the line of sight direction do you want, if they have set perpendicular to the OpenGL program is automatically to the parameter changes,

CodePudding user response:

The document, should be don't need to be vertical, didn't mention the vertical,

CodePudding user response:

Vertical is not opengl code will automatically adjust the UP vector value, the line of sight and the UP vector theory must be vertical

CodePudding user response:

reference 1/f, Iberia response:
should be vertical, do not need to document didn't mention the vertical,

In theory should be vertical, can't imagine how the UP direction, and the line of sight direction is not perpendicular imaging, whether OpenGL correlation function in the code to make relevant adjustment, such as the line of sight direction invariable, the value of the adjustment of the UP vector makes UP vertical vector and the line of sight

CodePudding user response:

Void SetCamera ()
{
Double x, y, z, The Phi;
Phi=(double) globMouse. MoveX/(double) globMouse M_PI ScreenX * * 2.0;
The=(double) globMouse. MoveY/(double) globMouse M_PI ScreenY * * 2.0;
X=globMouse. Radius * cos (Phi) * cos (The);
Y=globMouse. Radius * sin (The);
Z=globMouse. Radius * sin (Phi) * cos (The);
Int Oben=(The & lt;=0.5 * M_PI | | The & gt; 1.5 * M_PI) * 2-1;
GluLookAt (x, y, z, 0, 0, 0, Oben, 0).//==0
//equivalent to our head position at (0.0, 0.0, 5.0),
//eyes looked at (0.0, 0.0, 0.0), namely the origin,
//at the back of the three parameters (0.0, 1.0, 0.0), y is 1, the rest is 0, said head up, is a normal situation,
//if not call gluLookAt (), then the camera is set to the default position and direction,
//by default, the camera is located at the origin, pointing in the direction of the negative to the z axis, the up vector is (0, 0),
}


GluLookAt (0.0, 0.0, 5.0, eye is at (0,0,5)/* */
0.0, 0.0, 0.0, the center is at (0, 0)/* */
0.0, 1.0, 0.);/* up is postivie in Y direction */

CodePudding user response:

reference 4 floor schlafenhamster response:
void SetCamera ()
{
Double x, y, z, The Phi;
Phi=(double) globMouse. MoveX/(double) globMouse M_PI ScreenX * * 2.0;
The=(double) globMouse. MoveY/(double) globMouse M_PI ScreenY * * 2.0;
X=globMouse. Radius * cos (Phi) * cos (The);
Y=globMouse. Radius * sin (The);
Z=globMouse. Radius * sin (Phi) * cos (The);
Int Oben=(The & lt;=0.5 * M_PI | | The & gt; 1.5 * M_PI) * 2-1;
GluLookAt (x, y, z, 0, 0, 0, Oben, 0).//==0
//equivalent to our head position at (0.0, 0.0, 5.0),
//eyes looked at (0.0, 0.0, 0.0), namely the origin,
//at the back of the three parameters (0.0, 1.0, 0.0), y is 1, the rest is 0, said head up, is a normal situation,
//if not call gluLookAt (), then the camera is set to the default position and direction,
//by default, the camera is located at the origin, pointing in the direction of the negative to the z axis, the up vector is (0, 0),
}


GluLookAt (0.0, 0.0, 5.0, eye is at (0,0,5)/* */
0.0, 0.0, 0.0, the center is at (0, 0)/* */
0.0, 1.0, 0.);/* up is postivie in Y direction */

I knew the meaning of the nine parameters, I would like to ask is whether the up vector must be vertical and the line of sight direction, even if the setting of parameters is not vertical, gluLookAt function is to adjust the up vector inside, make up and vertical view

CodePudding user response:

https://blog.csdn.net/yangzhiloveyou/article/details/20299759
Said should be right
  • Related