载入中...
搜索中...
未找到
AnimTrail.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include "common/Time.h"
5
6#include <string>
7#include <vector>
8
9namespace eve::graphics {
10class Graphics;
11}
12
13namespace eve::animation {
14
15class AnimPose;
16
35public:
37 explicit AnimTrail(int capacity = 64);
39 ~AnimTrail() = default;
40
41 AnimTrail(const AnimTrail &) = delete;
42 AnimTrail &operator=(const AnimTrail &) = delete;
43
45 void setCapacity(int capacity);
47 int getCapacity() const { return capacity_; }
48
50 void setDuration(float seconds);
52 float getDuration() const { return duration_; }
53
55 void setMinDistance(float distance);
57 float getMinDistance() const { return minDistance_; }
58
60 void setWidth(float pixels);
62 float getWidth() const { return width_; }
63
65 void setColor(float r, float g, float b, float a = 1.f);
67 float getColorR() const { return colorR_; }
69 float getColorG() const { return colorG_; }
71 float getColorB() const { return colorB_; }
73 float getColorA() const { return colorA_; }
74
76 void setFade(bool enable);
78 bool getFade() const { return fade_; }
79
81 void setStyle(const std::string &style);
83 std::string getStyle() const;
84
89 void setDrawScale(float sx, float sy);
91 float getDrawScaleX() const { return drawScaleX_; }
93 float getDrawScaleY() const { return drawScaleY_; }
95 void setDrawOffset(float ox, float oy);
97 float getDrawOffsetX() const { return drawOffsetX_; }
99 float getDrawOffsetY() const { return drawOffsetY_; }
100
102 void addPoint(float x, float y);
104 void addPoint3(float x, float y, float z);
105
111 void sampleBone(const AnimPose *pose, int boneIndex, const std::string &plane = "xy");
113 void sampleBoneOffset(const AnimPose *pose, int boneIndex, float ox, float oy, float oz,
114 const std::string &plane = "xy");
115
117 void clear();
118
120 [[nodiscard]] eve::Result<void> advance(const eve::SimulationStep &step);
122 void update(float dt);
123
125 int getPointCount() const { return static_cast<int>(points_.size()); }
127 float getPointX(int index) const;
129 float getPointY(int index) const;
131 float getPointZ(int index) const;
133 float getPointAge(int index) const;
135 float getPointAlpha(int index) const;
136
138 void draw(graphics::Graphics *gfx);
139
140private:
141 enum class Style { Line, Points };
142
143 struct Point {
144 float x = 0.f, y = 0.f, z = 0.f;
145 float age = 0.f;
146 };
147
148 void pushPoint(float x, float y, float z);
149 void requireIndex(int index) const;
150 void projectPlane(float x, float y, float z, const std::string &plane, float *outX,
151 float *outY) const;
152 float alphaFor(const Point &p) const;
153 void toScreen(float x, float y, float *sx, float *sy) const;
154 void drawSegment(graphics::Graphics *gfx, float x0, float y0, float x1, float y1, float a0,
155 float a1) const;
156 void drawDot(graphics::Graphics *gfx, float x, float y, float alpha) const;
157
158 int capacity_ = 64;
159 float duration_ = 0.5f;
160 float minDistance_ = 0.f;
161 float width_ = 3.f;
162 float colorR_ = 1.f, colorG_ = 0.85f, colorB_ = 0.35f, colorA_ = 1.f;
163 bool fade_ = true;
164 Style style_ = Style::Line;
165
166 float drawScaleX_ = 1.f;
167 float drawScaleY_ = 1.f;
168 float drawOffsetX_ = 0.f;
169 float drawOffsetY_ = 0.f;
170
171 std::vector<Point> points_;
173 bool hasLastTick_ = false;
174
175 void updateUnchecked(float dt);
176};
177
178} // namespace eve::animation
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
eve::EntitySpatialPose pose
glm::vec4 p[6]
#define EVENGINE_API_WORLD
Definition Export.h:109
tensor::Graph g
Definition GpuGraph.cpp:7
std::uint32_t capacity
double r
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float distance
MeshVfxBatchedDraw draw
uint8_t * pixels
Common time values and an injectable deterministic simulation clock.
float step
Definition TreeMesh.cpp:314
uint32_t index
double oy
double ox
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Evaluated local (and optional world) pose for an AnimSkeleton. Script type: AnimPose.
Definition AnimPose.h:17
Motion trail / afterimage recorder + 2D trajectory drawer.
Definition AnimTrail.h:34
float getColorB() const
Returns the color b.
Definition AnimTrail.h:71
bool getFade() const
Returns the fade.
Definition AnimTrail.h:78
int getPointCount() const
Returns the point count.
Definition AnimTrail.h:125
~AnimTrail()=default
Anim trail.
float getDrawScaleY() const
Returns the draw scale y.
Definition AnimTrail.h:93
float getWidth() const
Returns the width.
Definition AnimTrail.h:62
float getDrawOffsetX() const
Returns the draw offset x.
Definition AnimTrail.h:97
AnimTrail & operator=(const AnimTrail &)=delete
float getColorR() const
Returns the color r.
Definition AnimTrail.h:67
float getDrawOffsetY() const
Returns the draw offset y.
Definition AnimTrail.h:99
float getDrawScaleX() const
Returns the draw scale x.
Definition AnimTrail.h:91
float getMinDistance() const
Returns the min distance.
Definition AnimTrail.h:57
AnimTrail(const AnimTrail &)=delete
float getColorG() const
Returns the color g.
Definition AnimTrail.h:69
float getColorA() const
Returns the color a.
Definition AnimTrail.h:73
float getDuration() const
Returns the duration.
Definition AnimTrail.h:52
int getCapacity() const
Returns the capacity.
Definition AnimTrail.h:47
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158