views:

132

answers:

1

I'm stitching together an image using multiple instances of the sandy.primitive.Box. Each box is 96x91 while the viewport is 960x273 which should make for an exact fit if I layout the boxes in a perfect grid of 10x3. However, I can't seem to get the exact camera fieldOfView. I've tried a couple formulas (one for adjusting the "focal length" and one for adjusting the fov, directly). Both of these formulas produce a fov angle that is too narrow.

// focal length
(stage.stageHeight/2) / Math.tan(cam.fov / 2 * Math.PI / 180)

// field of view
2 * Math.atan2( (stage.stageHeight/2), -cam.z ) * (180 / Math.PI)

Another question about the same project: I need to adjust the perspective of each cube so that the image appears to be in 2D space (flat)... Any ideas on the best method for calculating such a "correction"?

A: 

I realized shortly after posing this question that I wasn't taking into account the cubes' depth (actually, half of the depth) when determining the distance.

// field of view
2 * Math.atan2( (stage.stageHeight/2), -(cam.z + (cubeDepth/2)) ) * (180 / Math.PI)
Andrew Mullins