Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Rendering::RenderObject Class Reference

Top-level scene object combining a world transform with renderable content. More...

#include <RenderObject.hpp>

Inheritance diagram for Infinity::Types::Rendering::RenderObject:
[legend]
Collaboration diagram for Infinity::Types::Rendering::RenderObject:
[legend]

Public Member Functions

 RenderObject ()
 Default constructor.
 
virtual ~RenderObject ()
 Destructor.
 
std::unique_ptr< Core::Baseclone () const override
 
const Infinity::Types::TypeIDtypeId () const override
 Gets the TypeID for RenderObject.
 
- Public Member Functions inherited from Infinity::Types::Core::Data
 Data ()
 
 Data (const Data &other)
 
 Data (Data &&other)
 
Dataoperator= (const Data &other)
 
Dataoperator= (Data &&other)
 
virtual ~Data ()
 Virtual destructor.
 
bool hasProperty (const std::string &key) const
 
template<typename T >
void setProperty (const std::string &key, T &&value)
 Sets a typed property value.
 
template<typename T >
void setProperty (const std::string &key, const T &value)
 Sets a typed property value.
 
void setProperty (const std::string &key, PropertyValue &&value)
 Sets a typed property value.
 
const PropertyValuegetProperty (const std::string &key) const
 Gets a property value without type checking.
 
template<typename T >
const T & getProperty (const std::string &key) const
 Gets a typed property value.
 
void removeProperty (const std::string &key)
 
- Public Member Functions inherited from Infinity::Types::Core::Base
virtual ~Base ()
 Virtual destructor.
 
virtual std::istream & legibleDataRead (std::istream &in) override
 Deserializes the object from a single-line text representation.
 
virtual std::ostream & legibleDataWrite (std::ostream &out) const override
 Serializes the object to a single-line text representation.
 

Public Attributes

Spatial::Transform transform
 World-space transform for this object.
 
Renderable renderable
 Renderable content (geometry, materials, instances).
 
- Public Attributes inherited from Infinity::Types::Core::Data
std::unordered_map< std::string, PropertyValueproperties
 Property storage for arbitrary metadata.
 

Detailed Description

Top-level scene object combining a world transform with renderable content.

RenderObject represents a complete object in the scene hierarchy, combining a world-space Transform with a Renderable (geometry, materials, and optional instances). This is the highest-level rendering primitive in the Infinity Engine, representing objects as they exist in the scene with both their spatial properties and visual representation.

The distinction between RenderObject and Renderable:

This two-level transform hierarchy enables:

  • Positioning complex multi-instance objects in the scene
  • Hierarchical transformations (object transform + instance offsets)
  • Scene graph organization
  • Efficient culling at object level
  • LOD switching for entire objects

Common use cases:

  • Scene composition from procedural generation
  • Placing procedurally generated objects in the world
  • Building complex scenes from renderable components
  • Hierarchical object organization
  • Terrain chunks as positioned scene objects
  • Specialized rendering types (Landscape inherits from RenderObject)
Note
RenderObject.transform applies to the entire Renderable.
Renderable.instances[i] transforms are relative to RenderObject.transform.
Final instance position = RenderObject.transform * Renderable.instances[i].
Landscape and other specialized types inherit from RenderObject.

Example usage:

