Open GoogleCodeExporter opened 9 years ago
[deleted comment]
I answer myself
I got it!!!
this is the code
public void updateScene()
{
if (_dx != 0)
{
/**
* When trackball moves horizontally...
*
* Rotate camera around center of the box in a circle.
* Its position is 9.0f above the box, but its target() position
* remains at the scene origin, so the camera always looks towards the center.
*/
_rot += _dx * 40f;
steering=_rot;
scene.camera().position.y=2;
scene.camera().position.x = cube.position().x + (float)Math.sin(cube.rotation().y)*cameraDistance;
scene.camera().position.z = cube.position().z - (float)Math.cos(cube.rotation().y)*cameraDistance;
_dx = 0;
}
if (_dy != 0)
{
// When trackball moves vertically, change camera's frustum "shortSideLength" property
// This effectively changes field of view. (??)
float len = scene.camera().frustum.shortSideLength() + _dy;
if (len < 0.1f) len = 0.1f;
if (len > 50f) len = 5f;
scene.camera().frustum.shortSideLength(1f);
speed=_dy;
cube.position().x += speed*Math.sin(cube.rotation().y);
cube.position().z -= speed*Math.cos(cube.rotation().y);
scene.camera().position.x = cube.position().x + (float)Math.sin(cube.rotation().y)*cameraDistance;
scene.camera().position.z = cube.position().z - (float)Math.cos(cube.rotation().y)*cameraDistance;
_dy = 0;
}
}
Original comment by ggpe...@gmail.com
on 25 Sep 2011 at 1:13
Original issue reported on code.google.com by
ggpe...@gmail.com
on 23 Sep 2011 at 7:16