yage.scene.scene
Authors:
Eric Poggel
License:
LGPL v3
- class
Scene
: yage.scene.node.Node;
- A
Scene
is the root of a tree of Nodes, and threfore never has a parent.
Certain "global" variables are stored per
Scene
and affect all Nodes in that
Scene
.
Examples include global ambient lighting and the speed of sound.
Scenes also maintain an array of all LightNodes in them.
Each
Scene
updates its nodes in its own thread at a fixed frequencty,
controlled by play(), pause() and other ITemporal methods.
Example:
Scene scene = new Scene();
scene.play(); // Start the scene updater at 60 times per second.
scope(exit) scene.pause(); // Ensure it stops later.
Scene skybox = new Scene(); // Create a skybox for the scene.
ModelNode sky = skybox.addChild(new ModelNode()); // A model with all faces pointing inward.
sky.setModel("sky/sanctuary.ms3d"); // Use this 3D model as geometry for the skybox.
scene.setSkybox(skybox);
- Color
ambient
;
- The color of the scene's global
ambient
light, defaults to black.
- Color
backgroundColor
;
- Background color rendered for this Scene when no skybox is specified. TODO: allow transparency.
- Color
fogColor
;
- Color of global scene fog, when fog is enabled.
- float
fogDensity
;
- The thickness (density) of the Scene's global fog, when fog is enabled.
- bool
fogEnabled
;
- Get / set whether global distance fog is enabled for this scene.
Depending on the scale of your scene, decent values range between .001 and .1.
- float
speedOfSound
;
- Speed of sound in units/second
For best results, use no skybox and set the clear color the same as the fog color.
For improved performance, set the cameras' max view distance to just beyond
where objects become completely obscured by the fog. */
- Scene
skyBox
;
- A Scene can have another heirarchy of nodes that will be rendered as a skybox by any camera.
- this();
- Construct an empty Scene.
- Scene
clone
(bool children = false);
- Make a duplicate of this scene.
The duplicate will always start with its update thread paused.
Params:
bool children |
recursively
clone
children (and descendants) and add them as children to the new Node. |
Returns:
The cloned Node.
- void
dispose
();
- Overridden to pause the scene update and sound threads and to remove this instance from the array of all scenes.
- float
getDeltaTime
();
- Return the amount of time since the last time update() was called for this Scene.
- CameraNode[CameraNode]
getAllCameras
();
- Get all CameraNodes that are currently a part of this scene.
Returns:
a self indexed array.
- LightNode[]
getAllLights
();
- Get all LightNodes that are currently a part of this scene.
Returns:
A copy of the Lights array to avoid synchronization issues.
- SoundNode[SoundNode]
getAllSounds
();
- Get all SoundNodes that are currently a part of this scene.
Returns:
a self indexed array.
- void
setErrorFunction
(void delegate(Exception e) on_error);
void
setErrorFunction
(void function(Exception e) on_error);
- Get / a function to call if the sound or update thread's update function throws an exception.
If this is set to null
(the default), then the exception will just be thrown.
Params:
void delegate(Exception e) on_error |
Defaults to System.abortException. If null
, any errors from the Scene's
sound or update threads will cause the threads to terminate silently. |
- void
play
();
void
pause
();
bool
paused
();
void
seek
(double seconds);
double
tell
();
- Implement the time control functions of ITemporal.
When the scene's timer (implementd as a Repeater) runs, it updates
the positions and rotations of all Nodes in this Scene.
Each Scene is updated in its own thread.
If the updating thread gets behind, it will always attempt to catch up by updating more frequently.
- void
swapTransformRead
();
- Swap the transform buffer cache for each Node to the latest that's not currently
being written to.
- void
swapTransformWrite
();
- Start writing to the transform buffer cache that's not currently being read.
- void
update
(float delta = cast(float)delta.tell());
- Update all Nodes in the scene by delta seconds.
This function is typically called automatically at a set interval from the scene's update_thread once scene.play() is called.
Params:
float delta |
time in seconds. If not set, defaults to the amount of time since the last time
update
() was called. |
- static Scene[Scene]
getAllScenes
();
- Get a self-indexed array of all senes that are active (have been constructed but not disposed).
|