com.ericsson.tic.vi
Class Camera

java.lang.Object
  extended by com.ericsson.tic.vi.Camera

public class Camera
extends Object

Keeps track of all common camera related variables.

Version:
1.0 (2008-12-04)
Author:
Sami Matilainen

Field Summary
 float camX
          Camera coordinate.
 float camY
          Camera coordinate.
 float camZ
          Camera coordinate.
 boolean dragging
          A flag used to determine wheter the mouse is dragging or not.
private  int id
          The view id for this camera.
 float lookX
          Camera look at coordinate.
 float lookY
          Camera look at coordinate.
 float lookZ
          Camera look at coordinate.
 int mouseX
          Mouse coordinate given by mouse events.
 int mouseY
          Mouse coordinate given by mouse events.
 int moveCounter
          A counter which is used to keep track of inertia.
private  ViewPanel pv
          The parent panel of this camera.
 float rotAngle
          Angle which determines how much the world/globe should be rotated relative to the camera
 float speedX
          The motion vector calculated by mouse events.
 float speedY
          The motion vector calculated by mouse events.
private  float tilt
          This is the tilt of the lookAt vector.
 float tiltAngle
          Angle which determines the tilt angle (around relative camera x axis).
 boolean tilting
          Specifies if we are currently in tilting mode.
 float upX
          The Camera "up" vector coordinate.
 float upY
          The Camera "up" vector coordinate.
 float upZ
          The Camera "up" vector coordinate.
 float zoom
          The zoom distance of the camera.
 
Constructor Summary
Camera(int id, ViewPanel parentView)
          A constructor which sets up the camera.
 
Method Summary
 void mDragged(int x, int y)
          To be called when the mouse is dragged.
 void mPressed(int x, int y)
          To be called when the mouse is pressed.
 void mReleased()
          To be called when the mouse is pressed.
 void mWheelMoved(int w)
          To be called when the mousewheel is scrolled.
 void tilt(float t)
          Updates the tilt of the tilt of the lookAt vector.
 void update()
          Updates the camera.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

private int id
The view id for this camera.


tilting

public boolean tilting
Specifies if we are currently in tilting mode.


dragging

public boolean dragging
A flag used to determine wheter the mouse is dragging or not.


camX

public float camX
Camera coordinate.


camY

public float camY
Camera coordinate.


camZ

public float camZ
Camera coordinate.


lookX

public float lookX
Camera look at coordinate.


lookY

public float lookY
Camera look at coordinate.


lookZ

public float lookZ
Camera look at coordinate.


upX

public float upX
The Camera "up" vector coordinate.


upY

public float upY
The Camera "up" vector coordinate.


upZ

public float upZ
The Camera "up" vector coordinate.


zoom

public float zoom
The zoom distance of the camera.


mouseX

public int mouseX
Mouse coordinate given by mouse events.


mouseY

public int mouseY
Mouse coordinate given by mouse events.


speedX

public float speedX
The motion vector calculated by mouse events.


speedY

public float speedY
The motion vector calculated by mouse events.


rotAngle

public float rotAngle
Angle which determines how much the world/globe should be rotated relative to the camera


tiltAngle

public float tiltAngle
Angle which determines the tilt angle (around relative camera x axis).


moveCounter

public int moveCounter
A counter which is used to keep track of inertia.


pv

private ViewPanel pv
The parent panel of this camera. pv stands for Parent View.


tilt

private float tilt
This is the tilt of the lookAt vector. This is not the same as tiltAngle which specifies tilt of the camera.

Constructor Detail

Camera

public Camera(int id,
              ViewPanel parentView)
A constructor which sets up the camera.

Parameters:
id - The view id for this camera.
parentView - The ViewPanel which this camera belongs to.
Method Detail

mPressed

public void mPressed(int x,
                     int y)
To be called when the mouse is pressed. Sets dragging mode on.

Parameters:
x - Mouse coordinate.
y - Mouse coordinate.

tilt

public void tilt(float t)
Updates the tilt of the tilt of the lookAt vector.

Parameters:
t - Specifies the magnitude and direction of the tilt.

mReleased

public void mReleased()
To be called when the mouse is pressed. Cancels dragging mode.


mWheelMoved

public void mWheelMoved(int w)
To be called when the mousewheel is scrolled. Updates the zoom.

Parameters:
w - The amount the wheel was scrolled.

mDragged

public void mDragged(int x,
                     int y)
To be called when the mouse is dragged. Updates the speed/motion vector.

Parameters:
x - Mouse coordinate.
y - Mouse coordinate.

update

public void update()
Updates the camera. Should be called with even intervalls. Tuned for 20-30ups (updates per second). Keeps track of cool stuff like the up-vector and inertia.