Package org.sunflow.core
Class Scene
- java.lang.Object
-
- org.sunflow.core.Scene
-
public class Scene extends java.lang.Object
Represents a entire scene, defined as a collection of instances viewed by a camera.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
acceltype
private AccelerationStructure
bakingAccel
private Instance
bakingInstance
private PrimitiveList
bakingPrimitives
private boolean
bakingViewDependent
private Camera
camera
private int
imageHeight
private int
imageWidth
private InstanceList
infiniteInstanceList
private InstanceList
instanceList
private AccelerationStructure
intAccel
private LightServer
lightServer
private boolean
lowPriority
private boolean
rebuildAccel
private Statistics
stats
private int
threads
-
Constructor Summary
Constructors Constructor Description Scene()
Creates an empty scene.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accumulateStats(IntersectionState state)
void
accumulateStats(ShadingCache cache)
boolean
calculatePhotons(PhotonStore map, java.lang.String type, int seed, Options options)
Create a photon map as prescribed by the givenPhotonStore
.private void
createAreaLightInstances()
BoundingBox
getBounds()
Get scene world space bounding box.(package private) Camera
getCamera()
ShadingState
getRadiance(IntersectionState istate, float rx, float ry, double lensU, double lensV, double time, int instance, int dim, ShadingCache cache)
Get the radiance seen through a particular pixelint
getThreadPriority()
Get the priority level to assign to multi-threaded operations.int
getThreads()
Get number of allowed threads for multi-threaded operations.private void
removeAreaLightInstances()
void
render(Options options, ImageSampler sampler, Display display)
Render the scene using the specified options, image sampler and display.void
setBakingInstance(Instance instance)
The provided instance will be considered for lightmap baking.void
setCamera(Camera camera)
Sets the current camera (no support for multiple cameras yet).void
setInstanceLists(Instance[] instances, Instance[] infinite)
Update the instance lists for this scene.void
setLightList(LightSource[] lights)
Update the light list for this scene.void
setShaderOverride(Shader shader, boolean photonOverride)
Enables shader overiding (set null to disable).(package private) void
trace(Ray r, IntersectionState state)
(package private) void
traceBake(Ray r, IntersectionState state)
(package private) Color
traceShadow(Ray r, IntersectionState state)
-
-
-
Field Detail
-
lightServer
private LightServer lightServer
-
instanceList
private InstanceList instanceList
-
infiniteInstanceList
private InstanceList infiniteInstanceList
-
camera
private Camera camera
-
intAccel
private AccelerationStructure intAccel
-
acceltype
private java.lang.String acceltype
-
stats
private Statistics stats
-
bakingViewDependent
private boolean bakingViewDependent
-
bakingInstance
private Instance bakingInstance
-
bakingPrimitives
private PrimitiveList bakingPrimitives
-
bakingAccel
private AccelerationStructure bakingAccel
-
rebuildAccel
private boolean rebuildAccel
-
imageWidth
private int imageWidth
-
imageHeight
private int imageHeight
-
threads
private int threads
-
lowPriority
private boolean lowPriority
-
-
Method Detail
-
getThreads
public int getThreads()
Get number of allowed threads for multi-threaded operations.- Returns:
- number of threads that can be started
-
getThreadPriority
public int getThreadPriority()
Get the priority level to assign to multi-threaded operations.- Returns:
- thread priority
-
setCamera
public void setCamera(Camera camera)
Sets the current camera (no support for multiple cameras yet).- Parameters:
camera
- camera to be used as the viewpoint for the scene
-
getCamera
Camera getCamera()
-
setInstanceLists
public void setInstanceLists(Instance[] instances, Instance[] infinite)
Update the instance lists for this scene.- Parameters:
instances
- regular instancesinfinite
- infinite instances (no bounds)
-
setLightList
public void setLightList(LightSource[] lights)
Update the light list for this scene.- Parameters:
lights
- array of light source objects
-
setShaderOverride
public void setShaderOverride(Shader shader, boolean photonOverride)
Enables shader overiding (set null to disable). The specified shader will be used to shade all surfaces- Parameters:
shader
- shader to run over all surfaces, ornull
to disable overridingphotonOverride
-true
to override photon scattering with this shader orfalse
to run the regular shaders
-
setBakingInstance
public void setBakingInstance(Instance instance)
The provided instance will be considered for lightmap baking. If the specified instance isnull
, lightmap baking will be disabled and normal rendering will occur.- Parameters:
instance
- instance to bake
-
getRadiance
public ShadingState getRadiance(IntersectionState istate, float rx, float ry, double lensU, double lensV, double time, int instance, int dim, ShadingCache cache)
Get the radiance seen through a particular pixel- Parameters:
istate
- intersection state for ray tracingrx
- pixel x coordinatery
- pixel y coordinatelensU
- DOF sampling variablelensV
- DOF sampling variabletime
- motion blur sampling variableinstance
- QMC instance seed- Returns:
- a shading state for the intersected primitive, or
null
if nothing is seen through the specifieFd point
-
getBounds
public BoundingBox getBounds()
Get scene world space bounding box.- Returns:
- scene bounding box
-
accumulateStats
public void accumulateStats(IntersectionState state)
-
accumulateStats
public void accumulateStats(ShadingCache cache)
-
trace
void trace(Ray r, IntersectionState state)
-
traceShadow
Color traceShadow(Ray r, IntersectionState state)
-
traceBake
void traceBake(Ray r, IntersectionState state)
-
createAreaLightInstances
private void createAreaLightInstances()
-
removeAreaLightInstances
private void removeAreaLightInstances()
-
render
public void render(Options options, ImageSampler sampler, Display display)
Render the scene using the specified options, image sampler and display.- Parameters:
options
- rendering options objectsampler
- image samplerdisplay
- display to send the final image to, a default display will be created ifnull
-
calculatePhotons
public boolean calculatePhotons(PhotonStore map, java.lang.String type, int seed, Options options)
Create a photon map as prescribed by the givenPhotonStore
.- Parameters:
map
- object that will recieve shot photonstype
- type of photons being shotseed
- QMC seed parameter- Returns:
true
upon success
-
-