com.jme3.renderer
クラス Camera

java.lang.Object
  上位を拡張 com.jme3.renderer.Camera
すべての実装されたインタフェース:
Savable, java.lang.Cloneable

public class Camera
extends java.lang.Object
implements Savable, java.lang.Cloneable

Camera is a standalone, purely mathematical class for doing camera-related computations.

Given input data such as location, orientation (direction, left, up), and viewport settings, it can compute data neccessary to render objects with the graphics library. Two matrices are generated, the view matrix transforms objects from world space into eye space, while the projection matrix transforms objects from eye space into clip space.

Another purpose of the camera class is to do frustum culling operations, defined by six planes which define a 3D frustum shape, it is possible to test if an object bounded by a mathematically defined volume is inside the camera frustum, and thus to avoid rendering objects that are outside the frustum


入れ子のクラスの概要
static class Camera.FrustumIntersect
          The FrustumIntersect enum is returned as a result of a culling check operation, see contains(com.jme3.bounding.BoundingVolume)
 
コンストラクタの概要
Camera()
          Serialization only.
Camera(int width, int height)
          Constructor instantiates a new Camera object.
 
メソッドの概要
 void clearViewportChanged()
          Clears the viewport changed flag once it has been updated inside the renderer.
 Camera clone()
           
 Camera.FrustumIntersect contains(BoundingVolume bound)
          contains tests a bounding volume against the planes of the camera's frustum.
 boolean containsGui(BoundingVolume bound)
          containsGui tests a bounding volume against the ortho bounding box of the camera.
 float distanceToNearPlane(Vector3f pos)
          Returns the pseudo distance from the given position to the near plane of the camera.
 Vector3f getDirection()
          getDirection retrieves the direction vector the camera is facing.
 Vector3f getDirection(Vector3f store)
          getDirection retrieves the direction vector the camera is facing.
 float getFrustumBottom()
          getFrustumBottom returns the value of the bottom frustum plane.
 float getFrustumFar()
          getFrustumFar gets the value of the far frustum plane.
 float getFrustumLeft()
          getFrustumLeft gets the value of the left frustum plane.
 float getFrustumNear()
          getFrustumNear gets the value of the near frustum plane.
 float getFrustumRight()
          getFrustumRight gets the value of the right frustum plane.
 float getFrustumTop()
          getFrustumTop gets the value of the top frustum plane.
 int getHeight()
           
 Vector3f getLeft()
          getLeft retrieves the left axis of the camera.
 Vector3f getLeft(Vector3f store)
          getLeft retrieves the left axis of the camera.
 Vector3f getLocation()
          getLocation retrieves the location vector of the camera.
 java.lang.String getName()
          This method returns the cameras name.
 int getPlaneState()
          getPlaneState returns the state of the frustum planes.
 Matrix4f getProjectionMatrix()
           
 Quaternion getRotation()
          getRotation retrieves the rotation quaternion of the camera.
 Vector3f getScreenCoordinates(Vector3f worldPos)
          Converts the given position from world space to screen space.
 Vector3f getScreenCoordinates(Vector3f worldPosition, Vector3f store)
          Converts the given position from world space to screen space.
 Vector3f getUp()
          getUp retrieves the up axis of the camera.
 Vector3f getUp(Vector3f store)
          getUp retrieves the up axis of the camera.
 Matrix4f getViewMatrix()
           
 float getViewPortBottom()
          getViewPortBottom gets the bottom boundary of the viewport
 float getViewPortLeft()
          getViewPortLeft gets the left boundary of the viewport
 float getViewPortRight()
          getViewPortRight gets the right boundary of the viewport
 float getViewPortTop()
          getViewPortTop gets the top boundary of the viewport
 Matrix4f getViewProjectionMatrix()
           
 int getWidth()
           
 Vector3f getWorldCoordinates(Vector2f screenPos, float zPos)
           
 Vector3f getWorldCoordinates(Vector2f screenPosition, float zPos, Vector3f store)
           
 boolean isParallelProjection()
           
 boolean isViewportChanged()
           
 void lookAt(Vector3f pos, Vector3f worldUpVector)
          lookAt is a convienence method for auto-setting the frame based on a world position the user desires the camera to look at.
 void lookAtDirection(Vector3f direction, Vector3f up)
          lookAtDirection sets the direction the camera is facing given a direction and an up vector.
 void normalize()
          normalize normalizes the camera vectors.
 void onFrameChange()
          onFrameChange updates the view frame of the camera.
 void onFrustumChange()
          onFrustumChange updates the frustum to reflect any changes made to the planes.
 void onViewPortChange()
          Called when the viewport has been changed.
 void read(JmeImporter e)
           
 void resize(int width, int height, boolean fixAspect)
          Resizes this camera's view with the given width and height.
 void setAxes(Quaternion axes)
          setAxes uses a rotational matrix to set the axes of the camera.
 void setAxes(Vector3f left, Vector3f up, Vector3f direction)
          setAxes sets the axes (left, up and direction) for this camera.
 void setClipPlane(Plane clipPlane)
          Sets a clipPlane for this camera.
 void setClipPlane(Plane clipPlane, Plane.Side side)
          Sets a clipPlane for this camera.
 void setFrame(Vector3f location, Quaternion axes)
          setFrame sets the orientation and location of the camera.
 void setFrame(Vector3f location, Vector3f left, Vector3f up, Vector3f direction)
          setFrame sets the orientation and location of the camera.
 void setFrustum(float near, float far, float left, float right, float top, float bottom)
          setFrustum sets the frustum of this camera object.
 void setFrustumBottom(float frustumBottom)
          setFrustumBottom sets the value of the bottom frustum plane.
 void setFrustumFar(float frustumFar)
          setFrustumFar sets the value of the far frustum plane.
 void setFrustumLeft(float frustumLeft)
          setFrustumLeft sets the value of the left frustum plane.
 void setFrustumNear(float frustumNear)
          setFrustumNear sets the value of the near frustum plane.
 void setFrustumPerspective(float fovY, float aspect, float near, float far)
          setFrustumPerspective defines the frustum for the camera.
 void setFrustumRight(float frustumRight)
          setFrustumRight sets the value of the right frustum plane.
 void setFrustumTop(float frustumTop)
          setFrustumTop sets the value of the top frustum plane.
 void setLocation(Vector3f location)
          setLocation sets the position of the camera.
 void setName(java.lang.String name)
          This method sets the cameras name.
 void setParallelProjection(boolean value)
          Enable/disable parallel projection.
 void setPlaneState(int planeState)
          setPlaneState sets the state to keep track of tested planes for culling.
 void setProjectionMatrix(Matrix4f projMatrix)
          Overrides the projection matrix used by the camera.
 void setRotation(Quaternion rotation)
          setRotation sets the orientation of this camera.
 void setViewPort(float left, float right, float bottom, float top)
          setViewPort sets the boundaries of the viewport
 void setViewPortBottom(float bottom)
          setViewPortBottom sets the bottom boundary of the viewport
 void setViewPortLeft(float left)
          setViewPortLeft sets the left boundary of the viewport
 void setViewPortRight(float right)
          setViewPortRight sets the right boundary of the viewport
 void setViewPortTop(float top)
          setViewPortTop sets the top boundary of the viewport
 java.lang.String toString()
           
 void update()
          update updates the camera parameters by calling onFrustumChange,onViewPortChange and onFrameChange.
 void updateViewProjection()
          Updates the view projection matrix.
 void write(JmeExporter e)
           
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

