summaryrefslogtreecommitdiff
path: root/include/m
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2024-09-12 22:36:34 +0200
committerGitHub <noreply@github.com>2024-09-12 16:36:34 -0400
commit1180e1f4860d62bccd64bfa2a29eaeebd2c4b019 (patch)
treece6e231ef46aacbdad52ad7f6cbcd9d02dba555e /include/m
parente2c4bb7be7fa731a335bce4bc22283d899133e39 (diff)
m3d (#13)
* Initial M3d Pass * `m_bmdl` and `m_bline` left --------- Co-authored-by: elijah-thomas774 <elijahthomas774@gmail.com> Co-authored-by: Elijah Thomas <42302100+elijah-thomas774@users.noreply.github.com>
Diffstat (limited to 'include/m')
-rw-r--r--include/m/m3d/m3d.h59
-rw-r--r--include/m/m3d/m_anmchr.h24
-rw-r--r--include/m/m3d/m_anmchrblend.h28
-rw-r--r--include/m/m3d/m_anmmatclr.h57
-rw-r--r--include/m/m3d/m_anmmdl.h50
-rw-r--r--include/m/m3d/m_anmshp.h24
-rw-r--r--include/m/m3d/m_anmtexpat.h52
-rw-r--r--include/m/m3d/m_anmtexsrt.h56
-rw-r--r--include/m/m3d/m_anmvis.h22
-rw-r--r--include/m/m3d/m_banm.h38
-rw-r--r--include/m/m3d/m_bline.h85
-rw-r--r--include/m/m3d/m_bmdl.h48
-rw-r--r--include/m/m3d/m_calc_ratio.h49
-rw-r--r--include/m/m3d/m_fanm.h58
-rw-r--r--include/m/m3d/m_mdl.h76
-rw-r--r--include/m/m3d/m_proc.h21
-rw-r--r--include/m/m3d/m_scnleaf.h58
-rw-r--r--include/m/m3d/m_smdl.h25
-rw-r--r--include/m/m_allocator.h4
-rw-r--r--include/m/m_mtx.h9
-rw-r--r--include/m/m_video.h17
21 files changed, 859 insertions, 1 deletions
diff --git a/include/m/m3d/m3d.h b/include/m/m3d/m3d.h
new file mode 100644
index 00000000..d8ba87fc
--- /dev/null
+++ b/include/m/m3d/m3d.h
@@ -0,0 +1,59 @@
+#ifndef M3D_H
+#define M3D_H
+
+#include <egg/core/eggHeap.h>
+#include <egg/gfx/eggFog.h>
+#include <egg/gfx/eggLight.h>
+#include <m/m_allocator.h>
+#include <nw4r/g3d/g3d_scnroot.h>
+
+namespace m3d {
+
+namespace internal {
+
+extern mAllocator_c *l_allocator_p;
+extern nw4r::g3d::ScnRoot *l_scnRoot_p;
+extern u32 l_numLightMgr;
+extern EGG::LightManager **l_lightMgr_pp;
+extern u32 l_numFogMgr;
+extern EGG::FogManager **l_fogMgr_pp;
+extern size_t l_alignment;
+
+} // namespace internal
+
+bool create(EGG::Heap *pHeap, u32 maxNumChildren, u32 maxNumScnObj, u32 numLightObj, u32 numLightSet);
+bool create(EGG::Heap *pHeap, GXPixelFmt pxlFmt, GXColor clearColor, u32 maxNumChildren, u32 maxNumScnObj,
+ u32 numLightObj, u32 numLightSet, u32 numLightMgr, u32 numFogMgr);
+bool createLightMgr(EGG::Heap *, u16, u16, u8, bool, int);
+bool createFogMgr(EGG::Heap *, int, int);
+
+nw4r::g3d::ScnRoot *getScnRoot();
+nw4r::g3d::Camera getCamera(int id);
+nw4r::g3d::Camera getCurrentCamera();
+int getCurrentCameraID();
+
+EGG::LightManager *getLightMgr(int idx);
+EGG::FogManager *getFogMgr(int idx);
+void drawDone(int idx);
+void drawLightMapTexture(int idx);
+
+void calcWorld(int idx);
+void calcMaterial();
+void calcView(int idx);
+
+void drawOpa();
+void drawXlu();
+
+bool pushBack(nw4r::g3d::ScnObj *obj);
+void clear();
+
+void reset();
+
+int getMatID(nw4r::g3d::ResMdl, const char *);
+int getNodeID(nw4r::g3d::ResMdl, const char *);
+
+void resetMaterial();
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmchr.h b/include/m/m3d/m_anmchr.h
new file mode 100644
index 00000000..082cf504
--- /dev/null
+++ b/include/m/m3d/m_anmchr.h
@@ -0,0 +1,24 @@
+#ifndef M3D_M_ANMCHR_H
+#define M3D_M_ANMCHR_H
+
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_fanm.h>
+#include <nw4r/g3d/g3d_resanmchr.h>
+
+namespace m3d {
+
+class anmChr_c : public fanm_c {
+public:
+ virtual ~anmChr_c();
+
+ virtual int getType() const override;
+
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmChr, mAllocator_c *, u32 *);
+ void setAnm(bmdl_c &, nw4r::g3d::ResAnmChr, playMode_e);
+ void setAnmAfter(bmdl_c &, nw4r::g3d::ResAnmChr, playMode_e);
+ void setFrmCtrlDefault(nw4r::g3d::ResAnmChr &, m3d::playMode_e);
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmchrblend.h b/include/m/m3d/m_anmchrblend.h
new file mode 100644
index 00000000..e8d038d3
--- /dev/null
+++ b/include/m/m3d/m_anmchrblend.h
@@ -0,0 +1,28 @@
+#ifndef M3D_M_ANMCHRBLEND_H
+#define M3D_M_ANMCHRBLEND_H
+
+#include <m/m3d/m_anmchr.h>
+#include <m/m3d/m_banm.h>
+#include <m/m3d/m_bmdl.h>
+#include <nw4r/g3d/g3d_anmchr.h>
+
+namespace m3d {
+
+class anmChrBlend_c : public banm_c {
+public:
+ virtual ~anmChrBlend_c();
+
+ virtual int getType() const override;
+
+ bool create(nw4r::g3d::ResMdl, int, mAllocator_c *, u32 *);
+ void attach(int, nw4r::g3d::AnmObjChrRes *, f32);
+ void attach(int, anmChr_c *, f32);
+ void detach(int);
+ // Not in NSMBW
+ void setWeight(int, f32);
+ f32 getWeight(int) const;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmmatclr.h b/include/m/m3d/m_anmmatclr.h
new file mode 100644
index 00000000..1a2db51c
--- /dev/null
+++ b/include/m/m3d/m_anmmatclr.h
@@ -0,0 +1,57 @@
+#ifndef M3D_M_ANMMATCLR_H
+#define M3D_M_ANMMATCLR_H
+
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_fanm.h>
+#include <nw4r/g3d/g3d_anmclr.h>
+
+namespace m3d {
+
+class anmMatClr_c : public banm_c {
+ class child_c : public fanm_c {
+ public:
+ child_c() {}
+ virtual ~child_c();
+ virtual int getType() const override;
+
+ static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmClr, bool);
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmClr, mAllocator_c *, u32 *);
+ void setAnm(bmdl_c &, nw4r::g3d::ResAnmClr, playMode_e);
+ void releaseAnm();
+ void setFrmCtrlDefault(nw4r::g3d::ResAnmClr &, playMode_e);
+ };
+
+public:
+ anmMatClr_c() : mpChildren(nullptr) {}
+ virtual ~anmMatClr_c();
+
+ virtual int getType() const override;
+ virtual void remove() override;
+ virtual void play() override;
+
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmClr, mAllocator_c *, u32 *, s32);
+ static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmClr, s32, bool);
+
+ void setAnm(bmdl_c &, nw4r::g3d::ResAnmClr, s32, playMode_e);
+
+ void play(s32);
+ f32 getFrame(s32) const;
+ void setFrame(f32, s32);
+ f32 getRate(s32) const;
+ void setRate(f32, s32);
+ bool isStop(s32) const;
+
+ bool checkFrame(f32, s32) const;
+
+ void setPlayMode(playMode_e, s32);
+ f32 getFrameMax(s32) const;
+ void setFrameStart(f32, s32);
+ f32 getFrameStart(s32) const;
+
+private:
+ child_c *mpChildren;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmmdl.h b/include/m/m3d/m_anmmdl.h
new file mode 100644
index 00000000..1673b421
--- /dev/null
+++ b/include/m/m3d/m_anmmdl.h
@@ -0,0 +1,50 @@
+#ifndef M3D_M_ANMMDL_H
+#define M3D_M_ANMMDL_H
+
+#include <m/m3d/m_anmchr.h>
+#include <m/m3d/m_mdl.h>
+#include <nw4r/g3d/g3d_resfile.h>
+
+namespace m3d {
+
+// Not in NSMBW, name pulled from City Folk
+class mdlAnmChr {
+public:
+ mdlAnmChr() {}
+ virtual ~mdlAnmChr(); // 0x08
+
+ virtual void play(); // 0x0C
+ virtual void setFrame(f32); // 0x10
+ virtual void setAnm(const char *name, playMode_e mode, f32); // 0x14
+ virtual void setAnm(const char *name, playMode_e mode); // 0x18
+ virtual void setRate(f32); // 0x20
+
+ bool create(void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, mAllocator_c *alloc,
+ u32 bufferOption, int nView, u32 *pSize);
+ // Unknown overload
+ bool create2(void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, mAllocator_c *alloc,
+ u32 bufferOption, int nView, u32 *pSize);
+ bool create(void *resFile, const char *mdlName, const char *anmName, mAllocator_c *alloc, u32 bufferOption,
+ int nView, u32 *pSize);
+ bool create(void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, mdl_c::mdlCallback_c *callback,
+ mAllocator_c *alloc, u32 bufferOption, int nView, u32 *pSize);
+
+ inline bool create(void *resFile, const char *mdlName, const char *anmName, mAllocator_c *alloc, u32 bufferOption) {
+ return create(resFile, mdlName, anmName, alloc, bufferOption, 1, nullptr);
+ }
+
+ inline mdl_c &getModel() {
+ return mMdl;
+ }
+
+private:
+ nw4r::g3d::ResFile mMdlFile;
+ nw4r::g3d::ResFile mAnmFile;
+
+ mdl_c mMdl;
+ anmChr_c mAnm;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmshp.h b/include/m/m3d/m_anmshp.h
new file mode 100644
index 00000000..2e550802
--- /dev/null
+++ b/include/m/m3d/m_anmshp.h
@@ -0,0 +1,24 @@
+#ifndef M_M3D_ANMSHP_H
+#define M_M3D_ANMSHP_H
+
+#include <common.h>
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_fanm.h>
+#include <nw4r/g3d/g3d_resanmshp.h>
+
+namespace m3d {
+
+class anmShp_c : public fanm_c {
+public:
+ virtual ~anmShp_c();
+
+ virtual int getType() const override;
+
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmShp, mAllocator_c *, u32 *);
+ void setAnm(m3d::bmdl_c &, nw4r::g3d::ResAnmShp, m3d::playMode_e);
+ void setFrmCtrlDefault(nw4r::g3d::ResAnmShp &, m3d::playMode_e);
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmtexpat.h b/include/m/m3d/m_anmtexpat.h
new file mode 100644
index 00000000..1fc5b1d0
--- /dev/null
+++ b/include/m/m3d/m_anmtexpat.h
@@ -0,0 +1,52 @@
+#ifndef M3D_M_ANMTEXPAT_H
+#define M3D_M_ANMTEXPAT_H
+
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_fanm.h>
+#include <nw4r/g3d/g3d_anmtexpat.h>
+
+namespace m3d {
+
+class anmTexPat_c : public banm_c {
+ class child_c : public fanm_c {
+ public:
+ child_c() {}
+ virtual ~child_c();
+ virtual int getType() const override;
+
+ static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, bool);
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, mAllocator_c *, u32 *);
+ void setAnm(m3d::bmdl_c &, nw4r::g3d::ResAnmTexPat, m3d::playMode_e);
+ void releaseAnm();
+ void setFrmCtrlDefault(nw4r::g3d::ResAnmTexPat &, playMode_e);
+ };
+
+public:
+ anmTexPat_c() : mpChildren(nullptr) {}
+ virtual ~anmTexPat_c();
+
+ virtual int getType() const override;
+ virtual void remove() override;
+ virtual void play() override;
+
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, mAllocator_c *, u32 *, s32);
+ static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexPat, s32, bool);
+
+ void setAnm(bmdl_c &, nw4r::g3d::ResAnmTexPat, s32, playMode_e);
+
+ void play(s32);
+ f32 getFrame(s32) const;
+ void setFrame(f32, s32);
+ void setRate(f32, s32);
+ bool isStop(s32) const;
+
+ f32 getFrameMax(s32) const;
+ void setFrameStart(f32, s32);
+
+private:
+ child_c *mpChildren;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmtexsrt.h b/include/m/m3d/m_anmtexsrt.h
new file mode 100644
index 00000000..d736a7b1
--- /dev/null
+++ b/include/m/m3d/m_anmtexsrt.h
@@ -0,0 +1,56 @@
+#ifndef M3D_M_ANMTEXSRT_H
+#define M3D_M_ANMTEXSRT_H
+
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_fanm.h>
+#include <nw4r/g3d/g3d_anmtexsrt.h>
+
+namespace m3d {
+
+class anmTexSrt_c : public banm_c {
+ class child_c : public fanm_c {
+ public:
+ child_c() {}
+ virtual ~child_c();
+ virtual int getType() const override;
+
+ static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexSrt, bool);
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexSrt, mAllocator_c *, u32 *);
+ void setAnm(m3d::bmdl_c &, nw4r::g3d::ResAnmTexSrt, m3d::playMode_e);
+ void releaseAnm();
+ void setFrmCtrlDefault(nw4r::g3d::ResAnmTexSrt &, playMode_e);
+ };
+
+public:
+ anmTexSrt_c() : mpChildren(nullptr) {}
+ virtual ~anmTexSrt_c();
+
+ virtual int getType() const override;
+ virtual void remove() override;
+ virtual void play() override;
+
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexSrt, mAllocator_c *, u32 *, s32);
+ static u32 heapCost(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmTexSrt, s32, bool);
+
+ void setAnm(bmdl_c &, nw4r::g3d::ResAnmTexSrt, s32, playMode_e);
+
+ void play(s32);
+ f32 getFrame(s32) const;
+ void setFrame(f32, s32);
+ void setRate(f32, s32);
+ bool isStop(s32) const;
+
+ bool checkFrame(f32, s32) const;
+
+ void setPlayMode(playMode_e, s32);
+ f32 getFrameMax(s32) const;
+ void setFrameStart(f32, s32);
+ f32 getFrameStart(s32) const;
+
+private:
+ child_c *mpChildren;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_anmvis.h b/include/m/m3d/m_anmvis.h
new file mode 100644
index 00000000..053c330d
--- /dev/null
+++ b/include/m/m3d/m_anmvis.h
@@ -0,0 +1,22 @@
+#ifndef M3D_M_ANMVIS_H
+#define M3D_M_ANMVIS_H
+
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_fanm.h>
+
+namespace m3d {
+
+class anmVis_c : public fanm_c {
+public:
+ virtual ~anmVis_c();
+
+ virtual int getType() const override;
+
+ bool create(nw4r::g3d::ResMdl, nw4r::g3d::ResAnmVis, mAllocator_c *, u32 *);
+ void setAnm(m3d::bmdl_c &, nw4r::g3d::ResAnmVis, m3d::playMode_e);
+ void setFrmCtrlDefault(nw4r::g3d::ResAnmVis &, m3d::playMode_e);
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_banm.h b/include/m/m3d/m_banm.h
new file mode 100644
index 00000000..35b1b896
--- /dev/null
+++ b/include/m/m3d/m_banm.h
@@ -0,0 +1,38 @@
+#ifndef M3D_M_BANM_H
+#define M3D_M_BANM_H
+
+#include <egg/core/eggFrmHeap.h>
+#include <m/m_allocator.h>
+#include <nw4r/g3d/g3d_anmobj.h>
+
+namespace m3d {
+
+class banm_c {
+public:
+ banm_c() : mpAnmObj(nullptr), mpFrameHeap(nullptr) {}
+ virtual ~banm_c();
+
+ virtual int getType() const = 0;
+ virtual void remove();
+ virtual void play();
+
+ bool createAllocator(mAllocator_c *alloc, u32 *pSize);
+ bool IsBound() const;
+ f32 getFrame() const;
+ void setFrameOnly(f32);
+ f32 getRate() const;
+ void setRate(f32);
+
+ inline nw4r::g3d::AnmObj *getAnimObj() const {
+ return mpAnmObj;
+ }
+
+protected:
+ nw4r::g3d::AnmObj *mpAnmObj;
+ EGG::FrmHeap *mpFrameHeap;
+ mAllocator_c mAllocator;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_bline.h b/include/m/m3d/m_bline.h
new file mode 100644
index 00000000..d47f269c
--- /dev/null
+++ b/include/m/m3d/m_bline.h
@@ -0,0 +1,85 @@
+#ifndef M3D_BLINE_H
+#define M3D_BLINE_H
+
+#include <egg/gfx/eggTexture.h>
+#include <m/m3d/m_proc.h>
+#include <m/m_math.h>
+#include <nw4r/ut/ut_Color.h>
+
+namespace m3d {
+
+// The Actual line
+class bline_c {
+public:
+ bline_c() : mpPathArr(0), mpVtxPosArr(0), mpVtxNrmArr(0), mpVtxTexArr(0), mFlags(0) {}
+ // This is mainly a Guess, When the array is created, it has both a ctor/dtor
+ struct VtxPos {
+ mVec3_c pos1;
+ mVec3_c pos2;
+ };
+ struct Vec3u8 {
+ u8 x, y, z;
+ };
+ // This is mainly a Guess, When the array is created, it has only a ctor
+ struct VtxNrm {
+ union {
+ struct {
+ Vec3u8 nrm1;
+ Vec3u8 nrm2;
+ };
+ EGG::Vector3s nrm_u16; // There is a short by short copy later
+ };
+ };
+ // This is mainly a Guess, When the array is created, it doesnt use the array alloc
+ struct VtxTex {
+ f32 tex;
+ };
+
+ /* 0x00 */ u8 field_0x00[0x8];
+
+ bool create(EGG::Heap *pHeap, u16 numPts, f32 width, f32 repeat, const nw4r::ut::Color &color);
+ void update(mVec3_c *startPos);
+ void remove();
+ void draw();
+
+ // vt at 0x08
+ virtual ~bline_c();
+
+ /* 0x0C */ f32 mWidth; // could be a scale too
+ /* 0x10 */ nw4r::ut::Color mColor;
+ /* 0x14 */ mVec3_c *mpPathArr;
+ /* 0x18 */ VtxPos *mpVtxPosArr;
+ /* 0x1C */ VtxNrm *mpVtxNrmArr;
+ /* 0x20 */ VtxTex *mpVtxTexArr;
+ /* 0x24 */ f32 mTexRepeat; // Higher value causes the texture to repeat more often
+ /* 0x28 */ u16 mPathNum; // Guess
+ /* 0x2A */ u16 mVtxNum; // Guess
+ /* 0x2C */ u16 field_0x2C;
+ /* 0x2E */ u8 mFlags;
+ /* 0x2F u8 _pad; */
+};
+
+class blineMat_c : public proc_c {
+public:
+ virtual ~blineMat_c();
+ virtual void remove() override;
+ virtual void drawOpa() override;
+ virtual void drawXlu() override;
+ virtual void setupGX(bool bTransparent);
+
+ bool create(mAllocator_c *pAllocator, int numLines, u16 numLinePts, f32 width, f32 repeat, nw4r::ut::Color &color,
+ EGG::ResTIMG *pTex, bool);
+ void update();
+ bline_c *getLine(u16 idx);
+
+ /* 0x1C */ mAllocator_c mAllocator;
+ /* 0x34 */ EGG::ResTIMG *mpTex;
+ /* 0x38 */ nw4r::ut::List mLines;
+ /* 0x44 */ bline_c *mpLineArr;
+ /* 0x48 */ short mLineArrNum;
+ /* 0x4A */ bool field_0x4A;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_bmdl.h b/include/m/m3d/m_bmdl.h
new file mode 100644
index 00000000..aa692b29
--- /dev/null
+++ b/include/m/m3d/m_bmdl.h
@@ -0,0 +1,48 @@
+#ifndef M3D_M_BMDL_H
+#define M3D_M_BMDL_H
+
+#include <m/m3d/m_banm.h>
+#include <m/m3d/m_scnleaf.h>
+#include <m/m_math.h>
+#include <nw4r/g3d/g3d_scnmdlsmpl.h>
+
+namespace m3d {
+
+class bmdl_c : public scnLeaf_c {
+public:
+ bmdl_c() : mpCurrentAnm(nullptr) {}
+ virtual ~bmdl_c();
+
+ virtual int getType() const override;
+ virtual void remove() override;
+ virtual void setAnm(banm_c &anm);
+ virtual void play();
+
+ int getMatID(const char *name) const;
+ int getNodeID(const char *name) const;
+ bool getNodeWorldMtx(u32 p1, nw4r::math::MTX34 *out) const;
+ bool getNodeWorldMtxMultVecZero(u32 p1, nw4r::math::VEC3 &out) const;
+ bool getNodeWorldMtxMultVec(u32, nw4r::math::VEC3 &, nw4r::math::VEC3 &) const;
+ nw4r::g3d::ResMdl getResMdl() const;
+ nw4r::g3d::ResMat getResMat(u32 index) const;
+
+ void removeAnm(nw4r::g3d::ScnMdlSimple::AnmObjType);
+ nw4r::g3d::AnmObj *getAnmObj(nw4r::g3d::ScnMdlSimple::AnmObjType) const;
+ void setTevColor(u32, GXTevRegID, GXColor, bool);
+ void setTevColorAll(GXTevRegID, GXColor, bool);
+ void setTevKColor(u32, GXTevKColorID, GXColor, bool);
+ void setTevKColorAll(GXTevKColorID, GXColor, bool);
+ void setBlendModeAll(GXBlendMode, GXBlendFactor, GXBlendFactor, GXLogicOp, bool bMarkDirty);
+ void setCullMode(u32 matId, GXCullMode cullMode, bool bMarkDirty);
+ void setCullModeAll(GXCullMode cullMode, bool bMarkDirty);
+ void setMatVisible(u32 matId, bool bVisble);
+ int setMatTexture(char *name, GXTexObj *texObj, bool copy, void *unk, int, int);
+ bool getBounds(mVec3_c *min, mVec3_c *max);
+
+private:
+ banm_c *mpCurrentAnm;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_calc_ratio.h b/include/m/m3d/m_calc_ratio.h
new file mode 100644
index 00000000..ee850bc9
--- /dev/null
+++ b/include/m/m3d/m_calc_ratio.h
@@ -0,0 +1,49 @@
+#ifndef M3D_M_CALC_RATIO_H
+#define M3D_M_CALC_RATIO_H
+
+#include <egg/core/eggFrmHeap.h>
+#include <m/m_allocator.h>
+
+namespace m3d {
+
+class calcRatio_c {
+public:
+ calcRatio_c();
+ virtual ~calcRatio_c();
+
+ void remove();
+ void reset();
+ void offUpdate();
+ void set(f32);
+ void calc();
+ bool isEnd() const;
+
+ f32 get0x10() const {
+ return mf4;
+ }
+
+ f32 get0x14() const {
+ return mf5;
+ }
+
+ bool is0x18() const {
+ return mb1;
+ }
+
+ bool is0x19() const {
+ return mb2;
+ }
+
+private:
+ /* 0x04 */ f32 mf1;
+ /* 0x08 */ f32 mf2;
+ /* 0x0C */ f32 mf3;
+ /* 0x10 */ f32 mf4;
+ /* 0x14 */ f32 mf5;
+ /* 0x18 */ bool mb1;
+ /* 0x19 */ bool mb2;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_fanm.h b/include/m/m3d/m_fanm.h
new file mode 100644
index 00000000..1dc0d9f2
--- /dev/null
+++ b/include/m/m3d/m_fanm.h
@@ -0,0 +1,58 @@
+#ifndef M3D_M_FANM_H
+#define M3D_M_FANM_H
+
+#include <m/m3d/m_banm.h>
+
+namespace m3d {
+
+enum playMode_e {
+ PLAY_MODE_0,
+ PLAY_MODE_1,
+ PLAY_MODE_2,
+ PLAY_MODE_3,
+ PLAY_MODE_4,
+};
+
+class fanm_c : public banm_c {
+public:
+ fanm_c();
+ virtual ~fanm_c();
+
+ virtual int getType() const = 0;
+ virtual void play();
+
+ void set(f32, playMode_e, f32, f32);
+ void set2(f32, playMode_e, f32, f32, f32);
+ void setFrame(f32);
+ void setFrameOnly(f32);
+ bool isStop() const;
+ bool checkFrame(f32) const;
+ bool unk_802EAE70() const;
+
+ inline void setPlayState(playMode_e state) {
+ mPlayState = state;
+ }
+
+ inline f32 getEndFrame() {
+ return mEndFrame;
+ }
+
+ // Something about this is wrong
+ inline void setStartFrame(f32 f) {
+ mEndFrame = f;
+ }
+
+ inline f32 getStartFrame() {
+ return mStartFrame;
+ }
+
+private:
+ f32 mEndFrame;
+ f32 mStartFrame;
+ f32 mCurrentFrame;
+ u8 mPlayState;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_mdl.h b/include/m/m3d/m_mdl.h
new file mode 100644
index 00000000..82b475e8
--- /dev/null
+++ b/include/m/m3d/m_mdl.h
@@ -0,0 +1,76 @@
+#ifndef M3D_M_MDL_H
+#define M3D_M_MDL_H
+
+#include <m/m3d/m_banm.h>
+#include <m/m3d/m_calc_ratio.h>
+#include <m/m3d/m_smdl.h>
+#include <nw4r/g3d/g3d_anmchr.h>
+#include <nw4r/g3d/g3d_calcworld.h>
+#include <nw4r/g3d/g3d_resmdl.h>
+
+namespace m3d {
+
+class callback_c {
+public:
+ virtual ~callback_c() {}
+ virtual void timingA(u32, nw4r::g3d::ChrAnmResult *, nw4r::g3d::ResMdl) {}
+ virtual void timingB(u32, nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl) {}
+ virtual void timingC(nw4r::math::MTX34 *, nw4r::g3d::ResMdl) {}
+};
+
+class mdl_c : public smdl_c {
+public:
+ class mdlCallback_c : public nw4r::g3d::ICalcWorldCallback {
+ public:
+ mdlCallback_c();
+ virtual ~mdlCallback_c();
+
+ bool create(nw4r::g3d::ResMdl, mAllocator_c *, u32 *);
+
+ virtual void ExecCallbackA(nw4r::g3d::ChrAnmResult *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *);
+ virtual void ExecCallbackB(nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *);
+ virtual void ExecCallbackC(nw4r::math::MTX34 *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *);
+
+ void remove();
+ void setBlendFrame(f32);
+ void calcBlend();
+
+ mAllocator_c *getAllocator() {
+ return mpAlloc;
+ }
+
+ void setBaseCallback(callback_c *cb) {
+ mpBaseCallback = cb;
+ }
+
+ private:
+ /* 0x04 */ calcRatio_c mCalcRatio;
+ /* 0x20 */ int mNumNode;
+ /* 0x24 */ nw4r::g3d::ChrAnmResult *mpNodes;
+ /* 0x28 */ callback_c *mpBaseCallback;
+ /* 0x2C */ mAllocator_c *mpAlloc;
+ };
+
+ mdl_c();
+ virtual ~mdl_c();
+
+ bool create(nw4r::g3d::ResMdl, mAllocator_c *, u32, int, u32 *);
+ bool create(nw4r::g3d::ResMdl, mdlCallback_c *cb, mAllocator_c *, u32, int, u32 *);
+
+ virtual void remove();
+
+ void setCallback(callback_c *cb);
+ void play();
+ void setAnm(banm_c &);
+ void setAnm(banm_c &, f32);
+
+private:
+ /** If we allocated the callback ourselves, this is what we need to free */
+ mdlCallback_c *mpOwnedCallback;
+ /** The actual callback to use */
+ mdlCallback_c *mpCallback;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_proc.h b/include/m/m3d/m_proc.h
new file mode 100644
index 00000000..47fc4c84
--- /dev/null
+++ b/include/m/m3d/m_proc.h
@@ -0,0 +1,21 @@
+#ifndef M_M3D_PROC_H
+#define M_M3D_PROC_H
+
+#include <common.h>
+#include <m/m3d/m_scnleaf.h>
+
+namespace m3d {
+
+class proc_c : public scnLeaf_c {
+public:
+ virtual ~proc_c();
+ virtual int getType() const override;
+ bool create(mAllocator_c *, u32 *);
+
+ virtual void drawOpa();
+ virtual void drawXlu();
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_scnleaf.h b/include/m/m3d/m_scnleaf.h
new file mode 100644
index 00000000..18e9db9c
--- /dev/null
+++ b/include/m/m3d/m_scnleaf.h
@@ -0,0 +1,58 @@
+#ifndef M3D_M_SCNLEAF_H
+#define M3D_M_SCNLEAF_H
+
+#include <egg/core/eggDisposer.h>
+#include <m/m_allocator.h>
+#include <nw4r/g3d/g3d_scnobj.h>
+
+namespace m3d {
+
+// NON-OFFICIAL
+enum ScnLeafType_e {
+ SCN_LEAF_MODEL = 0,
+ SCN_LEAF_PROC = 2,
+};
+
+class UnkClass {
+public:
+ UnkClass() {}
+};
+
+class scnLeaf_c : UnkClass, EGG::Disposer {
+public:
+ scnLeaf_c();
+ virtual ~scnLeaf_c();
+ virtual int getType() const = 0;
+ virtual void remove();
+ virtual int entry();
+
+ void setOption(u32 flag, u32 set);
+ void setScale(f32, f32, f32);
+ void setScale(const nw4r::math::VEC3 &);
+ void getScale(nw4r::math::VEC3 *) const;
+
+ void setLocalMtx(const nw4r::math::MTX34 *);
+ void getLocalMtx(nw4r::math::MTX34 *) const;
+ const nw4r::math::MTX34 *getLocalMtx() const;
+ void getWorldMtx(nw4r::math::MTX34 *) const;
+ void getViewMtx(nw4r::math::MTX34 *) const;
+
+ void setCallback(nw4r::g3d::IScnObjCallback *cb);
+ nw4r::g3d::IScnObjCallback *swapCallback(nw4r::g3d::IScnObjCallback *cb);
+
+ void enableCallbackTiming(nw4r::g3d::ScnObj::Timing);
+ void enableCallbackOp(nw4r::g3d::ScnObj::ExecOp);
+
+ void calc(bool);
+ void calcVtx(bool);
+ void calcView(void *, bool);
+
+ void setPriorityDraw(int, int);
+
+protected:
+ nw4r::g3d::ScnLeaf *mpScnLeaf;
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m3d/m_smdl.h b/include/m/m3d/m_smdl.h
new file mode 100644
index 00000000..e55f759a
--- /dev/null
+++ b/include/m/m3d/m_smdl.h
@@ -0,0 +1,25 @@
+#ifndef M3D_M_SMDL_H
+#define M3D_M_SMDL_H
+
+#include <m/m3d/m_bmdl.h>
+#include <m/m3d/m_scnleaf.h>
+#include <nw4r/g3d/g3d_resmdl.h>
+
+class UnkClass2 {};
+
+namespace m3d {
+
+class smdl_c : public bmdl_c, UnkClass2 {
+public:
+ smdl_c();
+ virtual ~smdl_c();
+
+ bool create(nw4r::g3d::ResMdl mdl, mAllocator_c *alloc, u32 bufferOption, int nView, u32 *pSize);
+ bool create(nw4r::g3d::ResMdl mdl, mAllocator_c *alloc, u32 bufferOption) {
+ return create(mdl, alloc, bufferOption, 1, nullptr);
+ }
+};
+
+} // namespace m3d
+
+#endif
diff --git a/include/m/m_allocator.h b/include/m/m_allocator.h
index e4f2a175..4391ad0e 100644
--- a/include/m/m_allocator.h
+++ b/include/m/m_allocator.h
@@ -26,6 +26,8 @@ public:
s32 adjustExpHeap();
bool createNewTempFrmHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 unk);
void adjustFrmHeapRestoreCurrent();
- static void *allocOnHeap(u32 size, mHeapAllocator_c *allocator);
};
+
+void *operator new[](size_t size, mAllocator_c *);
+
#endif
diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h
index ee60b72d..879e62cf 100644
--- a/include/m/m_mtx.h
+++ b/include/m/m_mtx.h
@@ -8,6 +8,8 @@
#include "nw4r/nw4r_types.h"
#include <common.h>
+#pragma push
+#pragma warning off(10402)
class mMtx_c {
public:
mMtx_c(){};
@@ -38,10 +40,15 @@ public:
/* 802f1c40 */ void rot(int, int); // does some werrd operation to rotate the matrix
/* 802f1e60 */ bool quatRelated();
+ operator nw4r::math::MTX34 *() {
+ return &nw4rm;
+ }
+
public:
union {
EGG::Matrix34f mat;
f32 m[3][4];
+ nw4r::math::MTX34 nw4rm;
struct {
f32 xx, xy, xz, xw;
f32 yx, yy, yz, yw;
@@ -53,4 +60,6 @@ public:
static mMtx_c Identity;
};
+#pragma pop
+
#endif
diff --git a/include/m/m_video.h b/include/m/m_video.h
new file mode 100644
index 00000000..5a0e382b
--- /dev/null
+++ b/include/m/m_video.h
@@ -0,0 +1,17 @@
+#ifndef M_VIDEO_H
+#define M_VIDEO_H
+
+#include <egg/core/eggVideo.h>
+
+namespace mVideo {
+
+// 0x80065590
+void create();
+
+extern EGG::Video *m_video;
+
+extern f32 l_fbAspect;
+
+} // namespace mVideo
+
+#endif