com.threed.jpct.util
Class LensFlare

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

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

A simple lens flare effect. You need four different textures for this, one burst and three halos. How to create/get these textures is up to you. jPCT doesn't come with any.

See Also:
Serialized Form

Constructor Summary
LensFlare(SimpleVector lightPos, java.lang.String burst, java.lang.String halo1, java.lang.String halo2, java.lang.String halo3)
          Create a new lens flare for a light source.
 
Method Summary
 void render(FrameBuffer buffer)
          Renders the effect.
 void setDirection(boolean lightToCam)
          If hiding is enabled, the visibility calculations can be done camera->light (default) or light->camera.
 void setGlobalScale(float scale)
          Sets the global scale of the effect.
 void setHiding(boolean hides)
          If true (default), all geometry that is a potential collider hides the effect if it's located in a direct line between the camera and the light source.
 void setLightPosition(SimpleVector lightPos)
          Sets a new light position.
 void setMaximumDistance(float distance)
          If hiding is enabled, this value specifies how far away from the camera a polygon can maximally be to be considered as a blocker.
 void setTransparency(int trans)
          Sets the transparency of the effect.
 void update(FrameBuffer buffer, World world)
          Updates the lens flare.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LensFlare

public LensFlare(SimpleVector lightPos,
                 java.lang.String burst,
                 java.lang.String halo1,
                 java.lang.String halo2,
                 java.lang.String halo3)
Create a new lens flare for a light source.

Parameters:
lightPos - the position of the light source
burst - the name of the burst texture as added to the TextureManager
halo1 - the name of the first halo texture as added to the TextureManager
halo2 - the name of the second halo as added to the TextureManager
halo3 - the name of the third halo texture added to the TextureManager
Method Detail

setTransparency

public void setTransparency(int trans)
Sets the transparency of the effect.

Parameters:
trans - the transparency. 0 is lowest,

setLightPosition

public void setLightPosition(SimpleVector lightPos)
Sets a new light position.

Parameters:
lightPos - the new position

setGlobalScale

public void setGlobalScale(float scale)
Sets the global scale of the effect.

Parameters:
scale - the scale

setHiding

public void setHiding(boolean hides)
If true (default), all geometry that is a potential collider hides the effect if it's located in a direct line between the camera and the light source.

Parameters:
hides - should geometry hide it or not?

setMaximumDistance

public void setMaximumDistance(float distance)
If hiding is enabled, this value specifies how far away from the camera a polygon can maximally be to be considered as a blocker. Anything farer away can't hide the effect. Lowering this value can improve performance but may lead to flares where non should be. -1 is default, which means no limits.

Parameters:
distance - the distance

setDirection

public void setDirection(boolean lightToCam)
If hiding is enabled, the visibility calculations can be done camera->light (default) or light->camera. Depending on the scene, one or the other will be faster.

Parameters:
lightToCam - do it light->camera or vice versa

update

public void update(FrameBuffer buffer,
                   World world)
Updates the lens flare. Skipping this method and calling render only will cause the lens flare to remain static. This method should be called if either the camera or, if hiding is enabled, the hiding objects are moving.

Parameters:
buffer - the frame buffer
world - the world

render

public void render(FrameBuffer buffer)
Renders the effect.

Parameters:
buffer - the frame buffer