WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
InputAction.h
Go to the documentation of this file.
1
#pragma once
2
3
// ---- Input Action System --------------------------------------------------
4
// Data-driven input-to-action mapping inspired by Game Engine Architecture
5
// (Gregory). Raw inputs (mouse, keyboard) are resolved to logical actions
6
// via configurable bindings. The resolved InputState is consumed by the
7
// ViewportController to manipulate the camera.
8
9
#include "imgui.h"
10
11
// ---------------------------------------------------------------------------
12
// Logical viewport actions
13
// ---------------------------------------------------------------------------
14
15
enum class
ViewportAction
16
{
17
Orbit
,
// 2D mouse drag: yaw (from dx) + pitch (from dy)
18
Pan
,
// 2D mouse drag: lateral (from dx) + vertical (from dy)
19
Zoom
,
// 1D: scroll wheel or mouse-Y drag changes radius
20
OrbitYaw
,
// 1D key: yaw offset per frame
21
OrbitPitch
,
// 1D key: pitch offset per frame
22
PanLateral
,
// 1D key: pan along camera right vector
23
PanVertical
,
// 1D key: pan along world Z axis
24
ResetCamera
,
// Discrete one-shot trigger
25
};
26
27
// ---------------------------------------------------------------------------
28
// Trigger types
29
// ---------------------------------------------------------------------------
30
31
enum class
TriggerType
32
{
33
MouseDrag
,
// Mouse button held + pointer movement
34
MouseScroll
,
// Mouse wheel rotation
35
KeyHold
,
// Key held down (continuous, per-frame)
36
KeyPress
,
// Key pressed (single trigger, edge-detected)
37
};
38
39
// ---------------------------------------------------------------------------
40
// Input binding — maps a raw input to a logical action
41
// ---------------------------------------------------------------------------
42
43
struct
InputBinding
44
{
45
ViewportAction
action
=
ViewportAction::Orbit
;
46
TriggerType
trigger
=
TriggerType::MouseDrag
;
47
49
ImGuiMouseButton
mouseButton
= ImGuiMouseButton_Left;
50
52
ImGuiKey
key
= ImGuiKey_None;
53
55
float
scaleX
= 1.0f;
56
58
float
scaleY
= 1.0f;
59
61
float
keyDelta
= 0.0f;
62
64
float
shiftScale
= 0.1f;
65
};
66
67
// ---------------------------------------------------------------------------
68
// Resolved input state for one frame — consumed by ViewportController
69
// ---------------------------------------------------------------------------
70
71
struct
InputState
72
{
73
float
orbitYaw
= 0.0f;
// Accumulated yaw delta
74
float
orbitPitch
= 0.0f;
// Accumulated pitch delta
75
float
panX
= 0.0f;
// Lateral pan (camera-right units)
76
float
panZ
= 0.0f;
// Vertical pan (world-Z units)
77
float
zoom
= 0.0f;
// Radius delta (positive = further away)
78
bool
resetCamera
=
false
;
// One-shot trigger
79
};
TriggerType
TriggerType
Definition
InputAction.h:32
TriggerType::KeyPress
@ KeyPress
TriggerType::MouseScroll
@ MouseScroll
TriggerType::MouseDrag
@ MouseDrag
TriggerType::KeyHold
@ KeyHold
ViewportAction
ViewportAction
Definition
InputAction.h:16
ViewportAction::OrbitPitch
@ OrbitPitch
ViewportAction::ResetCamera
@ ResetCamera
ViewportAction::OrbitYaw
@ OrbitYaw
ViewportAction::Zoom
@ Zoom
ViewportAction::Orbit
@ Orbit
ViewportAction::PanVertical
@ PanVertical
ViewportAction::PanLateral
@ PanLateral
ViewportAction::Pan
@ Pan
InputBinding
Definition
InputAction.h:44
InputBinding::scaleX
float scaleX
Scale applied to mouse delta X (MouseDrag) or wheel value (MouseScroll).
Definition
InputAction.h:55
InputBinding::trigger
TriggerType trigger
Definition
InputAction.h:46
InputBinding::keyDelta
float keyDelta
Fixed delta per frame for KeyHold bindings.
Definition
InputAction.h:61
InputBinding::mouseButton
ImGuiMouseButton mouseButton
Mouse button for MouseDrag trigger.
Definition
InputAction.h:49
InputBinding::shiftScale
float shiftScale
Multiplier applied when Shift is held (1.0 = Shift has no effect).
Definition
InputAction.h:64
InputBinding::action
ViewportAction action
Definition
InputAction.h:45
InputBinding::scaleY
float scaleY
Scale applied to mouse delta Y (MouseDrag). Unused for 1D triggers.
Definition
InputAction.h:58
InputBinding::key
ImGuiKey key
Key for KeyHold / KeyPress triggers.
Definition
InputAction.h:52
InputState
Definition
InputAction.h:72
InputState::resetCamera
bool resetCamera
Definition
InputAction.h:78
InputState::panZ
float panZ
Definition
InputAction.h:76
InputState::orbitPitch
float orbitPitch
Definition
InputAction.h:74
InputState::zoom
float zoom
Definition
InputAction.h:77
InputState::panX
float panX
Definition
InputAction.h:75
InputState::orbitYaw
float orbitYaw
Definition
InputAction.h:73
Source
App
InputAction.h
Generated by
1.9.8