载入中...
搜索中...
未找到
Animation.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
8#include "animation/Tween.h"
9#include "common/Module.h"
10#include "common/Time.h"
11
12#include <string>
13#include <memory>
14#include <unordered_map>
15#include <vector>
16
17namespace ssq {
18class Class;
19}
20
21namespace eve::model3d {
22class ModelData;
23}
24
25namespace eve::graphics {
26class Graphics;
27}
28
29namespace eve::animation {
30
31class AnimSkeleton;
32class AnimClip;
33class AnimPose;
34class AnimPlayer;
35class AnimGraph;
36class AnimBoneMask;
37class AnimLayerMixer;
38class AnimStateMachine;
39class MotionDatabase;
40class MotionMatcher;
41class ControlAnim;
42class ControlPose;
43class PhysicalBalancePose;
44class AnimSkin;
45class AnimLattice;
46class AnimTrail;
47class AnimBatch;
48class AnimConstraintStack;
49class AnimSyncGroup;
50class DynamicBoneSolver;
51class FootIKSolver;
52class SpriteSheet;
53class SpriteClip;
54class SpriteAnim;
55class SpineAtlas;
56class SpineSkeletonData;
57class SpineSkeleton;
58class SpineAnim;
59
81public:
83 // Declared, not `= default`: class-level dllexport forces MSVC to compute the
84 // defaulted constructor's exception specification, which needs the destructor of
85 // every member -- and `SpriteSheet` is only forward-declared here (line 47), so an
86 // in-class `= default` is C2027 "can't delete an incomplete type". Defined in
87 // Animation.cpp, which includes animation/SpriteSheet.h.
91 ~Animation() override;
92 // `spriteSequenceCache_` is a container of `unique_ptr`: dllexport instantiates
93 // every member, so the implicitly-defined copy operations would instantiate the
94 // container's copy (hard C2280). Copy is deleted; no move is declared because
95 // `MotionRuntime motions_` is itself neither copyable nor movable
96 // (MotionRuntime.h:130 deletes copy and declares no move), which would make a
97 // defaulted move operation ill-formed.
98 Animation(const Animation &) = delete;
99 Animation &operator=(const Animation &) = delete;
100
102 Tween *newTween(float duration = 1.f);
103
105 SpriteSheet *newSpriteSheet();
111 SpriteSheet *newSpriteSheetFromSequence(eve::graphics::Graphics *gfx,
112 const std::string &pattern, int first,
113 int last, int columns = 0);
115 SpriteSheet *newSpriteSheetFromAtlasJson(eve::graphics::Graphics *gfx,
116 const std::string &texturePath,
117 const std::string &jsonPath);
119 SpriteClip *newSpriteClip(const std::string &name = "");
121 SpriteAnim *newSpriteAnim();
123 int getSpriteSequenceCacheCount() const;
125 int getSpriteSequenceCacheBytes() const;
127 void clearSpriteSequenceCache();
128
130 SpineAtlas *newSpineAtlas();
132 SpineSkeletonData *newSpineSkeletonData();
134 SpineSkeleton *newSpineSkeleton(SpineSkeletonData *data);
136 SpineAnim *newSpineAnim(SpineSkeleton *skeleton);
137
139 SpineAtlas *newSpineAtlasFromFile(const std::string &path);
141 SpineAtlas *newSpineAtlasFromText(const std::string &text);
143 SpineSkeletonData *newSpineSkeletonDataFromFile(const std::string &path);
145 SpineSkeletonData *newSpineSkeletonDataFromJson(const std::string &json);
146
148 AnimSkeleton *newSkeleton();
150 AnimClip *newClip(const std::string &name = "");
152 AnimPose *newPose(int boneCount = 0);
154 AnimBatch *newBatch();
156 AnimConstraintStack *newConstraintStack(AnimSkeleton* skeleton);
162 DynamicBoneSolver *newDynamicBoneSolver(AnimSkeleton *skeleton);
163
168 int setupHairChain(DynamicBoneSolver *solver, const std::string &rootBone,
169 const std::string &tipBone, float stiffness = 0.12f,
170 float damping = 0.18f, float inertia = 0.8f, float endLength = 0.08f,
171 bool selfCollision = true);
172
177 int setupHairHeadCollider(DynamicBoneSolver *solver, const std::string &boneName,
178 float radius = 0.12f);
179
185 FootIKSolver *newFootIKSolver(AnimSkeleton *skeleton);
187 AnimSyncGroup* newSyncGroup();
189 AnimPlayer *newPlayer(AnimSkeleton *skeleton);
191 AnimGraph *newGraph(AnimSkeleton *skeleton);
193 AnimBoneMask* newBoneMask(AnimSkeleton* skeleton);
195 AnimLayerMixer* newLayerMixer(AnimSkeleton* skeleton);
197 AnimStateMachine *newStateMachine(AnimSkeleton *skeleton);
199 MotionDatabase *newMotionDatabase(AnimSkeleton *skeleton);
201 MotionMatcher *newMotionMatcher(AnimSkeleton *skeleton, MotionDatabase *database);
202
207 ControlAnim *newControlAnim(float frequencyHz = 3.f, float dampingZeta = 1.f,
208 float response = 1.f);
210 ControlPose *newControlPose(AnimSkeleton *skeleton);
220 PhysicalBalancePose* newPhysicalBalancePose(AnimSkeleton* skeleton);
221
228 AnimSkeleton *newSkeletonFromModel(eve::model3d::ModelData *model);
230 AnimClip *newClipFromModel(eve::model3d::ModelData *model, AnimSkeleton *skeleton,
231 int animIndex = 0);
242 AnimSkeleton *newSkeletonFromAnimationFixtureText(const std::string &path);
254 AnimClip *newClipFromAnimationFixtureText(const std::string &path);
255
260 AnimSkin *newSkinFromModel(eve::model3d::ModelData *model, int meshIndex,
261 AnimSkeleton *skeleton);
262
269 AnimLattice *newLattice(int divX = 2, int divY = 2, int divZ = 2);
270
272 AnimLattice *newLatticeFromModel(eve::model3d::ModelData *model, int meshIndex,
273 int divX = 2, int divY = 2, int divZ = 2);
274
279 AnimTrail *newTrail(int capacity = 64);
280
285 [[nodiscard]] MotionBuilder motion(float from, float to, float duration);
287 [[nodiscard]] MotionVec2Builder motionVec2(MotionVec2 from, MotionVec2 to, float duration);
289 [[nodiscard]] MotionVec3Builder motionVec3(MotionVec3 from, MotionVec3 to, float duration);
290
297 [[nodiscard]] MotionBuilder punch(float from, float strength, float duration);
299 [[nodiscard]] MotionBuilder shake(float from, float strength, float duration);
301 [[nodiscard]] MotionVec2Builder punchVec2(MotionVec2 from, MotionVec2 strength, float duration);
303 [[nodiscard]] MotionVec2Builder shakeVec2(MotionVec2 from, MotionVec2 strength, float duration);
305 [[nodiscard]] MotionVec3Builder punchVec3(MotionVec3 from, MotionVec3 strength, float duration);
307 [[nodiscard]] MotionVec3Builder shakeVec3(MotionVec3 from, MotionVec3 strength, float duration);
309 [[nodiscard]] MotionColorBuilder motionColor(MotionColor from, MotionColor to, float duration);
311 [[nodiscard]] MotionQuatBuilder motionQuat(MotionQuat from, MotionQuat to, float duration);
312
313 [[nodiscard]] MotionSequence sequence();
314
316 [[nodiscard]] MotionRuntime &motions() noexcept { return motions_; }
317 [[nodiscard]] const MotionRuntime &motions() const noexcept { return motions_; }
318
320 [[nodiscard]] eve::Result<void> advance(const eve::SimulationStep &step);
321
323 [[nodiscard]] eve::SimulationTick currentTick() const noexcept { return lastTick_; }
324
326 void update(float dt);
327
329 int getTweenCount() const { return static_cast<int>(tweens_.size()); }
331 int getMotionCount() const { return motions_.activeCount(); }
332
337 void ensureMotionCapacity(std::size_t floatCount) { motions_.ensureCapacity(floatCount); }
339 [[nodiscard]] std::size_t getMotionFloatCapacity() const noexcept {
340 return motions_.floatCapacity();
341 }
343 [[nodiscard]] std::size_t getMotionFloatFreeCount() const noexcept {
344 return motions_.floatFreeCount();
345 }
347 int getSpriteAnimCount() const { return static_cast<int>(spriteAnims_.size()); }
349 int getSpineAnimCount() const { return static_cast<int>(spineAnims_.size()); }
351 int getActiveCount() const;
352
354 void clearFinished();
356 void clearAll();
357
358private:
359 std::unordered_map<std::string, std::unique_ptr<SpriteSheet>> spriteSequenceCache_;
360 friend class Tween;
361 friend class SpriteAnim;
362 friend class SpineAnim;
363
364 void registerTween(Tween *t);
365 void unregisterTween(Tween *t);
366 void registerSpriteAnim(SpriteAnim *a);
367 void unregisterSpriteAnim(SpriteAnim *a);
368 void registerSpineAnim(SpineAnim *a);
369 void unregisterSpineAnim(SpineAnim *a);
370
371 std::vector<Tween *> tweens_;
372 std::vector<SpriteAnim *> spriteAnims_;
373 std::vector<SpineAnim *> spineAnims_;
374 MotionRuntime motions_;
376 bool hasLastTick_ = false;
377};
378
384
385} // namespace eve::animation
float duration
std::string from
HSQOBJECT cls
Definition ECS.cpp:21
#define EVENGINE_API_WORLD
Definition Export.h:109
std::string pattern
std::uint32_t capacity
std::int32_t first
HexCoordinates to
Cell the unit walks towards on this segment.
Definition HexUnits.cpp:64
std::string text
std::string name
MeleePoint3 a
Definition MeleeHit.cpp:40
Fluent LitMotion-style builder that commits into MotionRuntime.
Dense motion storage advanced by Animation::advance(SimulationStep).
Lean LitMotion-style sequence: Append / Join / Insert / AppendInterval.
LitMotion-style typed motion handles, values, and sink interfaces.
std::unique_ptr< gpgpu::Sequence > sequence
Definition OnnxGpgpu.cpp:43
float radius
std::string path
Definition PlayHost.cpp:110
float t
glm::mat4 model
int columns
Common time values and an injectable deterministic simulation clock.
float inertia
Definition TreeMesh.cpp:309
float step
Definition TreeMesh.cpp:314
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Parallel batch evaluator for independent character clip poses. Script type: AnimBatch.
Definition AnimBatch.h:13
Per-bone weights used by override and additive animation layers.
Keyframed skeletal animation clip (local TRS tracks per bone). Script type: AnimClip.
Definition AnimClip.h:145
Ordered main-thread post-process stack with aim, limb IK and foot planting.
Composable runtime pose graph supporting clips, blends, additive layers, per-bone masks,...
Definition AnimGraph.h:26
CPU 3D lattice scale-deformer (晶格缩放变形).
Definition AnimLattice.h:42
Combines a borrowed base pose source with ordered override/additive layers.
Single-clip (or cross-fading) 3D animation player. Script type: AnimPlayer.
Definition AnimPlayer.h:30
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
Definition AnimPose.h:17
3D bone hierarchy + bind-pose local TRS for skeletal animation. Independent of ik::Skeleton3D (FABRIK...
CPU linear-blend skinning binding for one mesh against an AnimSkeleton.
Definition AnimSkin.h:47
Clip-driven animation state machine with float/bool/trigger parameters and cross-fade transitions....
Marker-aware synchronization group for locomotion animation players.
Motion trail / afterimage recorder + 2D trajectory drawer.
Definition AnimTrail.h:34
Animation module — tween factory + 2D sprite-sheet / Spine + 3D skeletal playback (player / state mac...
Definition Animation.h:80
std::size_t getMotionFloatFreeCount() const noexcept
Returns the motion float free count.
Definition Animation.h:343
Animation & operator=(const Animation &)=delete
int getSpriteAnimCount() const
Returns the sprite anim count.
Definition Animation.h:347
Animation(const Animation &)=delete
std::size_t getMotionFloatCapacity() const noexcept
Returns the motion float capacity.
Definition Animation.h:339
int getTweenCount() const
Returns the tween count.
Definition Animation.h:329
void ensureMotionCapacity(std::size_t floatCount)
Pre-size motion float pool for churn-free spawn (Phase 4).
Definition Animation.h:337
const MotionRuntime & motions() const noexcept
Definition Animation.h:317
int getSpineAnimCount() const
Returns the spine anim count.
Definition Animation.h:349
int getMotionCount() const
Returns the motion count.
Definition Animation.h:331
eve::SimulationTick currentTick() const noexcept
Last scheduler tick consumed by the checked module pump.
Definition Animation.h:323
MotionRuntime & motions() noexcept
Shared motion storage for builders and handle queries.
Definition Animation.h:316
Control-theory procedural animation for named scalar properties.
Definition ControlAnim.h:25
Control-theory procedural pose driver: tracks a target AnimPose with per-channel second-order / sprin...
Definition ControlPose.h:23
World-space spring-chain solver that writes results as local bone rotations.
Paired-foot IK with contact smoothing and pelvis compensation.
Configure then bind/run a float motion into a MotionRuntime.
Color fluent builder (Tween / lerp only).
Baked motion-matching feature database from one or more AnimClips. Feature layout per frame: [0....
Runtime motion matching player: builds a query feature from current pose + desired trajectory,...
Quaternion fluent builder (Tween / slerp only).
Owns typed motion slots and applies SimulationStep updates.
Schedule unspawned builders onto a shared MotionRuntime timeline.
Authored-pose overlay that wobbles from world impulses and recovers balance.
Spine animation player + 2D draw collector (region attachments).
Definition SpineAnim.h:35
Esoteric Spine .atlas text parser (region rectangles + page metadata). Does not load image pixels — b...
Definition SpineAtlas.h:16
Spine skeleton JSON data (bones / slots / skins / animations).
Runtime Spine skeleton pose (local + world bone transforms, slot attachments). Script type: SpineSkel...
2D sprite-sheet clip player.
Definition SpriteAnim.h:26
Named 2D frame sequence referencing SpriteSheet frame indices. Script type: SpriteClip.
Definition SpriteClip.h:17
Sprite-sheet / texture-atlas frame table (pixel rects).
Definition SpriteSheet.h:23
Property tween — interpolates named float properties from → to over time.
Definition Tween.h:25
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
CPU-side decoded 3D model (Assimp scene owned via medialoader::ModelScene). Does not upload to GPU — ...
Definition ModelData.h:39
void exposeAnimationModelImportBindings(ssq::Class &cls)
Register ModelData/Assimp import factories when AnimationModelImport.cpp is linked (OPTIONAL_DEPS mod...
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:14
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
Compact RGBA color used by motion adapters.
Definition MotionTypes.h:52
Compact quaternion used by motion adapters (xyzw).
Definition MotionTypes.h:60
Compact float2 used by motion adapters (avoids graphics math deps).
Definition MotionTypes.h:39
Compact float3 used by motion adapters.
Definition MotionTypes.h:45