summaryrefslogtreecommitdiffstats
path: root/src/modelinfo
diff options
context:
space:
mode:
Diffstat (limited to 'src/modelinfo')
-rw-r--r--src/modelinfo/MloModelInfo.cpp39
-rw-r--r--src/modelinfo/MloModelInfo.h14
-rw-r--r--src/modelinfo/ModelInfo.cpp25
-rw-r--r--src/modelinfo/ModelInfo.h8
-rw-r--r--src/modelinfo/XtraCompsModelInfo.h12
5 files changed, 98 insertions, 0 deletions
diff --git a/src/modelinfo/MloModelInfo.cpp b/src/modelinfo/MloModelInfo.cpp
new file mode 100644
index 00000000..693f1fb6
--- /dev/null
+++ b/src/modelinfo/MloModelInfo.cpp
@@ -0,0 +1,39 @@
+#include "common.h"
+#include "patcher.h"
+#include "VisibilityPlugins.h"
+#include "ModelInfo.h"
+
+void
+CMloModelInfo::ConstructClump()
+{
+ m_clump = RpClumpCreate();
+ RwFrame *mainFrame = RwFrameCreate();
+ RwFrameSetIdentity(mainFrame);
+ RpClumpSetFrame(m_clump, mainFrame);
+
+ for (int i = firstInstance; i < lastInstance; i++) {
+ int modelId = CModelInfo::GetMloInstanceStore()->store[i].m_modelIndex;
+ RwMatrix *attMat = CModelInfo::GetMloInstanceStore()->store[i].GetMatrix().m_attachment;
+ CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId);
+
+ if (minfo->m_atomics[0] != nil) {
+ RpAtomic *newAtomic = RpAtomicClone(minfo->m_atomics[0]);
+ RwFrame *newFrame = RwFrameCreate();
+ if (newAtomic != nil && newFrame != nil) {
+ *RwFrameGetMatrix(newFrame) = *attMat;
+ RpAtomicSetFrame(newAtomic, newFrame);
+ RwFrameAddChild(mainFrame, newFrame);
+ RpClumpAddAtomic(m_clump, newAtomic);
+ } else {
+ debug("Failed to allocate memory while creating template MLO.\n");
+ }
+ }
+ }
+
+ if (RpClumpGetNumAtomics(m_clump) != 0) {
+ CVisibilityPlugins::SetClumpModelInfo(m_clump, this);
+ } else {
+ RpClumpDestroy(m_clump);
+ m_clump = nil;
+ }
+} \ No newline at end of file
diff --git a/src/modelinfo/MloModelInfo.h b/src/modelinfo/MloModelInfo.h
new file mode 100644
index 00000000..19ae63d5
--- /dev/null
+++ b/src/modelinfo/MloModelInfo.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "ClumpModelInfo.h"
+
+class CMloModelInfo : public CClumpModelInfo
+{
+public:
+ float field_34; // draw distance?
+ int firstInstance;
+ int lastInstance;
+public:
+ CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {}
+ void ConstructClump();
+}; \ No newline at end of file
diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp
index c7e18e5f..fdde699b 100644
--- a/src/modelinfo/ModelInfo.cpp
+++ b/src/modelinfo/ModelInfo.cpp
@@ -11,10 +11,13 @@ CBaseModelInfo **CModelInfo::ms_modelInfoPtrs = (CBaseModelInfo**)0x83D408;
//CStore<CTimeModelInfo, TIMEMODELSIZE> &CModelInfo::ms_timeModelStore = *(CStore<CTimeModelInfo, TIMEMODELSIZE>*)0x94076C;
//CStore<C2dEffect, TWODFXSIZE> &CModelInfo::ms_2dEffectStore = *(CStore<C2dEffect, TWODFXSIZE>*)0x9434F8;
CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore;
+CStore<CMloModelInfo, MLOMODELSIZE> CModelInfo::ms_mloModelStore;
+CStore<CInstance, MLOINSTANCESIZE> CModelInfo::ms_mloInstanceStore;
CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore;
CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore;
CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore;
CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore;
+CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> CModelInfo::ms_xtraCompsModelStore;
CStore<C2dEffect, TWODFXSIZE> CModelInfo::ms_2dEffectStore;
void
@@ -26,8 +29,11 @@ CModelInfo::Initialise(void)
for(i = 0; i < MODELINFOSIZE; i++)
ms_modelInfoPtrs[i] = nil;
ms_2dEffectStore.clear();
+ ms_mloInstanceStore.clear();
+ ms_xtraCompsModelStore.clear();
ms_simpleModelStore.clear();
ms_timeModelStore.clear();
+ ms_mloModelStore.clear();
ms_clumpModelStore.clear();
ms_pedModelStore.clear();
ms_vehicleModelStore.clear();
@@ -109,6 +115,18 @@ CModelInfo::AddSimpleModel(int id)
return modelinfo;
}
+CMloModelInfo *
+CModelInfo::AddMloModel(int id)
+{
+ CMloModelInfo *modelinfo;
+ modelinfo = CModelInfo::ms_mloModelStore.alloc();
+ CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
+ modelinfo->m_clump = 0;
+ modelinfo->firstInstance = 0;
+ modelinfo->lastInstance = 0;
+ return modelinfo;
+}
+
CTimeModelInfo*
CModelInfo::AddTimeModel(int id)
{
@@ -200,6 +218,13 @@ CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
}
}
+
+CStore<CInstance, MLOINSTANCESIZE>*
+CModelInfo::GetMloInstanceStore()
+{
+ return &CModelInfo::ms_mloInstanceStore;
+}
+
STARTPATCHES
InjectHook(0x50B310, CModelInfo::Initialise, PATCH_JUMP);
InjectHook(0x50B5B0, CModelInfo::ShutDown, PATCH_JUMP);
diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h
index ee82276d..1a295264 100644
--- a/src/modelinfo/ModelInfo.h
+++ b/src/modelinfo/ModelInfo.h
@@ -3,26 +3,33 @@
#include "2dEffect.h"
#include "BaseModelInfo.h"
#include "SimpleModelInfo.h"
+#include "MloModelInfo.h"
#include "TimeModelInfo.h"
#include "ClumpModelInfo.h"
#include "PedModelInfo.h"
#include "VehicleModelInfo.h"
+#include "XtraCompsModelInfo.h"
+#include "Instance.h"
class CModelInfo
{
static CBaseModelInfo **ms_modelInfoPtrs; //[MODELINFOSIZE];
static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore;
+ static CStore<CMloModelInfo, MLOMODELSIZE> ms_mloModelStore;
+ static CStore<CInstance, MLOINSTANCESIZE> ms_mloInstanceStore;
static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore;
static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore;
static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore;
static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore;
static CStore<C2dEffect, TWODFXSIZE> ms_2dEffectStore;
+ static CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> ms_xtraCompsModelStore;
public:
static void Initialise(void);
static void ShutDown(void);
static CSimpleModelInfo *AddSimpleModel(int id);
+ static CMloModelInfo *AddMloModel(int id);
static CTimeModelInfo *AddTimeModel(int id);
static CClumpModelInfo *AddClumpModel(int id);
static CPedModelInfo *AddPedModel(int id);
@@ -38,4 +45,5 @@ public:
static bool IsBoatModel(int32 id);
static bool IsBikeModel(int32 id);
static void RemoveColModelsFromOtherLevels(eLevelName level);
+ static CStore<CInstance, MLOINSTANCESIZE>* CModelInfo::GetMloInstanceStore();
};
diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h
new file mode 100644
index 00000000..bb37ffe3
--- /dev/null
+++ b/src/modelinfo/XtraCompsModelInfo.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "ClumpModelInfo.h"
+
+class CXtraCompsModelInfo : public CClumpModelInfo
+{
+ int field_34;
+public:
+ CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; }
+ void SetClump(RpClump*) {};
+ void Shutdown(void) {};
+}; \ No newline at end of file