Avara3D 0.2.0
C++ API reference
a3d::ext::TurntableCameraController Class Reference

Provides orbit, pan, and dolly control around a world-space or Node-relative target. More...

#include <a3d/extension/camera/TurntableCameraController.h>

Classes

struct  Config
 Limits, sensitivities, and input bindings used by the controller. More...
 
struct  Controls
 Pointer buttons and modifier keys used for camera manipulation. More...
 
struct  NodeTarget
 Target point expressed in the local coordinates of a weakly referenced Node. More...
 
struct  PointerClick
 Pointer click reported when a configured button is released without becoming a drag. More...
 
struct  UpdateResult
 Results produced by one input update. More...
 
struct  View
 Camera orbit state around a target. More...
 

Public Types

using Target = std::variant< math::vec3, NodeTarget >
 Orbit target represented by either a fixed world position or a Node-relative point. More...
 

Public Member Functions

 TurntableCameraController ()
 Creates a controller with the default configuration and View. More...
 
 TurntableCameraController (const Config &config)
 Creates a controller with config and the default View. More...
 
const Configconfig () const
 Returns the current controller configuration. More...
 
void config (const Config &config)
 Replaces the controller configuration and clamps the current View to its new limits. More...
 
const Viewview () const
 Returns the current orbit View. More...
 
void view (const View &view)
 Replaces the orbit View, clamping pitch and distance to the configured limits. More...
 
void target (const math::vec3 &worldPosition)
 Sets a fixed world-space orbit target. More...
 
void target (const std::shared_ptr< Node > &node)
 Sets the orbit target to the local origin of node. More...
 
void target (const std::shared_ptr< Node > &node, const math::vec3 &localPosition)
 Sets the orbit target to localPosition in node coordinates. More...
 
UpdateResult update (DesktopInputContext &input, float vFov, float viewportHeight)
 Updates the View from pointer-button, pointer-motion, and scroll input. More...
 
void apply (Node &pov)
 Applies the current View to pov so it looks at the resolved target. More...
 

Detailed Description

Provides orbit, pan, and dolly control around a world-space or Node-relative target.

update() consumes DesktopInputContext state and changes the controller's View; apply() then positions and orients a supplied point-of-view Node from that View. A Node-relative target is retained weakly and follows the selected local point while the Node exists. If it later expires, the controller preserves the last resolved world-space target position.

Definition at line 36 of file TurntableCameraController.h.

Member Typedef Documentation

◆ Target

Orbit target represented by either a fixed world position or a Node-relative point.

Definition at line 49 of file TurntableCameraController.h.

Constructor & Destructor Documentation

◆ TurntableCameraController() [1/2]

a3d::ext::TurntableCameraController::TurntableCameraController ( )

Creates a controller with the default configuration and View.

◆ TurntableCameraController() [2/2]

a3d::ext::TurntableCameraController::TurntableCameraController ( const Config config)
explicit

Creates a controller with config and the default View.

Exceptions
std::invalid_argumentif config is invalid.

Member Function Documentation

◆ apply()

void a3d::ext::TurntableCameraController::apply ( Node pov)

Applies the current View to pov so it looks at the resolved target.

The resulting world transform is converted into parent coordinates when the POV has a parent. Node-relative targets are resolved again each time apply() is called.

◆ config() [1/2]

const Config & a3d::ext::TurntableCameraController::config ( ) const

Returns the current controller configuration.

◆ config() [2/2]

void a3d::ext::TurntableCameraController::config ( const Config config)

Replaces the controller configuration and clamps the current View to its new limits.

Exceptions
std::invalid_argumentif config is invalid.

◆ target() [1/3]

void a3d::ext::TurntableCameraController::target ( const math::vec3 worldPosition)

Sets a fixed world-space orbit target.

◆ target() [2/3]

void a3d::ext::TurntableCameraController::target ( const std::shared_ptr< Node > &  node)

Sets the orbit target to the local origin of node.

The Node is retained weakly.

Exceptions
std::invalid_argumentif node is null.

◆ target() [3/3]

void a3d::ext::TurntableCameraController::target ( const std::shared_ptr< Node > &  node,
const math::vec3 localPosition 
)

Sets the orbit target to localPosition in node coordinates.

The Node is retained weakly and the target follows changes to its world transform.

Exceptions
std::invalid_argumentif node is null.

◆ update()

UpdateResult a3d::ext::TurntableCameraController::update ( DesktopInputContext input,
float  vFov,
float  viewportHeight 
)

Updates the View from pointer-button, pointer-motion, and scroll input.

The orbit button normally orbits, or pans/dollies when the configured modifier was held when the button was pressed. The dedicated pan button always pans. A button released before crossing dragThreshold is reported as a click instead. This function changes controller state only; call apply() to update a POV Node.

Parameters
inputCurrent desktop-style input state.
vFovVertical camera field of view in radians.
viewportHeightLogical viewport height used to scale panning.
Returns
Input-processing results for this update.
Exceptions
std::invalid_argumentif vFov or viewportHeight is invalid.

◆ view() [1/2]

const View & a3d::ext::TurntableCameraController::view ( ) const

Returns the current orbit View.

◆ view() [2/2]

void a3d::ext::TurntableCameraController::view ( const View view)

Replaces the orbit View, clamping pitch and distance to the configured limits.

A NodeTarget must contain a live Node at the time the View is assigned.

Exceptions
std::invalid_argumentif the View or its target is invalid.

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