In JavaFX, I want to add a camera that orbits around an object like a satellite. I want the orbit to move along a horizontal and vertical line around the object. I also want the camera to always be pointed at the object in the center of the matrix.
At the moment i try to move the camera along the x and y axis by using the unit circle. The code looks like this at the moment:
<code>
int r = 10;
Slider nxSlider = new Slider(0, 360, 0);
nxSlider.valueProperty().addListener((observable, oldvalue, newvalue) ->
{
double i = newvalue.doubleValue();
camera.setTranslateX(r * Math.cos(Math.toRadians(i)));
camera.setTranslateY(r * Math.sin(Math.toRadians(i)));
rotateX.setAngle(Math.toDegrees(Math.cos(Math.toRadians(i))));
});
rotateZ.setAngle(0);
rotateY.setAngle(0);
rotateX.setAngle(0);
camera.setTranslateX(r);
camera.setTranslateZ(0);
camera.setTranslateY(0);
</code>
Where as rotateX, rotateY and rotateZ are Transform Rotates.
I think im pretty lost and I've had this problem for a long time. My code is probably a wrong and I would be extremly grateful if anyone could propose an idea of how I can continue.