Camera

public Camera()
Serialization only. Do not use.


Camera

public Camera(int width,
              int height)
Constructor instantiates a new Camera object. All values of the camera are set to default.

メソッドの詳細

clone

public Camera clone()
オーバーライド:
クラス java.lang.Object 内の clone

setName

public void setName(java.lang.String name)
This method sets the cameras name.

パラメータ:
name - the cameras name

getName

public java.lang.String getName()
This method returns the cameras name.

戻り値:
the cameras name

setClipPlane

public void setClipPlane(Plane clipPlane,
                         Plane.Side side)
Sets a clipPlane for this camera. The cliPlane is used to recompute the projectionMatrix using the plane as the near plane This technique is known as the oblique near-plane clipping method introduced by Eric Lengyel more info here http://www.terathon.com/code/oblique.html http://aras-p.info/texts/obliqueortho.html http://hacksoflife.blogspot.com/2008/12/every-now-and-then-i-come-across.html Note that this will work properly only if it's called on each update, and be aware that it won't work properly with the sky bucket. if you want to handle the sky bucket, look at how it's done in SimpleWaterProcessor.java

パラメータ:
clipPlane - the plane
side - the side the camera stands from the plane

setClipPlane

public void setClipPlane(Plane clipPlane)
Sets a clipPlane for this camera. The cliPlane is used to recompute the projectionMatrix using the plane as the near plane This technique is known as the oblique near-plane clipping method introduced by Eric Lengyel more info here http://www.terathon.com/code/oblique.html http://aras-p.info/texts/obliqueortho.html http://hacksoflife.blogspot.com/2008/12/every-now-and-then-i-come-across.html Note that this will work properly only if it's called on each update, and be aware that it won't work properly with the sky bucket. if you want to handle the sky bucket, look at how it's done in SimpleWaterProcessor.java

