载入中...
搜索中...
未找到
MotionMatcher.h
浏览该文件的文档.
1#pragma once
2
4
5#include <vector>
6
7namespace eve::animation {
8
9class AnimSkeleton;
10class MotionDatabase;
11
18public:
19 MotionMatcher(AnimSkeleton *skeleton, MotionDatabase *database);
20 ~MotionMatcher() = default;
21
22 MotionMatcher(const MotionMatcher &) = delete;
24
25 AnimSkeleton *getSkeleton() const { return skeleton_; }
26 MotionDatabase *getDatabase() const { return database_; }
27
29 void setDesiredVelocity(float x, float z);
30 float getDesiredVelocityX() const { return desiredVelX_; }
31 float getDesiredVelocityZ() const { return desiredVelZ_; }
32
34 void setDesiredYaw(float yaw);
35 float getDesiredYaw() const { return desiredYaw_; }
36
37 void setSearchInterval(float seconds);
38 float getSearchInterval() const { return searchInterval_; }
39 void setBlendTime(float seconds);
40 float getBlendTime() const { return blendTime_; }
41 void setTrajectoryWeight(float w);
42 float getTrajectoryWeight() const { return trajWeight_; }
43 void setPoseWeight(float w);
44 float getPoseWeight() const { return poseWeight_; }
45 void setVelocityWeight(float w);
46 float getVelocityWeight() const { return velWeight_; }
47
49 void setIgnoreRadius(int frames);
50 int getIgnoreRadius() const { return ignoreRadius_; }
51
52 int getMatchedFrame() const { return matchedFrame_; }
53 int getMatchedClipIndex() const;
54 float getMatchedTime() const { return matchedTime_; }
55 float getLastSearchCost() const { return lastCost_; }
56
58
60 void search();
61
62 void update(float dt);
63
64private:
65 void buildQuery(std::vector<float> &query) const;
66 float cost(const std::vector<float> &query, const std::vector<float> &cand) const;
67 void sampleMatched(AnimPose *out) const;
68
69 AnimSkeleton *skeleton_ = nullptr;
70 MotionDatabase *database_ = nullptr;
71 AnimPose pose_;
72 AnimPose fromPose_;
73 AnimPose matchedPose_;
74
75 float desiredVelX_ = 0.f;
76 float desiredVelZ_ = 0.f;
77 float desiredYaw_ = 0.f;
78
79 float searchInterval_ = 0.1f;
80 float searchTimer_ = 0.f;
81 float blendTime_ = 0.15f;
82 float blendElapsed_ = 0.f;
83 bool blending_ = false;
84
85 float trajWeight_ = 1.f;
86 float poseWeight_ = 1.f;
87 float velWeight_ = 1.f;
88 int ignoreRadius_ = 2;
89
90 int matchedFrame_ = -1;
91 float matchedTime_ = 0.f;
92 float lastCost_ = 0.f;
93 bool playing_ = false;
94};
95
96} // namespace eve::animation
int z
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
int w
std::vector< float > cost
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
Definition AnimPose.h:15
3D bone hierarchy + bind-pose local TRS for skeletal animation. Independent of ik::Skeleton3D (FABRIK...
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,...
void search()
Force an immediate search (also called periodically from update).
void setBlendTime(float seconds)
AnimSkeleton * getSkeleton() const
void setDesiredYaw(float yaw)
Desired facing yaw (radians, Y-up).
void setDesiredVelocity(float x, float z)
Desired planar velocity in character/world XZ (units/sec).
MotionDatabase * getDatabase() const
void setIgnoreRadius(int frames)
Skip rematching the same frame / nearby frames to reduce jitter.
MotionMatcher & operator=(const MotionMatcher &)=delete
void setSearchInterval(float seconds)
MotionMatcher(const MotionMatcher &)=delete