Avara3D 0.2.0
C++ API reference
a3d::Scene Class Reference

Owns a scene graph and the worlds used to simulate and render it. More...

#include <a3d/scene/Scene.h>

Classes

struct  StepInfo
 Timing information for one simulation step. More...
 

Public Types

enum class  ImportOptions : uint16_t {
  None = 0 , ImportMeshes = 1 << 0 , ImportMaterials = 1 << 1 , ImportLights = 1 << 2 ,
  ImportCameras = 1 << 3 , ImportAll = UINT16_MAX
}
 Selects which resource categories are imported by FromFile(). More...
 
enum class  DebugOptions : uint32_t {
  None = 0 , ShowStatsOverlay = 1 << 0 , ShowMeshBounds = 1 << 1 , ShowMeshFrames = 1 << 2 ,
  ShowMeshWireframes = 1 << 3 , ShowCameras = 1 << 4 , ShowLights = 1 << 5 , ShowLightExtents = 1 << 6 ,
  ShowPhysicsBounds = 1 << 7 , ShowPhysicsFrames = 1 << 8 , ShowPhysicsWireframes = 1 << 9 , ShowPhysicsContactPoints = 1 << 10 ,
  ShowPhysicsNormals = 1 << 11 , ShowPhysicsConstraints = 1 << 12 , ShowPhysicsConstraintLimits
}
 Scene-wide debug visualization options. More...
 
using WillStepCallback = std::function< void(Scene &scene, const StepInfo &info)>
 Callback invoked immediately before a Scene simulation step. More...
 
using DidStepCallback = std::function< void(Scene &scene, const StepInfo &info)>
 Callback invoked immediately after a Scene simulation step. More...
 

Public Member Functions

 Scene ()
 Creates a Scene with an empty root node and no worlds or input context. More...
 
 Scene (const std::string &name)
 Creates a named Scene with an empty root node and no worlds or input context. More...
 
 Scene (std::unique_ptr< VisualWorld > visualWorld, std::unique_ptr< PhysicsWorld > physicsWorld, std::unique_ptr< InputContext > inputContext)
 Creates a Scene and takes ownership of its optional worlds and input context. More...
 
 Scene (const std::string &name, std::unique_ptr< VisualWorld > visualWorld, std::unique_ptr< PhysicsWorld > physicsWorld, std::unique_ptr< InputContext > inputContext)
 Creates a named Scene and takes ownership of its optional worlds and input context. More...
 
const std::optional< std::string > & name () const
 Returns the optional Scene name. More...
 
void name (const std::string &name)
 Sets the Scene name. More...
 
const std::shared_ptr< Node > & rootNode () const
 Returns the root node of the Scene hierarchy. More...
 
void rootNode (const std::shared_ptr< Node > &node)
 Replaces the root node of the Scene hierarchy. More...
 
VisualWorldvisualWorld () const
 Returns the owned VisualWorld, or nullptr if none is installed. More...
 
void visualWorld (std::unique_ptr< VisualWorld > world)
 Replaces the owned VisualWorld; nullptr removes the current world. More...
 
PhysicsWorldphysicsWorld () const
 Returns the owned PhysicsWorld, or nullptr if none is installed. More...
 
void physicsWorld (std::unique_ptr< PhysicsWorld > world)
 Replaces the owned PhysicsWorld; nullptr removes the current world. More...
 
InputContextinputContext () const
 Returns the owned InputContext, or nullptr if none is installed. More...
 
void inputContext (std::unique_ptr< InputContext > context)
 Replaces the owned InputContext; nullptr removes the current context. More...
 
AABB aabb (bool vertfit=false) const
 Returns the world-space axis-aligned bounding box enclosing the Scene hierarchy. More...
 
math::vec3 extent (bool vertfit=false) const
 Returns the dimensions of the Scene world-space axis-aligned bounding box. More...
 
DebugOptions debugOptions () const
 Returns the enabled Scene debug visualization options. More...
 
