Joe Ante wrote:
> 
> 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.

The gluUnproject and gluProject functions in Mesa's GLU library
haven't changed in a long time.  I'm pretty confident that they're
correct.  Lot's of people use them.

I don't have a copy of the blue book to verify your information.

-Brian


_______________________________________________
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