Etterna 0.74.4
Loading...
Searching...
No Matches
ActorMultiVertex.h
1
4#ifndef ACTOR_MULTI_VERTEX_H
5#define ACTOR_MULTI_VERTEX_H
6
7#include "Actor.h"
8#include "Etterna/Models/Misc/CubicSpline.h"
9#include "RageUtil/Graphics/RageDisplay.h"
10#include "RageUtil/Graphics/RageTextureID.h"
11
12enum DrawMode
13{
14 DrawMode_Quads = 0,
15 DrawMode_QuadStrip,
16 DrawMode_Fan,
17 DrawMode_Strip,
18 DrawMode_Triangles,
19 DrawMode_LineStrip,
20 DrawMode_SymmetricQuadStrip,
21 NUM_DrawMode,
22 DrawMode_Invalid
23};
24
25const std::string&
26DrawModeToString(DrawMode cat);
27const std::string&
28DrawModeToLocalizedString(DrawMode cat);
29LuaDeclareType(DrawMode);
30
31class RageTexture;
32
33class ActorMultiVertex : public Actor
34{
35 public:
36 static const size_t num_vert_splines = 4;
39 ~ActorMultiVertex() override;
40
41 void LoadFromNode(const XNode* Node) override;
42 [[nodiscard]] ActorMultiVertex* Copy() const override;
43
45 {
46 AMV_TweenState() = default;
47 static void MakeWeightedAverage(AMV_TweenState& average_out,
48 const AMV_TweenState& ts1,
49 const AMV_TweenState& ts2,
50 float percent_between);
51 bool operator==(const AMV_TweenState& other) const;
52 bool operator!=(const AMV_TweenState& other) const
53 {
54 return !operator==(other);
55 }
56
57 void SetDrawState(DrawMode dm, int first, int num);
58 [[nodiscard]] int GetSafeNumToDraw(DrawMode dm, int num) const;
59
60 std::vector<RageSpriteVertex> vertices;
61 std::vector<size_t> quad_states;
62
63 DrawMode _DrawMode{ DrawMode_Invalid };
64 int FirstToDraw{ 0 };
65 int NumToDraw{ -1 };
66
67 // needed for DrawMode_LineStrip
68 float line_width{ 1.0f };
69 };
70
71 AMV_TweenState& AMV_DestTweenState()
72 {
73 if (AMV_Tweens.empty()) {
74 return AMV_current;
75 }
76
77 return AMV_Tweens.back();
78 }
79
80 [[nodiscard]] const AMV_TweenState& AMV_DestTweenState() const
81 {
82 return const_cast<ActorMultiVertex*>(this)->AMV_DestTweenState();
83 }
84
85 void EnableAnimation(bool bEnable) override;
86 void Update(float fDelta) override;
87 [[nodiscard]] bool EarlyAbortDraw() const override;
88 void DrawPrimitives() override;
89 virtual void DrawInternal(const AMV_TweenState* TS);
90
91 void SetCurrentTweenStart() override;
92 void EraseHeadTween() override;
93 void UpdatePercentThroughTween(float PercentThroughTween) override;
94 void BeginTweening(float time, ITween* pInterp) override;
95
96 void StopTweening() override;
97 void FinishTweening() override;
98
99 void SetTexture(RageTexture* Texture);
100 [[nodiscard]] RageTexture* GetTexture() const { return _Texture; };
101 void LoadFromTexture(const RageTextureID& ID);
102
103 void UnloadTexture();
104 void SetNumVertices(size_t n);
105
106 void AddVertex();
107 void AddVertices(int Add);
108
109 void SetEffectMode(EffectMode em) { _EffectMode = em; }
110 void SetTextureMode(TextureMode tm) { _TextureMode = tm; }
111 void SetLineWidth(float width) { AMV_DestTweenState().line_width = width; }
112
113 void SetDrawState(DrawMode dm, int first, int num)
114 {
115 AMV_DestTweenState().SetDrawState(dm, first, num);
116 }
117
118 [[nodiscard]] DrawMode GetDestDrawMode() const
119 {
120 return AMV_DestTweenState()._DrawMode;
121 }
122 [[nodiscard]] int GetDestFirstToDraw() const
123 {
124 return AMV_DestTweenState().FirstToDraw;
125 }
126 [[nodiscard]] int GetDestNumToDraw() const
127 {
128 return AMV_DestTweenState().NumToDraw;
129 }
130 [[nodiscard]] DrawMode GetCurrDrawMode() const
131 {
132 return AMV_current._DrawMode;
133 }
134 [[nodiscard]] int GetCurrFirstToDraw() const
135 {
136 return AMV_current.FirstToDraw;
137 }
138 [[nodiscard]] int GetCurrNumToDraw() const { return AMV_current.NumToDraw; }
139 size_t GetNumVertices() { return AMV_DestTweenState().vertices.size(); }
140
141 void SetVertexPos(int index, float x, float y, float z);
142 void SetVertexColor(int index, const RageColor& c);
143 void SetVertexCoords(int index, float TexCoordX, float TexCoordY);
144
145 inline void SetVertsFromSplinesInternal(size_t num_splines,
146 size_t start_vert);
147 void SetVertsFromSplines();
148 CubicSplineN* GetSpline(size_t i);
149
150 struct State
151 {
152 RectF rect;
153 float delay;
154 };
155
156 [[nodiscard]] int GetNumStates() const override { return _states.size(); }
157 void AddState(const State& new_state) { _states.push_back(new_state); }
158 void RemoveState(size_t i)
159 {
160 ASSERT(i < _states.size());
161 _states.erase(_states.begin() + i);
162 }
163
164 [[nodiscard]] size_t GetState() const { return _cur_state; }
165 State& GetStateData(size_t i)
166 {
167 ASSERT(i < _states.size());
168 return _states[i];
169 }
170 void SetStateData(size_t i, const State& s)
171 {
172 ASSERT(i < _states.size());
173 _states[i] = s;
174 }
175 void SetStateProperties(const std::vector<State>& new_states)
176 {
177 _states = new_states;
178 SetState(0);
179 }
180 void SetState(int i) override;
181 void SetAllStateDelays(float delay);
182 [[nodiscard]] float GetAnimationLengthSeconds() const override;
183 void SetSecondsIntoAnimation(float seconds) override;
184 void UpdateAnimationState(bool force_update = false);
185
186 [[nodiscard]] size_t GetNumQuadStates() const
187 {
188 return AMV_DestTweenState().quad_states.size();
189 }
190 void AddQuadState(size_t s)
191 {
192 AMV_DestTweenState().quad_states.push_back(s);
193 }
194 void RemoveQuadState(size_t i)
195 {
196 AMV_DestTweenState().quad_states.erase(
197 AMV_DestTweenState().quad_states.begin() + i);
198 }
199 size_t GetQuadState(size_t i)
200 {
201 return AMV_DestTweenState().quad_states[i];
202 }
203 void SetQuadState(size_t i, size_t s)
204 {
205 AMV_DestTweenState().quad_states[i] = s;
206 }
207 bool _use_animation_state;
208 bool _decode_movie;
209
210 void PushSelf(lua_State* L) override;
211
212 private:
213 RageTexture* _Texture;
214
215 std::vector<RageSpriteVertex> _Vertices;
216 std::vector<AMV_TweenState> AMV_Tweens;
217 AMV_TweenState AMV_current;
218 AMV_TweenState AMV_start;
219
220 // required to handle diffuse and glow
221 AMV_TweenState* AMV_TempState;
222
223 EffectMode _EffectMode;
224 TextureMode _TextureMode;
225
226 // Four splines for controlling vert positions, because quads drawmode
227 // requires four. -Kyz
228 std::vector<CubicSplineN> _splines;
229
230 bool _skip_next_update;
231 float _secs_into_state;
232 size_t _cur_state;
233 std::vector<State> _states;
234};
235
236#endif // ACTOR_MULTI_VERTEX_H
Definition ActorMultiVertex.h:34
bool EarlyAbortDraw() const override
Allow the Actor to be aborted early.
Definition ActorMultiVertex.cpp:316
void DrawPrimitives() override
Draw the primitives of the Actor.
Definition ActorMultiVertex.cpp:209
Base class for all objects that appear on the screen.
Definition Actor.h:77
The interface for simple interpolation.
Definition Tween.h:29
Definition RageTexture.h:14
Definition XmlFile.h:95
Definition ActorMultiVertex.h:45
Definition ActorMultiVertex.h:151
Definition CubicSpline.h:55
Definition RageTypes.h:332
Definition RageTextureID.h:12