FRME Fixes

This commit is contained in:
Phillip Stephens 2017-01-21 07:46:51 -08:00
parent a1911e8262
commit 4a7a3bea2f
14 changed files with 151 additions and 40 deletions

View File

@ -619,7 +619,7 @@ static std::unique_ptr<uint8_t[]> ReadPalette(png_structp png, png_infop info, s
for (int i=0 ; i<paletteCount ; ++i)
{
png_sPLT_tp palette = &palettes[i];
if (!strcmp(palette->name, "GXPalette"))
if (!strncmp(palette->name, "GX_", 3))
{
if (palette->nentries > 16)
{

View File

@ -9,6 +9,7 @@ std::unique_ptr<std::vector<CCollisionPrimitive::Type>> CCollisionPrimitive::sCo
std::unique_ptr<std::vector<ComparisonFunc>> CCollisionPrimitive::sTableOfCollidables;
std::unique_ptr<std::vector<BooleanComparisonFunc>> CCollisionPrimitive::sTableOfBooleanCollidables;
std::unique_ptr<std::vector<MovingComparisonFunc>> CCollisionPrimitive::sTableOfMovingCollidables;
s32 CCollisionPrimitive::sNumTypes = 0;
bool CCollisionPrimitive::sTypesAdded = false;
bool CCollisionPrimitive::sTypesAdding = false;
bool CCollisionPrimitive::sCollidersAdded = false;
@ -68,13 +69,29 @@ void CCollisionPrimitive::InitAddMovingCollider(const MovingComparisonFunc& cmp,
InitAddMovingCollider({std::move(cmp), a, b});
}
void CCollisionPrimitive::InitAddCollider(const CCollisionPrimitive::Comparison& cmp) {}
void CCollisionPrimitive::InitAddCollider(const CCollisionPrimitive::Comparison& cmp)
{
}
void CCollisionPrimitive::InitAddCollider(const ComparisonFunc& cmp, const char* a, const char* b)
{
InitAddCollider({std::move(cmp), a, b});
}
void CCollisionPrimitive::InitEndColliders()
{
}
void CCollisionPrimitive::Unitialize()
{
sCollidersAdding = false;
sTypesAdding = false;
sCollisionTypeList.reset();
sTableOfCollidables.reset();
sTableOfMovingCollidables.reset();
sTableOfBooleanCollidables.reset();
}
CCollisionPrimitive::Type::Type(const std::function<void(u32)>& setter, const char* info)
: x0_setter(setter), x4_info(info)
{

View File

@ -94,6 +94,7 @@ private:
static std::unique_ptr<std::vector<ComparisonFunc>> sTableOfCollidables;
static std::unique_ptr<std::vector<BooleanComparisonFunc>> sTableOfBooleanCollidables;
static std::unique_ptr<std::vector<MovingComparisonFunc>> sTableOfMovingCollidables;
static s32 sNumTypes;
static bool sTypesAdded;
static bool sTypesAdding;
static bool sCollidersAdded;
@ -125,6 +126,8 @@ public:
static void InitAddCollider(const Comparison& cmp);
static void InitAddCollider(const ComparisonFunc&, const char*, const char*);
static void InitEndColliders();
static void Unitialize();
};
}

View File

@ -12,7 +12,9 @@ CAuiEnergyBarT01* CAuiEnergyBarT01::Create(CGuiFrame* frame, CInputStream& in, b
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
u32 a = in.readUint32Big();
return new CAuiEnergyBarT01(parms, a);
CAuiEnergyBarT01* ret = new CAuiEnergyBarT01(parms, a);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -0,0 +1,32 @@
#include "CAuiImagePane.hpp"
namespace urde
{
CAuiImagePane::CAuiImagePane(const CGuiWidget::CGuiWidgetParms& parms, s32, s32,
const rstl::reserved_vector<zeus::CVector3f, 4>&,
const rstl::reserved_vector<zeus::CVector2f, 4>&, bool)
: CGuiWidget(parms)
{
}
CGuiWidget* CAuiImagePane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
in.readUint32Big();
in.readUint32Big();
in.readUint32Big();
rstl::reserved_vector<zeus::CVector3f, 4> coords;
u32 coordCount = in.readUint32Big();
for (u32 i = 0; i < coordCount; ++i)
coords.push_back(in.readVec3fBig());
rstl::reserved_vector<zeus::CVector2f, 4> uvs;
u32 uvCount = in.readUint32Big();
for (u32 i = 0; i < uvCount; ++i)
uvs.push_back(in.readVec2fBig());
CAuiImagePane* ret = new CAuiImagePane(parms, -1, -1, coords, uvs, false);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -8,8 +8,12 @@ namespace urde
class CAuiImagePane : public CGuiWidget
{
};
public:
CAuiImagePane(const CGuiWidgetParms&, s32, s32, const rstl::reserved_vector<zeus::CVector3f, 4>&,
const rstl::reserved_vector<zeus::CVector2f, 4>&, bool);
static CGuiWidget* Create(CGuiFrame *frame, CInputStream &in, bool);
};
}
#endif // __URDE_CAUIIMAGEPANE_HPP__

View File

@ -76,6 +76,7 @@ CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag)
break;
}
frame->SetFrameCamera(ret);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -142,6 +142,7 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in)
{
DataSpec::DNAFourCC type;
type.read(in);
printf("%.4s\n", type.toString().c_str());
CGuiWidget* widget = CGuiSys::CreateWidgetInGame(type, in, this);
type = widget->GetWidgetTypeID();
switch (type)

View File

@ -57,7 +57,9 @@ CGuiPane* CGuiPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
float z = in.readFloatBig();
zeus::CVector3f scaleCenter;
scaleCenter.readBig(in);
return new CGuiPane(parms, x, z, scaleCenter);
CGuiPane* pane = new CGuiPane(parms, x, z, scaleCenter);
pane->ParseBaseInfo(frame, in, parms);
return pane;
}
}