void debugOptions (DebugOptions options)
 Sets the enabled Scene debug visualization options. More...
 
WillStepCallback willStepCallback () const
 Returns the callback invoked before each simulation step. More...
 
void willStepCallback (WillStepCallback callback)
 Replaces the callback invoked before each simulation step; an empty callback disables it. More...
 
DidStepCallback didStepCallback () const
 Returns the callback invoked after each simulation step. More...
 
void didStepCallback (DidStepCallback callback)
 Replaces the callback invoked after each simulation step; an empty callback disables it. More...
 

Static Public Member Functions

static std::unique_ptr< SceneFromFile (const std::filesystem::path &path, ImportOptions options=ImportOptions::ImportAll)
 Imports a Scene from path. More...
 

Detailed Description

Owns a scene graph and the worlds used to simulate and render it.

A Scene always has a root Node. VisualWorld, PhysicsWorld, and InputContext are optional and may be installed or replaced independently. Nodes attached beneath the root become part of the Scene hierarchy and can discover the Scene and its currently installed worlds.

Definition at line 44 of file Scene.h.

Member Typedef Documentation

◆ DidStepCallback

using a3d::Scene::DidStepCallback = std::function<void(Scene& scene, const StepInfo& info)>

Callback invoked immediately after a Scene simulation step.

Definition at line 106 of file Scene.h.

◆ WillStepCallback

using a3d::Scene::WillStepCallback = std::function<void(Scene& scene, const StepInfo& info)>

Callback invoked immediately before a Scene simulation step.

Definition at line 103 of file Scene.h.

Member Enumeration Documentation

◆ DebugOptions

enum class a3d::Scene::DebugOptions : uint32_t
strong

Scene-wide debug visualization options.

Enumerator
None 

No scene debug visualization options enabled.

ShowStatsOverlay 

Displays the runtime statistics overlay.

ShowMeshBounds 

Draws bounding boxes for meshes.

ShowMeshFrames 

Draws each mesh's local coordinate frame.

ShowMeshWireframes 

Renders meshes as wireframes.

ShowCameras 

Displays camera debug geometry. Not currently implemented.

ShowLights 

Displays light debug geometry. Not currently implemented.

ShowLightExtents 

Displays light extents. Not currently implemented.

ShowPhysicsBounds 

Draws axis-aligned bounds for physics collision objects.

ShowPhysicsFrames 

Draws coordinate frames for physics bodies.

ShowPhysicsWireframes 

Draws physics collision geometry as wireframes.

ShowPhysicsContactPoints 

Draws physics contact points.

ShowPhysicsNormals 

Draws contact normals.

ShowPhysicsConstraints 

Displays physics constraints. Not currently implemented.

ShowPhysicsConstraintLimits 

Displays physics constraint limits. Not currently implemented.

Definition at line 61 of file Scene.h.

◆ ImportOptions

enum class a3d::Scene::ImportOptions : uint16_t
strong

Selects which resource categories are imported by FromFile().

Enumerator
None 

Import no optional resource categories.

ImportMeshes 

Import meshes.

ImportMaterials 

Import materials.

ImportLights 

Import lights.

ImportCameras 

Import cameras.

ImportAll 

Import all supported resource categories.

Definition at line 50 of file Scene.h.

Constructor & Destructor Documentation

◆ Scene() [1/4]

a3d::Scene::Scene ( )

Creates a Scene with an empty root node and no worlds or input context.

◆ Scene() [2/4]

a3d::Scene::Scene ( const std::string &  name)
explicit

Creates a named Scene with an empty root node and no worlds or input context.

◆ Scene() [3/4]

a3d::Scene::Scene ( std::unique_ptr< VisualWorld visualWorld,
std::unique_ptr< PhysicsWorld physicsWorld,
std::unique_ptr< InputContext inputContext 
)

Creates a Scene and takes ownership of its optional worlds and input context.

Any argument may be nullptr.

◆ Scene() [4/4]

