org.sunflow.core

Class Instance

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.

Method Summary

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.
Vector3
transformNormalObjectToWorld(Vector3 n)
Transform the given normal from object space to world space.
Vector3
transformNormalWorldToObject(Vector3 n)
Transform the given normal from world space to object space.
Point3
transformObjectToWorld(Point3 p)
Transform the given point from object space to world space.
Vector3
transformVectorObjectToWorld(Vector3 v)
Transform the given vector from object space to world space.
Vector3
transformVectorWorldToObject(Vector3 v)
Transform the given vector from world space to object space.
Point3
transformWorldToObject(Point3 p)
Transform the given point from world space to object space.
boolean
update(ParameterList pl, SunflowAPI api)
void
updateBounds()
Recompute world space bounding box of this instance.

Method Details

getBounds

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

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

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

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

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

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

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

transformNormalObjectToWorld

public Vector3 transformNormalObjectToWorld(Vector3 n)
Transform the given normal from object space to world space. A new Vector3 object is returned.
Parameters:
n - object space normal to transform
Returns:
transformed normal

transformNormalWorldToObject

public Vector3 transformNormalWorldToObject(Vector3 n)
Transform the given normal from world space to object space. A new Vector3 object is returned.
Parameters:
n - world space normal to transform
Returns:
transformed normal

transformObjectToWorld

public Point3 transformObjectToWorld(Point3 p)
Transform the given point from object space to world space. A new Point3 object is returned.
Parameters:
p - object space position to transform
Returns:
transformed position

transformVectorObjectToWorld

public Vector3 transformVectorObjectToWorld(Vector3 v)
Transform the given vector from object space to world space. A new Vector3 object is returned.
Parameters:
v - object space vector to transform
Returns:
transformed vector

transformVectorWorldToObject

public Vector3 transformVectorWorldToObject(Vector3 v)
Transform the given vector from world space to object space. A new Vector3 object is returned.
Parameters:
v - world space vector to transform
Returns:
transformed vector

transformWorldToObject

public Point3 transformWorldToObject(Point3 p)
Transform the given point from world space to object space. A new Point3 object is returned.
Parameters:
p - world space position to transform
Returns:
transformed position

update

public boolean update(ParameterList pl,
                      SunflowAPI api)
Specified by:
update in interface RenderObject

updateBounds

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