Hi,

In the gluReference it is stated that gluUnProject applies the Inverse
Matrix of (P*M) to the vector and before applies this:

    vec.x = (inWinCoord.x-viewport[0])*2/viewport[2] - 1.0;
    vec.y = (inWinCoord.y-viewport[1])*2/viewport[3] - 1.0;
    vec.z = 2*inWinCoord.z - 1.0);
    vec.w = 1;

But this seems to give incorrect results and also doesnt give the same
results as the ones of gluUnProject. The function below seems to work, (so
one only has to multply the z coord with -1)


void Vector3D::ProjectToWorldSpace (Vector3D &inWinCoord, Matrix
&finalMatrix, const GLint *viewport)
{
    Vector3D vec;
    vec.x = (inWinCoord.x-viewport[0])*2/viewport[2] - 1.0;
    vec.y = (inWinCoord.y-viewport[1])*2/viewport[3] - 1.0;
    vec.z = -2*inWinCoord.z + 1.0);

    *this = finalMatrix.MatrixMultVecWithW1 (vec);
// MatrixMultVecWithW1 treats the vector which is x,y,z like a vector with
x,y,z, w=1
}

In Mesa 3.2 it seems to use the method proposed by the blue book and so will
propably give wrong results. Though I havent tested this, I just looked at
the code and saw that it uses the bluebooks method.

bye joe


_______________________________________________
Mesa-bug maillist  -  [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-bug


_______________________________________________
Mesa-dev maillist  -  [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev

Reply via email to