|
Kemena3D
|
Base scene-graph node. More...
#include <kobject.h>

Public Member Functions | |
| kObject (kObject *parentNode=nullptr) | |
| Constructs a kObject and optionally attaches it to a parent. | |
| virtual | ~kObject () |
| Destroys the object. | |
| kObject * | getParent () |
| Returns the parent node. | |
| void | setParent (kObject *newParent) |
Reparents this object under newParent. | |
| void | detachFromParent () |
| Removes this object from its parent's children list. | |
| void | setParentKeepTransform (kObject *newParent) |
| Reparents this object while keeping its world transform. | |
| std::vector< kObject * > | getChildren () |
| Returns the list of direct children. | |
| std::vector< kScript > & | getScripts () |
| Returns a mutable reference to the list of attached scripts. | |
| void | addScript (const kScript &script) |
| Appends a script descriptor to this object. | |
| void | removeScript (const kString &uuid) |
| Removes the script with the given UUID from this object. | |
| std::vector< kParticle > & | getParticles () |
| Returns a mutable reference to the list of attached particle systems. | |
| void | addParticle (const kParticle &particle) |
| Appends a particle system descriptor to this object. | |
| void | removeParticle (const kString &uuid) |
| Removes the particle system with the given UUID from this object. | |
| std::vector< kAudioSource > & | getAudioSources () |
| Returns a mutable reference to the list of attached audio sources. | |
| void | addAudioSource (const kAudioSource &source) |
| Appends an audio source descriptor to this object. | |
| void | removeAudioSource (const kString &uuid) |
| Removes the audio source with the given UUID from this object. | |
| std::vector< kAudioListener > & | getAudioListeners () |
| Returns a mutable reference to the list of audio listener components (0 or 1). | |
| void | addAudioListener (const kAudioListener &listener) |
| Attaches an audio listener descriptor to this object. | |
| void | removeAudioListener (const kString &uuid) |
| Removes the audio listener with the given UUID from this object. | |
| bool | getHasPhysicsDesc () const |
| Returns true if this object has a physics body descriptor configured. | |
| void | setHasPhysicsDesc (bool val) |
| Sets whether this object has a physics body descriptor. | |
| kPhysicsObjectDesc & | getPhysicsDesc () |
| Returns a mutable reference to the physics body descriptor. | |
| bool | getHasCharacterDesc () const |
| Returns true if this object has a character controller configured. | |
| void | setHasCharacterDesc (bool val) |
| Sets whether this object has a character controller descriptor. | |
| kCharacterControllerDesc & | getCharacterDesc () |
| Returns a mutable reference to the character controller descriptor. | |
| bool | getHasNavMeshDesc () const |
| Returns true if this object carries a navigation surface. | |
| void | setHasNavMeshDesc (bool val) |
| Sets whether this object carries a navigation surface. | |
| kNavMeshDesc & | getNavMeshDesc () |
| Returns a mutable reference to the navigation surface descriptor. | |
| kNodeType | getType () |
| Returns the scene-graph node type tag. | |
| void | setType (kNodeType newType) |
| Sets the node type tag. | |
| bool | getActive () |
| Returns whether this object is active (visible/processed). | |
| void | setActive (bool newActive) |
| Activates or deactivates the object. | |
| bool | getStatic () |
| Returns whether this object is marked as static (immobile geometry). | |
| void | setStatic (bool newStatic) |
| Marks the object as static or dynamic. | |
| bool | getDebugMode () |
| Returns whether editor debug visualization is enabled. | |
| void | setDebugMode (bool newMode) |
| Enables or disables editor debug visualization for this object. | |
| unsigned int | getId () |
| Returns the numeric identifier of this object. | |
| void | setId (unsigned int newId) |
| Sets the numeric identifier. | |
| kString | getUuid () |
| Returns the UUID kString of this object. | |
| void | setUuid (kString newUuid) |
| Sets the UUID kString. | |
| kString | getName () |
| Returns the display name of this object. | |
| void | setName (kString newName) |
| Sets the display name. | |
| kString | getPrefabRef () const |
| Returns the prefab asset UUID this object is an instance of, or empty. | |
| void | setPrefabRef (const kString &ref) |
| Sets the prefab asset UUID this object is an instance of. | |
| kString | getTemplateUuid () const |
| Returns the UUID of the corresponding node in the prefab template. | |
| void | setTemplateUuid (const kString &uuid) |
| Sets the corresponding template UUID for this prefab instance node. | |
| kVec3 | getPosition () |
| Returns the local position. | |
| virtual void | setPosition (kVec3 newPosition) |
| Sets the local position. | |
| kQuat | getRotation () |
| Returns the local rotation as a quaternion. | |
| kVec3 | getRotationEuler () |
| Returns the local rotation as Euler angles in degrees. | |
| virtual void | setRotation (kQuat newRotation) |
| Sets the local rotation from a quaternion. | |
| kVec3 | getScale () |
| Returns the local scale. | |
| virtual void | setScale (kVec3 newScale) |
| Sets the local scale. | |
| kVec3 | calculateRight () |
| Computes the local right (+X) direction in world space. | |
| kVec3 | calculateForward () |
| Computes the local forward (-Z) direction in world space. | |
| kVec3 | calculateUp () |
| Computes the local up (+Y) direction in world space. | |
| void | rotate (kVec3 rotationAxis, float angularSpeed) |
| Rotates the object around an axis by a given angular speed. | |
| kVec3 | getGlobalPosition () |
| Returns the world-space position derived from the world transform. | |
| kQuat | getGlobalRotation () |
| Returns the world-space rotation derived from the world transform. | |
| kVec3 | getGlobalScale () |
| Returns the world-space scale derived from the world transform. | |
| void | setMaterial (kMaterial *newMaterial, bool setChildren=true) |
| Assigns a material to this object and optionally its children. | |
| kMaterial * | getMaterial () |
| Returns the assigned material. | |
| void | setMaterialUuid (const kString &uuid) |
| Sets the source asset UUID of the assigned material. | |
| kString | getMaterialUuid () const |
| Returns the source asset UUID of the assigned material. | |
| void | setImportChild (bool v) |
| Marks this node as an import-derived sub-mesh. | |
| bool | getImportChild () const |
| Whether this node is an import-derived sub-mesh (see setImportChild). | |
| void | calculateModelMatrix () |
| Recomputes the local and world-space model matrices. | |
| kMat4 | getModelMatrixWorld () |
| Returns the world-space model matrix. | |
| kMat4 | getModelMatrixLocal () |
| Returns the local model matrix (relative to the parent). | |
| virtual void | draw () |
| Draws the object. | |
| virtual json | serialize () |
| Serialises the object to a JSON value. | |
| virtual void | deserialize (json data) |
| Restores the object state from a JSON value. | |
| void | attachPhysics (kPhysicsObject *physicsObj) |
| Attaches a physics body to this object. | |
| void | detachPhysics () |
| Detaches the physics body without destroying it. | |
| kPhysicsObject * | getPhysicsObject () |
| Returns the attached physics body, or nullptr if none is attached. | |
| void | syncFromPhysics () |
| Copies the physics body's current position and rotation into this object's local transform. | |
| void | attachCharacter (kCharacterController *character) |
| Attaches a runtime character controller to this object. | |
| void | detachCharacter () |
| Detaches the character controller without destroying it. | |
| kCharacterController * | getCharacterController () |
| Returns the attached character controller, or nullptr. | |
| void | syncFromCharacter () |
| Copies the character controller's position into this object's local transform. Call once per frame after the physics update. | |
Base scene-graph node.
Every entity in the world hierarchy — meshes, lights, cameras, and plain empty objects — derives from kObject. It manages parent/child relationships, a local and world-space transform, an optional material, and a list of attached AngelScript scripts.
| kemena::kObject::kObject | ( | kObject * | parentNode = nullptr | ) |
Constructs a kObject and optionally attaches it to a parent.
| parentNode | Parent to attach to, or nullptr for a root node. |


