org.deegree.rendering.r3d
Class ViewFrustum

java.lang.Object
  extended by org.deegree.rendering.r3d.ViewFrustum

public class ViewFrustum
extends Object

Models a frustum volume, commonly used for view frustums (space volume visible to a viewer of a 3D scene).

Offers convenient methods for view-frustum culling (intersects(double[][]), intersects(float[][])), viewer-relative movements (moveForward(double), moveRight(double), moveUp(double)) as well as rotations (rotateX(double), rotateY(double), rotateZ(double)).

NOTE: The viewer-local coordinate system is modelled as a right-handed one, which must be taken into account when using the rotation methods: the Z-axis is oriented towards the opposite viewing direction.

Version:
$Revision: 30126 $
Author:
Markus Schneider, last edited by: $Author: aschmitz $

Field Summary
 javax.vecmath.Point3d fbl
          far bottom left
 javax.vecmath.Point3d fbr
          far bottom right
 javax.vecmath.Point3d ftl
          far top left
 javax.vecmath.Point3d ftr
          far top right
 javax.vecmath.Point3d nbl
          near bottom left
 javax.vecmath.Point3d nbr
          near bottom right
 javax.vecmath.Point3d ntl
          near top left
 javax.vecmath.Point3d ntr
          near top right
 
Constructor Summary
ViewFrustum(double pitch, double yaw, double roll, double distance, javax.vecmath.Point3d lookingAt, double fovy, double aspect, double zNear, double zFar)
          Create a view Frustum by using the given roll, pitch, yaw and distance to the point of interest (looking at), to calculate the eye and the up vector.
ViewFrustum(javax.vecmath.Point3d eye, javax.vecmath.Point3d lookingAt, javax.vecmath.Vector3d up, double fovy, double aspect, double zNear, double zFar)
          Create a viewFrustum from the given parameters.
 
Method Summary
 javax.vecmath.Vector3d getBackward()
           
 javax.vecmath.Point3d getEyePos()
           
 double getFOVY()
           
 javax.vecmath.Point3d getLookingAt()
           
 javax.vecmath.Vector3d getRight()
           
 javax.vecmath.Vector3d getUp()
           
 double getZFar()
           
 double getZNear()
           
 boolean intersects(double[][] box)
           
 boolean intersects(float[] box)
           
 boolean intersects(float[][] box)
           
 void moveForward(double delta)
          Move the viewfrustum to the forward (according to the view direction).
 void moveRight(double delta)
          Move the viewfrustum to the right (according to the view direction).
 void moveUp(double delta)
          Move the viewfrustum to the up (according to the view direction).
 void rotateX(double delta)
          Rotate the viewfrustum around the x-axis (according to the view direction). pitch
 void rotateY(double delta)
          Rotate the viewfrustum around the y-axis (according to the view direction). roll
 void rotateZ(double delta)
          Rotate the viewfrustum around the z-axis (according to the view direction). yaw
 void setCameraParams(javax.vecmath.Point3d eye, javax.vecmath.Point3d lookingAt, javax.vecmath.Vector3d up)
          Sets the view frustum parameters that correspond to the viewing transform.
 void setPerspectiveParams(double fovy, double aspect, double zNear, double zFar)
          Sets the view frustum parameters that correspond to the perspective transformation matrix.
 String toInitString()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ntl

public javax.vecmath.Point3d ntl
near top left


ntr

public javax.vecmath.Point3d ntr
near top right


nbl

public javax.vecmath.Point3d nbl
near bottom left


nbr

public javax.vecmath.Point3d nbr
near bottom right


ftl

public javax.vecmath.Point3d ftl
far top left


ftr

public javax.vecmath.Point3d ftr
far top right


fbl

public javax.vecmath.Point3d fbl
far bottom left


fbr

public javax.vecmath.Point3d fbr
far bottom right

Constructor Detail

ViewFrustum

public ViewFrustum(javax.vecmath.Point3d eye,
                   javax.vecmath.Point3d lookingAt,
                   javax.vecmath.Vector3d up,
                   double fovy,
                   double aspect,
                   double zNear,
                   double zFar)
Create a viewFrustum from the given parameters.

Parameters:
eye -
lookingAt -
up -
fovy - the field-of-view in y direction
aspect -
zNear -
zFar -

ViewFrustum

public ViewFrustum(double pitch,
                   double yaw,
                   double roll,
                   double distance,
                   javax.vecmath.Point3d lookingAt,
                   double fovy,
                   double aspect,
                   double zNear,
                   double zFar)
Create a view Frustum by using the given roll, pitch, yaw and distance to the point of interest (looking at), to calculate the eye and the up vector.

Parameters:
pitch -
yaw -
roll -
distance -
lookingAt -
fovy - the field-of-view in y direction
aspect -
zNear -
zFar -
Method Detail

getEyePos

public javax.vecmath.Point3d getEyePos()
Returns:
the eye position

getLookingAt

public javax.vecmath.Point3d getLookingAt()
Returns:
the poi

getUp

public javax.vecmath.Vector3d getUp()
Returns:
the up vector

getRight

public javax.vecmath.Vector3d getRight()
Returns:
the right vector

getBackward

public javax.vecmath.Vector3d getBackward()
Returns:
the backward vector

getFOVY

public double getFOVY()
Returns:
the field-of-view in y direction

getZNear

public double getZNear()
Returns:
the near clipping plane.

getZFar

public double getZFar()
Returns:
the far clipping plane

intersects

public boolean intersects(double[][] box)
Parameters:
box -
Returns:
true if the box intersect with this viewfrustum.

intersects

public boolean intersects(float[][] box)
Parameters:
box -
Returns:
true if the box intersect with this viewfrustum.

intersects

public boolean intersects(float[] box)
Parameters:
box -
Returns:
true if the box intersect with this viewfrustum.

setPerspectiveParams

public void setPerspectiveParams(double fovy,
                                 double aspect,
                                 double zNear,
                                 double zFar)
Sets the view frustum parameters that correspond to the perspective transformation matrix.

The parameters correspond to those of the OpenGL gluPerspective() function.

NOTE: When this method is called, it is necessary to call setCameraParams(Point3d, Point3d, Vector3d) afterwards, so the internal state is consistent.

Parameters:
fovy -
aspect -
zNear -
zFar -

setCameraParams

public void setCameraParams(javax.vecmath.Point3d eye,
                            javax.vecmath.Point3d lookingAt,
                            javax.vecmath.Vector3d up)
Sets the view frustum parameters that correspond to the viewing transform.

The parameters correspond to those of the OpenGL gluLookAt() function.

Parameters:
eye -
lookingAt -
up -

moveRight

public void moveRight(double delta)
Move the viewfrustum to the right (according to the view direction).

Parameters:
delta -

moveUp

public void moveUp(double delta)
Move the viewfrustum to the up (according to the view direction).

Parameters:
delta -

moveForward

public void moveForward(double delta)
Move the viewfrustum to the forward (according to the view direction).

Parameters:
delta -

rotateX

public void rotateX(double delta)
Rotate the viewfrustum around the x-axis (according to the view direction). pitch

Parameters:
delta -

rotateY

public void rotateY(double delta)
Rotate the viewfrustum around the y-axis (according to the view direction). roll

Parameters:
delta -

rotateZ

public void rotateZ(double delta)
Rotate the viewfrustum around the z-axis (according to the view direction). yaw

Parameters:
delta -

toString

public String toString()
Overrides:
toString in class Object

toInitString

public String toInitString()
Returns:
a string representation of this view frustums initialization parameters.


Copyright © 2011. All Rights Reserved.