prime/include/Kyoto/Graphics/CModelFlags.hpp

114 lines
3.6 KiB
C++
Raw Normal View History

#ifndef _CMODELFLAGS
#define _CMODELFLAGS
2022-08-13 01:26:00 +00:00
#include "types.h"
#include "Kyoto/Graphics/CColor.hpp"
class CModelFlags {
public:
enum ETrans {
kT_Opaque = 0,
2022-10-11 15:30:39 +00:00
kT_One = 1, // ?
kT_Two = 2, // ?
2022-08-13 01:26:00 +00:00
kT_Blend = 5,
kT_Additive = 7,
};
enum EFlags {
kF_DepthCompare = 0x1,
kF_DepthUpdate = 0x2,
kF_NoTextureLock = 0x4,
kF_DepthGreater = 0x8,
kF_DepthNonInclusive = 0x10,
kF_DrawNormal = 0x20,
kF_ThermalUnsortedOnly = 0x40,
};
CModelFlags(ETrans trans, float rgba)
2022-09-18 06:05:46 +00:00
: x0_blendMode(trans)
, x1_matSetIdx(0)
, x2_flags(kF_DepthCompare | kF_DepthUpdate)
2022-10-05 23:06:15 +00:00
, x4_color(1.f, 1.f, 1.f, rgba) {}
2022-08-13 01:26:00 +00:00
CModelFlags(ETrans trans, CColor color)
2022-09-18 06:05:46 +00:00
: x0_blendMode(trans)
, x1_matSetIdx(0)
, x2_flags(kF_DepthCompare | kF_DepthUpdate)
, x4_color(color) {}
2022-10-05 23:06:15 +00:00
CModelFlags(ETrans blendMode, uchar shadIdx, EFlags flags, const CColor& col)
2022-10-05 18:05:56 +00:00
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {}
CModelFlags(const CModelFlags& flags, uint otherFlags)
2022-09-18 06:05:46 +00:00
: x0_blendMode(flags.x0_blendMode)
, x1_matSetIdx(flags.x1_matSetIdx)
, x2_flags(otherFlags)
, x4_color(flags.x4_color) {}
CModelFlags(const CModelFlags& flags, bool b /* TODO what's this? */, int shaderSet)
2022-09-18 06:05:46 +00:00
: x0_blendMode(flags.x0_blendMode)
, x1_matSetIdx(shaderSet)
, x2_flags(flags.x2_flags)
, x4_color(flags.x4_color) {}
2022-08-13 01:26:00 +00:00
// ?
CModelFlags(const CModelFlags& flags, ETrans trans, CColor color)
2022-09-18 06:05:46 +00:00
: x0_blendMode(trans)
, x1_matSetIdx(flags.x1_matSetIdx)
, x2_flags(flags.x2_flags)
, x4_color(color) {}
2022-10-05 23:06:15 +00:00
// CModelFlags(const CModelFlags& other) : x0_blendMode(other.x0_blendMode),
// x1_matSetIdx(other.x1_matSetIdx), x2_flags(other.x2_flags), x4_color(other.x4_color) {}
CModelFlags& operator=(const CModelFlags& other) {
x0_blendMode = other.x0_blendMode;
x1_matSetIdx = other.x1_matSetIdx;
x2_flags = other.x2_flags;
x4_color = other.x4_color;
return *this;
}
CModelFlags UseShaderSet(int matSet) const { return CModelFlags(*this, false, matSet); }
CModelFlags DontLoadTextures() const {
return CModelFlags(*this, GetOtherFlags() | kF_NoTextureLock);
}
CModelFlags DepthCompareUpdate(bool compare, bool update) const {
uint newFlags = 0;
2022-08-13 01:26:00 +00:00
if (compare) {
2022-10-05 23:06:15 +00:00
newFlags |= kF_DepthCompare;
2022-08-13 01:26:00 +00:00
}
if (update) {
2022-10-05 23:06:15 +00:00
newFlags |= kF_DepthUpdate;
2022-08-13 01:26:00 +00:00
}
2022-10-05 23:06:15 +00:00
return CModelFlags(*this, (x2_flags & ~(kF_DepthCompare | kF_DepthUpdate)) | newFlags);
}
CModelFlags DepthBackwards() const {
return CModelFlags(*this, GetOtherFlags() | kF_DepthGreater);
2022-08-13 01:26:00 +00:00
}
ETrans GetTrans() const { return static_cast< ETrans >(x0_blendMode); }
int GetShaderSet() const { return x1_matSetIdx; }
uint GetOtherFlags() const { return x2_flags; }
2022-08-13 01:26:00 +00:00
CColor GetColor() const { return x4_color; }
static CModelFlags Normal() { return CModelFlags(kT_Opaque, 1.f); }
static CModelFlags AlphaBlended(float alpha) { return CModelFlags(kT_Blend, alpha); }
2022-10-11 15:30:39 +00:00
static CModelFlags AlphaBlended(const CColor& color) { return CModelFlags(kT_Blend, color); }
static CModelFlags Additive(float f);
2022-08-13 01:26:00 +00:00
static CModelFlags Additive(const CColor& color);
static CModelFlags AdditiveRGB(const CColor& color);
static CModelFlags ColorModulate(const CColor& color);
private:
uchar x0_blendMode;
uchar x1_matSetIdx;
ushort x2_flags;
2022-08-13 01:26:00 +00:00
CColor x4_color;
};
CHECK_SIZEOF(CModelFlags, 0x8)
2022-11-04 05:25:39 +00:00
static inline bool operator==(const CModelFlags& lhs, const CModelFlags& rhs) {
return lhs.GetTrans() == rhs.GetTrans() && lhs.GetShaderSet() == rhs.GetShaderSet() &&
lhs.GetOtherFlags() == rhs.GetOtherFlags() && lhs.GetColor() == rhs.GetColor();
}
#endif // _CMODELFLAGS