amcgala/amcgala — Issue #11: SimplePerspectiveCamera - Wie ist's genau gemeint?
Author: stetro
Created: 2012-01-29 20:43:15+00:00
State: open

Wie genau soll die SimplePerspectiveCamera funktionieren? Wenn man ein Objekt auf die Kamera, oder die Kamera auf ein Objekt über die Position zubewegt und sich die Positionen überschneiden müssten dreht sich das Objekt und verschwindet wieder in den Hintergrund. Liegt das daran dass die Matrix das Clipping noch nicht macht oder wie ist das gedacht?

```java
import java.awt.event.KeyEvent;
import com.google.common.eventbus.Subscribe;
import amcgala.Framework;
import amcgala.framework.camera.SimplePerspectiveCamera;
import amcgala.framework.event.InputHandler;
import amcgala.framework.math.Vector3d;
import amcgala.framework.shape.Box3d;

public class FPWindow extends Framework implements InputHandler {

private Vector3d direction = Vector3d.UNIT_X;
private Vector3d up = Vector3d.UNIT_Y;
private Vector3d position = new Vector3d(0, 0, 0);
private final int DESTINATION = 1900;

public FPWindow(int width, int height) {
super(width, height);
setCamera(new SimplePerspectiveCamera(up, position, direction,
DESTINATION));
registerInputEventHandler(this);
}

@Override
public void initGraph() {
add(new Box3d(new Vector3d(0, 0, -20), 30, 40, 50));
}

@Subscribe
public void moveCamera(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED
&& e.getKeyCode() == KeyEvent.VK_W) {
position.z++;
setCamera(new SimplePerspectiveCamera(up, position, direction,
DESTINATION));
}
if (e.getID() == KeyEvent.KEY_PRESSED
&& e.getKeyCode() == KeyEvent.VK_S) {
position.z--;
setCamera(new SimplePerspectiveCamera(up, position, direction,
DESTINATION));
}
if (e.getID() == KeyEvent.KEY_PRESSED
&& e.getKeyCode() == KeyEvent.VK_A) {
position.x--;
setCamera(new SimplePerspectiveCamera(up, position, direction,
DESTINATION));
}
if (e.getID() == KeyEvent.KEY_PRESSED
&& e.getKeyCode() == KeyEvent.VK_D) {
position.x++;
setCamera(new SimplePerspectiveCamera(up, position, direction,
DESTINATION));
}
}

public static void main(String[] args) {
FPWindow fp = new FPWindow(500, 300);
fp.start();
}
}

```