|
Kemena3D
|
Holds all objects, lights, and rendering settings for one scene. More...
#include <kscene.h>
Public Member Functions | |
| kScene () | |
| Constructs an empty scene with a default root node. | |
| virtual | ~kScene () |
| Destroys the scene. Does not free objects/meshes/lights held by pointer. | |
| void | setAssetManager (kAssetManager *manager) |
| Sets the asset manager used to load resources into this scene. | |
| kAssetManager * | getAssetManager () |
| Returns the asset manager associated with this scene. | |
| void | setWorld (kWorld *newWorld) |
| Associates this scene with a parent world. | |
| kWorld * | getWorld () |
| Returns the parent world. | |
| bool | getActive () |
| Returns whether this scene is active (rendered and updated). | |
| void | setActive (bool newActive) |
| Activates or deactivates this scene. | |
| void | setFrustumCullingEnabled (bool enable) |
| Enable or disable frustum culling for this scene (default: enabled). | |
| bool | getFrustumCullingEnabled () const |
| Returns whether frustum culling is enabled for this scene. | |
| kString | getUuid () |
| Returns the UUID of this scene. | |
| void | setUuid (kString newUuid) |
| Sets the UUID of this scene. | |
| kString | getName () |
| Returns the human-readable scene name. | |
| void | setName (kString newName) |
| Sets the human-readable scene name. | |
| unsigned int | getIncrement () |
| Returns the auto-increment counter used to assign object IDs. | |
| void | setIncrement (unsigned int newIncrement) |
| Sets the auto-increment counter (used when deserialising). | |
| std::vector< kObject * > | getObjects () |
| Returns all generic scene-graph objects. | |
| std::vector< kMesh * > | getMeshes () |
| Returns all mesh nodes in the scene. | |
| std::vector< kLight * > | getLights () |
| Returns all light nodes in the scene. | |
| kObject * | getRootNode () |
| Returns the root node of the scene graph. | |
| void | addObject (kObject *object, kString objectUuid="") |
| Adds a generic object to the scene graph. | |
| kMesh * | addMesh (kString fileName, kString objectUuid="") |
| Loads a mesh asset and adds it to the scene. | |
| void | addMesh (kMesh *mesh, kString objectUuid="") |
| Adds an existing mesh node to the scene graph. | |
| kVec3 | getAmbientLightColor () |
| Returns the scene-level ambient light colour. | |
| void | setAmbientLightColor (kVec3 newColor) |
| Sets the scene-level ambient light colour. | |
| kLight * | addSunLight (kVec3 position=kVec3(0.0f, 0.0f, 0.0f), kVec3 direction=kVec3(0.0f, -1.0f, 0.0f), kVec3 diffuseColor=kVec3(1.0f, 1.0f, 1.0f), kVec3 specularColor=kVec3(1.0f, 1.0f, 1.0f), kString objectUuid="") |
| Creates and adds a directional (sun) light. | |
| kLight * | addPointLight (kVec3 position=kVec3(0.0f, 0.0f, 0.0f), kVec3 diffuseColor=kVec3(1.0f, 1.0f, 1.0f), kVec3 specularColor=kVec3(1.0f, 1.0f, 1.0f), kString objectUuid="") |
| Creates and adds an omnidirectional point light. | |
| kLight * | addSpotLight (kVec3 position=kVec3(0.0f, 0.0f, 0.0f), kVec3 diffuseColor=kVec3(1.0f, 1.0f, 1.0f), kVec3 specularColor=kVec3(1.0f, 1.0f, 1.0f), kString objectUuid="") |
| Creates and adds a cone spotlight. | |
| void | removeObject (kObject *object) |
| Removes a generic object from the scene graph. | |
| void | removeMesh (kMesh *mesh) |
| Removes a mesh node from the scene graph. | |
| void | removeLight (kLight *light) |
| Removes a light node from the scene graph and the light list. | |
| void | addLight (kLight *light) |
| Re-attaches an existing light to the scene (used for undo). | |
| bool | getShadowsEnabled () const |
| Returns whether the scene wants shadow rendering. | |
| void | setShadowsEnabled (bool enabled) |
| Toggles shadow rendering for this scene. | |
| float | getShadowBias () const |
| Returns the constant shadow bias used by lit shaders. | |
| void | setShadowBias (float bias) |
| Sets the constant shadow bias used by lit shaders. Larger values reduce acne but can detach the shadow from its caster (peter-panning). | |
| float | getShadowNormalBias () const |
| Returns the slope-scaled component of the shadow bias. | |
| void | setShadowNormalBias (float bias) |
| Sets the slope-scaled component of the shadow bias. Multiplied by (1 - N·L); only affects grazing-angle surfaces. | |
| int | getShadowMapResolution () const |
| Returns the per-cascade shadow map resolution in pixels. | |
| void | setShadowMapResolution (int resolution) |
| Sets the per-cascade shadow map resolution (e.g. 512, 1024, 2048, 4096). Reallocates the shadow texture on the renderer. | |
| float | getShadowSoftness () const |
| Returns the PCF tap spacing (in shadow-map texels). | |
| void | setShadowSoftness (float softness) |
| Sets the PCF tap spacing in shadow-map texels. Larger = softer edges but more bleeding of small occluders. | |
| bool | getSkyboxAmbientEnabled () |
| Returns whether skybox image-based ambient is enabled. | |
| void | setSkyboxAmbientEnabled (bool enabled) |
| Enables or disables skybox image-based ambient lighting. | |
| float | getSkyboxAmbientStrength () |
| Returns the skybox ambient strength multiplier. | |
| void | setSkyboxAmbientStrength (float strength) |
| Sets the skybox ambient strength multiplier. | |
| void | setSkybox (kMaterial *newMaterial, kMesh *newMesh) |
| Sets the skybox material and mesh. | |
| kMaterial * | getSkyboxMaterial () |
| Returns the skybox material. | |
| kMesh * | getSkyboxMesh () |
| Returns the skybox mesh. | |
| virtual json | serialize () |
| Serialises the scene to JSON. | |
| virtual void | deserialize (json data) |
| Restores the scene from a JSON object. | |
Holds all objects, lights, and rendering settings for one scene.
A kScene owns a root scene-graph node under which all kObject, kMesh, and kLight instances are organised. Multiple scenes can coexist inside a kWorld; only active scenes are rendered.
| kemena::kScene::kScene | ( | ) |
Constructs an empty scene with a default root node.
|
virtual |
Destroys the scene. Does not free objects/meshes/lights held by pointer.
| void kemena::kScene::addLight | ( | kLight * | light | ) |
Re-attaches an existing light to the scene (used for undo).
| light | Light to re-add; must already have its UUID set. |
Adds an existing mesh node to the scene graph.
| mesh | Pre-constructed mesh to add. |
| objectUuid | Optional UUID override. |
Loads a mesh asset and adds it to the scene.
| fileName | Path to the mesh asset file. |
| objectUuid | Optional UUID for the new mesh node. |
Adds a generic object to the scene graph.
| object | Object to add; ownership is not transferred. |
| objectUuid | Optional UUID to assign; auto-generated if empty. |
| kLight * kemena::kScene::addPointLight | ( | kVec3 | position = kVec3(0.0f, 0.0f, 0.0f), |
| kVec3 | diffuseColor = kVec3(1.0f, 1.0f, 1.0f), | ||
| kVec3 | specularColor = kVec3(1.0f, 1.0f, 1.0f), | ||
| kString | objectUuid = "" ) |
Creates and adds an omnidirectional point light.
| position | World-space position. |
| diffuseColor | Diffuse colour component. |
| specularColor | Specular colour component. |
| objectUuid | Optional UUID for the new node. |
| kLight * kemena::kScene::addSpotLight | ( | kVec3 | position = kVec3(0.0f, 0.0f, 0.0f), |
| kVec3 | diffuseColor = kVec3(1.0f, 1.0f, 1.0f), | ||
| kVec3 | specularColor = kVec3(1.0f, 1.0f, 1.0f), | ||
| kString | objectUuid = "" ) |
Creates and adds a cone spotlight.
| position | World-space position. |
| diffuseColor | Diffuse colour component. |
| specularColor | Specular colour component. |
| objectUuid | Optional UUID for the new node. |
| kLight * kemena::kScene::addSunLight | ( | kVec3 | position = kVec3(0.0f, 0.0f, 0.0f), |
| kVec3 | direction = kVec3(0.0f, -1.0f, 0.0f), | ||
| kVec3 | diffuseColor = kVec3(1.0f, 1.0f, 1.0f), | ||
| kVec3 | specularColor = kVec3(1.0f, 1.0f, 1.0f), | ||
| kString | objectUuid = "" ) |
Creates and adds a directional (sun) light.
| position | World-space position of the light node. |
| direction | Normalised light direction. |
| diffuseColor | Diffuse colour component. |
| specularColor | Specular colour component. |
| objectUuid | Optional UUID for the new node. |
|
virtual |
Restores the scene from a JSON object.
| data | JSON produced by serialize(). |
| bool kemena::kScene::getActive | ( | ) |
Returns whether this scene is active (rendered and updated).
| kVec3 kemena::kScene::getAmbientLightColor | ( | ) |
Returns the scene-level ambient light colour.
| kAssetManager * kemena::kScene::getAssetManager | ( | ) |
Returns the asset manager associated with this scene.
|
inline |
Returns whether frustum culling is enabled for this scene.
| unsigned int kemena::kScene::getIncrement | ( | ) |
Returns the auto-increment counter used to assign object IDs.
| std::vector< kLight * > kemena::kScene::getLights | ( | ) |
Returns all light nodes in the scene.
| std::vector< kMesh * > kemena::kScene::getMeshes | ( | ) |
Returns all mesh nodes in the scene.
| kString kemena::kScene::getName | ( | ) |
Returns the human-readable scene name.
| std::vector< kObject * > kemena::kScene::getObjects | ( | ) |
Returns all generic scene-graph objects.
| kObject * kemena::kScene::getRootNode | ( | ) |
Returns the root node of the scene graph.
| float kemena::kScene::getShadowBias | ( | ) | const |
Returns the constant shadow bias used by lit shaders.
| int kemena::kScene::getShadowMapResolution | ( | ) | const |
Returns the per-cascade shadow map resolution in pixels.
| float kemena::kScene::getShadowNormalBias | ( | ) | const |
Returns the slope-scaled component of the shadow bias.
| bool kemena::kScene::getShadowsEnabled | ( | ) | const |
Returns whether the scene wants shadow rendering.
The renderer reads this each frame; turning it off skips the shadow map pass entirely and tells lit shaders to drop the shadow term. Default: true.
| float kemena::kScene::getShadowSoftness | ( | ) | const |
Returns the PCF tap spacing (in shadow-map texels).
| bool kemena::kScene::getSkyboxAmbientEnabled | ( | ) |
Returns whether skybox image-based ambient is enabled.
| float kemena::kScene::getSkyboxAmbientStrength | ( | ) |
Returns the skybox ambient strength multiplier.
| kMaterial * kemena::kScene::getSkyboxMaterial | ( | ) |
Returns the skybox material.
| kMesh * kemena::kScene::getSkyboxMesh | ( | ) |
Returns the skybox mesh.
| kWorld * kemena::kScene::getWorld | ( | ) |
Returns the parent world.
| void kemena::kScene::removeLight | ( | kLight * | light | ) |
Removes a light node from the scene graph and the light list.
| light | Light to detach; memory is NOT freed. |
| void kemena::kScene::removeMesh | ( | kMesh * | mesh | ) |
Removes a mesh node from the scene graph.
| mesh | Mesh to detach; memory is NOT freed. |
| void kemena::kScene::removeObject | ( | kObject * | object | ) |
Removes a generic object from the scene graph.
| object | Object to detach; memory is NOT freed. |
|
virtual |
Serialises the scene to JSON.
| void kemena::kScene::setActive | ( | bool | newActive | ) |
Activates or deactivates this scene.
| newActive | false to skip this scene during rendering. |
| void kemena::kScene::setAmbientLightColor | ( | kVec3 | newColor | ) |
Sets the scene-level ambient light colour.
| newColor | RGB ambient colour. |
| void kemena::kScene::setAssetManager | ( | kAssetManager * | manager | ) |
Sets the asset manager used to load resources into this scene.
| manager | Pointer to the asset manager; must outlive the scene. |
|
inline |
Enable or disable frustum culling for this scene (default: enabled).
| void kemena::kScene::setIncrement | ( | unsigned int | newIncrement | ) |
Sets the auto-increment counter (used when deserialising).
| newIncrement | New counter value. |
| void kemena::kScene::setName | ( | kString | newName | ) |
Sets the human-readable scene name.
| newName | New name kString. |
| void kemena::kScene::setShadowBias | ( | float | bias | ) |
Sets the constant shadow bias used by lit shaders. Larger values reduce acne but can detach the shadow from its caster (peter-panning).
| void kemena::kScene::setShadowMapResolution | ( | int | resolution | ) |
Sets the per-cascade shadow map resolution (e.g. 512, 1024, 2048, 4096). Reallocates the shadow texture on the renderer.
| void kemena::kScene::setShadowNormalBias | ( | float | bias | ) |
Sets the slope-scaled component of the shadow bias. Multiplied by (1 - N·L); only affects grazing-angle surfaces.
| void kemena::kScene::setShadowsEnabled | ( | bool | enabled | ) |
Toggles shadow rendering for this scene.
| void kemena::kScene::setShadowSoftness | ( | float | softness | ) |
Sets the PCF tap spacing in shadow-map texels. Larger = softer edges but more bleeding of small occluders.
Sets the skybox material and mesh.
| newMaterial | Material with a cube-map texture. |
| newMesh | Unit-cube mesh used to render the skybox. |
| void kemena::kScene::setSkyboxAmbientEnabled | ( | bool | enabled | ) |
Enables or disables skybox image-based ambient lighting.
| void kemena::kScene::setSkyboxAmbientStrength | ( | float | strength | ) |
Sets the skybox ambient strength multiplier.
| void kemena::kScene::setUuid | ( | kString | newUuid | ) |
Sets the UUID of this scene.
| newUuid | UUID v4 kString. |
| void kemena::kScene::setWorld | ( | kWorld * | newWorld | ) |
Associates this scene with a parent world.
| newWorld | Owning world instance. |