// Create a positioned building
RenderObject building;
building.transform.position = Vector3{100.0f, 0.0f, 50.0f};
building.transform.rotation = quaternionFromEuler(0, 45, 0);
// Set up renderable with multi-material mesh
building.renderable.mesh = generateBuildingMesh();
building.renderable.materials.push_back(brickMaterial);
building.renderable.materials.push_back(glassMaterial);
building.renderable.materials.push_back(roofMaterial);
// Positioned forest (object transform + instanced trees)
RenderObject forest;
forest.transform.position = Vector3{-200.0f, 0.0f, 300.0f};
forest.renderable.mesh = treeMesh;
forest.renderable.materials.push_back(treeMaterial);
// Tree instances are relative to forest position
for (int i = 0; i < 100; ++i) {
Spatial::Transform treeInstance;
treeInstance.position = Vector3{
randomFloat(-50.0f, 50.0f), // Relative to forest.transform
0.0f,
randomFloat(-50.0f, 50.0f)
};
treeInstance.rotation = quaternionFromEuler(0, randomFloat(0, 360), 0);
forest.renderable.instances.push_back(treeInstance);
}
// Procedural scene generation
Array<RenderObject> scene;
// Add terrain chunk
RenderObject terrain;
terrain.transform.position = Vector3{0, 0, 0};
terrain.renderable = generateTerrainChunk(chunkX, chunkZ);
scene.push_back(std::move(terrain));
// Add scattered rocks
for (const auto& rockPosition : scatterPoints) {
rock.transform.position = rockPosition;
rock.transform.rotation = randomRotation();
rock.transform.scale = Vector3{randomFloat(0.5f, 2.0f)};
rock.renderable.mesh = rockMesh;
rock.renderable.materials.push_back(rockMaterial);
scene.push_back(std::move(rock));
}
// Hierarchical transform example
// Final tree position = forest.transform * treeInstance.transform
// If forest is at (100, 0, 200) and tree instance at (10, 0, 5):
// Final tree world position ≈ (110, 0, 205) (plus rotation/scale)
// Specialized types (Landscape extends RenderObject)
Landscape terrainChunk;
terrainChunk.transform.position = Vector3{512.0f, 0.0f, 512.0f};
terrainChunk.heightmap = generateHeightmap();
// terrainChunk.renderable contains the terrain mesh
// Use with ProceduralSystem
system->setIn("scene_objects", std::move(scene));
Top-level scene object combining a world transform with renderable content.
Definition RenderObject.hpp:114
Renderable renderable
Renderable content (geometry, materials, instances).
Definition RenderObject.hpp:137
Spatial::Transform transform
World-space transform for this object.
Definition RenderObject.hpp:128
Mesh mesh
Mesh geometry for this renderable.
Definition Renderable.hpp:135
Containers::Array< Material > materials
Array of materials applied to the mesh.
Definition Renderable.hpp:146
Containers::Array< Spatial::Transform > instances
Array of transform instances for instanced rendering.
Definition Renderable.hpp:162
t_Vector3< float > Vector3
Alias for t_Vector3<float>, the default 3D vector type.
Definition Vector3.hpp:580
Complete 3D spatial transformation combining position, rotation, and scale.
Definition Transform.hpp:84
Infinity::Types::Math::Vector4 rotation
Orientation as a quaternion.
Definition Transform.hpp:104
Infinity::Types::Math::Vector3 position
World-space position (translation).
Definition Transform.hpp:91

Constructor & Destructor Documentation

◆ RenderObject()

Infinity::Types::Rendering::RenderObject::RenderObject ( )

Default constructor.

Creates an empty render object with identity transform and empty renderable.

◆ ~RenderObject()

virtual Infinity::Types::Rendering::RenderObject::~RenderObject ( )
virtual

Destructor.

Member Function Documentation

◆ clone()

std::unique_ptr< Core::Base > Infinity::Types::Rendering::RenderObject::clone ( ) const
overridevirtual

Reimplemented from Infinity::Types::Core::Data.

◆ typeId()

const Infinity::Types::TypeID & Infinity::Types::Rendering::RenderObject::typeId ( ) const
overridevirtual

Gets the TypeID for RenderObject.

Returns
TypeID identifying this RenderObject type.

Reimplemented from Infinity::Types::Core::Data.

Member Data Documentation

◆ renderable

Renderable Infinity::Types::Rendering::RenderObject::renderable

Renderable content (geometry, materials, instances).

Contains the mesh, materials, and optional instance transforms that define what and how this object renders. The renderable's instances are positioned relative to this RenderObject's transform.

◆ transform

Spatial::Transform Infinity::Types::Rendering::RenderObject::transform

World-space transform for this object.

Defines the position, rotation, and scale of this object in world space. This transform is applied to the entire renderable, including all its instances.

If the renderable has instances, their transforms are relative to this transform, creating a two-level hierarchy: