summaryrefslogtreecommitdiff
path: root/src/JSystem
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2023-10-16 13:36:36 -0700
committerGitHub <noreply@github.com>2023-10-16 13:36:36 -0700
commit20cc6db46bbf036ce447f9ee9d1ef2b93502e23d (patch)
tree38f61f19dc3764ce694dcf2f7b3aefe4a14278c8 /src/JSystem
parent8a37ec07d14b5691b222ebb749cf4df32b5a8d09 (diff)
parent0413154d722d29df43887607c2dabbb6eb27cbf6 (diff)
Merge pull request #524 from Jcw87/J3DJoint
J3DJoint
Diffstat (limited to 'src/JSystem')
-rw-r--r--src/JSystem/J3DGraphAnimator/J3DJoint.cpp202
-rw-r--r--src/JSystem/J3DGraphAnimator/J3DModelData.cpp5
-rw-r--r--src/JSystem/J3DGraphAnimator/J3DNode.cpp6
-rw-r--r--src/JSystem/J3DU/J3DUMotion.cpp11
4 files changed, 198 insertions, 26 deletions
diff --git a/src/JSystem/J3DGraphAnimator/J3DJoint.cpp b/src/JSystem/J3DGraphAnimator/J3DJoint.cpp
index 9b6b9400..d5565c2b 100644
--- a/src/JSystem/J3DGraphAnimator/J3DJoint.cpp
+++ b/src/JSystem/J3DGraphAnimator/J3DJoint.cpp
@@ -4,59 +4,235 @@
//
#include "JSystem/J3DGraphAnimator/J3DJoint.h"
+#include "JSystem/J3DGraphAnimator/J3DAnimation.h"
+#include "JSystem/J3DGraphAnimator/J3DModel.h"
+#include "JSystem/J3DGraphBase/J3DSys.h"
#include "dolphin/types.h"
/* 802F4DC0-802F4EB0 .text calc__13J3DMtxCalcAnmFUs */
-void J3DMtxCalcAnm::calc(u16) {
- /* Nonmatching */
+void J3DMtxCalcAnm::calc(u16 param_0) {
+ j3dSys.setCurrentMtxCalc(this);
+ J3DTransformInfo info;
+ J3DAnmTransform* transform = mOne[0];
+ if (transform) {
+ transform->getTransform(param_0, &info);
+ } else {
+ info = j3dSys.getModel()->getModelData()->getJointNodePointer(param_0)->getTransformInfo();
+ }
+ calcTransform(param_0, info);
}
/* 802F4EB0-802F4EF8 .text __ct__15J3DMtxCalcBasicFv */
J3DMtxCalcBasic::J3DMtxCalcBasic() {}
/* 802F4EF8-802F5090 .text recursiveCalc__15J3DMtxCalcBasicFP7J3DNode */
-void J3DMtxCalcBasic::recursiveCalc(J3DNode*) {
- /* Nonmatching */
+void J3DMtxCalcBasic::recursiveCalc(J3DNode* node) {
+ if (!node) {
+ return;
+ }
+ J3DMtxCalcBasic mtxCalc;
+ MTXCopy(J3DSys::mCurrentMtx, mtxCalc.getBackupMtx());
+ mtxCalc.setBackupS(J3DSys::mCurrentS);
+ mtxCalc.setBackupParentS(J3DSys::mParentS);
+ node->calcIn();
+ if (node->getCallBack()) {
+ node->getCallBack()(node, 0);
+ }
+ recursiveCalc(node->getChild());
+ MTXCopy(mtxCalc.getBackupMtx(), J3DSys::mCurrentMtx);
+ J3DSys::mCurrentS = mtxCalc.getBackupS();
+ J3DSys::mParentS = mtxCalc.getBackupParentS();
+ node->calcOut();
+ if (node->getCallBack()) {
+ node->getCallBack()(node, 1);
+ }
+ recursiveCalc(node->getYounger());
}
/* 802F5090-802F525C .text calcTransform__15J3DMtxCalcBasicFUsRC16J3DTransformInfo */
-void J3DMtxCalcBasic::calcTransform(u16, const J3DTransformInfo&) {
+void J3DMtxCalcBasic::calcTransform(u16 param_0, const J3DTransformInfo& info) {
/* Nonmatching */
+ J3DSys::mCurrentS.x *= info.mScale.x;
+ J3DSys::mCurrentS.y *= info.mScale.y;
+ J3DSys::mCurrentS.z *= info.mScale.z;
+ Vec tmp = J3DSys::mCurrentS;
+ s32 var1;
+ if (tmp.x == 1.0f && tmp.y == 1.0f && tmp.z == 1.0f) {
+ var1 = 1;
+ } else {
+ var1 = 0;
+ }
+ s32 r29;
+ if (var1) {
+ j3dSys.getModel()->setScaleFlag(param_0, 1);
+ r29 = 1;
+ } else {
+ j3dSys.getModel()->setScaleFlag(param_0, 0);
+ r29 = 0;
+ }
+ Mtx mtx;
+ J3DGetTranslateRotateMtx(info, mtx);
+ if (r29 == 0) {
+ mtx[0][0] *= info.mScale.x;
+ mtx[0][1] *= info.mScale.y;
+ mtx[0][2] *= info.mScale.z;
+ mtx[1][0] *= info.mScale.x;
+ mtx[1][1] *= info.mScale.y;
+ mtx[1][2] *= info.mScale.z;
+ mtx[2][0] *= info.mScale.x;
+ mtx[2][1] *= info.mScale.y;
+ mtx[2][2] *= info.mScale.z;
+ }
+ MTXConcat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx);
+ MTXCopy(J3DSys::mCurrentMtx, j3dSys.getModel()->getAnmMtx(param_0));
}
/* 802F525C-802F52BC .text calc__15J3DMtxCalcBasicFUs */
-void J3DMtxCalcBasic::calc(u16) {
- /* Nonmatching */
+void J3DMtxCalcBasic::calc(u16 param_0) {
+ j3dSys.mCurrentMtxCalc = this;
+ calcTransform(param_0, j3dSys.getModel()->getModelData()->getJointNodePointer(param_0)->getTransformInfo());
}
/* 802F52BC-802F5508 .text calcTransform__19J3DMtxCalcSoftimageFUsRC16J3DTransformInfo */
-void J3DMtxCalcSoftimage::calcTransform(u16, const J3DTransformInfo&) {
+void J3DMtxCalcSoftimage::calcTransform(u16 param_0, const J3DTransformInfo& info) {
/* Nonmatching */
+ Mtx mtx;
+ J3DGetTranslateRotateMtx(
+ info.mRotation.x,
+ info.mRotation.y,
+ info.mRotation.z,
+ info.mTranslate.x * J3DSys::mCurrentS.x,
+ info.mTranslate.y * J3DSys::mCurrentS.y,
+ info.mTranslate.z * J3DSys::mCurrentS.z,
+ mtx
+ );
+ MTXConcat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx);
+ J3DSys::mCurrentS.x = J3DSys::mCurrentS.x * info.mScale.x;
+ J3DSys::mCurrentS.y = J3DSys::mCurrentS.y * info.mScale.y;
+ J3DSys::mCurrentS.z = J3DSys::mCurrentS.z * info.mScale.z;
+ Vec tmp = J3DSys::mCurrentS;
+ s32 var1;
+ if (tmp.x == 1.0f && tmp.y == 1.0f && tmp.z == 1.0f) {
+ var1 = 1;
+ } else {
+ var1 = 0;
+ }
+ s32 var2;
+ if (var1) {
+ j3dSys.getModel()->setScaleFlag(param_0, 1);
+ var2 = 1;
+ } else {
+ j3dSys.getModel()->setScaleFlag(param_0, 0);
+ var2 = 0;
+ }
+ if (!var2) {
+ mtx[0][0] = J3DSys::mCurrentMtx[0][0] * J3DSys::mCurrentS.x;
+ mtx[0][1] = J3DSys::mCurrentMtx[0][1] * J3DSys::mCurrentS.y;
+ mtx[0][2] = J3DSys::mCurrentMtx[0][2] * J3DSys::mCurrentS.z;
+ mtx[0][3] = J3DSys::mCurrentMtx[0][3];
+ mtx[1][0] = J3DSys::mCurrentMtx[1][0] * J3DSys::mCurrentS.x;
+ mtx[1][1] = J3DSys::mCurrentMtx[1][1] * J3DSys::mCurrentS.y;
+ mtx[1][2] = J3DSys::mCurrentMtx[1][2] * J3DSys::mCurrentS.z;
+ mtx[1][3] = J3DSys::mCurrentMtx[1][3];
+ mtx[2][0] = J3DSys::mCurrentMtx[2][0] * J3DSys::mCurrentS.x;
+ mtx[2][1] = J3DSys::mCurrentMtx[2][1] * J3DSys::mCurrentS.y;
+ mtx[2][2] = J3DSys::mCurrentMtx[2][2] * J3DSys::mCurrentS.z;
+ mtx[2][3] = J3DSys::mCurrentMtx[2][3];
+ MTXCopy(mtx, j3dSys.getModel()->getAnmMtx(param_0));
+ } else {
+ MTXCopy(J3DSys::mCurrentMtx, j3dSys.getModel()->getAnmMtx(param_0));
+ }
}
/* 802F5508-802F5724 .text calcTransform__14J3DMtxCalcMayaFUsRC16J3DTransformInfo */
-void J3DMtxCalcMaya::calcTransform(u16, const J3DTransformInfo&) {
+void J3DMtxCalcMaya::calcTransform(u16 param_1, const J3DTransformInfo& param_2) {
/* Nonmatching */
+ J3DModel* model = j3dSys.getModel();
+ u8 scaleCompensate = model->getModelData()->getJointNodePointer(param_1)->getScaleCompensate();
+ s32 tmp;
+ if (param_2.mScale.x == 1.0f && param_2.mScale.y == 1.0f && param_2.mScale.z == 1.0f) {
+ model->setScaleFlag(param_1, 1);
+ tmp = true;
+ } else {
+ model->setScaleFlag(param_1, 0);
+ tmp = false;
+ }
+ Mtx mtx;
+ J3DGetTranslateRotateMtx(param_2, mtx);
+ if (tmp == 0) {
+ mtx[0][0] *= param_2.mScale.x;
+ mtx[0][1] *= param_2.mScale.y;
+ mtx[0][2] *= param_2.mScale.z;
+ mtx[1][0] *= param_2.mScale.x;
+ mtx[1][1] *= param_2.mScale.y;
+ mtx[1][2] *= param_2.mScale.z;
+ mtx[2][0] *= param_2.mScale.x;
+ mtx[2][1] *= param_2.mScale.y;
+ mtx[2][2] *= param_2.mScale.z;
+ }
+ if (scaleCompensate == 1) {
+ f32 x = 1.0f / J3DSys::mParentS.x;
+ f32 y = 1.0f / J3DSys::mParentS.y;
+ f32 z = 1.0f / J3DSys::mParentS.z;
+ mtx[0][0] *= x;
+ mtx[0][1] *= x;
+ mtx[0][2] *= x;
+ mtx[1][0] *= y;
+ mtx[1][1] *= y;
+ mtx[1][2] *= y;
+ mtx[2][0] *= z;
+ mtx[2][1] *= z;
+ mtx[2][2] *= z;
+ }
+ MTXConcat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx);
+ MTXCopy(J3DSys::mCurrentMtx, j3dSys.getModel()->getAnmMtx(param_1));
+ J3DSys::mParentS.x = param_2.mScale.x;
+ J3DSys::mParentS.y = param_2.mScale.y;
+ J3DSys::mParentS.z = param_2.mScale.z;
}
/* 802F5724-802F5814 .text initialize__8J3DJointFv */
void J3DJoint::initialize() {
/* Nonmatching */
+ mJntNo = 0;
+ mKind = 1;
+ mScaleCompensate = 0;
+ mTransformInfo = j3dDefaultTransformInfo;
+ mBoundingSphereRadius = 0.0f;
+ mMin = (Vec){0.0f, 0.0f, 0.0f};
+ mMax = (Vec){0.0f, 0.0f, 0.0f};
+ mMtxCalc = NULL;
+ mOldMtxCalc = NULL;
+ mMesh = NULL;
}
/* 802F5814-802F5834 .text addMesh__8J3DJointFP11J3DMaterial */
-void J3DJoint::addMesh(J3DMaterial*) {
- /* Nonmatching */
+void J3DJoint::addMesh(J3DMaterial* material) {
+ if (!mMesh) {
+ mMesh = material;
+ return;
+ }
+ material->setNext(mMesh);
+ mMesh = material;
}
/* 802F5834-802F58B4 .text calcIn__8J3DJointFv */
void J3DJoint::calcIn() {
- /* Nonmatching */
+ if (mMtxCalc) {
+ mOldMtxCalc = j3dSys.getCurrentMtxCalc();
+ mMtxCalc->calc(mJntNo);
+ } else if (j3dSys.getCurrentMtxCalc()) {
+ j3dSys.getCurrentMtxCalc()->calc(mJntNo);
+ }
}
/* 802F58B4-802F58D8 .text calcOut__8J3DJointFv */
void J3DJoint::calcOut() {
- /* Nonmatching */
+ if (!mOldMtxCalc) {
+ return;
+ }
+ j3dSys.setCurrentMtxCalc(mOldMtxCalc);
+ mOldMtxCalc = NULL;
}
/* 802F58D8-802F5A78 .text entryIn__8J3DJointFv */
diff --git a/src/JSystem/J3DGraphAnimator/J3DModelData.cpp b/src/JSystem/J3DGraphAnimator/J3DModelData.cpp
index 6d6d6c53..46191fc5 100644
--- a/src/JSystem/J3DGraphAnimator/J3DModelData.cpp
+++ b/src/JSystem/J3DGraphAnimator/J3DModelData.cpp
@@ -177,8 +177,3 @@ void J3DModelData::setMaterialTable(J3DMaterialTable* pMaterialTable, J3DMateria
setTextureName(pMaterialTable->getTextureName());
}
}
-
-/* 802ED4F4-802ED500 .text getType__7J3DNodeCFv */
-u32 J3DNode::getType() const {
- return 'NNON';
-}
diff --git a/src/JSystem/J3DGraphAnimator/J3DNode.cpp b/src/JSystem/J3DGraphAnimator/J3DNode.cpp
index 006aec6f..59e667aa 100644
--- a/src/JSystem/J3DGraphAnimator/J3DNode.cpp
+++ b/src/JSystem/J3DGraphAnimator/J3DNode.cpp
@@ -16,7 +16,6 @@ J3DNode::J3DNode() {
/* 802F5BC8-802F5C10 .text __dt__7J3DNodeFv */
J3DNode::~J3DNode() {
- /* Nonmatching */
}
/* 802F5C10-802F5C44 .text appendChild__7J3DNodeFP7J3DNode */
@@ -31,8 +30,3 @@ void J3DNode::appendChild(J3DNode* pChild) {
curChild->setYounger(pChild);
}
}
-
-/* 802F5C44-802F5C48 .text entryIn__7J3DNodeFv */
-void J3DNode::entryIn() {
- /* Nonmatching */
-}
diff --git a/src/JSystem/J3DU/J3DUMotion.cpp b/src/JSystem/J3DU/J3DUMotion.cpp
index f21ae9b2..8f80e668 100644
--- a/src/JSystem/J3DU/J3DUMotion.cpp
+++ b/src/JSystem/J3DU/J3DUMotion.cpp
@@ -7,8 +7,15 @@
#include "JSystem/J3DGraphAnimator/J3DJoint.h"
#include "dolphin/types.h"
-// The following are probably weak functions?
-// Not sure how they ended up here, exactly.
+// this puts the correct functions here when they are weak
+// however, the data from J3DMtxCalcBasic::init starts appearing in other TUs
+static void dummy(J3DMtxCalcBasic* calc1, J3DMtxCalcSoftimage* calc2) {
+ Vec vec;
+ Mtx mtx;
+ calc1->init(vec, mtx);
+ calc2->init(vec, mtx);
+ delete calc2;
+}
/* 80256DBC-80256E4C .text __dt__19J3DMtxCalcSoftimageFv */
J3DMtxCalcSoftimage::~J3DMtxCalcSoftimage() {}