|
virtual |
Destroys the object.
Virtual to allow correct destruction through a kObject* pointer to a derived node. Does not delete attached children or the physics body.
| void kemena::kObject::addAudioListener | ( | const kAudioListener & | listener | ) |
Attaches an audio listener descriptor to this object.
| listener | Descriptor to add. |
| void kemena::kObject::addAudioSource | ( | const kAudioSource & | source | ) |
Appends an audio source descriptor to this object.
| source | Descriptor to add. |
| void kemena::kObject::addParticle | ( | const kParticle & | particle | ) |
Appends a particle system descriptor to this object.
| particle | Descriptor to add. |
| void kemena::kObject::addScript | ( | const kScript & | script | ) |
Appends a script descriptor to this object.
| script | Descriptor to add (uuid and fileName should be set by the caller). |
| void kemena::kObject::attachCharacter | ( | kCharacterController * | character | ) |
Attaches a runtime character controller to this object.
Ownership stays with kPhysicsManager (destroy via destroyCharacter()).
| void kemena::kObject::attachPhysics | ( | kPhysicsObject * | physicsObj | ) |
Attaches a physics body to this object.
The kObject does NOT take ownership of physicsObj — it must be managed (and destroyed) via kPhysicsManager::destroyObject().
| physicsObj | Physics body created by kPhysicsManager::createObject(). |
| kVec3 kemena::kObject::calculateForward | ( | ) |
Computes the local forward (-Z) direction in world space.
| void kemena::kObject::calculateModelMatrix | ( | ) |
Recomputes the local and world-space model matrices.
Combines position, rotation, and scale into localTransform, then multiplies by the parent's world transform to produce worldTransform.
| kVec3 kemena::kObject::calculateRight | ( | ) |
Computes the local right (+X) direction in world space.
| kVec3 kemena::kObject::calculateUp | ( | ) |
Computes the local up (+Y) direction in world space.
|
virtual |
Restores the object state from a JSON value.
| data | JSON object produced by serialize(). |
Reimplemented in kemena::kCamera, and kemena::kMesh.
| void kemena::kObject::detachCharacter | ( | ) |
Detaches the character controller without destroying it.
| void kemena::kObject::detachFromParent | ( | ) |
Removes this object from its parent's children list.
The object is not deleted; its parent pointer is set to nullptr. Has no effect if the object has no parent.
| void kemena::kObject::detachPhysics | ( | ) |
Detaches the physics body without destroying it.
|
virtual |
Draws the object.
For base kObject (non-mesh, non-light) nodes this renders a billboard icon quad. Derived classes override this for their own geometry.
Reimplemented in kemena::kMesh.
| bool kemena::kObject::getActive | ( | ) |
Returns whether this object is active (visible/processed).
| std::vector< kAudioListener > & kemena::kObject::getAudioListeners | ( | ) |
Returns a mutable reference to the list of audio listener components (0 or 1).
| std::vector< kAudioSource > & kemena::kObject::getAudioSources | ( | ) |
Returns a mutable reference to the list of attached audio sources.
| kCharacterController * kemena::kObject::getCharacterController | ( | ) |
Returns the attached character controller, or nullptr.
| kCharacterControllerDesc & kemena::kObject::getCharacterDesc | ( | ) |
Returns a mutable reference to the character controller descriptor.
| std::vector< kObject * > kemena::kObject::getChildren | ( | ) |
Returns the list of direct children.
| bool kemena::kObject::getDebugMode | ( | ) |
Returns whether editor debug visualization is enabled.
| kVec3 kemena::kObject::getGlobalPosition | ( | ) |
Returns the world-space position derived from the world transform.
| kQuat kemena::kObject::getGlobalRotation | ( | ) |
Returns the world-space rotation derived from the world transform.
| kVec3 kemena::kObject::getGlobalScale | ( | ) |
Returns the world-space scale derived from the world transform.
| bool kemena::kObject::getHasCharacterDesc | ( | ) | const |
Returns true if this object has a character controller configured.
| bool kemena::kObject::getHasNavMeshDesc | ( | ) | const |
Returns true if this object carries a navigation surface.
| bool kemena::kObject::getHasPhysicsDesc | ( | ) | const |
Returns true if this object has a physics body descriptor configured.
| unsigned int kemena::kObject::getId | ( | ) |
Returns the numeric identifier of this object.
|
inline |
Whether this node is an import-derived sub-mesh (see setImportChild).
| kMaterial * kemena::kObject::getMaterial | ( | ) |
Returns the assigned material.
|
inline |
Returns the source asset UUID of the assigned material.
| kMat4 kemena::kObject::getModelMatrixLocal | ( | ) |
Returns the local model matrix (relative to the parent).
| kMat4 kemena::kObject::getModelMatrixWorld | ( | ) |
Returns the world-space model matrix.
| kString kemena::kObject::getName | ( | ) |
Returns the display name of this object.
| kNavMeshDesc & kemena::kObject::getNavMeshDesc | ( | ) |
Returns a mutable reference to the navigation surface descriptor.
| kObject * kemena::kObject::getParent | ( | ) |
Returns the parent node.

