jme.entity.camera
Class Camera

java.lang.Object
  extended byjme.entity.Entity
      extended byjme.entity.camera.Camera
All Implemented Interfaces:
EntityInterface

public class Camera
extends Entity

Camera defines a camera in three dimensional space. The camera has three aspects. A position defines where the camera is located, the view defines what point the camera is looking at and the up defines the orientation of the camera. To set the viewport a single call to look is all that is required.

Version:
1
Author:
Mark Powell

Field Summary
protected  Sky sky
          sky the sky representation.
 
Fields inherited from class jme.entity.Entity
boundingVolume, children, geometry, VISIBILITY_CUBE, VISIBILITY_POINT, VISIBILITY_SPHERE
 
Constructor Summary
Camera(int id)
          Default constructor sets all three attributes to (0, 0, 0).
Camera(int id, Entity child)
          Constructor instantiates a new Camera object with a given entity as a child.
Camera(int id, float positionX, float positionY, float positionZ, float viewX, float viewY, float viewZ, float upX, float upY, float upZ)
          Constructor takes the nine parameters that make up the three attributes and initializes the camera's vectors to them.
Camera(int id, Vector position, Vector view, Vector up)
          Constructor takes three Vector3 parameters and sets them to the camera's attributes.
 
Method Summary
 Frustum getFrustum()
          getFrustum returns the view frustum of the camera.
 Vector getStrafe()
          getStrafe returns the strafe vector of the camera.
 Vector getUp()
          getUp returns the "up" orientation of the camera.
 Vector getView()
          getView returns the three dimensional point that the camera is looking at.
 void render()
          look uses the current position, view and up vector of the camera to determine the view.
 void set(Vector position, Vector view, Vector up)
          set sets the camera's attributes to the three Vector3 parameters and sets them to the camera's attributes.
 void setAttributes(float positionX, float positionY, float positionZ, float viewX, float viewY, float viewZ, float upX, float upY, float upZ)
          setAttributes sets the camera's attributes to the new nine parameters that make up the three attributes and initializes the camera's vectors to them.
 void setSky(Sky sky)
          setSky sets the sky representation of the terrain.
 void setStrafe(Vector strafe)
          setStrafe sets the strafe vector of the entity.
 void setUp(float x, float y, float z)
          setUp sets the orientation of the camera.
 void setUp(Vector up)
          setUp sets the orienation of the camera.
 void setView(float x, float y, float z)
          setView sets the point at which the camera is looking.
 void setView(Vector view)
          setView sets the point vector at which the camera is looking.
 java.lang.String toString()
          toString returns the string representation of this camera object in the format:

jme.entity.camera.Camera@861f24
Position: {VECTOR}
View: {VECTOR}
Up: {VECTOR}
 void update(float time)
          update updates the sky parameters if necessary.
 void updateFrustum()
          updateFrustum sets the view frustum to the newest values based on the location and orientation of the camera.
 
Methods inherited from class jme.entity.Entity
addChild, checkVisibility, distance, getBoundingVolume, getGeometry, getId, getPhysics, getPosition, hasCollision, hasMoved, isVisible, removeChild, setBoundingVolume, setGeometry, setMoved, setPhysicsModule, setPitch, setPosition, setRoll, setVisibilityType, setYaw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sky

protected Sky sky
sky the sky representation.

Constructor Detail

Camera

public Camera(int id)
Default constructor sets all three attributes to (0, 0, 0).


Camera

public Camera(int id,
              Entity child)
Constructor instantiates a new Camera object with a given entity as a child.

Parameters:
id - the id of the camera.
child - the entity child.

Camera

public Camera(int id,
              float positionX,
              float positionY,
              float positionZ,
              float viewX,
              float viewY,
              float viewZ,
              float upX,
              float upY,
              float upZ)
Constructor takes the nine parameters that make up the three attributes and initializes the camera's vectors to them.

Parameters:
positionX - the x position of the camera.
positionY - the y position of the camera.
positionZ - the z position of the camera.
viewX - the x position of the point viewed.
viewY - the y position of the point viewed.
viewZ - the z position of the point viewed.
upX - the x component of the up vector.
upY - the y component of the up vector.
upZ - the z component of the up vector.

Camera

public Camera(int id,
              Vector position,
              Vector view,
              Vector up)
Constructor takes three Vector3 parameters and sets them to the camera's attributes.

Parameters:
position - the position of the camera.
view - the point the camera is looking.
up - the orientation of the camera.
Method Detail

setAttributes

public void setAttributes(float positionX,
                          float positionY,
                          float positionZ,
                          float viewX,
                          float viewY,
                          float viewZ,
                          float upX,
                          float upY,
                          float upZ)
setAttributes sets the camera's attributes to the new nine parameters that make up the three attributes and initializes the camera's vectors to them.

Parameters:
positionX - the x position of the camera.
positionY - the y position of the camera.
positionZ - the z position of the camera.
viewX - the x position of the point viewed.
viewY - the y position of the point viewed.
viewZ - the z position of the point viewed.
upX - the x component of the up vector.
upY - the y component of the up vector.
upZ - the z component of the up vector.

updateFrustum

public void updateFrustum()
updateFrustum sets the view frustum to the newest values based on the location and orientation of the camera.


getFrustum

public Frustum getFrustum()
getFrustum returns the view frustum of the camera.

Returns:
the view frustum

set

public void set(Vector position,
                Vector view,
                Vector up)
set sets the camera's attributes to the three Vector3 parameters and sets them to the camera's attributes.

Parameters:
position - the position of the camera.
view - the point the camera is looking.
up - the orientation of the camera.

setView

public void setView(float x,
                    float y,
                    float z)
setView sets the point at which the camera is looking.

Parameters:
x - the x component of the new view.
y - the y component of the new view.
z - the z component of the new view.

setView

public void setView(Vector view)
setView sets the point vector at which the camera is looking.

Parameters:
view - the new view point.

setUp

public void setUp(float x,
                  float y,
                  float z)
setUp sets the orientation of the camera.

Parameters:
x - the new x component of the orientation vector.
y - the new y component of the orientation vector.
z - the new z component of the orientation vector.

setUp

public void setUp(Vector up)
setUp sets the orienation of the camera.

Parameters:
up - the new orientation vector of the camera.

setStrafe

public void setStrafe(Vector strafe)
setStrafe sets the strafe vector of the entity.

Parameters:
strafe - the strafe vector.

getStrafe

public Vector getStrafe()
getStrafe returns the strafe vector of the camera.

Returns:
the strafe vector of the camera.

getView

public Vector getView()
getView returns the three dimensional point that the camera is looking at.

Returns:
the view of the camera.

getUp

public Vector getUp()
getUp returns the "up" orientation of the camera.

Returns:
the up vector of the camera.

setSky

public void setSky(Sky sky)
setSky sets the sky representation of the terrain. This takes an Sky subclass. The client is reponsible for calling the sky's render method during the terrain's render call.


update

public void update(float time)
update updates the sky parameters if necessary.

Specified by:
update in interface EntityInterface
Overrides:
update in class Entity
Parameters:
time - the time between frames.

render

public void render()
look uses the current position, view and up vector of the camera to determine the view.

Specified by:
render in interface EntityInterface
Overrides:
render in class Entity

toString

public java.lang.String toString()
toString returns the string representation of this camera object in the format:

jme.entity.camera.Camera@861f24
Position: {VECTOR}
View: {VECTOR}
Up: {VECTOR}

Overrides:
toString in class Entity
Returns:
string representation of this object.