View3D project() giving strange results

Software: Away3D 4.x

jhocking, Newbie
Posted: 17 November 2011 07:22 PM   Total Posts: 12

I’m currently having some problems due to odd results from View3D.project()  It looks like when the camera moves far away from an object then project() doesn’t work correctly on that object.

For example, I have an object sitting at 0,0,0 and here are the results as I move further and further away from it mostly straight down the Z axis:

camera 0.1680 46 63.0177
projected 278.439 50449.907

camera 0.1829 46 63.8687
projected 56.214 148284.089

camera 0.1916 46 64.6895
projected 774.7247 -173250.922

camera 0.1948 46 65.5422
projected 503.5555 -53556.7500

camera 0.1924 46 66.3523
projected 453.6297 -32432.771

Is this a bug or is it likely I’m doing something wrong here? When the camera is close to the object the projected coordinates work great, but I’m also needing to get coordinates for distant objects.

   

jhocking, Newbie
Posted: 28 November 2011 05:41 PM   Total Posts: 12   [ # 1 ]

Well a fix/workaround for the problem is to change these lines in LensBase:project()

p.x = v.x/v.w;
p.y = -v.y/v.w;

to

p.x = v.x/Math.abs(v.w);
p.y = -v.y/Math.abs(v.w);

Now I’m not sure if that screws up the math or anything, but someone who is a core developer of Away3D might want to check that out.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X