| std::vector< kParticle > & kemena::kObject::getParticles | ( | ) |
Returns a mutable reference to the list of attached particle systems.
| kPhysicsObjectDesc & kemena::kObject::getPhysicsDesc | ( | ) |
Returns a mutable reference to the physics body descriptor.
Only meaningful when getHasPhysicsDesc() returns true.
| kPhysicsObject * kemena::kObject::getPhysicsObject | ( | ) |
Returns the attached physics body, or nullptr if none is attached.
| kVec3 kemena::kObject::getPosition | ( | ) |
Returns the local position.
| kString kemena::kObject::getPrefabRef | ( | ) | const |
Returns the prefab asset UUID this object is an instance of, or empty.
Non-empty only on the root node of a prefab instance. Set by the editor when instantiating a prefab into a scene.
| kQuat kemena::kObject::getRotation | ( | ) |
Returns the local rotation as a quaternion.
| kVec3 kemena::kObject::getRotationEuler | ( | ) |
Returns the local rotation as Euler angles in degrees.
| kVec3 kemena::kObject::getScale | ( | ) |
Returns the local scale.
| std::vector< kScript > & kemena::kObject::getScripts | ( | ) |
Returns a mutable reference to the list of attached scripts.
| bool kemena::kObject::getStatic | ( | ) |
Returns whether this object is marked as static (immobile geometry).
| kString kemena::kObject::getTemplateUuid | ( | ) | const |
Returns the UUID of the corresponding node in the prefab template.
Set on every node of a prefab instance subtree so the editor can match instance nodes back to their template counterparts.
| kNodeType kemena::kObject::getType | ( | ) |
Returns the scene-graph node type tag.
| kString kemena::kObject::getUuid | ( | ) |
| void kemena::kObject::removeAudioListener | ( | const kString & | uuid | ) |
Removes the audio listener with the given UUID from this object.
| uuid | UUID of the listener to remove. |
| void kemena::kObject::removeAudioSource | ( | const kString & | uuid | ) |
Removes the audio source with the given UUID from this object.
| uuid | UUID of the audio source to remove. |
| void kemena::kObject::removeParticle | ( | const kString & | uuid | ) |
Removes the particle system with the given UUID from this object.
| uuid | UUID of the particle system to remove. |
| void kemena::kObject::removeScript | ( | const kString & | uuid | ) |
Removes the script with the given UUID from this object.
| uuid | UUID of the script to remove. |
| void kemena::kObject::rotate | ( | kVec3 | rotationAxis, |
| float | angularSpeed ) |
Rotates the object around an axis by a given angular speed.
| rotationAxis | World-space rotation axis (normalised). |
| angularSpeed | Rotation magnitude in radians. |
|
virtual |
Serialises the object to a JSON value.
Reimplemented in kemena::kCamera, kemena::kLight, and kemena::kMesh.
| void kemena::kObject::setActive | ( | bool | newActive | ) |
Activates or deactivates the object.
| newActive | false to hide and skip the object during rendering. |
| void kemena::kObject::setDebugMode | ( | bool | newMode | ) |
Enables or disables editor debug visualization for this object.
| newMode | true to draw debug shapes in the editor viewport. |
| void kemena::kObject::setHasCharacterDesc | ( | bool | val | ) |
Sets whether this object has a character controller descriptor.
| val | true = a character is created at game-start. |
| void kemena::kObject::setHasNavMeshDesc | ( | bool | val | ) |
Sets whether this object carries a navigation surface.
| void kemena::kObject::setHasPhysicsDesc | ( | bool | val | ) |
Sets whether this object has a physics body descriptor.
| val | true = descriptor is active and should create a body at game-start. |
| void kemena::kObject::setId | ( | unsigned int | newId | ) |
Sets the numeric identifier.
| newId | New ID value. |
|
inline |
Marks this node as an import-derived sub-mesh.
Sub-meshes produced when loading a model file are reconstructed from that file on every load, so they must not be serialized as children of their parent (doing so would duplicate them). The editor still assigns them a UUID for selection/hierarchy purposes; this flag lets serialize() skip them while keeping authored children intact.
| v | true if this node was created by the model importer. |
| void kemena::kObject::setMaterial | ( | kMaterial * | newMaterial, |
| bool | setChildren = true ) |
Assigns a material to this object and optionally its children.
| newMaterial | Material to assign. |
| setChildren | If true, the same material is assigned to all descendants. |
|
inline |
Sets the source asset UUID of the assigned material.
The runtime kMaterial carries no link back to the .mat asset it was built from, so the editor records the material asset's UUID here. It is serialized with the object so the assignment survives save/load; an empty string means "no material asset assigned".
| uuid | Material asset UUID, or empty string for none. |
| void kemena::kObject::setName | ( | kString | newName | ) |
Sets the display name.
| newName | New name kString. |
| void kemena::kObject::setParent | ( | kObject * | newParent | ) |
Reparents this object under newParent.
| newParent | New parent node. |

