org.sunflow.core
Class Instance

java.lang.Object
  extended by org.sunflow.core.Instance
All Implemented Interfaces:
RenderObject

public class Instance
extends java.lang.Object
implements RenderObject

This represents an instance of a Geometry into the scene. This class maps object space to world space and maintains a list of shaders and modifiers attached to the surface.


Constructor Summary
Instance()
           
 
Method Summary
static Instance createTemporary(PrimitiveList primitives, Matrix4 transform, Shader shader)
           
 BoundingBox getBounds()
          Get the world space bounding box for this instance.
 Modifier getModifier(int i)
          Get a modifier for the instance's list.
 Shader getShader(int i)
          Get a shader for the instance's list.
 boolean hasGeometry(Geometry g)
          Checks to see if this instance is relative to the specified geometry.
 void prepareShadingState(ShadingState state)
          Prepare the shading state for shader invocation.
 void removeModifier(Modifier m)
          Remove the specified modifier from the instance's list if it is being used.
 void removeShader(Shader s)
          Remove the specified shader from the instance's list if it is being used.
 boolean update(ParameterList pl, SunflowAPI api)
          Update this object given a list of parameters.
 void updateBounds()
          Recompute world space bounding box of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Instance

public Instance()
Method Detail

createTemporary

public static Instance createTemporary(PrimitiveList primitives,
                                       Matrix4 transform,
                                       Shader shader)

update

public boolean update(ParameterList pl,
                      SunflowAPI api)
Description copied from interface: RenderObject
Update this object given a list of parameters. This method is guarenteed to be called at least once on every object, but it should correctly handle empty parameter lists. This means that the object should be in a valid state from the time it is constructed. This method should also return true or false depending on whether the update was succesfull or not.

Specified by:
update in interface RenderObject
Parameters:
pl - list of parameters to read from
api - reference to the current scene
Returns:
true if the update is succesfull, false otherwise

updateBounds

public void updateBounds()
Recompute world space bounding box of this instance.


hasGeometry

public boolean hasGeometry(Geometry g)
Checks to see if this instance is relative to the specified geometry.

Parameters:
g - geometry to check against
Returns:
true if the instanced geometry is equals to g, false otherwise

removeShader

public void removeShader(Shader s)
Remove the specified shader from the instance's list if it is being used.

Parameters:
s - shader to remove

removeModifier

public void removeModifier(Modifier m)
Remove the specified modifier from the instance's list if it is being used.

Parameters:
m - modifier to remove

getBounds

public BoundingBox getBounds()
Get the world space bounding box for this instance.

Returns:
bounding box in world space

prepareShadingState

public void prepareShadingState(ShadingState state)
Prepare the shading state for shader invocation. This also runs the currently attached surface modifier.

Parameters:
state - shading state to be prepared

getShader

public Shader getShader(int i)
Get a shader for the instance's list.

Parameters:
i - index into the shader list
Returns:
requested shader, or null if the input is invalid

getModifier

public Modifier getModifier(int i)
Get a modifier for the instance's list.

Parameters:
i - index into the modifier list
Returns:
requested modifier, or null if the input is invalid