a3d::Scene::Scene ( const std::string &  name,
std::unique_ptr< VisualWorld visualWorld,
std::unique_ptr< PhysicsWorld physicsWorld,
std::unique_ptr< InputContext inputContext 
)

Creates a named Scene and takes ownership of its optional worlds and input context.

Any world or input-context argument may be nullptr.

Member Function Documentation

◆ aabb()

AABB a3d::Scene::aabb ( bool  vertfit = false) const

Returns the world-space axis-aligned bounding box enclosing the Scene hierarchy.

Parameters
vertfitwhen true, fits bounds to transformed mesh vertices; when false, uses transformed local mesh bounds for a faster, potentially looser result.

◆ debugOptions() [1/2]

DebugOptions a3d::Scene::debugOptions ( ) const

Returns the enabled Scene debug visualization options.

◆ debugOptions() [2/2]

void a3d::Scene::debugOptions ( DebugOptions  options)

Sets the enabled Scene debug visualization options.

◆ didStepCallback() [1/2]

DidStepCallback a3d::Scene::didStepCallback ( ) const

Returns the callback invoked after each simulation step.

◆ didStepCallback() [2/2]

void a3d::Scene::didStepCallback ( DidStepCallback  callback)

Replaces the callback invoked after each simulation step; an empty callback disables it.

◆ extent()

math::vec3 a3d::Scene::extent ( bool  vertfit = false) const

Returns the dimensions of the Scene world-space axis-aligned bounding box.

Parameters
vertfitwhen true, fits bounds to transformed mesh vertices; when false, uses transformed local mesh bounds for a faster, potentially looser result.

◆ FromFile()

static std::unique_ptr< Scene > a3d::Scene::FromFile ( const std::filesystem::path &  path,
ImportOptions  options = ImportOptions::ImportAll 
)
static

Imports a Scene from path.

Parameters
pathglTF scene file to import.
optionsresource categories to import.
Returns
The imported Scene.

◆ inputContext() [1/2]

InputContext * a3d::Scene::inputContext ( ) const

Returns the owned InputContext, or nullptr if none is installed.

◆ inputContext() [2/2]

void a3d::Scene::inputContext ( std::unique_ptr< InputContext context)

Replaces the owned InputContext; nullptr removes the current context.

◆ name() [1/2]

const std::optional< std::string > & a3d::Scene::name ( ) const

Returns the optional Scene name.

◆ name() [2/2]

void a3d::Scene::name ( const std::string &  name)

Sets the Scene name.

◆ physicsWorld() [1/2]

PhysicsWorld * a3d::Scene::physicsWorld ( ) const

Returns the owned PhysicsWorld, or nullptr if none is installed.

◆ physicsWorld() [2/2]

void a3d::Scene::physicsWorld ( std::unique_ptr< PhysicsWorld world)

Replaces the owned PhysicsWorld; nullptr removes the current world.

◆ rootNode() [1/2]

const std::shared_ptr< Node > & a3d::Scene::rootNode ( ) const

Returns the root node of the Scene hierarchy.

◆ rootNode() [2/2]

void a3d::Scene::rootNode ( const std::shared_ptr< Node > &  node)

Replaces the root node of the Scene hierarchy.

The old root is detached from this Scene and node is attached in its place.

Exceptions
std::invalid_argumentif node is nullptr.

◆ visualWorld() [1/2]

VisualWorld * a3d::Scene::visualWorld ( ) const

Returns the owned VisualWorld, or nullptr if none is installed.

◆ visualWorld() [2/2]

void a3d::Scene::visualWorld ( std::unique_ptr< VisualWorld world)

Replaces the owned VisualWorld; nullptr removes the current world.

◆ willStepCallback() [1/2]

WillStepCallback a3d::Scene::willStepCallback ( ) const

Returns the callback invoked before each simulation step.

◆ willStepCallback() [2/2]

void a3d::Scene::willStepCallback ( WillStepCallback  callback)

Replaces the callback invoked before each simulation step; an empty callback disables it.


The documentation for this class was generated from the following file: