CGuiModel imps

This commit is contained in:
Jack Andersen 2016-03-16 16:18:01 -10:00
parent b4514fc6a6
commit 79d90f46d3
16 changed files with 190 additions and 39 deletions

View File

@ -31,7 +31,7 @@ struct FRME : BigDNA
Value<bool> useAnimController;
Value<bool> defaultVisible;
Value<bool> defaultActive;
Value<bool> unk4;
Value<bool> cullFaces;
Value<atVec4f> color;
Value<atUint32> modelDrawFlags;
} header;
@ -114,7 +114,7 @@ struct FRME : BigDNA
};
Value<atUint32> blendMode;
Value<atUint32> lightMode;
Value<atUint32> lightMask;
};
struct LITEInfo : IWidgetInfo

View File

@ -249,8 +249,8 @@ public:
TLockedToken() : m_obj(nullptr) {}
TLockedToken(const CToken& other) : TToken<T>(other) {m_obj = TToken<T>::GetObj();}
TLockedToken(CToken&& other) : TToken<T>(std::move(other)) {m_obj = TToken<T>::GetObj();}
T* GetObj() {return m_obj;}
T* operator->() {return m_obj;}
T* GetObj() const {return m_obj;}
T* operator->() const {return m_obj;}
};
}

View File

@ -9,16 +9,23 @@ namespace urde
struct CModelFlags
{
u8 f1;
u8 f1; /* Blend state 3/5 enable additive */
u8 f2;
u16 f3;
zeus::CColor color;
u16 f3; /* Depth state */
zeus::CColor color; /* Set into kcolor slot specified by material */
/* depth flags
0x8: greater
0x10: non-inclusive
*/
};
class CModel
{
public:
void Draw(const CModelFlags& flags) const;
void Touch(int) const;
bool IsLoaded(int) const;
};
}

View File

@ -7,4 +7,12 @@ void CModel::Draw(const CModelFlags& flags) const
{
}
void CModel::Touch(int) const
{
}
bool CModel::IsLoaded(int) const
{
}
}

View File

@ -358,12 +358,18 @@ void CGuiFrame::EnableLights(u32 lights) const
CGraphics::DisableAllLights();
zeus::CColor accumColor(zeus::CColor::skBlack);
ERglLight lightId = ERglLight::Zero;
int idx = 0;
for (CGuiLight* light : xa0_lights)
{
// accumulate color
CGraphics::LoadLight(lightId, light->BuildLight());
CGraphics::EnableLight(lightId);
if ((lights & (1 << idx)) != 0)
{
// accumulate color
accumColor += light->GetColor();
CGraphics::LoadLight(lightId, light->BuildLight());
CGraphics::EnableLight(lightId);
}
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
}
if (xa0_lights.empty())
CGraphics::SetAmbientColor(zeus::CColor::skWhite);

View File

@ -27,6 +27,7 @@ public:
CLight BuildLight() const;
void SetIsVisible(bool vis);
u32 GetLoadedIdx() const {return x118_loadedIdx;}
const zeus::CColor& GetColor() const {return x11c_color;}
static CGuiLight* Create(CGuiFrame* frame, CInputStream& in, bool);
};

View File

