de.rico.engine.camera
Class CameraPerspective

java.lang.Object
  extended by de.rico.engine.camera.CameraPerspective

public class CameraPerspective
extends java.lang.Object

This class encapsulates a camera's position and alignment.

Author:
Frank Bruns

Constructor Summary
CameraPerspective(float x, float y, float z, float rotX, float rotY, float near, float far)
          Creates a new camera perspective with the specified parameters.
CameraPerspective(Point3D position, float rotX, float rotY, float near, float far)
          Creates a new camera perspective with the specified parameters.
 
Method Summary
 CameraPerspective clone()
           
 AbstractMesh getAttachedMesh()
          Returns the mesh this camera perspective is attached to, if there is one, else it returns null.
 float getDistanceToMesh()
          Returns the distance of the camera perspective to the mesh
 float getFarPlane()
          Returns the far plane of camera perspective
 float getFieldOfView()
          Returns the field of view (viewing angle) of the camera (as used in gluPerspective()-method)
 float getNearPlane()
          Returns the near plane of the camera perspective
 float getOffsetY()
          Returns the height over the meshes center point of this camera perspective.
 Point3D getPosition()
          Returns a copied point with the position of the camera
 float getRotX()
          Returns the camera's rotation around the x axis
 float getRotY()
          Returns the rotation around the y axis
 void setAttachedMesh(AbstractMesh mesh, float dist, float offsetY)
          Sets the mesh to which this camera perspective is attached.
 void setDistanceToMesh(float dist)
          Sets the distance that the camera perspective ought to keep up to the attached mesh
 void setFarPlane(float far)
          Sets the far plane of the camera perspective to the specified value
 void setFieldOfView(float angle)
          Sets the field of view (viewing angle) of the camera to the specified value.
 void setNearPlane(float near)
          Sets the near plane of the camera perspective to the specified value
 void setOffestY(float offsetY)
          Sets the height over the center of the mesh (y-offset) for this camera perspective.
 void setPosition(float x, float y, float z)
          Sets the camera's position
 void setPosition(Point3D pos)
          Sets the camera's position.
 void setRotX(float rotX)
          Sets the rotation around the x axis
 void setRotY(float rotY)
          Sets the rotation around the y axis
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CameraPerspective

public CameraPerspective(Point3D position,
                         float rotX,
                         float rotY,
                         float near,
                         float far)
Creates a new camera perspective with the specified parameters.

Parameters:
position - position of the camera
rotX - rotation around the x axis of the camera
rotY - rotation around the y axis of the camera
near - near clipping plane distance
far - far clipping plane distance

CameraPerspective

public CameraPerspective(float x,
                         float y,
                         float z,
                         float rotX,
                         float rotY,
                         float near,
                         float far)
Creates a new camera perspective with the specified parameters.

Parameters:
x - x coordinate of the camera
y - y coordinate of the camera
z - z coordinate of the camera
rotX - rotation around the x axis of the camera
rotY - rotation around the y axis of the camera
near - near clipping plane distance
far - far clipping plane distance
Method Detail

setAttachedMesh

public void setAttachedMesh(AbstractMesh mesh,
                            float dist,
                            float offsetY)
Sets the mesh to which this camera perspective is attached.

Parameters:
mesh - mesh to attach this camera perspective to
dist - the distance to mesh that ought to be kept up
offsetY - y-axis offset, i.e. height over center point of the mesh

getAttachedMesh

public AbstractMesh getAttachedMesh()
Returns the mesh this camera perspective is attached to, if there is one, else it returns null.

Returns:
mesh that this camera perspective is attached to, else null.

setDistanceToMesh

public void setDistanceToMesh(float dist)
Sets the distance that the camera perspective ought to keep up to the attached mesh

Parameters:
dist - distance to the mesh

getDistanceToMesh

public float getDistanceToMesh()
Returns the distance of the camera perspective to the mesh

Returns:
kept up distance to the attached mesh

setOffestY

public void setOffestY(float offsetY)
Sets the height over the center of the mesh (y-offset) for this camera perspective.

Parameters:
offsetY - height over the mesh

getOffsetY

public float getOffsetY()
Returns the height over the meshes center point of this camera perspective.

Returns:
height over meshes center point

getPosition

public Point3D getPosition()
Returns a copied point with the position of the camera

Returns:
camera's position

setPosition

public void setPosition(float x,
                        float y,
                        float z)
Sets the camera's position

Parameters:
x - x coordinate
y - y coordinate
z - z coordinate

setPosition

public void setPosition(Point3D pos)
Sets the camera's position.
Note: It is possible that you have to invert the point that you are specifying as the position.

Parameters:
pos - position of the camera

getRotX

public float getRotX()
Returns the camera's rotation around the x axis

Returns:
rotation around the x axis

setRotX

public void setRotX(float rotX)
Sets the rotation around the x axis

Parameters:
rotX - rotation around the x axis

getRotY

public float getRotY()
Returns the rotation around the y axis

Returns:
rotation around y axis

setRotY

public void setRotY(float rotY)
Sets the rotation around the y axis

Parameters:
rotY - rotation around y axis

getFarPlane

public float getFarPlane()
Returns the far plane of camera perspective

Returns:
far plane of the camera perspective

setFarPlane

public void setFarPlane(float far)
Sets the far plane of the camera perspective to the specified value

Parameters:
far - far plane of the camera perspective

getNearPlane

public float getNearPlane()
Returns the near plane of the camera perspective

Returns:
near plane of the camera perspective

setNearPlane

public void setNearPlane(float near)
Sets the near plane of the camera perspective to the specified value

Parameters:
near - near plane of the camera perspective

getFieldOfView

public float getFieldOfView()
Returns the field of view (viewing angle) of the camera (as used in gluPerspective()-method)

Returns:
field of view (viewing angle) of the camera

setFieldOfView

public void setFieldOfView(float angle)
Sets the field of view (viewing angle) of the camera to the specified value. Usually 45f is a good value, which also is defined in the Camera.NORMAL_FOV constant. Smaller values will zoom in the sceen and bigger values will zoom out.

Parameters:
angle - field of view (viewing angle) for the camera

clone

public CameraPerspective clone()
Overrides:
clone in class java.lang.Object