パラメータ:
clipPlane - the plane

resize

public void resize(int width,
                   int height,
                   boolean fixAspect)
Resizes this camera's view with the given width and height. This is similar to constructing a new camera, but reusing the same Object. This method is called by an associated RenderManager to notify the camera of changes in the display dimensions.

パラメータ:
width - the view width
height - the view height
fixAspect - If true, the camera's aspect ratio will be recomputed. Recomputing the aspect ratio requires changing the frustum values.

getFrustumBottom

public float getFrustumBottom()
getFrustumBottom returns the value of the bottom frustum plane.

戻り値:
the value of the bottom frustum plane.

setFrustumBottom

public void setFrustumBottom(float frustumBottom)
setFrustumBottom sets the value of the bottom frustum plane.

パラメータ:
frustumBottom - the value of the bottom frustum plane.

getFrustumFar

public float getFrustumFar()
getFrustumFar gets the value of the far frustum plane.

戻り値:
the value of the far frustum plane.

setFrustumFar

public void setFrustumFar(float frustumFar)
setFrustumFar sets the value of the far frustum plane.

パラメータ:
frustumFar - the value of the far frustum plane.

getFrustumLeft

public float getFrustumLeft()
getFrustumLeft gets the value of the left frustum plane.

戻り値:
the value of the left frustum plane.

setFrustumLeft

public void setFrustumLeft(float frustumLeft)
setFrustumLeft sets the value of the left frustum plane.

パラメータ:
frustumLeft - the value of the left frustum plane.

getFrustumNear

public float getFrustumNear()
getFrustumNear gets the value of the near frustum plane.

戻り値:
the value of the near frustum plane.

setFrustumNear

public void setFrustumNear(float frustumNear)
setFrustumNear sets the value of the near frustum plane.

パラメータ:
frustumNear - the value of the near frustum plane.

getFrustumRight

public float getFrustumRight()
getFrustumRight gets the value of the right frustum plane.

戻り値:
frustumRight the value of the right frustum plane.

setFrustumRight

public void setFrustumRight(float frustumRight)
setFrustumRight sets the value of the right frustum plane.

パラメータ:
frustumRight - the value of the right frustum plane.

getFrustumTop