View File

@ -117,8 +117,12 @@ CGuiTextPane* CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, bool flag
outlineCol.readRGBABig(in);
int extentX = in.readFloatBig();
int extentY = in.readFloatBig();
return new CGuiTextPane(parms, xDim, zDim, vec, fontId, props,
CGuiTextPane* ret = new CGuiTextPane(parms, xDim, zDim, vec, fontId, props,
fontCol, outlineCol, extentX, extentY);
ret->ParseBaseInfo(frame, in, parms);
ret->InitializeBuffers();
ret->TextSupport()->SetText("?\?(?\?)", false);
return ret;
}
}

View File

@ -65,7 +65,7 @@ void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWid
ReapplyXform();
zeus::CVector3f rotCenter;
rotCenter.readBig(in);
SetRotationCenter(rotCenter);
in.readUint32Big();
in.readUint16Big();
if (a)
if (!parent->AddWorkerWidget(this))

View File

@ -146,6 +146,8 @@ public:
float GetPitch() const;
float GetYaw() const;
const CModelData* GetModelData() const { return x64_modelData.get(); }
void EnsureRendered(const CStateManager&);
void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CVector3f&);
};
}

View File

@ -3,45 +3,76 @@
namespace urde
{
CWorldLight::CWorldLight(CInputStream& in)
: x0_type(ELightType(in.readUint32Big())),
x4_color(zeus::CVector3f::ReadBig(in)),
x10_position(zeus::CVector3f::ReadBig(in)),
x1c_direction(zeus::CVector3f::ReadBig(in)),
x28_q(in.readFloatBig()),
x2c_cutoffAngle(in.readFloatBig()),
x34_castShadows(in.readBool()),
x38_(in.readFloatBig()),
x3c_falloff(EFalloffType(in.readUint32Big())),
x40_(in.readFloatBig())
: x0_type(EWorldLightType(in.readUint32Big()))
, x4_color(zeus::CVector3f::ReadBig(in))
, x10_position(zeus::CVector3f::ReadBig(in))
, x1c_direction(zeus::CVector3f::ReadBig(in))
, x28_q(in.readFloatBig())
, x2c_cutoffAngle(in.readFloatBig())
, x30_(in.readFloatBig())
, x34_castShadows(in.readBool())
, x38_(in.readFloatBig())
, x3c_falloff(EFalloffType(in.readUint32Big()))
, x40_(in.readFloatBig())
{
}
std::tuple<float, float, float> CalculateLightFalloff(EFalloffType falloff, float q)
{
float constant = 0.f;
float linear = 0.f;
float quadratic = 0.f;
if (falloff == EFalloffType::Constant)
constant = 2.f / q;
else if (falloff == EFalloffType::Linear)
linear = 250.f / q;
else if (falloff == EFalloffType::Quadratic)
quadratic = 25000.f / q;
return {constant, linear, quadratic};
}
CLight CWorldLight::GetAsCGraphicsLight() const
{
const float epsilon = 1.1920929e-7;
zeus::CVector3f tmpColor = x4_color;
zeus::CColor color(x4_color.x, x4_color.y, x4_color.z);
float tmp = x28_q;
if (epsilon < tmp)
tmp = 0.000001f;
/*
if (x0_type == ELightType::Spot)
zeus::CVector3f float_color = x4_color;
zeus::CColor tmpColor;
float q = x28_q;
if (q < FLT_EPSILON)
q = 0.000001f;
if (x0_type == EWorldLightType::LocalAmbient)
{
float f2 = tmpColor.x;
float f0 = tmpColor.y;
float f1 = tmpColor.z;
float f3 = f2 * tmp;
f2 = f0 * tmp;
f0 = 1.0f;
f1 *= tmp;
tmpColor.x = f3;
tmpColor.y = f2;
tmpColor.z = f1;
float_color *= q;
if (float_color.x >= 1.f)
float_color.x = 1.f;
if (f3 >= f0)
if (float_color.y >= 1.f)
float_color.y = 1.f;
if (float_color.z >= 1.f)
float_color.z = 1.f;
return CLight::BuildLocalAmbient(x10_position, zeus::CColor(float_color.x, float_color.y, float_color.z, 1.f));
}
*/
return CLight::BuildPoint({}, {});
}
else if (x0_type == EWorldLightType::Directional)
{
return CLight::BuildDirectional(x1c_direction, tmpColor);
}
else if (x0_type == EWorldLightType::Spot)
{
CLight light = CLight::BuildSpot(x10_position, x1c_direction.normalized(), tmpColor, x2c_cutoffAngle * .5f);
float c, l, q;
std::tie(c, l, q) = CalculateLightFalloff(x3c_falloff, x28_q);
light.SetAttenuation(c, l, q);
return light;
}
float distC, distL, distQ;
std::tie(distC, distL, distQ) = CalculateLightFalloff(x3c_falloff, x28_q);
return CLight::BuildCustom(x10_position, zeus::CVector3f{0.f, 1.f, 0.f},
zeus::CColor{x4_color.x, x4_color.y, x4_color.z, 1.f}, distC, distL, distQ, 1.f, 0.f,
0.f);
}
}

View File

@ -7,7 +7,19 @@ namespace urde
{
class CWorldLight
{
ELightType x0_type = ELightType::Custom;
public:
enum class EWorldLightType
{
LocalAmbient,
Directional,
Custom,
Spot,
Spot2,
LocalAmbient2,
};
private:
EWorldLightType x0_type = EWorldLightType::Spot2;
zeus::CVector3f x4_color;
zeus::CVector3f x10_position;
zeus::CVector3f x1c_direction;