// // Generated by dtk // Translation Unit: J3DJoint.cpp // #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/J3DGraphAnimator/J3DJoint.h" #include "JSystem/J3DGraphAnimator/J3DAnimation.h" #include "JSystem/J3DGraphAnimator/J3DModel.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" #include "dolphin/types.h" /* 802F4DC0-802F4EB0 .text calc__13J3DMtxCalcAnmFUs */ void J3DMtxCalcAnm::calc(u16 jnt_no) { j3dSys.setCurrentMtxCalc(this); J3DTransformInfo info; J3DAnmTransform* transform = mOne[0]; if (transform) { transform->getTransform(jnt_no, &info); } else { info = j3dSys.getModel()->getModelData()->getJointNodePointer(jnt_no)->getTransformInfo(); } calcTransform(jnt_no, info); } /* 802F4EB0-802F4EF8 .text __ct__15J3DMtxCalcBasicFv */ J3DMtxCalcBasic::J3DMtxCalcBasic() {} /* 802F4EF8-802F5090 .text recursiveCalc__15J3DMtxCalcBasicFP7J3DNode */ 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, J3DNodeCBCalcTiming_In); } recursiveCalc(node->getChild()); MTXCopy(mtxCalc.getBackupMtx(), J3DSys::mCurrentMtx); J3DSys::mCurrentS = mtxCalc.getBackupS(); J3DSys::mParentS = mtxCalc.getBackupParentS(); node->calcOut(); if (node->getCallBack()) { node->getCallBack()(node, J3DNodeCBCalcTiming_Out); } recursiveCalc(node->getYounger()); } /* 802F5090-802F525C .text calcTransform__15J3DMtxCalcBasicFUsRC16J3DTransformInfo */ void J3DMtxCalcBasic::calcTransform(u16 jnt_no, const J3DTransformInfo& info) { J3DSys::mCurrentS.x *= info.mScale.x; J3DSys::mCurrentS.y *= info.mScale.y; J3DSys::mCurrentS.z *= info.mScale.z; s32 r29; if (checkScaleOne(J3DSys::mCurrentS)) { j3dSys.getModel()->setScaleFlag(jnt_no, 1); r29 = 1; } else { j3dSys.getModel()->setScaleFlag(jnt_no, 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); J3DModel* model = j3dSys.getModel(); model->setAnmMtx(jnt_no, J3DSys::mCurrentMtx); } /* 802F525C-802F52BC .text calc__15J3DMtxCalcBasicFUs */ void J3DMtxCalcBasic::calc(u16 jnt_no) { j3dSys.setCurrentMtxCalc(this); calcTransform(jnt_no, j3dSys.getModel()->getModelData()->getJointNodePointer(jnt_no)->getTransformInfo()); } /* 802F52BC-802F5508 .text calcTransform__19J3DMtxCalcSoftimageFUsRC16J3DTransformInfo */ void J3DMtxCalcSoftimage::calcTransform(u16 jnt_no, 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; s32 var2; if (checkScaleOne(J3DSys::mCurrentS)) { j3dSys.getModel()->setScaleFlag(jnt_no, 1); var2 = 1; } else { j3dSys.getModel()->setScaleFlag(jnt_no, 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]; J3DModel* model = j3dSys.getModel(); model->setAnmMtx(jnt_no, mtx); } else { J3DModel* model = j3dSys.getModel(); model->setAnmMtx(jnt_no, J3DSys::mCurrentMtx); } } /* 802F5508-802F5724 .text calcTransform__14J3DMtxCalcMayaFUsRC16J3DTransformInfo */ void J3DMtxCalcMaya::calcTransform(u16 jnt_no, const J3DTransformInfo& param_2) { J3DModel* model = j3dSys.getModel(); u8 scaleCompensate = model->getModelData()->getJointNodePointer(jnt_no)->getScaleCompensate(); s32 tmp; if (param_2.mScale.x == 1.0f && param_2.mScale.y == 1.0f && param_2.mScale.z == 1.0f) { model->setScaleFlag(jnt_no, 1); tmp = true; } else { model->setScaleFlag(jnt_no, 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); model = j3dSys.getModel(); model->setAnmMtx(jnt_no, J3DSys::mCurrentMtx); 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() { mJntNo = 0; mKind = 1; mScaleCompensate = 0; mTransformInfo = j3dDefaultTransformInfo; mRadius = 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* material) { if (!mMesh) { mMesh = material; return; } material->setNext(mMesh); mMesh = material; } /* 802F5834-802F58B4 .text calcIn__8J3DJointFv */ void J3DJoint::calcIn() { if (mMtxCalc) { mOldMtxCalc = j3dSys.getCurrentMtxCalc(); mMtxCalc->calc(mJntNo); } else if (j3dSys.getCurrentMtxCalc()) { j3dSys.getCurrentMtxCalc()->calc(mJntNo); } } /* 802F58B4-802F58D8 .text calcOut__8J3DJointFv */ void J3DJoint::calcOut() { if (!mOldMtxCalc) { return; } j3dSys.setCurrentMtxCalc(mOldMtxCalc); mOldMtxCalc = NULL; } /* 802F58D8-802F5A78 .text entryIn__8J3DJointFv */ void J3DJoint::entryIn() { MtxP anmMtx = j3dSys.getModel()->getAnmMtx(mJntNo); j3dSys.getDrawBuffer(0)->setZMtx(anmMtx); j3dSys.getDrawBuffer(1)->setZMtx(anmMtx); for (J3DMaterial* mesh = mMesh; mesh != NULL; ) { if (mesh->getShape()->checkFlag(J3DShpFlag_Hide)) { mesh = mesh->getNext(); } else { J3DMatPacket* matPacket = j3dSys.getModel()->getMatPacket(mesh->getIndex()); J3DShapePacket* shapePacket = j3dSys.getModel()->getShapePacket(mesh->getShape()->getIndex()); if (!matPacket->isLocked()) { if (mesh->getMaterialAnm()) { J3DMaterialAnm* piVar8 = mesh->getMaterialAnm(); piVar8->calc(mesh); } mesh->calc(anmMtx); } mesh->setCurrentMtx(); matPacket->setMaterialAnmID(mesh->getMaterialAnm()); matPacket->setShapePacket(shapePacket); J3DDrawBuffer* drawBuffer = j3dSys.getDrawBuffer(mesh->isDrawModeOpaTexEdge()); if ((u8)matPacket->entry(drawBuffer)) { j3dSys.setMatPacket(matPacket); J3DDrawBuffer::entryNum++; mesh->makeDisplayList(); } mesh = mesh->getNext(); } } }