[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] Re: Get Viewport for converting coordinates

> First question: Which value is represented in view[0],view[1],.. if my
> viewport is 700x500px of size ?
Ok, forget this question. Of course it is an array that first
represents the origin and then the width and height.

But it that case, the maths I posted is correct?

Then it is even more strange that it is not working properly..

> mvPushMatrix();
> ...                                           //stuff like rotate and translate
>  //Viewport and Pixel
>   var v1=(2*(xCoord-0)/700)-1;    //xCoord= pixelcoordinate
>   var v2=(2*(yCoord-0)/530)-1;    //yCoord= pixelcoordinate
>   var v3=2*(-1)-1
>  //4D-Vector
>   var v = Vector.create([v1,v2,v3,1]);
>   //Projection and mvMatrix
>   var pM=pMatrix;
>   var mvM=mvMatrix;
>   var temp= pM.multiply(mvM);
>   var temp_inv=temp.inverse().multiply(v);
> ...
> The alerted value is the one that i used for the last translation.
> Then when changing the position pixel, all that changes is the value
> after the comma in the alerted result.

The values are changed a lot (numbers in front of comma) only if I
interact with the models like rotating or translating them. When
klicking somewhere on the canvas after such a transformation the
values still won't change correctly.

I am confused :)

You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: