com.threed.jpct.util
Class ReflectionHelper

java.lang.Object
  extended bycom.threed.jpct.util.ReflectionHelper

public class ReflectionHelper
extends java.lang.Object

A helper class for creating planar mirrors like water surfaces or marble floors. This works when using an OpenGL renderer only. The software renderers don't support this effect.


Constructor Summary
ReflectionHelper(FrameBuffer buffer, Object3D planeObj, int maxSize, int blendingMode)
          Creates a new helper.
 
Method Summary
 void drawScene(World world, FrameBuffer buffer)
          Draws the scene into the reflection map.
 void drawScene(World world, FrameBuffer buffer, World[] additionalWorlds)
          Draws the scene into the reflection map.
 void exclude(Object3D obj)
          Excludes an object from the reflection.
 void finalize()
           
 float getClippingPlaneOffset()
          Returns the clipping offset.
 Texture getReflectionTexture()
          Returns the texture used as reflection map.
 void include(Object3D obj)
          Re-includes an object in the reflection.
 void setClearColor(java.awt.Color col)
          Sets the clear color for the reflection map.
 void setClippingPlaneOffset(float clippingPlaneOffset)
          Sets an offset for the internal clipping plane.
 void setEnabled(boolean enabled)
          Enables/Disables the reflection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionHelper

public ReflectionHelper(FrameBuffer buffer,
                        Object3D planeObj,
                        int maxSize,
                        int blendingMode)
Creates a new helper.

Parameters:
buffer - the current FrameBuffer
planeObj - the object that ir the mirror, i.e. the floor or the water surface
maxSize - the maximum size of the texture which is used as a reflection map
blendingMode - the blending mode for the reflection (as defined in TextureInfo)
See Also:
TextureInfo
Method Detail

exclude

public void exclude(Object3D obj)
Excludes an object from the reflection. By default, the whole world reflects in the mirror (except for the mirror itself).

Parameters:
obj - the object to exclude

include

public void include(Object3D obj)
Re-includes an object in the reflection. This is only feasible if it has been excluded before.

Parameters:
obj - the object to re-include

setClearColor

public void setClearColor(java.awt.Color col)
Sets the clear color for the reflection map.

Parameters:
col - the color

getReflectionTexture

public Texture getReflectionTexture()
Returns the texture used as reflection map. Only useful for debugging.

Returns:
the texture

setEnabled

public void setEnabled(boolean enabled)
Enables/Disables the reflection.

Parameters:
enabled - is it on?

drawScene

public void drawScene(World world,
                      FrameBuffer buffer)
Draws the scene into the reflection map. This doesn't draw the whole scene, it just fills the reflection map with current pixels.

Parameters:
world - the world
buffer - the frame buffer

drawScene

public void drawScene(World world,
                      FrameBuffer buffer,
                      World[] additionalWorlds)
Draws the scene into the reflection map. This doesn't draw the whole scene, it just fill the reflection map with current pixels.

Parameters:
world - the world
buffer - the frame buffer
additionalWorlds - an array of additional worlds that should be rendered into the map

finalize

public void finalize()

setClippingPlaneOffset

public void setClippingPlaneOffset(float clippingPlaneOffset)
Sets an offset for the internal clipping plane. Default is 0. Can be useful, if some artifacts show up where the mirror "hits" the world.

Parameters:
clippingPlaneOffset - the new offset

getClippingPlaneOffset

public float getClippingPlaneOffset()
Returns the clipping offset.

Returns:
the offset