summaryrefslogtreecommitdiff
path: root/include/JSystem
diff options
context:
space:
mode:
authorTakaRikka <takarikka@outlook.com>2022-10-04 21:17:53 -0700
committerTakaRikka <takarikka@outlook.com>2022-10-04 21:17:53 -0700
commit74c248990c5cc991aff8f119efd8b733770178a7 (patch)
tree6f44f0e2711ebc8e59f3780ea78fe2ba89c452bd /include/JSystem
parenta3578d0c7c64b11258260bee1148d33195542c4f (diff)
move jasper's jsystem work over
Diffstat (limited to 'include/JSystem')
-rw-r--r--include/JSystem/J3DGraphAnimator/J3DJoint.h4
-rw-r--r--include/JSystem/J3DGraphBase/J3DPacket.h18
-rw-r--r--include/JSystem/J3DGraphBase/J3DSys.h3
-rw-r--r--include/JSystem/J3DGraphBase/J3DTransform.h7
-rw-r--r--include/JSystem/J3DGraphLoader/J3DJointFactory.h45
-rw-r--r--include/JSystem/JGeometry.h26
6 files changed, 90 insertions, 13 deletions
diff --git a/include/JSystem/J3DGraphAnimator/J3DJoint.h b/include/JSystem/J3DGraphAnimator/J3DJoint.h
index 0474f4eb5a..94ce45c74d 100644
--- a/include/JSystem/J3DGraphAnimator/J3DJoint.h
+++ b/include/JSystem/J3DGraphAnimator/J3DJoint.h
@@ -68,13 +68,15 @@ public:
static J3DMtxCalc* mCurrentMtxCalc;
private:
+ friend struct J3DJointFactory;
+
/* 0x00 */ void* mCallBackUserData;
/* 0x04 */ J3DJointCallBack mCallBack;
/* 0x08 */ void* field_0x8;
/* 0x0C */ J3DJoint* mChild;
/* 0x10 */ J3DJoint* mYounger;
/* 0x14 */ u16 mJntNo;
- /* 0x16 */ u8 mMtxType;
+ /* 0x16 */ u8 mKind;
/* 0x17 */ u8 mScaleCompensate;
/* 0x18 */ J3DTransformInfo mTransformInfo;
/* 0x38 */ f32 mBoundingSphereRadius;
diff --git a/include/JSystem/J3DGraphBase/J3DPacket.h b/include/JSystem/J3DGraphBase/J3DPacket.h
index 463ba0d356..232db283d3 100644
--- a/include/JSystem/J3DGraphBase/J3DPacket.h
+++ b/include/JSystem/J3DGraphBase/J3DPacket.h
@@ -51,29 +51,29 @@ public:
class J3DPacket {
public:
J3DPacket() {
- mpNextSibling = NULL;
+ mpNextPacket = NULL;
mpFirstChild = NULL;
mpUserData = NULL;
}
void addChildPacket(J3DPacket*);
- J3DPacket* getNextPacket() const { return mpNextSibling; }
- void setNextPacket(J3DPacket* i_packet) { mpNextSibling = i_packet; }
+ J3DPacket* getNextPacket() const { return mpNextPacket; }
+ void setNextPacket(J3DPacket* i_packet) { mpNextPacket = i_packet; }
void drawClear() {
- mpNextSibling = NULL;
+ mpNextPacket = NULL;
mpFirstChild = NULL;
}
void setUserArea(u32 area) { mpUserData = (void*)area; }
- virtual bool entry(J3DDrawBuffer*);
+ virtual int entry(J3DDrawBuffer*);
virtual void draw();
virtual ~J3DPacket() {}
public:
- /* 0x04 */ J3DPacket* mpNextSibling;
+ /* 0x04 */ J3DPacket* mpNextPacket;
/* 0x08 */ J3DPacket* mpFirstChild;
/* 0x0C */ void* mpUserData;
}; // Size: 0x10
@@ -145,19 +145,21 @@ public:
void endDiff();
bool isSame(J3DMatPacket*) const;
+ J3DMaterial* getMaterial() const { return mpMaterial; }
J3DShapePacket* getShapePacket() const { return mpShapePacket; }
void setShapePacket(J3DShapePacket* packet) { mpShapePacket = packet; }
void setInitShapePacket(J3DShapePacket* packet) { mpInitShapePacket = packet; }
+ bool isChanged() const { return mDiffFlag < 0; }
virtual ~J3DMatPacket();
- virtual bool entry(J3DDrawBuffer*);
+ virtual int entry(J3DDrawBuffer*);
virtual void draw();
public:
/* 0x28 */ J3DShapePacket* mpInitShapePacket;
/* 0x2C */ J3DShapePacket* mpShapePacket;
/* 0x30 */ J3DMaterial* mpMaterial;
- /* 0x34 */ u32 mSortFlags;
+ /* 0x34 */ u32 mDiffFlag;
/* 0x38 */ J3DTexture* mpTexture;
/* 0x3C */ J3DMaterialAnm* mpMaterialAnm;
}; // Size: 0x40
diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h
index fd75fc48f7..01f882e3f4 100644
--- a/include/JSystem/J3DGraphBase/J3DSys.h
+++ b/include/JSystem/J3DGraphBase/J3DSys.h
@@ -93,6 +93,9 @@ struct J3DSys {
void setMaterialMode(u32 mode) { mMaterialMode = mode; }
void setTexture(J3DTexture* pTex) { mTexture = pTex; }
+ J3DTexture* getTexture() { return mTexture; }
+
+ void setNBTScale(Vec* scale) { mNBTScale = scale; }
void onFlag(u32 flag) { mFlags |= flag; }
diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h
index 1bdc7ebb88..a162bd5b7c 100644
--- a/include/JSystem/J3DGraphBase/J3DTransform.h
+++ b/include/JSystem/J3DGraphBase/J3DTransform.h
@@ -1,13 +1,14 @@
#ifndef J3DTRANSFORM_H
#define J3DTRANSFORM_H
+#include "JSystem/JGeometry.h"
#include "dolphin/mtx/mtxvec.h"
#include "dolphin/types.h"
struct J3DTransformInfo {
- /* 0x00 */ Vec mScale;
- /* 0x0C */ SVec mRotation;
- /* 0x14 */ Vec mTranslate;
+ /* 0x00 */ JGeometry::TVec3<f32> mScale;
+ /* 0x0C */ JGeometry::TVec3<s16> mRotation;
+ /* 0x14 */ JGeometry::TVec3<f32> mTranslate;
}; // Size: 0x20
extern J3DTransformInfo const j3dDefaultTransformInfo;
diff --git a/include/JSystem/J3DGraphLoader/J3DJointFactory.h b/include/JSystem/J3DGraphLoader/J3DJointFactory.h
index 2e992b48f3..98409802a7 100644
--- a/include/JSystem/J3DGraphLoader/J3DJointFactory.h
+++ b/include/JSystem/J3DGraphLoader/J3DJointFactory.h
@@ -1,6 +1,49 @@
#ifndef J3DJOINTFACTORY_H
#define J3DJOINTFACTORY_H
+#include "JSystem/J3DGraphBase/J3DTransform.h"
+#include "JSystem/JGeometry.h"
#include "dolphin/types.h"
-#endif /* J3DJOINTFACTORY_H */
+struct J3DJoint;
+struct ResNTAB;
+
+struct J3DJointInitData {
+ /* 0x00 */ u16 mKind;
+ /* 0x02 */ bool mScaleCompensate;
+ /* 0x04 */ J3DTransformInfo mTransformInfo;
+ /* 0x24 */ f32 mRadius;
+ /* 0x28 */ Vec mMin;
+ /* 0x2C */ Vec mMax;
+}; // Size: 0x30
+
+struct J3DJointBlock {
+ /* 0x00 */ u8 mMagic[4];
+ /* 0x04 */ u32 mSize;
+
+ /* 0x08 */ u16 mJointNum;
+ /* 0x0A */ u16 _pad;
+
+ /* 0x0C */ J3DJointInitData* mJointInitData;
+ /* 0x10 */ u16* mIndexTable;
+ /* 0x14 */ ResNTAB* mNameTable;
+};
+
+struct J3DJointFactory {
+ /* 80337178 */ J3DJointFactory(J3DJointBlock const&);
+ /* 803371D0 */ J3DJoint* create(int);
+
+ J3DJointInitData* mJointInitData;
+ u16* mIndexTable;
+
+ u16 getKind(int no) const { return mJointInitData[mIndexTable[no]].mKind; }
+ u8 getScaleCompensate(int no) const { return mJointInitData[mIndexTable[no]].mScaleCompensate; }
+ const J3DTransformInfo& getTransformInfo(int no) const {
+ return mJointInitData[mIndexTable[no]].mTransformInfo;
+ }
+ f32 getRadius(int no) const { return mJointInitData[mIndexTable[no]].mRadius; }
+ Vec& getMin(int no) const { return mJointInitData[mIndexTable[no]].mMin; }
+ Vec& getMax(int no) const { return mJointInitData[mIndexTable[no]].mMax; }
+};
+
+#endif /* J3DJOINTFACTORY_H */ \ No newline at end of file
diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h
index 42e505a7b5..6eb88b0279 100644
--- a/include/JSystem/JGeometry.h
+++ b/include/JSystem/JGeometry.h
@@ -20,6 +20,18 @@ struct TVec3 {
};
template <>
+struct TVec3<s16> {
+ s16 x, y, z;
+
+ TVec3& operator=(const TVec3& b) {
+ // Force copies to use lwz/lha
+ *((s32*)this) = *((s32*)&b);
+ z = b.z;
+ return *this;
+ }
+};
+
+template <>
struct TVec3<f32> {
f32 x;
f32 y;
@@ -47,6 +59,20 @@ struct TVec3<f32> {
y = a.y * b.y;
z = a.z * b.z;
}
+
+ inline TVec3<f32>& operator=(const TVec3<f32>& b) {
+ register f32* dst = &x;
+ const register f32* src = &b.x;
+ register f32 x_y;
+ register f32 z;
+ asm {
+ psq_l x_y, 0(src), 0, 0
+ psq_st x_y, 0(dst), 0, 0
+ lfs z, 8(src)
+ stfs z, 8(dst)
+ };
+ return *this;
+ }
};
template <typename T>