2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2019-09-23 19:00:23 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CToken.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/Graphics/CTexture.hpp"
|
|
|
|
#include "Runtime/Particle/IElement.hpp"
|
2016-02-05 08:34:14 +00:00
|
|
|
|
2019-12-03 08:47:05 +00:00
|
|
|
/* Documentation at: https://wiki.axiodl.com/w/Particle_Script#UV_Elements */
|
2016-02-28 06:55:05 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-02-05 08:34:14 +00:00
|
|
|
class CToken;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SUVElementSet {
|
|
|
|
float xMin, yMin, xMax, yMax;
|
2016-02-05 08:34:14 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CUVElement : public IElement {
|
2016-02-05 08:34:14 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual TLockedToken<CTexture> GetValueTexture(int frame) const = 0;
|
|
|
|
virtual void GetValueUV(int frame, SUVElementSet& valOut) const = 0;
|
|
|
|
virtual bool HasConstantTexture() const = 0;
|
|
|
|
virtual bool HasConstantUV() const = 0;
|
2016-02-05 08:34:14 +00:00
|
|
|
};
|
|
|
|
|
2020-04-24 04:59:49 +00:00
|
|
|
class CUVEConstant : public CUVElement {
|
2018-12-08 05:30:43 +00:00
|
|
|
TLockedToken<CTexture> x4_tex;
|
2016-04-02 08:42:00 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
2020-03-26 01:25:11 +00:00
|
|
|
explicit CUVEConstant(TToken<CTexture>&& tex) : x4_tex(std::move(tex)) {}
|
2020-04-24 04:58:44 +00:00
|
|
|
TLockedToken<CTexture> GetValueTexture([[maybe_unused]] int frame) const override {
|
|
|
|
return TLockedToken<CTexture>(x4_tex);
|
|
|
|
}
|
|
|
|
void GetValueUV([[maybe_unused]] int frame, SUVElementSet& valOut) const override { valOut = {0.f, 0.f, 1.f, 1.f}; }
|
2019-08-09 12:45:18 +00:00
|
|
|
bool HasConstantTexture() const override { return true; }
|
|
|
|
bool HasConstantUV() const override { return true; }
|
2016-02-05 08:34:14 +00:00
|
|
|
};
|
2016-02-05 01:27:03 +00:00
|
|
|
|
2020-04-24 04:59:49 +00:00
|
|
|
class CUVEAnimTexture : public CUVElement {
|
2018-12-08 05:30:43 +00:00
|
|
|
TLockedToken<CTexture> x4_tex;
|
|
|
|
int x10_tileW, x14_tileH, x18_strideW, x1c_strideH;
|
|
|
|
int x20_tiles;
|
|
|
|
bool x24_loop;
|
|
|
|
std::unique_ptr<CIntElement> x28_cycleFrames;
|
|
|
|
std::vector<SUVElementSet> x2c_uvElems;
|
|
|
|
|
2016-02-05 08:34:14 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CUVEAnimTexture(TToken<CTexture>&& tex, std::unique_ptr<CIntElement>&& tileW, std::unique_ptr<CIntElement>&& tileH,
|
|
|
|
std::unique_ptr<CIntElement>&& strideW, std::unique_ptr<CIntElement>&& strideH,
|
|
|
|
std::unique_ptr<CIntElement>&& cycleFrames, bool loop);
|
2020-04-24 04:58:44 +00:00
|
|
|
TLockedToken<CTexture> GetValueTexture([[maybe_unused]] int frame) const override {
|
|
|
|
return TLockedToken<CTexture>(x4_tex);
|
|
|
|
}
|
2019-08-09 12:45:18 +00:00
|
|
|
void GetValueUV(int frame, SUVElementSet& valOut) const override;
|
|
|
|
bool HasConstantTexture() const override { return true; }
|
|
|
|
bool HasConstantUV() const override { return false; }
|
2016-02-05 01:27:03 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|