9#ifndef AVARA3D_APPLICATION_H
10#define AVARA3D_APPLICATION_H
16#include "a3d/Runner.h"
17#include "a3d/SimulationConfig.h"
18#include "a3d/input/InputContext.h"
19#include "a3d/physics/PhysicsWorld.h"
20#include "a3d/physics/PhysicsContact.h"
21#include "a3d/scene/Scene.h"
22#include "a3d/util/Timer.h"
23#include "a3d/visual/VisualWorld.h"
62 static int Run(std::unique_ptr<Application> application);
76 Application(
int argc,
char* argv[], log::Level logLevel = log::Level::Info);
103 virtual std::unique_ptr<Scene>
init() = 0;
176 const std::vector<std::string>&
args()
const;
255 void initLog(log::Level level);
258 void shutdown() noexcept;
259 void registerCallbacks();
274 std::vector<std::
string> _args;
275 std::unique_ptr<
Scene> _scene;
276 std::unique_ptr<
Runner> _runner;
280 util::Timer _startupTimer;
Base class and top-level entry point for A3D applications.
void queueScenePostStepCommand(SceneCommand command)
Queues command to run after the next simulation step.
virtual void inputDidUpdate(Runner &runner, Scene &scene, InputContext &inputContext, const InputContext::UpdateInfo &)
Called after the InputContext has processed the current host update.
virtual void sceneDidStep(Runner &runner, Scene &scene, const Scene::StepInfo &info)
Called immediately after each Scene simulation step.
Runner & runner()
Returns the application's Runner after initialization.
virtual bool shouldContinue(const Scene &scene)
Determines whether the application host loop should continue.
virtual SimulationConfig simulationConfig() const
Supplies the initial simulation scheduling configuration.
virtual void runnerUpdate(Runner &runner, Scene &scene, const Runner::UpdateInfo &info)
Called near the beginning of each Runner host update.
void queueScenePreStepCommand(SceneCommand command)
Queues command to run before the next simulation step.
const std::vector< std::string > & args() const
Returns process command-line arguments excluding the executable name.
Application(int argc, char *argv[], log::Level logLevel=log::Level::Info)
Creates application state from process arguments and configures logging.
virtual void sceneWillStep(Runner &runner, Scene &scene, const Scene::StepInfo &info)
Called immediately before each Scene simulation step.
virtual void contactDidBegin(Runner &runner, Scene &scene, PhysicsWorld &physicsWorld, const PhysicsContact &contact)
Called when the PhysicsWorld reports the beginning of a contact.
static int Run(std::unique_ptr< Application > application)
Runs application using the platform host loop.
Scene & scene()
Returns the application's Scene after initialization.
const Scene & scene() const
Returns the application's Scene after initialization.
std::function< void(Scene &)> SceneCommand
Callable queued for execution at a simulation-step boundary.
virtual void contactDidEnd(Runner &runner, Scene &scene, PhysicsWorld &physicsWorld, const PhysicsContact &contact)
Called when the PhysicsWorld reports the end of a contact.
virtual void contactDidContinue(Runner &runner, Scene &scene, PhysicsWorld &physicsWorld, const PhysicsContact &contact)
Called when the PhysicsWorld reports a continuing contact.
const Runner & runner() const
Returns the application's Runner after initialization.
virtual std::unique_ptr< Scene > init()=0
Creates the initial Scene for the application.
virtual void frameDidBegin(Runner &runner, Scene &scene, VisualWorld &visualWorld, const VisualWorld::RenderInfo &info)
Called after a render frame begins and before scene traversal and drawing.
virtual void didShutdown()
Called after the Runner and Scene have been destroyed during shutdown.
Base interface for Scene input state updated once per Runner host update.
Simulates rigid bodies and performs physics collision queries for a Scene.
Drives host updates, fixed-step simulation, and rendering for a Scene.
Owns a scene graph and the worlds used to simulate and render it.
Manages the visual presentation, camera, and visual queries for a Scene.
Timing information for one input update.
Timing information supplied to each host update callback.
Timing information for one simulation step.
Initial simulation scheduling parameters supplied to a Runner.
Timing and progression information associated with a rendered frame.