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

[Public WebGL] Get Viewport for converting coordinates

Hi, I'm trying to convert pixelcoordinates to objectcoordinates by
using the inverse of projection*modeview. Actually it's similar to
gluUnproject, that uses some viewport values like view[0].

First question: Which value is represented in view[0],view[1],.. if my
viewport is 700x500px of size ?

Second question: I tried to get the viewport via
getParameter(gl.VIEWPORT) so I can pass it to the manually built
unproject-method, but as result it's returning "undefined". Why?

Third question: By now I've been playing around with converting the
pixel coordinates but without success:


 //Viewport and Pixel
  var v1=(2*(xCoord-0)/700)-1;
  var v2=(2*(yCoord-0)/530)-1;
  var v3=2*(-1)-1

  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.

I don't know why. Maybe you know what's wrong?

..would appreciate your help !

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: