开发者

Calculate the rendered size of a 3D object in a view

I'm working on a project that the user navigates around by clicking on icons in 3d space. When a user engages one of these icons, the camera should pan and zoom so that the selected icon appears in the center of the screen at its original height and size (this is so when the 2d overlay is created over the icon, that it is the same size as its 3d counterpart.

My question is how to calculate the size a rendered object in a 3d 开发者_JAVA百科view, I should mention that this is using the Alternativa 3D platform.

So there's a camera at (x1, y1, z1) with a FOV of f, pointing at an icon at (x2, y2, z2), all being rendered in a view of dimensions w and h. This is doing my head in trying to figure it out, any help would be much appreciated.


I figured out the answer hunting around on another forum, what I was really looking for was how to get a 3d object to render in a view at a 1:1 size ratio.

I had come across the formula for calculating the focal length of a 3d camera:

F = d / tan(fov/2)

where d is one half the square root of your views height^2 + width^2

the value of F is the distance from the camera your object should be to render at a 1:1 size.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