-
M.D.
getting the ground position in 3D
using the basic 3D scaling formula:
var scaleRatio = focalLength/(focalLength+z);
how can i get the ground position of and object in 3D space and then convert that to Stage coordinates. simply grabbing the y coordinate in 3D space wont work because if the z depth is say 2000 the y coordinate wil still be the same if the z depth is 10.
Basically, i'm trying to make shadows, i need to know the height from the ground the current object is based on its z depth.
Not sure what i need to do to calculate this though.
Any help?
-
Set z=0 than you get:
scaleRatio = focalAngle / focalLength
Rearrange:
x3d = focalLength / focalAngle * x2d
y3d = focalLength / focalAngle * y2d
untested...
-
I think I missed the target
But you can simply take the Y-coordinate. If Y=0 is the ground, than the Y-coordinates of any object is its height.
-
M.D.
thanks andre, but i found the solution by simply converting the the negative y position of the 3D camera to 3D space then adding the camera's (stage or 2D coordinates)
var scaleRatio = focalLength/(focalLength+z);
//calculate ground
var ground = -(camera.y*scaleRatio)+camera.stageY
thanks anyway though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|