mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-04 12:35:52 +00:00
CGuiModel imps
This commit is contained in:
parent
b4514fc6a6
commit
79d90f46d3
@ -31,7 +31,7 @@ struct FRME : BigDNA
|
|||||||
Value<bool> useAnimController;
|
Value<bool> useAnimController;
|
||||||
Value<bool> defaultVisible;
|
Value<bool> defaultVisible;
|
||||||
Value<bool> defaultActive;
|
Value<bool> defaultActive;
|
||||||
Value<bool> unk4;
|
Value<bool> cullFaces;
|
||||||
Value<atVec4f> color;
|
Value<atVec4f> color;
|
||||||
Value<atUint32> modelDrawFlags;
|
Value<atUint32> modelDrawFlags;
|
||||||
} header;
|
} header;
|
||||||
@ -114,7 +114,7 @@ struct FRME : BigDNA
|
|||||||
};
|
};
|
||||||
|
|
||||||
Value<atUint32> blendMode;
|
Value<atUint32> blendMode;
|
||||||
Value<atUint32> lightMode;
|
Value<atUint32> lightMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LITEInfo : IWidgetInfo
|
struct LITEInfo : IWidgetInfo
|
||||||
|
@ -249,8 +249,8 @@ public:
|
|||||||
TLockedToken() : m_obj(nullptr) {}
|
TLockedToken() : m_obj(nullptr) {}
|
||||||
TLockedToken(const CToken& other) : TToken<T>(other) {m_obj = TToken<T>::GetObj();}
|
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();}
|
TLockedToken(CToken&& other) : TToken<T>(std::move(other)) {m_obj = TToken<T>::GetObj();}
|
||||||
T* GetObj() {return m_obj;}
|
T* GetObj() const {return m_obj;}
|
||||||
T* operator->() {return m_obj;}
|
T* operator->() const {return m_obj;}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,23 @@ namespace urde
|
|||||||
|
|
||||||
struct CModelFlags
|
struct CModelFlags
|
||||||
{
|
{
|
||||||
u8 f1;
|
u8 f1; /* Blend state 3/5 enable additive */
|
||||||
u8 f2;
|
u8 f2;
|
||||||
u16 f3;
|
u16 f3; /* Depth state */
|
||||||
zeus::CColor color;
|
zeus::CColor color; /* Set into kcolor slot specified by material */
|
||||||
|
|
||||||
|
/* depth flags
|
||||||
|
0x8: greater
|
||||||
|
0x10: non-inclusive
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
class CModel
|
class CModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Draw(const CModelFlags& flags) const;
|
void Draw(const CModelFlags& flags) const;
|
||||||
|
void Touch(int) const;
|
||||||
|
bool IsLoaded(int) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,4 +7,12 @@ void CModel::Draw(const CModelFlags& flags) const
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModel::Touch(int) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CModel::IsLoaded(int) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -358,12 +358,18 @@ void CGuiFrame::EnableLights(u32 lights) const
|
|||||||
CGraphics::DisableAllLights();
|
CGraphics::DisableAllLights();
|
||||||
zeus::CColor accumColor(zeus::CColor::skBlack);
|
zeus::CColor accumColor(zeus::CColor::skBlack);
|
||||||
ERglLight lightId = ERglLight::Zero;
|
ERglLight lightId = ERglLight::Zero;
|
||||||
|
int idx = 0;
|
||||||
for (CGuiLight* light : xa0_lights)
|
for (CGuiLight* light : xa0_lights)
|
||||||
{
|
{
|
||||||
// accumulate color
|
if ((lights & (1 << idx)) != 0)
|
||||||
CGraphics::LoadLight(lightId, light->BuildLight());
|
{
|
||||||
CGraphics::EnableLight(lightId);
|
// accumulate color
|
||||||
|
accumColor += light->GetColor();
|
||||||
|
CGraphics::LoadLight(lightId, light->BuildLight());
|
||||||
|
CGraphics::EnableLight(lightId);
|
||||||
|
}
|
||||||
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
|
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
|
||||||
|
++idx;
|
||||||
}
|
}
|
||||||
if (xa0_lights.empty())
|
if (xa0_lights.empty())
|
||||||
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
|
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
|
||||||
|
@ -27,6 +27,7 @@ public:
|
|||||||
CLight BuildLight() const;
|
CLight BuildLight() const;
|
||||||
void SetIsVisible(bool vis);
|
void SetIsVisible(bool vis);
|
||||||
u32 GetLoadedIdx() const {return x118_loadedIdx;}
|
u32 GetLoadedIdx() const {return x118_loadedIdx;}
|
||||||
|
const zeus::CColor& GetColor() const {return x11c_color;}
|
||||||
|
|
||||||
static CGuiLight* Create(CGuiFrame* frame, CInputStream& in, bool);
|
static CGuiLight* Create(CGuiFrame* frame, CInputStream& in, bool);
|
||||||
};
|
};
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
#include "CGuiSys.hpp"
|
#include "CGuiSys.hpp"
|
||||||
#include "CSimplePool.hpp"
|
#include "CSimplePool.hpp"
|
||||||
#include "CGuiAnimController.hpp"
|
#include "CGuiAnimController.hpp"
|
||||||
|
#include "CGuiWidgetDrawParms.hpp"
|
||||||
|
#include "Graphics/CGraphics.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMode, bool flag)
|
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, TResId modelId, u32 lightMask, bool flag)
|
||||||
: CGuiWidget(parms), x108_modelId(modelId), x10c_lightMode(lightMode)
|
: CGuiWidget(parms), x108_modelId(modelId), x10c_lightMask(lightMask)
|
||||||
{
|
{
|
||||||
if (!flag || (modelId & 0xffff) == 0xffff ||
|
if (!flag || (modelId & 0xffff) == 0xffff ||
|
||||||
parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two)
|
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});
|
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)
|
CGuiModel* CGuiModel::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||||
{
|
{
|
||||||
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
||||||
|
|
||||||
TResId model = in.readUint32Big();
|
TResId model = in.readUint32Big();
|
||||||
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);
|
ret->ParseBaseInfo(frame, in, parms);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,16 @@ class CGuiModel : public CGuiWidget
|
|||||||
{
|
{
|
||||||
TLockedToken<CModel> xf8_model;
|
TLockedToken<CModel> xf8_model;
|
||||||
TResId x108_modelId;
|
TResId x108_modelId;
|
||||||
u32 x10c_lightMode;
|
u32 x10c_lightMask;
|
||||||
public:
|
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);
|
static CGuiModel* Create(CGuiFrame* frame, CInputStream& in, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "CGuiObject.hpp"
|
#include "CGuiObject.hpp"
|
||||||
#include "CGuiWidgetDrawParams.hpp"
|
#include "CGuiWidgetDrawParms.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
class CGuiWidgetDrawParms;
|
struct CGuiWidgetDrawParms;
|
||||||
class CGuiMessage;
|
class CGuiMessage;
|
||||||
class CGuiFunctionDef;
|
class CGuiFunctionDef;
|
||||||
struct CGuiControllerInfo;
|
struct CGuiControllerInfo;
|
||||||
|
@ -27,7 +27,8 @@ CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
|
|||||||
xc4_drawFlags(parms.x14_drawFlags), xc8_frame(parms.x0_frame),
|
xc4_drawFlags(parms.x14_drawFlags), xc8_frame(parms.x0_frame),
|
||||||
xf6_24_pg(parms.xd_g), xf6_25_isVisible(parms.xa_defaultVisible),
|
xf6_24_pg(parms.xd_g), xf6_25_isVisible(parms.xa_defaultVisible),
|
||||||
xf6_26_isActive(parms.xb_defaultActive),
|
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)
|
xf6_31_(true), xf7_24_(false), xf7_25_(true)
|
||||||
{
|
{
|
||||||
if (parms.x4_useAnimController)
|
if (parms.x4_useAnimController)
|
||||||
@ -46,14 +47,14 @@ CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag)
|
|||||||
bool useAnimController = in.readBool();
|
bool useAnimController = in.readBool();
|
||||||
bool defaultVis = in.readBool();
|
bool defaultVis = in.readBool();
|
||||||
bool defaultActive = in.readBool();
|
bool defaultActive = in.readBool();
|
||||||
bool f = in.readBool();
|
bool cullFaces = in.readBool();
|
||||||
zeus::CColor color;
|
zeus::CColor color;
|
||||||
color.readRGBABig(in);
|
color.readRGBABig(in);
|
||||||
EGuiModelDrawFlags df = EGuiModelDrawFlags(in.readUint32Big());
|
EGuiModelDrawFlags df = EGuiModelDrawFlags(in.readUint32Big());
|
||||||
|
|
||||||
return CGuiWidget::CGuiWidgetParms(frame, useAnimController, selfId,
|
return CGuiWidget::CGuiWidgetParms(frame, useAnimController, selfId,
|
||||||
parentId, defaultVis, defaultActive,
|
parentId, defaultVis, defaultActive,
|
||||||
f, color, df, true, flag);
|
cullFaces, color, df, true, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||||
|
@ -53,7 +53,11 @@ class CGuiWidget : public CGuiObject
|
|||||||
public:
|
public:
|
||||||
enum class EGuiModelDrawFlags
|
enum class EGuiModelDrawFlags
|
||||||
{
|
{
|
||||||
Two = 2
|
Zero = 0,
|
||||||
|
One = 1,
|
||||||
|
Two = 2,
|
||||||
|
Three = 3,
|
||||||
|
Four = 4
|
||||||
};
|
};
|
||||||
struct CGuiWidgetParms
|
struct CGuiWidgetParms
|
||||||
{
|
{
|
||||||
@ -63,17 +67,18 @@ public:
|
|||||||
s16 x8_parentId;
|
s16 x8_parentId;
|
||||||
bool xa_defaultVisible;
|
bool xa_defaultVisible;
|
||||||
bool xb_defaultActive;
|
bool xb_defaultActive;
|
||||||
bool xc_f;
|
bool xc_cullFaces;
|
||||||
bool xd_g;
|
bool xd_g;
|
||||||
bool xe_h;
|
bool xe_h;
|
||||||
zeus::CColor x10_color;
|
zeus::CColor x10_color;
|
||||||
EGuiModelDrawFlags x14_drawFlags;
|
EGuiModelDrawFlags x14_drawFlags;
|
||||||
CGuiWidgetParms(CGuiFrame* frame, bool useAnimController, s16 selfId, s16 parentId,
|
CGuiWidgetParms(CGuiFrame* frame, bool useAnimController, s16 selfId, s16 parentId,
|
||||||
bool defaultVisible, bool defaultActive,
|
bool defaultVisible, bool defaultActive, bool cullFaces,
|
||||||
bool f, const zeus::CColor& color, EGuiModelDrawFlags drawFlags, bool g, bool h)
|
const zeus::CColor& color, EGuiModelDrawFlags drawFlags,
|
||||||
|
bool g, bool h)
|
||||||
: x0_frame(frame), x4_useAnimController(useAnimController), x6_selfId(selfId),
|
: x0_frame(frame), x4_useAnimController(useAnimController), x6_selfId(selfId),
|
||||||
x8_parentId(parentId), xa_defaultVisible(defaultVisible), xb_defaultActive(defaultActive),
|
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();
|
static void LoadWidgetFnMap();
|
||||||
virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');}
|
virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');}
|
||||||
@ -96,7 +101,7 @@ protected:
|
|||||||
bool xf6_26_isActive : 1;
|
bool xf6_26_isActive : 1;
|
||||||
bool xf6_27_ : 1;
|
bool xf6_27_ : 1;
|
||||||
bool xf6_28_eventLock : 1;
|
bool xf6_28_eventLock : 1;
|
||||||
bool xf6_29_pf : 1;
|
bool xf6_29_cullFaces : 1;
|
||||||
bool xf6_30_ : 1;
|
bool xf6_30_ : 1;
|
||||||
bool xf6_31_ : 1;
|
bool xf6_31_ : 1;
|
||||||
bool xf7_24_ : 1;
|
bool xf7_24_ : 1;
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#ifndef __URDE_CGUIWIDGETDRAWPARAMS_HPP__
|
|
||||||
#define __URDE_CGUIWIDGETDRAWPARAMS_HPP__
|
|
||||||
|
|
||||||
namespace urde
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __URDE_CGUIWIDGETDRAWPARAMS_HPP__
|
|
14
Runtime/GuiSys/CGuiWidgetDrawParms.hpp
Normal file
14
Runtime/GuiSys/CGuiWidgetDrawParms.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __URDE_CGUIWIDGETDRAWPARMS_HPP__
|
||||||
|
#define __URDE_CGUIWIDGETDRAWPARMS_HPP__
|
||||||
|
|
||||||
|
namespace urde
|
||||||
|
{
|
||||||
|
|
||||||
|
struct CGuiWidgetDrawParms
|
||||||
|
{
|
||||||
|
float x0_alphaMod;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __URDE_CGUIWIDGETDRAWPARMS_HPP__
|
@ -44,8 +44,8 @@ add_library(RuntimeCommonGuiSys
|
|||||||
CGuiTextSupport.cpp
|
CGuiTextSupport.cpp
|
||||||
CGuiTextSupport.hpp
|
CGuiTextSupport.hpp
|
||||||
CGuiWidget.cpp
|
CGuiWidget.cpp
|
||||||
CGuiWidgetDrawParams.cpp
|
CGuiWidgetDrawParms.cpp
|
||||||
CGuiWidgetDrawParams.hpp
|
CGuiWidgetDrawParms.hpp
|
||||||
CGuiWidget.hpp
|
CGuiWidget.hpp
|
||||||
CMakeLists.txt
|
CMakeLists.txt
|
||||||
CSplashScreen.cpp
|
CSplashScreen.cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user