pangwa
unread,Oct 31, 2011, 2:29:13 AM10/31/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PhiloGL
Hi,
I'm working on to converting the vertices of a model into screen
cooridinate while picking.
I use below code to convert the vertices
(camera.projection*camera.view * p), but apprently it doesn't work
correctly... I checked the verterx shader's code and it looks like
using the sampe algorithm to do the math. But I don't know why I got
the wrong result... Any idea?
onClick: function (e, model){
....
var camera = this.camera;
var mWorld = camera.view.mulMat4 (model.matrix);
var mPv1 = camera.projection.mulMat4 (mWorld);
var dist1 = PhiloGL.Vec3.distTo (camera.position,
camera.target);
var width = 2 * Math.tan ((Math.PI * camera.fov /
360)) * dist1;
var scaleDim = this.canvas.width / width;
//mPv = mPv1.scale (this.canvas.width / width,
this.canvas.height / width, 1);
faces2 = faces.map (function (v){
return v.map (function (pt){
var pt = mPv1.mulVec3 (pt);
pt[0] *= scaleDim;
pt[1] *= scaleDim;
return pt;
});
});