10
« on: February 28, 2011, 02:47:17 am »
I'm also using the dummy approach but I have a strange behaviour.
when I rotate the pivot dummy all works until I get closer to the top (90º) of the rotation, if I use camera.lookAt(), the camera should be upside down if you pass the top of the rotation, but it always stays upright, that causes a very nasty feel.
I also thought about using camera.setOrientation(dir,up) but I cant get it right.
The goal is to achieve a camara that moves around the object at a constant 3d radius with the camera Oriented to the centre of the object with "the exact same feel as the helloWorld AE" but rotating and moving the camera instead of rotating the 3dobject with a fixed camera
Here Is what I tried so far:
private void resetCameraPosition() {
camera.setPosition(cameraSatellite.getTransformedCenter());
camera.lookAt(cameraPivot.getTransformedCenter());
}
private void initCamera() {
//move the dummy pivot to the centre of the 3dobject
cameraPivot = Object3D.createDummyObj();
cameraPivot.translate(calcTrans(cameraPivot, 3dobject));
//move the dummy satellite to the centre of the 3dobject and separated it by a radius (-20)
cameraSatellite = Object3D.createDummyObj();
cameraSatellite.translate(calcTrans(cameraSatellite, 3dobject));
cameraSatellite.translate(new SimpleVector(0, 0, -20));
//Made child
cameraPivot.addChild(cameraSatellite);
camera = world.getCamera();
resetCameraPosition();
}
To turn the cameraPivot dummy I'm using the same code as in the AE helloWorld
if (touchTurn != 0) {
cameraPivot.rotateY(touchTurn);
resetCameraPosition();
// camera.rotateCameraY(touchTurn);
touchTurn = 0;
}
if (touchTurnUp != 0) {
cameraPivot.rotateX(touchTurnUp);
resetCameraPosition();
// camera.rotateCameraX(touchTurnUp);
touchTurnUp = 0;
}
I also tried several approaches for the resetCameraPosition() method, including getBack with invert, setOrientation etc etc. And none of them behaved as I would expect : (
Any idea of how to get this one right? Maby someone could do an example of the helloWorld using camera rotation instead of primitive cube rotation. It would be very handy.