@ -3,12 +3,14 @@
#include "CGuiSys.hpp"
#include "CSimplePool.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiWidgetDrawParms.hpp"
#include "Graphics/CGraphics.hpp"
namespace urde
{
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMode, bool flag)
: CGuiWidget(parms), x108_modelId(modelId), x10c_lightMode(lightMode)
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMask, bool flag)
: CGuiWidget(parms), x108_modelId(modelId), x10c_lightMask(lightMask)
{
if (!flag || (modelId & 0xffff) == 0xffff ||
parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two)
@ -17,15 +19,125 @@ CGuiModel::CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMode
xf8_model = parms.x0_frame->GetGuiSys().GetResStore().GetObj({SBIG('CMDL'), modelId});
}
std::vector<TResId> CGuiModel::GetModelAssets() const
{
return {x108_modelId};
}
bool CGuiModel::GetIsFinishedLoadingWidgetSpecific() const
{
if (!xf8_model)
return true;
CModel* model = xf8_model.GetObj();
if (!model)
return false;
model->Touch(0);
return model->IsLoaded(0);
}
void CGuiModel::Touch() const
{
CModel* model = xf8_model.GetObj();
if (model)
model->Touch(0);
}
void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
{
CGraphics::SetModelMatrix(x34_worldXF);
if (!xf8_model)
return;
if (!GetIsFinishedLoading())
return;
CModel* model = xf8_model.GetObj();
if (!model)
return;
if (GetIsVisible())
{
zeus::CColor moduCol = xb4_;
moduCol.a *= parms.x0_alphaMod;
xc8_frame->EnableLights(x10c_lightMask);
if (xf6_29_cullFaces)
CGraphics::SetCullMode(ERglCullMode::Front);
switch (xc4_drawFlags)
{
case EGuiModelDrawFlags::Zero:
{
CModelFlags flags;
flags.f1 = 0;
flags.f2 = 0;
flags.f3 = 3;
flags.color = zeus::CColor::skWhite;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::One:
{
CModelFlags flags;
flags.f1 = 1;
flags.f2 = 0;
flags.f3 = 3;
flags.color = moduCol;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Two:
{
CModelFlags flags;
flags.f1 = 4;
flags.f2 = 0;
flags.f3 = (xf7_24_ << 1) | xf6_31_;
flags.color = moduCol;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Three:
{
CModelFlags flags;
flags.f1 = 3;
flags.f2 = 0;
flags.f3 = (xf7_24_ << 1) | xf6_31_;
flags.color = moduCol;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Four:
{
CModelFlags flags;
flags.f1 = 4;
flags.f2 = 0;
flags.f3 = xf6_31_;
flags.color = moduCol;
model->Draw(flags);
flags.f1 = 5;
flags.f2 = 0;
flags.f3 = (xf7_24_ << 1) | xf6_31_;
flags.color = moduCol;
model->Draw(flags);
break;
}
default: break;
}
if (xf6_29_cullFaces)
CGraphics::SetCullMode(ERglCullMode::None);
}
CGuiWidget::Draw(parms);
}
CGuiModel* CGuiModel::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
TResId model = in.readUint32Big();
in.readUint32Big();
u32 lightMode = in.readUint32Big();
u32 lightMask = in.readUint32Big();
CGuiModel* ret = new CGuiModel(parms, model, lightMode, flag);
CGuiModel* ret = new CGuiModel(parms, model, lightMask, flag);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -12,9 +12,16 @@ class CGuiModel : public CGuiWidget
{
TLockedToken<CModel> xf8_model;
TResId x108_modelId;
u32 x10c_lightMode;
u32 x10c_lightMask;
public:
CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMode, bool flag);
CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMask, bool flag);
FourCC GetWidgetTypeID() const {return FOURCC('MODL');}
std::vector<TResId> GetModelAssets() const;
bool GetIsFinishedLoadingWidgetSpecific() const;
void Touch() const;
void Draw(const CGuiWidgetDrawParms& parms) const;
static CGuiModel* Create(CGuiFrame* frame, CInputStream& in, bool);
};

View File

@ -1,5 +1,5 @@
#include "CGuiObject.hpp"
#include "CGuiWidgetDrawParams.hpp"
#include "CGuiWidgetDrawParms.hpp"
namespace urde
{

View File

@ -7,7 +7,7 @@
namespace urde
{
class CGuiWidgetDrawParms;
struct CGuiWidgetDrawParms;
class CGuiMessage;
class CGuiFunctionDef;
struct CGuiControllerInfo;

View File

@ -27,7 +27,8 @@ CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
xc4_drawFlags(parms.x14_drawFlags), xc8_frame(parms.x0_frame),
xf6_24_pg(parms.xd_g), xf6_25_isVisible(parms.xa_defaultVisible),
xf6_26_isActive(parms.xb_defaultActive),
xf6_27_(true), xf6_28_eventLock(false), xf6_29_pf(parms.xc_f), xf6_30_(false),
xf6_27_(true), xf6_28_eventLock(false),
xf6_29_cullFaces(parms.xc_cullFaces), xf6_30_(false),
xf6_31_(true), xf7_24_(false), xf7_25_(true)
{
if (parms.x4_useAnimController)
@ -46,14 +47,14 @@ CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag)
bool useAnimController = in.readBool();
bool defaultVis = in.readBool();
bool defaultActive = in.readBool();
bool f = in.readBool();
bool cullFaces = in.readBool();
zeus::CColor color;
color.readRGBABig(in);
EGuiModelDrawFlags df = EGuiModelDrawFlags(in.readUint32Big());
return CGuiWidget::CGuiWidgetParms(frame, useAnimController, selfId,
parentId, defaultVis, defaultActive,
f, color, df, true, flag);
cullFaces, color, df, true, flag);
}
CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)

View File

@ -53,7 +53,11 @@ class CGuiWidget : public CGuiObject
public:
enum class EGuiModelDrawFlags
{
Two = 2
Zero = 0,
One = 1,
Two = 2,
Three = 3,
Four = 4
};
struct CGuiWidgetParms
{
@ -63,17 +67,18 @@ public:
s16 x8_parentId;
bool xa_defaultVisible;
bool xb_defaultActive;
bool xc_f;
bool xc_cullFaces;
bool xd_g;
bool xe_h;
zeus::CColor x10_color;
EGuiModelDrawFlags x14_drawFlags;
CGuiWidgetParms(CGuiFrame* frame, bool useAnimController, s16 selfId, s16 parentId,
bool defaultVisible, bool defaultActive,
bool f, const zeus::CColor& color, EGuiModelDrawFlags drawFlags, bool g, bool h)
bool defaultVisible, bool defaultActive, bool cullFaces,
const zeus::CColor& color, EGuiModelDrawFlags drawFlags,
bool g, bool h)
: x0_frame(frame), x4_useAnimController(useAnimController), x6_selfId(selfId),
x8_parentId(parentId), xa_defaultVisible(defaultVisible), xb_defaultActive(defaultActive),
xc_f(f), xd_g(g), xe_h(h), x10_color(color), x14_drawFlags(drawFlags) {}
xc_cullFaces(cullFaces), xd_g(g), xe_h(h), x10_color(color), x14_drawFlags(drawFlags) {}
};
static void LoadWidgetFnMap();
virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');}
@ -96,7 +101,7 @@ protected:
bool xf6_26_isActive : 1;
bool xf6_27_ : 1;
bool xf6_28_eventLock : 1;
bool xf6_29_pf : 1;
bool xf6_29_cullFaces : 1;
bool xf6_30_ : 1;
bool xf6_31_ : 1;
bool xf7_24_ : 1;

View File

@ -1,10 +0,0 @@
#ifndef __URDE_CGUIWIDGETDRAWPARAMS_HPP__
#define __URDE_CGUIWIDGETDRAWPARAMS_HPP__
namespace urde
{
}
#endif // __URDE_CGUIWIDGETDRAWPARAMS_HPP__

View File

@ -0,0 +1,14 @@
#ifndef __URDE_CGUIWIDGETDRAWPARMS_HPP__
#define __URDE_CGUIWIDGETDRAWPARMS_HPP__
namespace urde
{
struct CGuiWidgetDrawParms
{
float x0_alphaMod;
};
}
#endif // __URDE_CGUIWIDGETDRAWPARMS_HPP__

View File

@ -44,8 +44,8 @@ add_library(RuntimeCommonGuiSys
CGuiTextSupport.cpp
CGuiTextSupport.hpp
CGuiWidget.cpp
CGuiWidgetDrawParams.cpp
CGuiWidgetDrawParams.hpp
CGuiWidgetDrawParms.cpp
CGuiWidgetDrawParms.hpp
CGuiWidget.hpp
CMakeLists.txt
CSplashScreen.cpp