mirror of https://github.com/PrimeDecomp/prime.git
parent
8498bd6e94
commit
5707a847da
|
@ -26,8 +26,6 @@ public:
|
|||
mA = a;
|
||||
}
|
||||
|
||||
CColor(CColor rgb, float a) : mRgba((rgb.GetColor_u32() & 0xffffff00) | CCast::ToUint8(a * 255.f)) {}
|
||||
|
||||
void Set(float r, float g, float b, float a);
|
||||
void Set(uchar r, uchar g, uchar b, uchar a = 255) {
|
||||
mR = r;
|
||||
|
@ -37,9 +35,9 @@ public:
|
|||
}
|
||||
void Get(float& r, float& g, float& b, float& a) const;
|
||||
void Get(float& r, float& g, float& b) const;
|
||||
void SetAlpha(float a) {
|
||||
mA = CCast::ToUint8(a * 255.f);
|
||||
}
|
||||
// TODO check
|
||||
void SetAlpha(float a) { mA = CCast::ToUint8(a * 255.f); }
|
||||
void SetAlpha(uchar a) { mRgba = (mRgba & ~0xff) | a; }
|
||||
|
||||
static CColor Lerp(const CColor& a, const CColor& b, float t);
|
||||
static uint Lerp(uint a, uint b, float t);
|
||||
|
@ -54,7 +52,8 @@ public:
|
|||
uchar GetBlueu8() const { return mB; }
|
||||
uchar GetAlphau8() const { return mA; }
|
||||
ushort ToRGB5A3() const;
|
||||
GXColor ToGX(uint);
|
||||
// TODO check
|
||||
static GXColor ToGX(uint c) { return *reinterpret_cast< const GXColor* >(&c); }
|
||||
uint GetColor_u32() const { return mRgba; }
|
||||
|
||||
static const CColor& Black();
|
||||
|
|
|
@ -17,8 +17,7 @@ public:
|
|||
CAssetId c = kInvalidAssetId, CAssetId d = kInvalidAssetId,
|
||||
CAssetId e = kInvalidAssetId, CAssetId f = kInvalidAssetId,
|
||||
CAssetId g = kInvalidAssetId, CAssetId h = kInvalidAssetId)
|
||||
: count(8)
|
||||
{
|
||||
: count(8) {
|
||||
data[0] = a;
|
||||
data[1] = b;
|
||||
data[2] = c;
|
||||
|
@ -33,9 +32,8 @@ public:
|
|||
CPlasmaProjectile(const TToken< CWeaponDescription >& wDesc, const rstl::string& name,
|
||||
EWeaponType wType, const CBeamInfo& bInfo, const CTransform4f& xf,
|
||||
EMaterialTypes matType, const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid,
|
||||
TUniqueId owner,
|
||||
|
||||
const PlayerEffectResources& res, bool growingBeam, EProjectileAttrib attribs);
|
||||
TUniqueId owner, const PlayerEffectResources& res, bool growingBeam,
|
||||
EProjectileAttrib attribs);
|
||||
|
||||
void Accept(IVisitor& visitor) override;
|
||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override;
|
||||
|
|
|
@ -7,14 +7,8 @@ namespace rstl {
|
|||
template < typename L, typename R >
|
||||
class pair {
|
||||
public:
|
||||
inline pair() {}
|
||||
inline pair(const L& first, const R& second) : first(first), second(second) {}
|
||||
|
||||
inline pair& operator=(const pair& other) {
|
||||
first = other.first;
|
||||
second = other.second;
|
||||
return *this;
|
||||
}
|
||||
pair() {}
|
||||
pair(const L& first, const R& second) : first(first), second(second) {}
|
||||
|
||||
L first;
|
||||
R second;
|
||||
|
|
|
@ -29,11 +29,11 @@ void CVector3f::PutTo(COutputStream& out) const {
|
|||
}
|
||||
|
||||
CVector3f CVector3f::Slerp(const CVector3f& a, const CVector3f& b, const CRelAngle& angle) {
|
||||
CVector3f ab = CVector3f::Cross(a, b);
|
||||
CVector3f vec = CVector3f::Cross(ab.AsNormalized(), a);
|
||||
float sinAngle = sine(angle);
|
||||
float cosAngle = cosine(angle);
|
||||
return cosAngle * a + vec * sinAngle;
|
||||
CVector3f axb = CVector3f::Cross(a, b).AsNormalized();
|
||||
CVector3f crs = CVector3f::Cross(axb, a);
|
||||
float asin = sine(angle);
|
||||
float acos = cosine(angle);
|
||||
return acos * a + asin * crs;
|
||||
}
|
||||
|
||||
CVector3f& CVector3f::Normalize() {
|
||||
|
|
|
@ -135,7 +135,9 @@ void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const
|
|||
if (!close_enough(x24_, 0.f, 1.0E-5f)) {
|
||||
float acos = 0.f;
|
||||
if (!close_enough(x20_f3, 0.f, 1.0E-5f)) {
|
||||
CVector3f camDist(CVector3f(inPosCopy.GetX() - camPos.GetX(), inPosCopy.GetY() - camPos.GetY(), 0.f).AsNormalized());
|
||||
CVector3f camDist(
|
||||
CVector3f(inPosCopy.GetX() - camPos.GetX(), inPosCopy.GetY() - camPos.GetY(), 0.f)
|
||||
.AsNormalized());
|
||||
CVector3f camDir(CVector3f(camFront.GetX(), camFront.GetY(), 0.f).AsNormalized());
|
||||
acos = CMath::ArcCosineR(CVector3f::Dot(camDist, camDir));
|
||||
if (camDist.GetX() * camDir.GetY() - camDir.GetX() * camDist.GetY() < 0.f) {
|
||||
|
@ -179,27 +181,32 @@ void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const
|
|||
}
|
||||
|
||||
void CVisorFlare::DrawDirect(const CColor& color, float f1, float f2) const {
|
||||
// Giant TODO
|
||||
// CColor kcolor = color;
|
||||
// kcolor.a() *= x24_; // TODO i think this is wrong
|
||||
GXColor gxColor;
|
||||
CGX::SetTevKColor(GX_KCOLOR0, gxColor);
|
||||
CColor kcolor = color;
|
||||
kcolor.SetAlpha(kcolor.GetAlpha() * x24_);
|
||||
CGX::SetTevKColor(GX_KCOLOR0, *reinterpret_cast< const GXColor* >(&kcolor));
|
||||
CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
|
||||
// GXPosition3f32(f1 - f2, 0.f, f2 + f1);
|
||||
// GXTexCoord2f32(0.f, 1.f);
|
||||
// GXPosition3f32(f2 + f1, 0.f, f2 - f1);
|
||||
// GXTexCoord2f32(1.f, 1.f);
|
||||
// GXPosition3f32(-(f2 - f1), 0.f, -(f2 - f1));
|
||||
// GXTexCoord2f32(0.f, 0.f);
|
||||
// GXPosition3f32(-f1 + f2, 0.f, -f2 - f1);
|
||||
// GXTexCoord2f32(1.f, 0.f);
|
||||
GXPosition3f32(f1 - f2, 0.f, f2 + f1);
|
||||
GXTexCoord2f32(0.f, 1.f);
|
||||
GXPosition3f32(f2 + f1, 0.f, f2 - f1);
|
||||
GXTexCoord2f32(1.f, 1.f);
|
||||
GXPosition3f32(-(f2 - f1), 0.f, -(f2 - f1));
|
||||
GXTexCoord2f32(0.f, 0.f);
|
||||
GXPosition3f32(-f1 + f2, 0.f, -f2 - f1);
|
||||
GXTexCoord2f32(1.f, 0.f);
|
||||
CGX::End();
|
||||
}
|
||||
|
||||
// fake but close
|
||||
static inline CColor ModulateAlpha(const CColor& color, float alphaMod) {
|
||||
uchar a = CCast::ToUint8(static_cast< float >(color.GetAlphau8()) * alphaMod);
|
||||
CColor result = color;
|
||||
result.SetAlpha(a);
|
||||
return result;
|
||||
}
|
||||
|
||||
void CVisorFlare::DrawStreamed(const CColor& color, float f1, float f2) const {
|
||||
CGraphics::StreamBegin(kP_TriangleStrip);
|
||||
float a = color.GetAlpha(); // TODO: incorrect
|
||||
CGraphics::StreamColor(CColor(color, a * x24_));
|
||||
CGraphics::StreamColor(ModulateAlpha(color, x24_));
|
||||
CGraphics::StreamTexcoord(0.f, 1.f);
|
||||
CGraphics::StreamVertex(f1 - f2, 0.f, f2 + f1);
|
||||
CGraphics::StreamTexcoord(1.f, 1.f);
|
||||
|
|
Loading…
Reference in New Issue