Polyphase Game Engine
Loading...
Searching...
No Matches
AnimationBrowser.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <cstdint>
6#include "AssetRef.h"
7#include "Maths.h"
8#include "imgui.h"
9
10class World;
11class Image;
12class Camera3D;
14class SkeletalMesh3D;
15class SkeletalMesh;
16
17class AnimationBrowser
18{
19public:
20 void Open(SkeletalMesh* mesh);
21 void Close();
22 void Render();
23 void DrawPanel();
24
25 bool IsEnabled() const { return mEnabled; }
26
27 // Returns true exactly once after Open() has been called, so the caller
28 // (DrawDockspace) can re-dock the AnimationBrowser tab next to the CLI
29 // Terminal before its BeginDock runs. Without this, the dock floats away
30 // because it was force-hidden on the editor's first frame.
31 bool ConsumePendingDock()
32 {
33 bool v = mPendingDock;
34 mPendingDock = false;
35 return v;
36 }
37
38private:
39 void EnsurePreviewWorld();
40 void CreateRenderTargets(uint32_t w, uint32_t h);
41 void DestroyRenderTargets();
42 void FrameMesh();
43 void ApplyOrbitCamera();
44 void BuildGrid();
45 void HandleViewportInput();
46 void SelectAnimation(int32_t index);
47 void StepFrame(int32_t direction);
48 void SetPlaying(bool playing);
49 void SyncLoopFlag();
50 float GetCurrentDuration() const;
51 float GetFrameStep() const;
52 const char* GetCurrentAnimName() const;
53
54 bool mEnabled = false;
55 SkeletalMeshRef mTargetMesh;
56
57 World* mPreviewWorld = nullptr;
58 Camera3D* mPreviewCamera = nullptr;
59 DirectionalLight3D* mPreviewLight = nullptr;
60 SkeletalMesh3D* mPreviewNode = nullptr;
61
62 int32_t mSelectedAnimIndex = -1;
63 bool mLoop = true;
64 bool mPlaying = true;
65 bool mShowGrid = true;
66 float mScrubTime = 0.0f;
67 float mPreviewScale = 1.0f;
68
69 // Offscreen render targets
70 Image* mColorTarget = nullptr;
71 Image* mDepthTarget = nullptr;
72 ImTextureID mImGuiTexId = 0;
73 uint32_t mCurrentWidth = 0;
74 uint32_t mCurrentHeight = 0;
75
76 // Orbit camera state
77 float mCamYaw = 0.6f;
78 float mCamPitch = 0.25f;
79 float mCamDistance = 5.0f;
80 glm::vec3 mCamPivot = { 0.0f, 1.0f, 0.0f };
81
82 // Viewport rect captured by DrawPanel for hover/input gating
83 ImVec2 mImageMin = { 0, 0 };
84 ImVec2 mImageMax = { 0, 0 };
85 bool mPendingFocus = false;
86 bool mPendingDock = false;
87};
88
89AnimationBrowser* GetAnimationBrowser();
90
91#endif
Definition AssetRef.h:18
Definition Camera3d.h:12
Definition DirectionalLight3d.h:6
Definition SkeletalMesh3d.h:52
Definition SkeletalMesh.h:86
Definition World.h:24