How can I get view direction from the OpenGL ModelView Matrix?

前端 未结 2 1286
时光说笑
时光说笑 2020-12-19 19:43

I am writing a volume render program that constantly adjusts some plane geometry so it always faces the camera. The plane geometry rotates whenever the camera rotates in ord

2条回答
  •  有刺的猬
    2020-12-19 20:21

    You'll want to look at this picture @ http://db-in.com/images/local_vectors.jpg http://db-in.com/images/local_vectors.jpg

    The Direction-of-Flight ( DOF) is the 3rd row.

    GLfloat matrix[16]; 
    glGetFloatv( GL_MODELVIEW_MATRIX, matrix );
    
    float DOF[3];
    DOF[0] = matrix[  2 ]; // x
    DOF[1] = matrix[  6 ]; // y
    DOF[2] = matrix[ 10 ]; // z
    

    Reference:

    • http://blog.db-in.com/cameras-on-opengl-es-2-x/

提交回复
热议问题