Package org.sunflow.core
Class Instance
- java.lang.Object
-
- org.sunflow.core.Instance
-
- All Implemented Interfaces:
RenderObject
public class Instance extends java.lang.Object implements RenderObject
This represents an instance of aGeometryinto the scene. This class maps object space to world space and maintains a list of shaders and modifiers attached to the surface.
-
-
Field Summary
Fields Modifier and Type Field Description private BoundingBoxboundsprivate Geometrygeometryprivate Modifier[]modifiersprivate MovingMatrix4o2wprivate Shader[]shadersprivate MovingMatrix4w2o
-
Constructor Summary
Constructors Constructor Description Instance()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InstancecreateTemporary(PrimitiveList primitives, Matrix4 transform, Shader shader)(package private) PrimitiveListgetBakingPrimitives()BoundingBoxgetBounds()Get the world space bounding box for this instance.(package private) GeometrygetGeometry()ModifiergetModifier(int i)Get a modifier for the instance's list.(package private) intgetNumPrimitives()(package private) Matrix4getObjectToWorld(float time)ShadergetShader(int i)Get a shader for the instance's list.(package private) Matrix4getWorldToObject(float time)booleanhasGeometry(Geometry g)Checks to see if this instance is relative to the specified geometry.(package private) voidintersect(Ray r, IntersectionState state)voidprepareShadingState(ShadingState state)Prepare the shading state for shader invocation.voidremoveModifier(Modifier m)Remove the specified modifier from the instance's list if it is being used.voidremoveShader(Shader s)Remove the specified shader from the instance's list if it is being used.booleanupdate(ParameterList pl, SunflowAPI api)Update this object given a list of parameters.voidupdateBounds()Recompute world space bounding box of this instance.
-
-
-
Field Detail
-
o2w
private MovingMatrix4 o2w
-
w2o
private MovingMatrix4 w2o
-
bounds
private BoundingBox bounds
-
geometry
private Geometry geometry
-
shaders
private Shader[] shaders
-
modifiers
private Modifier[] modifiers
-
-
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:RenderObjectUpdate 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:
updatein interfaceRenderObject- Parameters:
pl- list of parameters to read fromapi- reference to the current scene- Returns:
trueif the update is succesfull,falseotherwise
-
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:
trueif the instanced geometry is equals to g,falseotherwise
-
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
-
getNumPrimitives
int getNumPrimitives()
-
intersect
void intersect(Ray r, IntersectionState state)
-
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
nullif 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
nullif the input is invalid
-
getObjectToWorld
Matrix4 getObjectToWorld(float time)
-
getWorldToObject
Matrix4 getWorldToObject(float time)
-
getBakingPrimitives
PrimitiveList getBakingPrimitives()
-
getGeometry
Geometry getGeometry()
-
-