From b3a4dd1d26b16e35b4b62b6318be4adb4ec3c163 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 3 Nov 2023 22:49:32 -0700 Subject: [PATCH] d_a_vrbox2 work --- include/JSystem/J3DGraphBase/J3DMatBlock.h | 3 +- include/SSystem/SComponent/c_m3d.h | 4 + src/d/actor/d_a_vrbox2.cpp | 102 ++++++++++++--------- src/d/d_kankyo_rain.cpp | 3 +- 4 files changed, 65 insertions(+), 47 deletions(-) diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index a49289be8..90826614b 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -551,7 +551,8 @@ struct J3DZMode { u8 getUpdateEnable() const { return j3dZModeTable[mZModeID].mUpdateEnable; } void setZModeInfo(const J3DZModeInfo& info) { - mZModeID = calcZModeID(info.mCompareEnable, info.mFunc, info.mUpdateEnable); + u8 compareEn = info.mCompareEnable; + mZModeID = calcZModeID(compareEn, info.mFunc, info.mUpdateEnable); } void load() { diff --git a/include/SSystem/SComponent/c_m3d.h b/include/SSystem/SComponent/c_m3d.h index b50854945..6ff4ade49 100644 --- a/include/SSystem/SComponent/c_m3d.h +++ b/include/SSystem/SComponent/c_m3d.h @@ -105,6 +105,10 @@ inline void cM3d_VectorProduct(const Vec* p0, const Vec* p1, const Vec* p2, Vec* VECCrossProduct(&v01, &v02, pDst); } +inline f32 cM3d_VectorProduct2d(f32 pX1, f32 pY1, f32 pX2, f32 pY2, f32 pX3, f32 pY3) { + return (pX2 - pX1) * (pY3 - pY1) - (pY2 - pY1) * (pX3 - pX1); +} + inline bool cM3d_CrossInfLineVsInfPlane_proc(f32 a, f32 b, const Vec* pA, const Vec* pB, Vec* pDst) { if (cM3d_IsZero(a - b)) { *pDst = *pB; diff --git a/src/d/actor/d_a_vrbox2.cpp b/src/d/actor/d_a_vrbox2.cpp index f320a0831..471a691ee 100644 --- a/src/d/actor/d_a_vrbox2.cpp +++ b/src/d/actor/d_a_vrbox2.cpp @@ -95,12 +95,25 @@ BOOL daVrbox2_Draw(vrbox2_class* i_this) { return TRUE; } -static const J3DZModeInfo l_zmodeInfo = { GX_FALSE, GX_LEQUAL, GX_FALSE }; +J3DZModeInfo l_zmodeInfo = { GX_FALSE, GX_LEQUAL, GX_FALSE }; /* 8015EC30-8015F368 .text daVrbox2_color_set__FP12vrbox2_class */ BOOL daVrbox2_color_set(vrbox2_class* i_this) { /* Nonmatching */ - camera_class * pCamera = dComIfGp_getCamera(0); + camera_class * pCamera; + cXyz eyePosXZ; + cXyz centerPosXZ; + cXyz lookDirXZ; + cXyz windNrmVec; + GXColor k0; + GXColorS10 c0; + cXyz * windVec; + J3DModelData * modelData; + J3DMaterial * mat; + J3DTexMtx * mtx; + f32 windPow; + f32 windDirView; + f32 scrollSpeed; if (g_env_light.mVrKasumiMaeColor.r + g_env_light.mVrKasumiMaeColor.g + g_env_light.mVrKasumiMaeColor.b + g_env_light.mVrSkyColor.r + g_env_light.mVrSkyColor.g + g_env_light.mVrSkyColor.b + @@ -109,9 +122,10 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { return TRUE; } - cXyz * windVec = dKyw_get_wind_vec(); - f32 windPow = dKyw_get_wind_pow(); - cXyz windNrmVec = *windVec; + pCamera = dComIfGp_getCamera(0); + windVec = dKyw_get_wind_vec(); + windPow = dKyw_get_wind_pow(); + windNrmVec = *windVec; if (dStage_stagInfo_GetSTType(dComIfGp_getStageStagInfo()) == 2) { s16 stageWindY = 0; @@ -126,7 +140,9 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { else if (strcmp(dComIfGp_getStartStageName(), "Onobuta") == 0) stageWindY = 0x4000; - s32 windX, windY; + s32 windY2; + s32 windX; + s16 windY; if (dComIfGs_getWindX() == -1 && dComIfGs_getWindY() == -1) { windX = 0; windY = 0; @@ -136,81 +152,80 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { } windY += stageWindY; + windY2 = windY; - windNrmVec.x = cM_scos(windX) * cM_scos(windY); - windNrmVec.z = cM_scos(windX) * cM_ssin(windY); + windNrmVec.x = cM_scos(windX) * cM_scos(windY2); + windNrmVec.y = cM_ssin(windX); + windNrmVec.z = cM_scos(windX) * cM_ssin(windY2); windPow = 0.6f; } - cXyz eyePosXZ, centerPosXZ, camFwdXZ; - eyePosXZ.x = pCamera->mLookat.mEye.x; - eyePosXZ.z = pCamera->mLookat.mEye.z; - centerPosXZ.x = pCamera->mLookat.mCenter.x; - centerPosXZ.z = pCamera->mLookat.mCenter.z; + eyePosXZ = pCamera->mLookat.mEye; + centerPosXZ = pCamera->mLookat.mCenter; eyePosXZ.y = 0.0f; centerPosXZ.y = 0.0f; - dKyr_get_vectle_calc(&eyePosXZ, ¢erPosXZ, &camFwdXZ); - // is this an inline? how do i get it to subtract 0.0f - f32 scrollSpeed = (-windNrmVec.x - 0.0f) * (camFwdXZ.z - 0.0f) * (-windNrmVec.z - 0.0f) * (camFwdXZ.x - 0.0f) * 0.0005f * windPow; + + dKyr_get_vectle_calc(&eyePosXZ, ¢erPosXZ, &lookDirXZ); + windDirView = cM3d_VectorProduct2d(0.0f, 0.0f, -windNrmVec.x, -windNrmVec.z, lookDirXZ.x, lookDirXZ.z) * 0.0005f; + scrollSpeed = windDirView * windPow; if (strcmp(dComIfGp_getStartStageName(), "M_DragB") == 0) scrollSpeed = -0.0004f; - J3DMaterial * mat = i_this->mpBackCloud->getModelData()->getMaterialNodePointer(0); + modelData = i_this->mpBackCloud->getModelData(); + mat = modelData->getMaterialNodePointer(0); mat->setCullMode(GX_CULL_NONE); mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); - J3DTexMtx * mtx0 = mat->getTexMtx(0); - mtx0->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed; - texScrollCheck(mtx0->getTexMtxInfo().mSRT.mTranslationX); - J3DTexMtx * mtx1 = mat->getTexMtx(1); - mtx1->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed; - texScrollCheck(mtx1->getTexMtxInfo().mSRT.mTranslationX); + mtx = mat->getTexMtx(0); + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed; + texScrollCheck(mtx->getTexMtxInfo().mSRT.mTranslationX); + mtx = mat->getTexMtx(1); + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed; + texScrollCheck(mtx->getTexMtxInfo().mSRT.mTranslationX); - GXColor k0; k0.r = g_env_light.mVrkumoColor.r; k0.g = g_env_light.mVrkumoColor.g; k0.b = g_env_light.mVrkumoColor.b; k0.a = 0xFF; mat->setTevKColor(0, (J3DGXColor*)&k0); - mat = i_this->mpBackCloud->getModelData()->getMaterialNodePointer(1); + mat = modelData->getMaterialNodePointer(1); mat->setCullMode(GX_CULL_NONE); mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); - mtx0 = mat->getTexMtx(0); - mtx0->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.8f; - texScrollCheck(mtx0->getTexMtxInfo().mSRT.mTranslationX); - mtx1 = mat->getTexMtx(1); - mtx1->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.8f; - texScrollCheck(mtx1->getTexMtxInfo().mSRT.mTranslationX); + mtx = mat->getTexMtx(0); + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.8f; + texScrollCheck(mtx->getTexMtxInfo().mSRT.mTranslationX); + mtx = mat->getTexMtx(1); + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.8f; + texScrollCheck(mtx->getTexMtxInfo().mSRT.mTranslationX); mat->setTevKColor(0, (J3DGXColor*)&k0); - mat = i_this->mpBackCloud->getModelData()->getMaterialNodePointer(2); + mat = modelData->getMaterialNodePointer(2); mat->setCullMode(GX_CULL_NONE); mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); - mtx0 = mat->getTexMtx(0); - mtx0->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.6f; - texScrollCheck(mtx0->getTexMtxInfo().mSRT.mTranslationX); - mtx1 = mat->getTexMtx(1); - mtx1->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.6f; - texScrollCheck(mtx1->getTexMtxInfo().mSRT.mTranslationX); + mtx = mat->getTexMtx(0); + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.6f; + texScrollCheck(mtx->getTexMtxInfo().mSRT.mTranslationX); + mtx = mat->getTexMtx(1); + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed; + mtx->getTexMtxInfo().mSRT.mTranslationX += scrollSpeed * 0.6f; + texScrollCheck(mtx->getTexMtxInfo().mSRT.mTranslationX); mat->setTevKColor(0, (J3DGXColor*)&k0); if (i_this->mpKasumiMae != NULL) { - mat = i_this->mpBackCloud->getModelData()->getMaterialNodePointer(0); - mat->setCullMode(GX_CULL_NONE); + mat = i_this->mpKasumiMae->getModelData()->getMaterialNodePointer(0); mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); - GXColorS10 c0; c0.r = g_env_light.mVrKasumiMaeColor.r; c0.g = g_env_light.mVrKasumiMaeColor.g; c0.b = g_env_light.mVrKasumiMaeColor.b; - k0.r = g_env_light.mVrkumoColor.r; + k0.r = g_env_light.mVrkumoColor.a; k0.g = 0x00; k0.b = 0x00; k0.a = 0x00; @@ -219,8 +234,7 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { } if (i_this->mpUsoUmi != NULL) { - mat = i_this->mpBackCloud->getModelData()->getMaterialNodePointer(0); - mat->setCullMode(GX_CULL_NONE); + mat = i_this->mpUsoUmi->getModelData()->getMaterialNodePointer(0); mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index 60d172df1..879e9e146 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -582,8 +582,7 @@ void wave_move() { cXyz lookDirXZ; vectle_calc(&deltaXZ, &lookDirXZ); - // is this an inline? how do i get it to subtract 0.0f - pPkt->mSkewDir = (-windNrmVec.x - 0.0f) * (lookDirXZ.z - 0.0f) * (-windNrmVec.z - 0.0f) * (lookDirXZ.x - 0.0f); + pPkt->mSkewDir = cM3d_VectorProduct2d(0.0f, 0.0f, -windNrmVec.x, -windNrmVec.z, lookDirXZ.x, lookDirXZ.z); pPkt->mSkewWidth = (1.0f - fabsf(windNrmVec.x * lookDirXZ.x + windNrmVec.z * lookDirXZ.z)) * windPow * (1.0f - fabsf(windNrmVec.y)); pPkt->mSkewWidth *= fabsf(pPkt->mSkewDir) * 0.6f;