载入中...
搜索中...
未找到
AnimationClipEditor.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
15
16#include <cstdint>
17#include <memory>
18#include <string>
19#include <vector>
20
21namespace eve::animation {
22class AnimClip;
23class AnimSkeleton;
24}
25
26namespace eve::editor {
27struct PreviewState;
28}
29
30namespace eve::animation_editor {
31class IAnimationClipPreviewProvider;
32
44public:
46 explicit AnimationClipEditor(std::string targetId);
47
65 const animation::AnimSkeleton& skeleton) const;
66
69
72
80 [[nodiscard]] animation_editing::Result<void> setPreviewProvider(
81 std::shared_ptr<const IAnimationClipPreviewProvider> provider);
87 [[nodiscard]] animation_editing::Result<void> requestPreview();
90 [[nodiscard]] animation_editing::Result<void> pollPreview();
92 [[nodiscard]] animation_editing::Result<void> cancelPreview();
94 void closePreview();
96 editor::PreviewState previewState() const noexcept;
97
99 const animation_editing::AnimationClipDocumentTarget& target() const noexcept { return target_; }
100
105 [[nodiscard]] animation_editing::Result<void> configureWorkspace(editor::EditorWorkspace& workspace) const;
106
113 [[nodiscard]] animation_editing::Result<void> setViewport(float width, float rowHeight, float labelWidth);
114
115 [[nodiscard]] animation_editing::Result<void> seekSeconds(double seconds);
116 [[nodiscard]] animation_editing::Result<void> seekX(float x);
117 [[nodiscard]] animation_editing::Result<void> pointerDown(float x, float y);
118 [[nodiscard]] animation_editing::Result<void> selectBone(std::string bone);
119 [[nodiscard]] animation_editing::Result<void> setMaskWeight(double weight);
124 [[nodiscard]] animation_editing::Result<void> setDuration(double duration);
129 [[nodiscard]] animation_editing::Result<void> setSampleRate(double sampleRate);
131 [[nodiscard]] animation_editing::Result<void> setLoop(bool loop);
133 [[nodiscard]] animation_editing::Result<void> keySelectedBone();
135 [[nodiscard]] animation_editing::Result<void> deleteSelectedKey();
137 [[nodiscard]] animation_editing::Result<void> setSelectedPosition(double x, double y, double z);
139 [[nodiscard]] animation_editing::Result<void> setSelectedRotation(double xDegrees, double yDegrees,
140 double zDegrees);
142 [[nodiscard]] animation_editing::Result<void> setSelectedScale(double x, double y, double z);
143 [[nodiscard]] animation_editing::Result<void> moveSelectedKey(double time);
144
147
148 void play() noexcept;
150 void pause() noexcept;
152 void stop() noexcept;
154 [[nodiscard]] animation_editing::Result<void> update(double deltaSeconds);
155
156 bool canUndo() const noexcept { return transactions_.canUndo(); }
158 bool canRedo() const noexcept { return transactions_.canRedo(); }
160 bool isPlaying() const noexcept { return playing_; }
162 std::uint64_t revision() const noexcept { return target_.revision(); }
164 double duration() const noexcept { return target_.duration(); }
166 double sampleRate() const noexcept { return target_.sampleRate(); }
168 bool isLooping() const noexcept { return target_.isLooping(); }
170 double playhead() const noexcept { return playhead_; }
172 float layoutWidth() const noexcept { return viewportWidth_; }
174 float layoutHeight() const noexcept;
176 float playheadX() const noexcept;
178 std::string selectedBone() const { return selectedBone_; }
180 animation_editing::StableId selectedKeyId() const { return selectedKeyId_; }
181 double selectedMaskWeight() const;
183 bool hasSelectedKey() const noexcept { return !selectedKeyId_.empty(); }
185 double selectedKeyTime() const;
187 double selectedPositionX() const;
189 double selectedPositionY() const;
191 double selectedPositionZ() const;
193 double selectedRotationX() const;
195 double selectedRotationY() const;
197 double selectedRotationZ() const;
199 double selectedScaleX() const;
201 double selectedScaleY() const;
203 double selectedScaleZ() const;
205 int boneCount() const noexcept;
207 std::string boneName(int index) const;
209 std::string boneParent(int index) const;
210
212 int trackCount() const;
214 std::string trackBone(int index) const;
216 std::string trackId(int index) const;
218 bool isTrackSelected(int index) const;
220 int keyCount() const;
222 float keyX(int index) const;
224 float keyY(int index) const;
226 bool isKeySelected(int index) const;
228 int eventCount() const;
230 float eventX(int index) const;
232 std::string eventName(int index) const;
233
235 int primitiveCount() const;
237 std::string primitiveKind(int index) const;
239 float primitiveX(int index) const;
241 float primitiveY(int index) const;
243 float primitiveDirX(int index) const;
245 float primitiveDirY(int index) const;
247 float primitiveLength(int index) const;
249 float primitiveRadius(int index) const;
251 float primitiveR(int index) const;
253 float primitiveG(int index) const;
255 float primitiveB(int index) const;
256
258 const animation_editing::AnimationClipPreview& preview() const noexcept { return preview_; }
259
260private:
261 struct PreviewSession;
262 struct PreviewSessionDeleter {
263 void operator()(PreviewSession*) const;
264 };
265 std::unique_ptr<PreviewSession, PreviewSessionDeleter> previewSession_;
266 void initializePreview();
267 struct SkeletonBone {
268 std::string name;
269 std::string parent;
270 };
271 struct TimelineKey {
272 animation_editing::StableId trackId;
273 std::string bone;
274 int keyIndex = 0;
275 double time = 0.0;
276 int row = 0;
277 };
278
279 [[nodiscard]] animation_editing::Result<void> commit(
280 animation_editing::Result<animation_editing::DomainOperation> operation, std::string label);
281 [[nodiscard]] animation_editing::Result<void> refreshPreview();
282 [[nodiscard]] animation_editing::Result<void> updateSelectedTransform(
283 const animation_editing::AnimationTransformKey& value, std::string label);
284 [[nodiscard]] animation_editing::AnimationTransformKey sampledSelectedTransform() const;
285 void seedPreviewClip();
286 std::vector<std::string> skeletonBones() const;
287 std::string skeletonParent(const std::string& bone) const;
288 float timeToX(double time) const;
289 double xToTime(float x) const;
291 const eve::editing::GizmoPrimitive* primitiveAt(int index) const;
292 std::vector<TimelineKey> flattenKeys() const;
293
294 animation_editing::AnimationClipDocumentTarget target_;
295 editor::LocalWorldAuthority authority_;
296 editor::LocalTransactionBackend transactions_;
297 animation_editing::AnimationClipPreview preview_;
299 std::string selectedBone_ = "Hips";
300 animation_editing::StableId selectedKeyTrack_;
301 animation_editing::StableId selectedKeyId_;
302 std::uint64_t txSequence_ = 0;
303 double playhead_ = 0.0;
304 bool playing_ = false;
305 bool previewDirty_ = false;
306 float viewportWidth_ = 800.0f;
307 float rowHeight_ = 36.0f;
308 float labelWidth_ = 120.0f;
309 std::vector<SkeletonBone> skeleton_;
310};
311
312} // namespace eve::animation_editor
double z
double y
double x
LogicalId target
ActionParameterOperation operation
LogicalId trackId
float duration
std::string name
Definition ECS.cpp:154
#define EVENGINE_API_EDITORS
Definition Export.h:112
glm::vec4 clip
std::uint32_t width
const ColourScope * parent
std::uint32_t bone
std::string label
std::uint32_t targetId
Object::Ptr value
double weight
uint32_t index
Move-only operation result carrying either a value or Status.
Definition Result.h:176
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
Keyframed skeletal animation clip (local TRS tracks per bone). Script type: AnimClip.
Definition AnimClip.h:145
3D bone hierarchy + bind-pose local TRS for skeletal animation. Independent of ik::Skeleton3D (FABRIK...
Timeline-style controller for one authored animation clip.
double duration() const noexcept
Duration.
animation_editing::Result< void > loadRuntimeClip(const animation::AnimSkeleton &skeleton, const animation::AnimClip &clip)
Atomically replace the editor document from a real runtime skeleton and clip.
bool isLooping() const noexcept
True when looping.
double playhead() const noexcept
Playhead.
std::uint64_t revision() const noexcept
Revision.
animation_editing::Result< void > writeRuntimeClip(animation::AnimClip &clip, const animation::AnimSkeleton &skeleton) const
Replace a runtime clip with the current authoritative editor document.
double sampleRate() const noexcept
Sample rate.
animation_editing::StableId selectedKeyId() const
Owning stable identity of the selected key, or empty for a bone-only selection.
AnimationClipEditor(const AnimationClipEditor &)=delete
AnimationClipEditor & operator=(const AnimationClipEditor &)=delete
float layoutWidth() const noexcept
Layout width.
bool hasSelectedKey() const noexcept
True when selected key.
bool isPlaying() const noexcept
True when playing.
Composition model shared by project-specific developer and runtime editors.
Result< VehiclePhysicsStatus > commit(physics::World &world, physics::ForceBatch &batch, std::shared_ptr< VehicleWheelRuntime > &runtime, std::vector< VehicleEntity::SuspensionState::WheelState > candidate, const SimulationStep &step)
Renderer-neutral wire primitive for authoring viewport overlays.
Immutable revision-tagged overlay snapshot consumed by any viewport renderer.
Owning preview lifecycle observation; payloads remain owned by the domain.