mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-19 00:06:16 +01:00
added documentation for CameraController
This commit is contained in:
parent
1f07affbef
commit
d0ba0d011f
@ -4,20 +4,16 @@ import com.jme3.math.Vector3f;
|
|||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Steuert die Kamerabewegung in der Szene.
|
* Controls the movement of the camera within the scene.
|
||||||
*/
|
*/
|
||||||
public class CameraController {
|
public class CameraController {
|
||||||
private final Camera camera;
|
private final Camera camera;
|
||||||
private final float height = 25; // Höhe der Kamera über dem Spielfeld // Aktueller Winkel in der Kreisbewegung
|
private final float height = 25; // Height of the camera above the game board
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor für den CameraController.
|
* Constructor for the CameraController.
|
||||||
*
|
*
|
||||||
* @param camera Die Kamera, die gesteuert werden soll
|
* @param camera The camera to be controlled
|
||||||
* @param center Der Mittelpunkt der Kreisbewegung (Fokuspunkt)
|
|
||||||
* @param radius Der Radius der Kreisbewegung
|
|
||||||
* @param height Die Höhe der Kamera über dem Fokuspunkt
|
|
||||||
* @param speed Die Geschwindigkeit der Kamerabewegung
|
|
||||||
*/
|
*/
|
||||||
public CameraController(Camera camera) {
|
public CameraController(Camera camera) {
|
||||||
this.camera = camera;
|
this.camera = camera;
|
||||||
@ -26,27 +22,45 @@ public class CameraController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aktualisiert die Kameraposition und -ausrichtung.
|
* Updates the camera's position and orientation.
|
||||||
*
|
*
|
||||||
* @param tpf Zeit pro Frame
|
* @param tpf Time per frame
|
||||||
*/
|
*/
|
||||||
public void update(float tpf) {
|
public void update(float tpf) {
|
||||||
camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the camera's position based on the field ID.
|
||||||
|
*
|
||||||
|
* @param fieldID The ID of the field to which the camera should move
|
||||||
|
*/
|
||||||
public void setPosition(int fieldID) {
|
public void setPosition(int fieldID) {
|
||||||
camera.setLocation(fieldIdToVector(fieldID));
|
camera.setLocation(fieldIdToVector(fieldID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the camera's position using specific coordinates.
|
||||||
|
*
|
||||||
|
* @param x The X-coordinate of the new camera position
|
||||||
|
* @param y The Y-coordinate of the new camera position
|
||||||
|
*/
|
||||||
public void setPosition(float x, float y) {
|
public void setPosition(float x, float y) {
|
||||||
camera.setLocation(new Vector3f(x,height,y));
|
camera.setLocation(new Vector3f(x, height, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a field ID to its corresponding position in the game world.
|
||||||
|
*
|
||||||
|
* @param fieldID The ID of the field
|
||||||
|
* @return The position of the field as a {@link Vector3f}
|
||||||
|
* @throws IllegalArgumentException If the field ID is invalid
|
||||||
|
*/
|
||||||
private Vector3f fieldIdToVector(int fieldID) {
|
private Vector3f fieldIdToVector(int fieldID) {
|
||||||
if (fieldID <= 10) return new Vector3f(30,height,0);
|
if (fieldID <= 10) return new Vector3f(30, height, 0);
|
||||||
if (fieldID <= 20) return new Vector3f(0, height, 30);
|
if (fieldID <= 20) return new Vector3f(0, height, 30);
|
||||||
if (fieldID <= 30) return new Vector3f(-30, height, 0);
|
if (fieldID <= 30) return new Vector3f(-30, height, 0);
|
||||||
if (fieldID <= 40) return new Vector3f(0, height, -30);
|
if (fieldID <= 40) return new Vector3f(0, height, -30);
|
||||||
else throw new IllegalArgumentException();
|
else throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user