net.jinx.video
Class Camera

java.lang.Object
  extended by net.jinx.video.View3D
      extended by net.jinx.video.Camera
All Implemented Interfaces:
View

public class Camera
extends View3D

Camera represents a point of view within the Renderer. Cameras consist of the following: position, point of focus, direction of up, and name.
Position is the camera's position in three-dimensional space.
Point of focus is the point in three-dimensional space that the camera is looking at.
Direction of up refers to which way is up for the camera.
Name referes to the name of the camera. This can be used for whatever you like. In previous projects, I used this for the window title; there were multiple cameras each with their own window, all within a JDesktopPane.

API Stability: Stable.


Constructor Summary
Camera()
          Builds a camera at origin, looking along positive z axis, up is y axis.
Camera(double[] pos)
          Builds a camera at given position, looking at origin, up is y axis.
Camera(double[] pos, double[] lookAt)
          Builds a camera at given position, looking at lookAt, up is y axis.
Camera(double[] pos, double[] lookAt, double[] up)
          Builds a camera at given position, looking at lookAt, up specified by up.
Camera(float[] pos, float[] lookAt, float[] up)
           
 
Method Summary
 double[] getLookAt()
          Returns the point that the camera is focused on.
 java.lang.String getName()
          Returns the name of the camera.
 double[] getPosition()
          Returns the position of the camera.
 double[] getUp()
          Returns the vector that tells the camera which way is up.
 void optimize(double radius, double fov)
          Puts this camera at an optimal distance from the lookat coordinates to view an object with the given radius.
 void optimize(Model model, double fov)
          Puts this Camera at an optimal distance from a Model (assuming it's at the origin), using the current position as a direction vector.
 void setLookAt(double[] lookingAt)
          Sets the point of focus.
 void setName(java.lang.String name)
          Sets the name of the camera.
 void setPosition(double[] position)
          Sets the position of the camera.
 void setUp(double[] up)
          Sets the vector that tells the camera which way is up.
 void view(Context options, java.awt.Rectangle viewport)
          Prepares the view.
 
Methods inherited from class net.jinx.video.View3D
deinit, getVisible, init, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Camera

public Camera()
Builds a camera at origin, looking along positive z axis, up is y axis.


Camera

public Camera(double[] pos)
Builds a camera at given position, looking at origin, up is y axis.

Parameters:
pos - the position of the camera.

Camera

public Camera(double[] pos,
              double[] lookAt)
Builds a camera at given position, looking at lookAt, up is y axis.

Parameters:
pos - the position of the camera.
lookAt - the point to look at.

Camera

public Camera(double[] pos,
              double[] lookAt,
              double[] up)
Builds a camera at given position, looking at lookAt, up specified by up.

Parameters:
pos - the position of the camera.
lookAt - the point to look at.
up - specifies which way is up.

Camera

public Camera(float[] pos,
              float[] lookAt,
              float[] up)
Method Detail

view

public void view(Context options,
                 java.awt.Rectangle viewport)
Description copied from interface: View
Prepares the view. Camera related OpenGL commands should be employed here.

Specified by:
view in interface View
Overrides:
view in class View3D
Parameters:
options - the Context object providing data on how rendering should proceed.
viewport - the rectangle within the window that this View will be rendered into. NOTE: The origin in OpenGL is the lower left hand corner, not the upper left hand corner.

getPosition

public double[] getPosition()
Returns the position of the camera.

Returns:
the position vector.

setPosition

public void setPosition(double[] position)
Sets the position of the camera.

Parameters:
position - the position vector.

getLookAt

public double[] getLookAt()
Returns the point that the camera is focused on.

Returns:
the vector for the point.

setLookAt

public void setLookAt(double[] lookingAt)
Sets the point of focus.

Parameters:
lookingAt - the point to have the camera look at.

getUp

public double[] getUp()
Returns the vector that tells the camera which way is up.

Returns:
the vector describing which way is up.

setUp

public void setUp(double[] up)
Sets the vector that tells the camera which way is up.

Parameters:
up - the vector describing which way is up.

getName

public java.lang.String getName()
Returns the name of the camera. The default name is "Camera".

Returns:
the name.

setName

public void setName(java.lang.String name)
Sets the name of the camera.

Parameters:
name - the name.

optimize

public void optimize(Model model,
                     double fov)
Puts this Camera at an optimal distance from a Model (assuming it's at the origin), using the current position as a direction vector. The Model is assumed to be at the lookat coordinates.

Parameters:
model - the Model to optimize for.

optimize

public void optimize(double radius,
                     double fov)
Puts this camera at an optimal distance from the lookat coordinates to view an object with the given radius.

Parameters:
radius - the radius of the object to optimize for.