Well i am new to Away3D and I am trying to do a simple model viewer in AIR using Away3D 4 to familiarize myself with the plataform. The basic idea is to load a 3D model from a file and display it on the GUI and give the posibility to turn around the model with a camera like the turntable camera of Blender. So far I manage to load the model with UVs but i am running in a little trouble with the camera. Using the rotationX and rotationY and setting the pivotPoint of the camara at the center of the Scene i am turning arround the camera when the user drags the mouse arround. But when I try to zoom out everything goes crazy because the pivot point its not a the center anymore, but when i try to set the pivotpoint to the center of the Scene again i get weird results.
I am using the translate method of the camera to move it away from the object. It works like a charm until i move the pivot point.
the relevant part of the code its:
private function onMouseWheel(e:MouseEvent):void
{
// Translation of the camara
_View.camera.translate(_View.camera.scenePosition, e.delta * 40);
// Change the pivot point to the center of the scene
//var pivot:Vector3D = new Vector3D(0, 0, 0);
//pivot = pivot.subtract(_View.camera.scenePosition);
//_View.camera.pivotPoint = pivot;
}
private function onEnterFrame($event:Event):void
{
if (_MouseLeftDown)
{
// Camera Rotation
var dx:Number = _View.mouseX - _MouseX;
var dy:Number = _View.mouseY - _MouseY;
_View.camera.rotationY += dx / _View.height * 180;
_View.camera.rotationX += dy / _View.width * 180;
_MouseX = _View.mouseX;
_MouseY = _View.mouseY;
}
_View.render();
}
And my question are:
Am I doing something wrong?
Is the pivot point used during the execution of the translate method?
Is there a way to make the pivot point stay in the center of the stage or change the coordinates it uses from local to global?
Thanks and sorry for my english but I am not used to write in english. =P