MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
ViewportPreset.hpp
Go to the documentation of this file.
1#pragma once
2
7
8namespace MayaFlux::Buffers {
9class RenderProcessor;
10}
11
12namespace MayaFlux::Core {
13class Window;
14}
15
16namespace MayaFlux {
17
18/// @brief Alias for backwards compatibility; prefer Kinesis::NavigationConfig in new code.
20
21/**
22 * @enum ViewportPresetMode
23 * @brief Selects which navigation controller bind_viewport_preset installs.
24 *
25 * Each mode registers a distinct set of event handlers and may interpret
26 * ViewportPresetConfig fields differently. Modes not yet implemented emit a
27 * runtime error and return without binding.
28 */
29enum class ViewportPresetMode : uint8_t {
30 Fly, ///< First-person fly: WASD/QE translate, RMB drag yaw/pitch, scroll dolly, KP ortho snaps
31 Orbit, ///< Tumble around a focal point (not yet implemented)
32 PanZoom2D, ///< Orthographic 2D pan and zoom (not yet implemented)
33 Screenspace, ///< Perspective pan in camera's local right/up plane, scroll dolly, no rotation
34 // Trackball, ///< Virtual trackball (not yet implemented)
35};
36
37/**
38 * @brief Bind a navigation preset to a window and render processor using default settings.
39 *
40 * Convenience wrapper that constructs a default config for the selected mode
41 * and forwards to the corresponding bind_*_preset function. To tune the
42 * controller, call bind_fly_preset(), bind_orbit_preset(), or
43 * bind_pan_zoom_preset() directly.
44 *
45 * Registers event handlers under the prefix "vp_<name>_".
46 *
47 * Mode defaults:
48 * Fly - WASD/QE translate, RMB drag yaw/pitch, scroll dolly, KP ortho snaps
49 * Orbit - MMB rotate around focal point, Shift+MMB pan, scroll dolly, KP ortho snaps
50 * PanZoom2D - MMB drag pan, scroll zoom, orthographic projection
51 *
52 * @param window Window supplying input events
53 * @param processor RenderProcessor that receives the ViewTransform source
54 * @param mode Navigation controller to install, defaults to Fly
55 * @param name Unique prefix for registered events; must be unique per window
56 */
57MAYAFLUX_API void bind_viewport_preset(
58 const std::shared_ptr<Core::Window>& window,
59 const std::shared_ptr<Buffers::RenderProcessor>& processor,
61 const std::string& name = "default");
62
63/**
64 * @brief Bind a navigation preset to all RenderProcessors currently registered
65 * against a window using default settings.
66 *
67 * Calls bind_viewport_preset(window, rp, mode, name) for every buffer
68 * registered with the window at call time that returns a non-null RenderProcessor.
69 * Buffers registered after this call are not covered.
70 *
71 * @param window Window supplying input events
72 * @param mode Navigation controller to install, defaults to Fly
73 * @param name Preset name forwarded to bind_viewport_preset()
74 */
75MAYAFLUX_API void bind_viewport_preset(
76 const std::shared_ptr<Core::Window>& window,
78 const std::string& name = "default");
79
80/**
81 * @brief Bind the fly navigation controller to a window and render processor.
82 *
83 * Registers event handlers under the prefix "vp_<name>_". Key assignments
84 * default to WASD/QE translation with KP ortho snaps; pass a FlyKeyMap to
85 * override any or all bindings. Ortho snap slots set to std::nullopt are
86 * silently skipped.
87 *
88 * @param window Window supplying input events
89 * @param processor RenderProcessor that receives the ViewTransform source
90 * @param config Camera/motion tuning parameters
91 * @param key_map Key assignments; defaults to WASD/QE + KP snaps
92 * @param name Unique prefix for registered events; must be unique per window
93 */
94MAYAFLUX_API void bind_fly_preset(
95 const std::shared_ptr<Core::Window>& window,
96 const std::shared_ptr<Buffers::RenderProcessor>& processor,
97 const ViewportPresetConfig& config = {},
98 const Kinesis::FlyKeyMap& key_map = {},
99 const std::string& name = "default");
100
101/**
102 * @brief Bind the fly navigation controller to all RenderProcessors currently
103 * registered against a window.
104 *
105 * Calls bind_fly_preset(window, rp, config, key_map, name) for every buffer
106 * registered with the window at call time that returns a non-null RenderProcessor.
107 * Buffers registered after this call are not covered.
108 *
109 * @param window Window supplying input events
110 * @param config Camera/motion tuning parameters
111 * @param key_map Key assignments; defaults to WASD/QE + KP snaps
112 * @param name Preset name forwarded to bind_fly_preset()
113 */
114MAYAFLUX_API void bind_fly_preset(
115 const std::shared_ptr<Core::Window>& window,
116 const ViewportPresetConfig& config = {},
117 const Kinesis::FlyKeyMap& key_map = {},
118 const std::string& name = "default");
119
120/**
121 * @brief Bind the orbit navigation controller to a window and render processor.
122 *
123 * Registers event handlers under the prefix "vp_<name>_". MMB drag rotates
124 * around the focal point; holding key_map.pan_modifier during MMB drag pans
125 * the focal point instead. Scroll dollies the distance. Ortho snap slots set
126 * to std::nullopt are silently skipped.
127 *
128 * @param window Window supplying input events
129 * @param processor RenderProcessor that receives the ViewTransform source
130 * @param config Orbit tuning parameters
131 * @param key_map Key assignments; defaults to Shift pan modifier + KP snaps
132 * @param name Unique prefix for registered events; must be unique per window
133 */
134MAYAFLUX_API void bind_orbit_preset(
135 const std::shared_ptr<Core::Window>& window,
136 const std::shared_ptr<Buffers::RenderProcessor>& processor,
137 const Kinesis::OrbitConfig& config = {},
138 const Kinesis::OrbitKeyMap& key_map = {},
139 const std::string& name = "default");
140
141/**
142 * @brief Bind the orbit navigation controller to all RenderProcessors currently
143 * registered against a window.
144 *
145 * @param window Window supplying input events
146 * @param config Orbit tuning parameters
147 * @param key_map Key assignments
148 * @param name Preset name forwarded to the per-processor overload
149 */
150MAYAFLUX_API void bind_orbit_preset(
151 const std::shared_ptr<Core::Window>& window,
152 const Kinesis::OrbitConfig& config = {},
153 const Kinesis::OrbitKeyMap& key_map = {},
154 const std::string& name = "default");
155
156/**
157 * @brief Bind the 2D pan/zoom controller to a window and render processor.
158 *
159 * Drag pans the view; scroll zooms by scaling the orthographic half-height.
160 * View matrix is always identity; only the orthographic projection changes.
161 *
162 * @param window Window supplying input events
163 * @param processor RenderProcessor that receives the ViewTransform source
164 * @param config Pan/zoom tuning parameters
165 * @param key_map Input assignments; defaults to MMB drag
166 * @param name Unique prefix for registered events; must be unique per window
167 */
168MAYAFLUX_API void bind_pan_zoom_preset(
169 const std::shared_ptr<Core::Window>& window,
170 const std::shared_ptr<Buffers::RenderProcessor>& processor,
171 const Kinesis::PanZoom2DConfig& config = {},
172 const Kinesis::PanZoom2DKeyMap& key_map = {},
173 const std::string& name = "default");
174
175/**
176 * @brief Bind the 2D pan/zoom controller to all RenderProcessors currently
177 * registered against a window.
178 *
179 * @param window Window supplying input events
180 * @param config Pan/zoom tuning parameters
181 * @param key_map Input assignments
182 * @param name Preset name forwarded to the per-processor overload
183 */
184MAYAFLUX_API void bind_pan_zoom_preset(
185 const std::shared_ptr<Core::Window>& window,
186 const Kinesis::PanZoom2DConfig& config = {},
187 const Kinesis::PanZoom2DKeyMap& key_map = {},
188 const std::string& name = "default");
189
190/**
191 * @brief Bind the screenspace navigation controller to a window and render processor.
192 *
193 * Drag translates the eye along the camera's local right and up axes derived
194 * from the current yaw and pitch. Rotation is never modified. Scroll dollies
195 * along the forward vector. Perspective projection is preserved throughout.
196 *
197 * To set the initial viewing direction, supply a NavigationConfig with
198 * initial_eye and initial_target; yaw and pitch are derived from those on
199 * construction exactly as in bind_fly_preset.
200 *
201 * @param window Window supplying input events
202 * @param processor RenderProcessor that receives the ViewTransform source
203 * @param config Camera tuning parameters; move_speed is unused
204 * @param key_map Input assignments; defaults to RMB drag
205 * @param name Unique prefix for registered events; must be unique per window
206 */
207MAYAFLUX_API void bind_screenspace_preset(
208 const std::shared_ptr<Core::Window>& window,
209 const std::shared_ptr<Buffers::RenderProcessor>& processor,
210 const Kinesis::NavigationConfig& config = {},
211 const Kinesis::ScreenspaceKeyMap& key_map = {},
212 const std::string& name = "default");
213
214/**
215 * @brief Bind the screenspace navigation controller to all RenderProcessors
216 * currently registered against a window.
217 *
218 * @param window Window supplying input events
219 * @param config Camera tuning parameters
220 * @param key_map Input assignments
221 * @param name Preset name forwarded to the per-processor overload
222 */
223MAYAFLUX_API void bind_screenspace_preset(
224 const std::shared_ptr<Core::Window>& window,
225 const Kinesis::NavigationConfig& config = {},
226 const Kinesis::ScreenspaceKeyMap& key_map = {},
227 const std::string& name = "default");
228
229/**
230 * @brief Cancel all event handlers registered by bind_viewport_preset() and
231 * restore the window input config to its state before bind was called.
232 *
233 * @param window Window passed to bind_viewport_preset()
234 * @param name Name passed to bind_viewport_preset()
235 */
236MAYAFLUX_API void unbind_viewport_preset(
237 const std::shared_ptr<Core::Window>& window,
238 const std::string& name = "default");
239
240} // namespace MayaFlux
void bind_screenspace_preset(const std::shared_ptr< Core::Window > &window, const std::shared_ptr< Buffers::RenderProcessor > &processor, const Kinesis::NavigationConfig &config, const Kinesis::ScreenspaceKeyMap &key_map, const std::string &name)
Bind the screenspace navigation controller to a window and render processor.
ViewportPresetMode
Selects which navigation controller bind_viewport_preset installs.
@ PanZoom2D
Orthographic 2D pan and zoom (not yet implemented)
@ Orbit
Tumble around a focal point (not yet implemented)
@ Fly
First-person fly: WASD/QE translate, RMB drag yaw/pitch, scroll dolly, KP ortho snaps.
@ Screenspace
Perspective pan in camera's local right/up plane, scroll dolly, no rotation.
Kinesis::NavigationConfig ViewportPresetConfig
Alias for backwards compatibility; prefer Kinesis::NavigationConfig in new code.
void bind_viewport_preset(const std::shared_ptr< Core::Window > &window, const std::shared_ptr< Buffers::RenderProcessor > &processor, ViewportPresetMode mode, const std::string &name)
Bind a navigation preset to a window and render processor using default settings.
void bind_pan_zoom_preset(const std::shared_ptr< Core::Window > &window, const std::shared_ptr< Buffers::RenderProcessor > &processor, const Kinesis::PanZoom2DConfig &config, const Kinesis::PanZoom2DKeyMap &key_map, const std::string &name)
Bind the 2D pan/zoom controller to a window and render processor.
void bind_orbit_preset(const std::shared_ptr< Core::Window > &window, const std::shared_ptr< Buffers::RenderProcessor > &processor, const Kinesis::OrbitConfig &config, const Kinesis::OrbitKeyMap &key_map, const std::string &name)
Bind the orbit navigation controller to a window and render processor.
void unbind_viewport_preset(const std::shared_ptr< Core::Window > &window, const std::string &name)
Cancel all event handlers registered by bind_viewport_preset() and restore the window input config to...
void bind_fly_preset(const std::shared_ptr< Core::Window > &window, const std::shared_ptr< Buffers::RenderProcessor > &processor, const ViewportPresetConfig &config, const Kinesis::FlyKeyMap &key_map, const std::string &name)
Bind the fly navigation controller to a window and render processor.
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12
Tuning parameters for a first-person fly-navigation controller.