Hi,
I have some problems getting the scale factor formula to work…
I’m using the lens perspective with fieldOfView = 20.
I need to adjust the camera z position in order to display all my object3d on the screen. This object’s height may vary.
Each time i modify my object, i adjust the camera position.
The distance formula works pretty well :
public function setCameraConfig(w : Number, h : Number, ypos : Number) : void {
var sw : Number = w / _view.width;
var sh : Number = h / _view.height;
// detection du mode
var mode : String = (sw > sh) ? "paysage" : "portrait";
var z : Number = (((mode == "portrait") ? h : _view.height * sw) / 2) / Math.tan((PerspectiveLens(_view.camera.lens).fieldOfView / (180 / Math.PI)) / 2);
return z;
}
I need to display a plane on front of this object, and this plane need to have the exact height of my view, and a width in pixels.
When i use this formula which seems to be correct:
public function scaleByFOV(FOV : Number, distance : Number, viewHeight : Number) : Number {
var fl : Number = viewHeight / (2 * Math.tan(FOV * (180 / Math.PI)));
// scale = fLength / (fLength distanceFromViewer);
return -1 / (fl / (fl distance));
}
the scale isn’t true. my plane is not at the right dimensions, and this dimensions vary when i move the camera .
I’ve searched a lot on this forum, but all the solutions returns the same result.
I’m using the last Away3d 4.0 gold one.
Have you some advice for me ?