| void kemena::kObject::setParentKeepTransform | ( | kObject * | newParent | ) |
Reparents this object while keeping its world transform.
Computes new local position/rotation/scale such that the object's world-space pose is unchanged after switching parents — i.e. the object does not visually jump. Use this for editor reparent operations (drag in the hierarchy, etc.); use the plain setParent() when constructing scenes where the local transform is what you want preserved.
| newParent | New parent node, or nullptr to detach to root space. |

|
virtual |
Sets the local position.
| newPosition | Position in parent space. |
Reimplemented in kemena::kCamera, and kemena::kMesh.
| void kemena::kObject::setPrefabRef | ( | const kString & | ref | ) |
Sets the prefab asset UUID this object is an instance of.
|
virtual |
Sets the local rotation from a quaternion.
| newRotation | Unit quaternion. |
Reimplemented in kemena::kCamera, and kemena::kMesh.
|
virtual |
| void kemena::kObject::setStatic | ( | bool | newStatic | ) |
Marks the object as static or dynamic.
| newStatic | true for immobile objects; false for moving/animated ones. |
| void kemena::kObject::setTemplateUuid | ( | const kString & | uuid | ) |
Sets the corresponding template UUID for this prefab instance node.
| void kemena::kObject::setType | ( | kNodeType | newType | ) |
Sets the node type tag.
| newType | Node type. |
| void kemena::kObject::setUuid | ( | kString | newUuid | ) |
| void kemena::kObject::syncFromCharacter | ( | ) |
Copies the character controller's position into this object's local transform. Call once per frame after the physics update.

| void kemena::kObject::syncFromPhysics | ( | ) |
Copies the physics body's current position and rotation into this object's local transform.
Call this once per frame after kPhysicsManager::update() to keep the scene node in sync with the simulation.
Has no effect if no physics body is attached.