public float getFrustumTop()
getFrustumTop gets the value of the top frustum plane.

戻り値:
the value of the top frustum plane.

setFrustumTop

public void setFrustumTop(float frustumTop)
setFrustumTop sets the value of the top frustum plane.

パラメータ:
frustumTop - the value of the top frustum plane.

getLocation

public Vector3f getLocation()
getLocation retrieves the location vector of the camera.

戻り値:
the position of the camera.
関連項目:
getLocation()

getRotation

public Quaternion getRotation()
getRotation retrieves the rotation quaternion of the camera.

戻り値:
the rotation of the camera.

getDirection

public Vector3f getDirection()
getDirection retrieves the direction vector the camera is facing.

戻り値:
the direction the camera is facing.
関連項目:
getDirection()

getLeft

public Vector3f getLeft()
getLeft retrieves the left axis of the camera.

戻り値:
the left axis of the camera.
関連項目:
getLeft()

getUp

public Vector3f getUp()
getUp retrieves the up axis of the camera.

戻り値:
the up axis of the camera.
関連項目:
getUp()

getDirection

public Vector3f getDirection(Vector3f store)
getDirection retrieves the direction vector the camera is facing.

戻り値:
the direction the camera is facing.
関連項目:
getDirection()

getLeft

public Vector3f getLeft(Vector3f store)
getLeft retrieves the left axis of the camera.

戻り値:
the left axis of the camera.
関連項目:
getLeft()

getUp

public Vector3f getUp(Vector3f store)
getUp retrieves the up axis of the camera.

戻り値:
the up axis of the camera.
関連項目:
getUp()

setLocation

public void setLocation(Vector3f location)
setLocation sets the position of the camera.

パラメータ:
location - the position of the camera.

setRotation

public void setRotation(Quaternion rotation)
setRotation sets the orientation of this camera. This will be equivelant to setting each of the axes:
cam.setLeft(rotation.getRotationColumn(0));
cam.setUp(rotation.getRotationColumn(1));
cam.setDirection(rotation.getRotationColumn(2));

パラメータ:
rotation - the rotation of this camera

lookAtDirection

public void lookAtDirection(Vector3f direction,
                            Vector3f up)
lookAtDirection sets the direction the camera is facing given a direction and an up vector.

パラメータ:
direction - the direction this camera is facing.

setAxes

public void setAxes(Vector3f left,
                    Vector3f up,
                    Vector3f direction)
setAxes sets the axes (left, up and direction) for this camera.

パラメータ:
left - the left axis of the camera.
up - the up axis of the camera.
direction - the direction the camera is facing.
関連項目:
setAxes(com.jme3.math.Quaternion)

setAxes

public void setAxes(Quaternion axes)
setAxes uses a rotational matrix to set the axes of the camera.

パラメータ:
axes - the matrix that defines the orientation of the camera.

normalize

public void normalize()
normalize normalizes the camera vectors.


setFrustum

public void setFrustum(float near,
                       float far,
                       float left,
                       float right,
                       float top,
                       float bottom)
setFrustum sets the frustum of this camera object.

パラメータ:
near - the near plane.
far - the far plane.
left - the left plane.
right - the right plane.
top - the top plane.
bottom - the bottom plane.
関連項目:
setFrustum(float, float, float, float, float, float)

setFrustumPerspective

public void setFrustumPerspective(float fovY,
                                  float aspect,
                                  float near,
                                  float far)
setFrustumPerspective defines the frustum for the camera. This frustum is defined by a viewing angle, aspect ratio, and near/far planes

パラメータ:
fovY - Frame of view angle along the Y in degrees.
aspect - Width:Height ratio
near - Near view plane distance
far - Far view plane distance

setFrame

public void setFrame(Vector3f location,
                     Vector3f left,
                     Vector3f up,
                     Vector3f direction)
setFrame sets the orientation and location of the camera.

