Avara3D 0.2.0
C++ API reference
Wanderer.h
1//
2// Wanderer.h
3// avara3d
4//
5// Created by Morgan Davis on 8/12/26.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_EXTENSION_WANDERER_H
10#define AVARA3D_EXTENSION_WANDERER_H
11
12#include <cstdint>
13#include <memory>
14#include <random>
15
16#include "a3d/Math.h"
17
18namespace a3d {
19
20 class Node;
21
22}
23
24namespace a3d::ext {
25
31 class Wanderer {
32
33 public:
34 // [Public Types]
35
37 struct Config {
38
40 1.0f, 1.0f,
41 1.0f};
43 3.0};
44 std::uint32_t seed {0};
45 };
46
47 // [Public Lifecycle Functions]
48
54 explicit Wanderer(const std::shared_ptr<Node>& node);
55
61 Wanderer(const std::shared_ptr<Node>& node, const Config& config);
62
63 // [Public Member Functions]
64
66 const Config& config() const;
67
73 void config(const Config& config);
74
76 const math::vec3& center() const;
77
79 void update(double deltaTime);
80
82 void reset();
83
85 void recenter();
86
87 private:
88 // [Private Member Functions]
89
90 void initializePath();
91 void advancePath();
92
93 math::vec3 randomPoint();
94 math::vec3 randomOffset(float scale);
95
96 // [Private Member Variables]
97
98 std::weak_ptr<Node> _node;
99
100 Config _config;
101 std::mt19937 _random;
102
103 math::vec3 _center;
104
105 math::vec3 _p0;
106 math::vec3 _p1;
107 math::vec3 _p2;
108 math::vec3 _p3;
109
110 double _phase {0.0};
111 };
112
113}
114
115#endif // AVARA3D_EXTENSION_WANDERER_H
Moves a Node along a smooth deterministic path within a configurable box.
Definition: Wanderer.h:31
const Config & config() const
Returns the current configuration.
void recenter()
Makes the Node's current position the new center and restarts the deterministic path.
Wanderer(const std::shared_ptr< Node > &node, const Config &config)
Creates a Wanderer centered on node's current position using config.
void update(double deltaTime)
Advances the wander path by deltaTime seconds; non-positive values do nothing.
void reset()
Returns the Node to the current center and restarts the same deterministic path.
const math::vec3 & center() const
Returns the center of the wander volume in the Node's parent coordinate space.
void config(const Config &config)
Replaces the configuration and restarts the deterministic path from the current center.
Wanderer(const std::shared_ptr< Node > &node)
Creates a Wanderer centered on node's current position using the default Config.
Configures the wander volume, pace, and deterministic random sequence.
Definition: Wanderer.h:37
double segmentDuration
Seconds between successive spline control points; must be greater than zero.
Definition: Wanderer.h:42
std::uint32_t seed
Random seed; the same seed produces the same path.
Definition: Wanderer.h:44
math::vec3 halfExtents
Half-size of the wander box; components must be non-negative. Zero locks an axis.
Definition: Wanderer.h:39