summaryrefslogtreecommitdiffstats
path: root/src/render/WeaponEffects.cpp
diff options
context:
space:
mode:
authorFire-Head <Fire-Head@users.noreply.github.com>2020-03-28 21:55:23 +0100
committerFire-Head <Fire-Head@users.noreply.github.com>2020-03-28 21:55:23 +0100
commit194ddc5f40835476673655bd3895f2b7fe7fee0c (patch)
tree530ef79acd32c90ce5ef5d545a04d4d09b5abfb7 /src/render/WeaponEffects.cpp
parentMerge pull request #363 from erorcun/erorcun (diff)
downloadre3-194ddc5f40835476673655bd3895f2b7fe7fee0c.tar
re3-194ddc5f40835476673655bd3895f2b7fe7fee0c.tar.gz
re3-194ddc5f40835476673655bd3895f2b7fe7fee0c.tar.bz2
re3-194ddc5f40835476673655bd3895f2b7fe7fee0c.tar.lz
re3-194ddc5f40835476673655bd3895f2b7fe7fee0c.tar.xz
re3-194ddc5f40835476673655bd3895f2b7fe7fee0c.tar.zst
re3-194ddc5f40835476673655bd3895f2b7fe7fee0c.zip
Diffstat (limited to 'src/render/WeaponEffects.cpp')
-rw-r--r--src/render/WeaponEffects.cpp111
1 files changed, 86 insertions, 25 deletions
diff --git a/src/render/WeaponEffects.cpp b/src/render/WeaponEffects.cpp
index 932c661e..1c29caf8 100644
--- a/src/render/WeaponEffects.cpp
+++ b/src/render/WeaponEffects.cpp
@@ -1,45 +1,106 @@
#include "common.h"
#include "patcher.h"
#include "WeaponEffects.h"
-
#include "TxdStore.h"
+#include "Sprite.h"
+
+RwTexture *gpCrossHairTex;
+RwRaster *gpCrossHairRaster;
-WRAPPER void CWeaponEffects::Render(void) { EAXJMP(0x564D70); }
+CWeaponEffects gCrossHair;
-CWeaponEffects &gCrossHair = *(CWeaponEffects*)0x6503BC;
+CWeaponEffects::CWeaponEffects()
+{
+
+}
+
+CWeaponEffects::~CWeaponEffects()
+{
+
+}
void
-CWeaponEffects::ClearCrossHair()
+CWeaponEffects::Init(void)
{
- gCrossHair.m_bCrosshair = false;
+ gCrossHair.m_bActive = false;
+ gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f);
+ gCrossHair.m_nRed = 0;
+ gCrossHair.m_nGreen = 0;
+ gCrossHair.m_nBlue = 0;
+ gCrossHair.m_nAlpha = 255;
+ gCrossHair.m_fSize = 1.0f;
+ gCrossHair.m_fRotation = 0.0f;
+
+
+ CTxdStore::PushCurrentTxd();
+ int32 slut = CTxdStore::FindTxdSlot("particle");
+ CTxdStore::SetCurrentTxd(slut);
+
+ gpCrossHairTex = RwTextureRead("crosshair", NULL);
+ gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex);
+
+ CTxdStore::PopCurrentTxd();
+}
+
+void
+CWeaponEffects::Shutdown(void)
+{
+ RwTextureDestroy(gpCrossHairTex);
}
void
CWeaponEffects::MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size)
{
- gCrossHair.m_bCrosshair = true;
+ gCrossHair.m_bActive = true;
gCrossHair.m_vecPos = pos;
- gCrossHair.m_red = red;
- gCrossHair.m_green = green;
- gCrossHair.m_blue = blue;
- gCrossHair.m_alpha = alpha;
- gCrossHair.m_size = size;
+ gCrossHair.m_nRed = red;
+ gCrossHair.m_nGreen = green;
+ gCrossHair.m_nBlue = blue;
+ gCrossHair.m_nAlpha = alpha;
+ gCrossHair.m_fSize = size;
}
void
-CWeaponEffects::Init()
+CWeaponEffects::ClearCrossHair(void)
{
- gCrossHair.m_bCrosshair = false;
- gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f);
- gCrossHair.m_red = 0;
- gCrossHair.m_green = 0;
- gCrossHair.m_blue = 0;
- gCrossHair.m_alpha = 255;
- gCrossHair.m_size = 1.0f;
- gCrossHair.field_24 = 0;
- CTxdStore::PushCurrentTxd();
- CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("particle"));
- gCrossHair.m_pTexture = RwTextureRead("crosshair", nil);
- gCrossHair.m_pRaster = gCrossHair.m_pTexture->raster;
- CTxdStore::PopCurrentTxd();
+ gCrossHair.m_bActive = false;
+}
+
+void
+CWeaponEffects::Render(void)
+{
+ if ( gCrossHair.m_bActive )
+ {
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpCrossHairRaster);
+
+ RwV3d pos;
+ float w, h;
+ if ( CSprite::CalcScreenCoors(gCrossHair.m_vecPos, &pos, &w, &h, true) )
+ {
+ float recipz = 1.0f / pos.z;
+ CSprite::RenderOneXLUSprite(pos.x, pos.y, pos.z,
+ gCrossHair.m_fSize * w, gCrossHair.m_fSize * h,
+ gCrossHair.m_nRed, gCrossHair.m_nGreen, gCrossHair.m_nBlue, 255,
+ recipz, 255);
+ }
+
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
+ }
}
+
+STARTPATCHES
+ //InjectHook(0x564C40, CWeaponEffects::CWeaponEffects, PATCH_JUMP);
+ //InjectHook(0x564C50, CWeaponEffects::~CWeaponEffects, PATCH_JUMP);
+ InjectHook(0x564C60, CWeaponEffects::Init, PATCH_JUMP);
+ InjectHook(0x564CF0, CWeaponEffects::Shutdown, PATCH_JUMP);
+ InjectHook(0x564D00, CWeaponEffects::MarkTarget, PATCH_JUMP);
+ InjectHook(0x564D60, CWeaponEffects::ClearCrossHair, PATCH_JUMP);
+ InjectHook(0x564D70, CWeaponEffects::Render, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file