summaryrefslogtreecommitdiffstats
path: root/src/render/SpecialFX.cpp
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-02-16 21:08:54 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2020-02-16 21:08:54 +0100
commit1337a9b6034570861a7cadaf5338d0cbb5b06255 (patch)
treedc65656c184c0060f053d0f0ea45a8125628e9cd /src/render/SpecialFX.cpp
parentreview fixes (diff)
downloadre3-1337a9b6034570861a7cadaf5338d0cbb5b06255.tar
re3-1337a9b6034570861a7cadaf5338d0cbb5b06255.tar.gz
re3-1337a9b6034570861a7cadaf5338d0cbb5b06255.tar.bz2
re3-1337a9b6034570861a7cadaf5338d0cbb5b06255.tar.lz
re3-1337a9b6034570861a7cadaf5338d0cbb5b06255.tar.xz
re3-1337a9b6034570861a7cadaf5338d0cbb5b06255.tar.zst
re3-1337a9b6034570861a7cadaf5338d0cbb5b06255.zip
Diffstat (limited to '')
-rw-r--r--src/render/SpecialFX.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp
index f1fd3f09..39b22671 100644
--- a/src/render/SpecialFX.cpp
+++ b/src/render/SpecialFX.cpp
@@ -11,6 +11,9 @@
#include "Lights.h"
#include "VisibilityPlugins.h"
#include "World.h"
+#include "Particle.h"
+#include "General.h"
+#include "Camera.h"
WRAPPER void CSpecialFX::Render(void) { EAXJMP(0x518DC0); }
WRAPPER void CSpecialFX::Update(void) { EAXJMP(0x518D40); }
@@ -383,6 +386,77 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8
aMoneyMessages[nIndex].m_fOpacity = fOpacity;
}
+void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles)
+{
+ int attempts = 0;
+ float outerFw = innerFw + 5.0f;
+ float outerRg = innerRg + 5.0f;
+ float outerUp = innerUp + 5.0f;
+ while (particles > 0 && attempts < 1000) {
+ CVector pos;
+ int rnd = CGeneral::GetRandomNumber();
+ pos.x = (int8)(rnd - 128) / 110.0f;
+ pos.y = (int8)((rnd >> 8) - 128) / 110.0f;
+ pos.z = 0.0f;
+ if (DotProduct2D(pos, TheCamera.GetForward()) >= 0)
+ continue;
+ pos += pMatrix->GetPosition();
+ pos.z = 2.0f;
+ // was there any point in adding it here?
+ float fw = DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition());
+ if (fw >= outerFw)
+ continue;
+ float rg = DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition());
+ if (rg >= outerRg)
+ continue;
+ float up = DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition());
+ if (up >= outerUp)
+ continue;
+ if (fw > innerFw || rg > innerRg || up > innerUp) {
+ CParticle::AddParticle(PARTICLE_STEAM2, pos, CVector(0.0f, 0.0f, 0.0f), nil, 4.0f, 1, 0, 0, 0);
+ particles--;
+ }
+ }
+}
+
+void CSpecialParticleStuff::StartBoatFoamAnimation()
+{
+ BoatFromStart = CTimer::GetTimeInMilliseconds();
+}
+
+CRGBA FoamColour(255, 255, 255, 255);
+unsigned int CSpecialParticleStuff::BoatFromStart;
+
+void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix)
+{
+ static int32 FrameInAnimation = 0;
+ static float X, Y, Z, dX, dY, dZ;
+ CreateFoamAroundObject(pMatrix, 107.0f, 24.1f, 30.5f, 2);
+ uint32 prev = CTimer::GetPreviousTimeInMilliseconds();
+ uint32 cur = CTimer::GetTimeInMilliseconds();
+ if (FrameInAnimation != 0) {
+ X += dX;
+ Y += dY;
+ Z += dZ;
+ CVector pos = *pMatrix * CVector(X, Y, Z);
+ CParticle::AddParticle(PARTICLE_STEAM_NY, pos, CVector(0.0f, 0.0f, 0.0f),
+ nil, FrameInAnimation * 0.5f + 2.0f, FoamColour, 1, 0, 0, 0);
+ if (++FrameInAnimation)
+ FrameInAnimation = 0;
+ }
+ if ((cur & 0x3FF) < (prev & 0x3FF)) {
+ FrameInAnimation = 1;
+ int rnd = CGeneral::GetRandomNumber();
+ X = (int8)(rnd - 128) * 0.2f;
+ Y = (int8)((rnd >> 8) - 128) * 0.2f;
+ Z = 10.0f;
+ rnd = CGeneral::GetRandomNumber();
+ dX = (int8)(rnd - 128) * 0.02f;
+ dY = (int8)((rnd >> 8) - 128) * 0.02f;
+ dZ = 2.0f;
+ }
+}
+
STARTPATCHES
InjectHook(0x51B070, &C3dMarker::AddMarker, PATCH_JUMP);
InjectHook(0x51B170, &C3dMarker::DeleteMarkerObject, PATCH_JUMP);