espresso3d.engine.base
Class E3DViewport

java.lang.Object
  extended byespresso3d.engine.base.E3DEngineItem
      extended byespresso3d.engine.base.E3DViewport

public class E3DViewport
extends E3DEngineItem

Author:
Curt A viewport is the region that defines where in the window to perform rendering, and what world to render in it Viewports can be switched to either perspective or orthographic rendering modes. They default in a perspective mode.

Field Summary
static int VIEWPORT_MODE_ORTHOGRAPHIC
          Orthographic mode for the viewport.
static int VIEWPORT_MODE_PERSPECTIVE
          Perspectve mode for the viewport.
 
Constructor Summary
E3DViewport(E3DEngine engine, int x, int y, int width, int height, java.lang.String viewportID)
          This is used to create a perspective viewport
 
Method Summary
 double getBottom()
          How far below the camera to render in Ortho Mode
 E3DActor getCameraActor()
          Gets the actor the camera is using as its camera
 E3DVector3F getClearColor()
          Get the color the viewport clears to
 double getFar()
          How far from the camera to render in Ortho Mode
 double getFarClipPlane()
           
 double getFovY()
           
 int getHeight()
           
 double getLeft()
          How far left of the camera to render in Ortho Mode
 int getMode()
          Gets what mode the viewport is in.
 double getNear()
          How close to the camera to render in Ortho Mode
 double getNearClipPlane()
           
 double getOrthoZoom()
          Gets what the current ortho zoom factor is
 double getRight()
          How far right of the camera to render in Ortho Mode
 double getTop()
          How far above the camera to render in Ortho Mode
 java.lang.String getViewportID()
           
 int getWidth()
           
 E3DWorld getWorld()
           
 int getX()
           
 int getY()
           
 void setBottom(double bottom)
          Set how far below the camera to render in Ortho Mode
 void setCameraActor(E3DActor cameraActor)
          This is the actor that the viewport uses as the camera
 void setClearColor(E3DVector3F clearColor)
          Set the color the viewport clears to (RGB = XYZ) (Defaults to 0, 0, 0 = black)
 void setFar(double far)
          Set how far from the camera to render in Ortho Mode
 void setFarClipPlane(double farClipPlane)
          Sets the far clipping plane.
 void setFovY(double fovY)
          Sets how many degress you can see in the Y dir.
 void setHeight(int height)
           
 void setLeft(double left)
          Set how far left of the camera to render in Ortho Mode
 void setNear(double near)
          Set how close to the camera to render in Ortho Mode
 void setNearClipPlane(double nearClipPlane)
          Sets the near clipping plane.
 void setOrthoBounds(double left, double right, double top, double bottom, double near, double far)
          set all the boundaries for the ortho view mode in one method
 void setOrthoZoom(double zoomScalar)
          This makes the current ortho view zoom out(positive # greater than 1), or zoom in (positive number > 0.0 and < 1.0).
 void setRight(double right)
          Set how far right of the camera to render in Ortho Mode
 void setTop(double top)
          Set how far above the camera to render in Ortho Mode
 void setWidth(int width)
           
 void setWorld(E3DWorld world)
           
 void setX(int x)
          Sets the x coordinate of the bottom left corner of the viewport.
 void setY(int y)
          Sets the y coordinate of the bottom left corner of the viewport
 void switchToOrthographicMode(double left, double right, double top, double bottom, double near, double far)
          Switch this viewport to orthographic rendering.
 void switchToPerspectiveMode(double fovY, double farClipPlane, double nearClipPlane)
          Switch this viewport to perspective rendering.
 void switchToViewport()
           
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VIEWPORT_MODE_ORTHOGRAPHIC

public static final int VIEWPORT_MODE_ORTHOGRAPHIC
Orthographic mode for the viewport. This is used for comparing with getMode if necessary, nto for setting the mode

See Also:
Constant Field Values

VIEWPORT_MODE_PERSPECTIVE

public static final int VIEWPORT_MODE_PERSPECTIVE
Perspectve mode for the viewport. This is used for comparing with getMode if necessary, not for setting the mode

See Also:
Constant Field Values
Constructor Detail

E3DViewport

public E3DViewport(E3DEngine engine,
                   int x,
                   int y,
                   int width,
                   int height,
                   java.lang.String viewportID)
This is used to create a perspective viewport

Parameters:
engine - The engine the viewport will be part of
x - The x coordinate of the bottom left corner of the viewport
y - The y coordinate of the bottom left corner of the viewport
width -
height -
viewportID -
Method Detail

getHeight

public int getHeight()
Returns:
Returns the height.

setHeight

public void setHeight(int height)
Parameters:
height - The height of the viewport. This is not a coordinate, it is how high to make it from y. Remember, Y gets larger as it goes up the screen

getWidth

public int getWidth()
Returns:
Returns the width.

setWidth

public void setWidth(int width)
Parameters:
width - The width of the viewport. This is not a coordinate, it is how wide to make it from x

getX

public int getX()
Returns:
Returns the x coordinate of the bottom left corner of the viewport

setX

public void setX(int x)
Sets the x coordinate of the bottom left corner of the viewport. The bottom left corner is 0, and X gets larger as it mvoes right

Parameters:
x -

getY

public int getY()
Returns:
Returns the y coordinate of the bottom left corner of the viewport. The upper bottom corner is 0, and Y gets larger as it goes up the screen

setY

public void setY(int y)
Sets the y coordinate of the bottom left corner of the viewport

Parameters:
y -

getFarClipPlane

public double getFarClipPlane()
Returns:
Returns the farClipPlane. This is how far the scene will be drawn away from the cameara. Defaults to 100

setFarClipPlane

public void setFarClipPlane(double farClipPlane)
Sets the far clipping plane. The large the value, the farther away you will be able to see. However, too large of a value can hurt performance.

Parameters:
farClipPlane - The farClipPlane to set.

getFovY

public double getFovY()
Returns:
Returns the fovY. This is how many degrees you can see in the Y dir

setFovY

public void setFovY(double fovY)
Sets how many degress you can see in the Y dir.

Parameters:
fovY - The fovY to set.

getNearClipPlane

public double getNearClipPlane()
Returns:
Returns the nearClipPlane.

setNearClipPlane

public void setNearClipPlane(double nearClipPlane)
Sets the near clipping plane. The smaller the value, the closer you will be able to see objects to the camera.Defaults to 0.1;

Parameters:
nearClipPlane - The nearClipPlane to set.

switchToViewport

public void switchToViewport()

getWorld

public E3DWorld getWorld()
Returns:
Returns the world that the viewport needs to display

setWorld

public void setWorld(E3DWorld world)
Parameters:
world - The world to set for the viewport to display

getViewportID

public java.lang.String getViewportID()

setCameraActor

public void setCameraActor(E3DActor cameraActor)
This is the actor that the viewport uses as the camera

Parameters:
cameraActor -

getCameraActor

public E3DActor getCameraActor()
Gets the actor the camera is using as its camera

Returns:

getMode

public int getMode()
Gets what mode the viewport is in. Orthographic or perspective

Returns:

switchToOrthographicMode

public void switchToOrthographicMode(double left,
                                     double right,
                                     double top,
                                     double bottom,
                                     double near,
                                     double far)
Switch this viewport to orthographic rendering. Ortho rendering doesn't give the illusion of perspective.

Parameters:
left - How far left to render of the viewport's camera actor
right - How right left to render of the viewport's camera actor
top - How far above to render of the viewport's camera actor
bottom - How far below to render of the viewport's camera actor
near - How close of objects to render by the camera
far - How far away to render objects from the camera

switchToPerspectiveMode

public void switchToPerspectiveMode(double fovY,
                                    double farClipPlane,
                                    double nearClipPlane)
Switch this viewport to perspective rendering. Perspective is a standard 3d rendering that simulates what our eyes see.

Parameters:
fovY - The field of view angle in degress in the Y direciton. 45 is a standard value. Too high makes things look fisheyed.
farClipPlane - This specifies the maximum distance that objects can be from the camera and still be rendered
nearClipPlane - Specifies the minimum distance that objects can be from the camera and still be rendered

setOrthoBounds

public void setOrthoBounds(double left,
                           double right,
                           double top,
                           double bottom,
                           double near,
                           double far)
set all the boundaries for the ortho view mode in one method

Parameters:
left -
right -
top -
bottom -
near -
far -

setOrthoZoom

public void setOrthoZoom(double zoomScalar)
This makes the current ortho view zoom out(positive # greater than 1), or zoom in (positive number > 0.0 and < 1.0). 1 will reset it to the original zoom. Negative numbers and 0 are not allowed and will be converted to 1 The actual ortho bounds are not modified, this is a scalar multiplied to them at runtime.


getOrthoZoom

public double getOrthoZoom()
Gets what the current ortho zoom factor is


getBottom

public double getBottom()
How far below the camera to render in Ortho Mode

Returns:

setBottom

public void setBottom(double bottom)
Set how far below the camera to render in Ortho Mode

Returns:

getFar

public double getFar()
How far from the camera to render in Ortho Mode

Returns:

setFar

public void setFar(double far)
Set how far from the camera to render in Ortho Mode

Returns:

getLeft

public double getLeft()
How far left of the camera to render in Ortho Mode

Returns:

setLeft

public void setLeft(double left)
Set how far left of the camera to render in Ortho Mode

Parameters:
left -

getNear

public double getNear()
How close to the camera to render in Ortho Mode


setNear

public void setNear(double near)
Set how close to the camera to render in Ortho Mode


getRight

public double getRight()
How far right of the camera to render in Ortho Mode


setRight

public void setRight(double right)
Set how far right of the camera to render in Ortho Mode


getTop

public double getTop()
How far above the camera to render in Ortho Mode


setTop

public void setTop(double top)
Set how far above the camera to render in Ortho Mode


getClearColor

public E3DVector3F getClearColor()
Get the color the viewport clears to

Returns:

setClearColor

public void setClearColor(E3DVector3F clearColor)
Set the color the viewport clears to (RGB = XYZ) (Defaults to 0, 0, 0 = black)

Parameters:
clearColor -