metaforce/Runtime/Particle/CUVElement.hpp

54 lines
1.8 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-02-05 08:34:14 +00:00
#include "IElement.hpp"
#include "CToken.hpp"
2016-03-04 23:04:53 +00:00
#include "Graphics/CTexture.hpp"
2016-02-05 08:34:14 +00:00
2016-02-28 06:55:05 +00:00
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#UV_Elements */
2018-12-08 05:30:43 +00:00
namespace urde {
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
};
2018-12-08 05:30:43 +00:00
struct CUVEConstant : public CUVElement {
TLockedToken<CTexture> x4_tex;
2018-12-08 05:30:43 +00:00
public:
CUVEConstant(TToken<CTexture>&& tex) : x4_tex(std::move(tex)) {}
TLockedToken<CTexture> GetValueTexture(int frame) const { return TLockedToken<CTexture>(x4_tex); }
void GetValueUV(int frame, SUVElementSet& valOut) const { valOut = {0.f, 0.f, 1.f, 1.f}; }
bool HasConstantTexture() const { return true; }
bool HasConstantUV() const { return true; }
2016-02-05 08:34:14 +00:00
};
2018-12-08 05:30:43 +00:00
struct CUVEAnimTexture : public CUVElement {
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);
TLockedToken<CTexture> GetValueTexture(int frame) const { return TLockedToken<CTexture>(x4_tex); }
void GetValueUV(int frame, SUVElementSet& valOut) const;
bool HasConstantTexture() const { return true; }
bool HasConstantUV() const { return false; }
};
2018-12-08 05:30:43 +00:00
} // namespace urde