com.threed.jpct.util
Class Overlay

java.lang.Object
  extended by com.threed.jpct.util.Overlay
All Implemented Interfaces:
java.io.Serializable

public class Overlay
extends java.lang.Object
implements java.io.Serializable

Overlay is a helper class to create opaque or transparent screen overlays from textures. An overlay is quite similar to scaled blit with the exception that an overlay has an actual depth and that it takes care of itself, i.e. once created, it will appear automatically until you dispose it. A scaled blit has to be applied by the application each frame.

See Also:
Serialized Form

Constructor Summary
Overlay(World world, FrameBuffer buffer, java.lang.String textureName)
          Creates a new overlay that covers the whole screen.
Overlay(World world, int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY, java.lang.String textureName)
          Creates a new overlay of arbritary size.
Overlay(World world, int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY, java.lang.String textureName, boolean modifyUV)
          Creates a new overlay of arbritary size with (optional) modifiable uv-coordinates.
 
Method Summary
 void dispose()
          Disposes the overlay and frees its resources.
 Object3D getObject3D()
          Returns the internal Object3D that is the actual Overlay.
 void setColor(RGBColor color)
          Sets a new additional color.
 void setDepth(float depth)
          Sets the depth of the overlay.
 void setNewCoordinates(int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY)
          Sets new coordinates for the overlay.
 void setRotation(float angle)
          Rotates the Overlay around it's midpoint.
 void setRotationPivot(int x, int y)
          Sets the pivot point for the rotation in screen coordinates.
 void setSourceCoordinates(int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY)
          Sets new source coordinates.
 void setTexture(java.lang.String textureName)
          Changes the texture of the overlay.
 void setTexture(TextureInfo textureInfo)
          Changes the texture of the overlay.
 void setTransparency(int trans)
          Set the transparency of the overlay.
 void setTransparencyMode(int mode)
          Sets the transparency mode similar to setTransparencyMode() in Object3D.
 void setVisibility(boolean visible)
          Sets the visibility similar to setVisibility() in Object3D.
 void unlink()
          Unlinks the overlay.
 void update(FrameBuffer buffer)
          Updates the overlay.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Overlay

public Overlay(World world,
               FrameBuffer buffer,
               java.lang.String textureName)
Creates a new overlay that covers the whole screen.

Parameters:
world - the world
buffer - the current frame buffer
textureName - the name of the texture that should be used as an overlay. The TextureManager has to know this texture.

Overlay

public Overlay(World world,
               int upperLeftX,
               int upperLeftY,
               int lowerRightX,
               int lowerRightY,
               java.lang.String textureName)
Creates a new overlay of arbritary size.

Parameters:
world - the world
upperLeftX - the upper left corner's x-coordinate in screen coordinates
upperLeftY - the upper left corner's y-coordinate in screen coordinates
lowerRightX - the lower right corner's x-coordinate in screen coordinates
lowerRightY - the lower right corner's y-coordinate in screen coordinates
textureName - the name of the texture that should be used as an overlay. The TextureManager has to know this texture.

Overlay

public Overlay(World world,
               int upperLeftX,
               int upperLeftY,
               int lowerRightX,
               int lowerRightY,
               java.lang.String textureName,
               boolean modifyUV)
Creates a new overlay of arbritary size with (optional) modifiable uv-coordinates.

Parameters:
world - the world
upperLeftX - the upper left corner's x-coordinate in screen coordinates
upperLeftY - the upper left corner's y-coordinate in screen coordinates
lowerRightX - the lower right corner's x-coordinate in screen coordinates
lowerRightY - the lower right corner's y-coordinate in screen coordinates
textureName - the name of the texture that should be used as an overlay. The TextureManager has to know this texture.
modifyUV - if true, uv-coordinates can be modified.
Method Detail

setDepth

public void setDepth(float depth)
Sets the depth of the overlay. By default the overlay is bound to Config.nearPlane with a small offset. By setting this to a higher value, the overlay will ovberlap differently with other objects in the world while still filling the whole screen.
Useful for using an (pseudo-)overlay as static backdrop.
When using a large overlay, the accuracy may suffer. In this case, it might also help to increase the depth value.

Parameters:
depth - the new depth (should be positive)

setTransparency

public void setTransparency(int trans)
Set the transparency of the overlay. The trans-value behaves as the value in Object3D's setTransparency()-method. By default, the overlay is opaque.

Parameters:
trans - the transparency value
See Also:
Object3D.setTransparency(int)

setColor

public void setColor(RGBColor color)
Sets a new additional color. With this, it's possible to give the overlay another coloring. Default is white, i.e. the overlay shows the same colors like they are defined in the texture.

Parameters:
color - the new Color

setTexture

public void setTexture(java.lang.String textureName)
Changes the texture of the overlay.

Parameters:
textureName - the new texture's name as the TextureManager knows it.

setTexture

public void setTexture(TextureInfo textureInfo)
Changes the texture of the overlay.

Parameters:
textureInfo - the new TextureInfo.

setVisibility

public void setVisibility(boolean visible)
Sets the visibility similar to setVisibility() in Object3D.

Parameters:
visible - should it be visible or not?
See Also:
Object3D.setVisibility(boolean)

setTransparencyMode

public void setTransparencyMode(int mode)
Sets the transparency mode similar to setTransparencyMode() in Object3D.

Parameters:
mode - the mode
See Also:
Object3D.setTransparencyMode(int), Object3D.TRANSPARENCY_MODE_DEFAULT, Object3D.TRANSPARENCY_MODE_ADD

setNewCoordinates

public void setNewCoordinates(int upperLeftX,
                              int upperLeftY,
                              int lowerRightX,
                              int lowerRightY)
Sets new coordinates for the overlay.

Parameters:
upperLeftX - the upper left corner's x-coordinate in screen coordinates
upperLeftY - the upper left corner's y-coordinate in screen coordinates
lowerRightX - the lower right corner's x-coordinate in screen coordinates
lowerRightY - the lower right corner's y-coordinate in screen coordinates

setSourceCoordinates

public void setSourceCoordinates(int upperLeftX,
                                 int upperLeftY,
                                 int lowerRightX,
                                 int lowerRightY)
Sets new source coordinates. Only the defined part of the source texture will be used as an overlay. Setting this will slow the overlay down a tiny little bit, but that shouldn't be noticable.

Parameters:
upperLeftX - the upper left corner's x-coordinate in texture coordinates
upperLeftY - the upper left corner's y-coordinate in texture coordinates
lowerRightX - the lower right corner's x-coordinate in texture coordinates
lowerRightY - the lower right corner's y-coordinate in texture coordinates

setRotation

public void setRotation(float angle)
Rotates the Overlay around it's midpoint.

Parameters:
angle - the angle

setRotationPivot

public void setRotationPivot(int x,
                             int y)
Sets the pivot point for the rotation in screen coordinates.

Parameters:
x - the x position
y - the y position

getObject3D

public Object3D getObject3D()
Returns the internal Object3D that is the actual Overlay. Handle with care!

Returns:
the internal Object3D

dispose

public void dispose()
Disposes the overlay and frees its resources. It can't be used after calling this method


unlink

public void unlink()
Unlinks the overlay. It shouldn't be required to call this method from a normal application.


update

public void update(FrameBuffer buffer)
Updates the overlay. It shouldn't be required to call this method from a normal application.

Parameters:
buffer -