
Untitled
By: a guest on
May 15th, 2012 | syntax:
None | size: 0.88 KB | hits: 23 | expires: Never
vec3.unproject() mouse collision problems
var fNearZ = -100.0;
var farZ = 100.0;
var fZoom = 10.0;
var iR = this.iWidth/fZoom;
var iL = (this.iWidth/fZoom)*(-1);
var iT = this.iHeight/fZoom;
var iB = (this.iHeight/fZoom)*(-1);
var pMatrix = new mat4.ortho(iL, iR, iB, iT, fNearZ, farZ);
var mvMatrix = new mat4.create();
mat4.identity(mvMatrix);
zI.debug(mat4.str(mvMatrix),{'grp':'mv_before','style':'color:#060;'});
mat4.translate(mvMatrix, [0.0, 0.0, -50.0]);
mat4.scale(mvMatrix, [3, 3, 3]);
zI.debug(vec3.unproject([
parseFloat(this.pLastMouse.x-this.iLeft),
parseFloat(this.pLastMouse.y-this.iTop),
0
],
mvMatrix,
pMatrix,
[
0,
0,
this.iWidth,
this.iHeight
]),{'grp':'dest____','style':'color:#00F;'});
this.setMatrices(pMatrix, mvMatrix);
//After this line, buffers will be set