Skip to content

ludus::content::scene_source

Ludus Wiki · API overview · Browse API

Namespace

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

Enumerations

SceneSourceStatus

enum class SceneSourceStatus : uint8
Outcome of ParseSceneSource.

Related types: uint8

Success

Success
The document is valid and the scene is available.

Malformed

Malformed
The text is not JSON, or a member is missing, unknown, repeated or of the wrong type.

UnsupportedVersion

UnsupportedVersion
format is not SCENE_SOURCE_FORMAT, is not the first member, or version is unsupported.

InvalidValue

InvalidValue
A number is out of its documented range, or a name is empty or repeated.

UnresolvedReference

UnresolvedReference
An object names a material the document does not declare.

InvalidGeometry

InvalidGeometry
A polygon has too few or repeated corners, an index out of range, or is not planar and strictly convex.

Limit

Limit
The document exceeds one of the MAX_SCENE_SOURCE_* limits.

OutOfMemory

OutOfMemory
Allocation failed.

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

SourceMaterialModel

enum class SourceMaterialModel : uint8
Reflection model of a source material.

Related types: uint8

Diffuse

Diffuse
Ideal Lambertian reflection of BaseColor ("model": "diffuse").

MetallicRoughness

MetallicRoughness
The engine's metallic-roughness model ("model": "metallic_roughness").

Mix

Mix
Weighted Lambertian and rough conductor reflection ("model": "mix").

ProjectBrdf

ProjectBrdf
Authored cosine-power reflection program ("model": "project_brdf").

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

Constants and variables

SCENE_SOURCE_FORMAT

constexpr std::string_view ludus::content::scene_source::SCENE_SOURCE_FORMAT = "ludus.scene"
Value of the document's format member, which must be its first member.

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

SCENE_SOURCE_VERSION

constexpr uint64 ludus::content::scene_source::SCENE_SOURCE_VERSION = 1
The only document version this reader supports.

Related types: uint64

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

SCENE_SOURCE_EXTENSION

constexpr std::string_view ludus::content::scene_source::SCENE_SOURCE_EXTENSION = ".luscene.json"
Conventional file name suffix of a scene source.

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_BYTES

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_BYTES = usize{16} * 1024 * 1024
Largest accepted document, in bytes.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_TEXT_BYTES

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_TEXT_BYTES = 1024
Longest scene, material or object name and scene description, in bytes.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_MATERIALS

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_MATERIALS = 256
Most materials in one document.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_OBJECTS

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_OBJECTS = 4096
Most objects in one document.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_POLYGON_VERTICES

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_POLYGON_VERTICES = 64
Most vertices of one polygon.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_POSITIONS

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_POSITIONS = usize{1} << 20
Most positions across all objects of one document.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_CORNERS

constexpr usize ludus::content::scene_source::MAX_SCENE_SOURCE_CORNERS = usize{1} << 22
Most polygon corners (index entries) across all objects of one document.

Related types: usize

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

MAX_SCENE_SOURCE_COORDINATE_METRES

constexpr float64 ludus::content::scene_source::MAX_SCENE_SOURCE_COORDINATE_METRES = 1000000.0
Largest absolute position coordinate, in metres; keeps every position exactly representable after narrowing to float32 within the cooked format's range.

Related types: float64

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

Functions

GetSceneSourceStatusName

std::string_view ludus::content::scene_source::GetSceneSourceStatusName(SceneSourceStatus status) noexcept
Return a stable lowercase name for a status, for tools and logs.

Related types: SceneSourceStatus

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

IsSceneSourcePrefix

bool ludus::content::scene_source::IsSceneSourcePrefix(std::string_view prefix) noexcept
Report whether text begins like a scene source.
True when, after optional whitespace, the text opens an object whose first member is "format": "ludus.scene". Every valid document satisfies this, so importers can classify a file from a short prefix without parsing it.
ParameterDescription
prefix
The first bytes of a file; may be truncated anywhere after the format value.

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h

ParseSceneSource

SceneSourceStatus ludus::content::scene_source::ParseSceneSource(std::string_view text, SceneSource &outScene, SceneSourceError &outError) noexcept
Parse and validate a complete scene source document.
Rejects unknown, missing or repeated members, values outside their documented ranges, unresolved material names and polygons that are not planar and strictly convex. Numbers are read as IEEE binary64.
ParameterDescription
text
The whole document, at most MAX_SCENE_SOURCE_BYTES.
outScene
Replaced on success; unchanged on failure.
outError
Set on failure; unchanged on success.

Returns

Success, or the first failure found.

Related types: SceneSourceStatus · SceneSource · SceneSourceError

Declared in modules/content/scene_source/include/ludus/content/scene_source/scene_source.h