パラメータ:
location - the point position of the camera.
left - the left axis of the camera.
up - the up axis of the camera.
direction - the facing of the camera.
関連項目:
setFrame(com.jme3.math.Vector3f, com.jme3.math.Vector3f, com.jme3.math.Vector3f, com.jme3.math.Vector3f)

lookAt

public void lookAt(Vector3f pos,
                   Vector3f worldUpVector)
lookAt is a convienence method for auto-setting the frame based on a world position the user desires the camera to look at. It repoints the camera towards the given position using the difference between the position and the current camera location as a direction vector and the worldUpVector to compute up and left camera vectors.

パラメータ:
pos - where to look at in terms of world coordinates
worldUpVector - a normalized vector indicating the up direction of the world. (typically {0, 1, 0} in jME.)

setFrame

public void setFrame(Vector3f location,
                     Quaternion axes)
setFrame sets the orientation and location of the camera.

パラメータ:
location - the point position of the camera.
axes - the orientation of the camera.

update

public void update()
update updates the camera parameters by calling onFrustumChange,onViewPortChange and onFrameChange.

関連項目:
update()

getPlaneState

public int getPlaneState()
getPlaneState returns the state of the frustum planes. So checks can be made as to which frustum plane has been examined for culling thus far.

戻り値:
the current plane state int.

setPlaneState

public void setPlaneState(int planeState)
setPlaneState sets the state to keep track of tested planes for culling.

パラメータ:
planeState - the updated state.

getViewPortLeft

public float getViewPortLeft()
getViewPortLeft gets the left boundary of the viewport

戻り値:
the left boundary of the viewport

setViewPortLeft

public void setViewPortLeft(float left)
setViewPortLeft sets the left boundary of the viewport

パラメータ:
left - the left boundary of the viewport

getViewPortRight

public float getViewPortRight()
getViewPortRight gets the right boundary of the viewport

戻り値:
the right boundary of the viewport

setViewPortRight

public void setViewPortRight(float right)
setViewPortRight sets the right boundary of the viewport

パラメータ:
right - the right boundary of the viewport

getViewPortTop

public float getViewPortTop()
getViewPortTop gets the top boundary of the viewport

戻り値:
the top boundary of the viewport

setViewPortTop

public void setViewPortTop(float top)
setViewPortTop sets the top boundary of the viewport

パラメータ:
top - the top boundary of the viewport

getViewPortBottom

public float getViewPortBottom()
getViewPortBottom gets the bottom boundary of the viewport

戻り値:
the bottom boundary of the viewport

setViewPortBottom

public void setViewPortBottom(float bottom)
setViewPortBottom sets the bottom boundary of the viewport

パラメータ:
bottom - the bottom boundary of the viewport

setViewPort

public void setViewPort(float left,
                        float right,
                        float bottom,
                        float top)
setViewPort sets the boundaries of the viewport

パラメータ:
left - the left boundary of the viewport (default: 0)
right - the right boundary of the viewport (default: 1)
bottom - the bottom boundary of the viewport (default: 0)
top - the top boundary of the viewport (default: 1)

distanceToNearPlane

public float distanceToNearPlane(Vector3f pos)
Returns the pseudo distance from the given position to the near plane of the camera. This is used for render queue sorting.

パラメータ:
pos - The position to compute a distance to.
戻り値:
Distance from the far plane to the point.

contains

public Camera.FrustumIntersect contains(BoundingVolume bound)
contains tests a bounding volume against the planes of the camera's frustum. The frustums planes are set such that the normals all face in towards the viewable scene. Therefore, if the bounding volume is on the negative side of the plane is can be culled out. NOTE: This method is used internally for culling, for public usage, the plane state of the bounding volume must be saved and restored, e.g: BoundingVolume bv;
Camera c;
int planeState = bv.getPlaneState();
bv.setPlaneState(0);
c.contains(bv);
bv.setPlaneState(plateState);

パラメータ:
bound - the bound to check for culling
戻り値:
See enums in FrustumIntersect

containsGui

public boolean containsGui(BoundingVolume bound)
containsGui tests a bounding volume against the ortho bounding box of the camera. A bounding box spanning from 0, 0 to Width, Height. Constrained by the viewport settings on the camera.

パラメータ:
bound - the bound to check for culling
戻り値:
True if the camera contains the gui element bounding volume.

getViewMatrix

public Matrix4f getViewMatrix()
戻り値:
the view matrix of the camera. The view matrix transforms world space into eye space. This matrix is usually defined by the position and orientation of the camera.

setProjectionMatrix

public void setProjectionMatrix(Matrix4f projMatrix)
Overrides the projection matrix used by the camera. Will use the matrix for computing the view projection matrix as well. Use null argument to return to normal functionality.

パラメータ:
projMatrix -

getProjectionMatrix

public Matrix4f getProjectionMatrix()
戻り値:
the projection matrix of the camera. The view projection matrix transforms eye space into clip space. This matrix is usually defined by the viewport and perspective settings of the camera.

updateViewProjection

public void updateViewProjection()
Updates the view projection matrix.


getViewProjectionMatrix

public Matrix4f getViewProjectionMatrix()
戻り値:
The result of multiplying the projection matrix by the view matrix. This matrix is required for rendering an object. It is precomputed so as to not compute it every time an object is rendered.

isViewportChanged

public boolean isViewportChanged()
戻り値:
True if the viewport (width, height, left, right, bottom, up) has been changed. This is needed in the renderer so that the proper viewport can be set-up.

clearViewportChanged

public void clearViewportChanged()
Clears the viewport changed flag once it has been updated inside the renderer.


onViewPortChange

public void onViewPortChange()
Called when the viewport has been changed.


onFrustumChange

public void onFrustumChange()
onFrustumChange updates the frustum to reflect any changes made to the planes. The new frustum values are kept in a temporary location for use when calculating the new frame. The projection matrix is updated to reflect the current values of the frustum.


onFrameChange

public void onFrameChange()
onFrameChange updates the view frame of the camera.


isParallelProjection

public boolean isParallelProjection()
戻り値:
true if parallel projection is enable, false if in normal perspective mode
関連項目:
setParallelProjection(boolean)

setParallelProjection

public void setParallelProjection(boolean value)
Enable/disable parallel projection.

パラメータ:
value - true to set up this camera for parallel projection is enable, false to enter normal perspective mode

getWorldCoordinates

public Vector3f getWorldCoordinates(Vector2f screenPos,
                                    float zPos)
関連項目:
getWorldCoordinates(com.jme3.math.Vector2f, float)

getWorldCoordinates

public Vector3f getWorldCoordinates(Vector2f screenPosition,
                                    float zPos,
                                    Vector3f store)
関連項目:
getWorldCoordinates(com.jme3.math.Vector2f, float)

getScreenCoordinates

public Vector3f getScreenCoordinates(Vector3f worldPos)
Converts the given position from world space to screen space.

関連項目:
getScreenCoordinates(com.jme3.math.Vector3f)

getScreenCoordinates

public Vector3f getScreenCoordinates(Vector3f worldPosition,
                                     Vector3f store)
Converts the given position from world space to screen space.

関連項目:
getScreenCoordinates(Vector3f, Vector3f)

getWidth

public int getWidth()
戻り値:
the width/resolution of the display.

getHeight

public int getHeight()
戻り値:
the height/resolution of the display.

toString

public java.lang.String toString()
オーバーライド:
クラス java.lang.Object 内の toString

write

public void write(JmeExporter e)
           throws java.io.IOException
定義:
インタフェース Savable 内の write
例外:
java.io.IOException

read

public void read(JmeImporter e)
          throws java.io.IOException
定義:
インタフェース Savable 内の read
例外:
java.io.IOException