From 881db86895dd5427efd3962909214be06270e1ab Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 9 Oct 2020 20:29:38 +0300 Subject: CSpecialFX and some other classes --- src/control/Script.cpp | 9 +- src/core/Timer.cpp | 3 +- src/core/main.cpp | 2 +- src/render/SpecialFX.cpp | 261 +++++++++++++++++++++++++++-------------------- src/render/SpecialFX.h | 29 ++++-- 5 files changed, 178 insertions(+), 126 deletions(-) (limited to 'src') diff --git a/src/control/Script.cpp b/src/control/Script.cpp index aa4e109f..d05a1442 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1804,9 +1804,8 @@ void CMissionCleanup::Process() if (!CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle) TheCamera.Restore(); TheCamera.SetWideScreenOff(); - // TODO(MIAMI) - //CSpecialFX::bLiftCam = false; - //CSpecialFX::bVideoCam = false; + CSpecialFX::bLiftCam = false; + CSpecialFX::bVideoCam = false; CTimeCycle::StopExtraColour(0); for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) DMAudio.ClearMissionAudio(i); @@ -12395,7 +12394,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SWITCH_SECURITY_CAMERA: { CollectParameters(&m_nIp, 1); - debug("SWITCH_SECURITY_CAMERA is not implemented\n"); // TODO(MIAMI) + CSpecialFX::bVideoCam = ScriptParams[0] != 0; return 0; } //case COMMAND_IS_CHAR_IN_FLYING_VEHICLE: @@ -12833,7 +12832,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SWITCH_LIFT_CAMERA: { CollectParameters(&m_nIp, 1); - debug("SWITCH_LIFT_CAMERA is not implemented\n"); // TODO(MIAMI) + CSpecialFX::bLiftCam = ScriptParams[0] != 0; return 0; } case COMMAND_CLOSE_ALL_CAR_DOORS: diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index f60adf07..5adc36b5 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -5,6 +5,7 @@ #include "DMAudio.h" #include "Record.h" #include "Timer.h" +#include "SpecialFX.h" uint32 CTimer::m_snTimeInMilliseconds; PauseModeTime CTimer::m_snTimeInMillisecondsPauseMode = 1; @@ -141,7 +142,7 @@ void CTimer::Update(void) } } - if ( ms_fTimeStep < 0.01f && !GetIsPaused() ) + if ( ms_fTimeStep < 0.01f && !GetIsPaused() && !CSpecialFX::bSnapShotActive) ms_fTimeStep = 0.01f; ms_fTimeStepNonClipped = ms_fTimeStep; diff --git a/src/core/main.cpp b/src/core/main.cpp index b39a9c8b..fa5a5000 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -969,7 +969,7 @@ Render2dStuff(void) else CHud::Draw(); // TODO(Miami) - // CSpecialFX::Render2DFXs(); + CSpecialFX::Render2DFXs(); CUserDisplay::OnscnTimer.ProcessForDisplay(); CMessages::Display(); CDarkel::DrawMessages(); diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index fa8379f0..69733aaa 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -28,17 +28,36 @@ RwIm3DVertex StreakVertices[4]; RwImVertexIndex StreakIndexList[12]; -RwIm3DVertex TraceVertices[6]; -RwImVertexIndex TraceIndexList[12]; +RwIm3DVertex TraceVertices[10]; +bool CSpecialFX::bVideoCam; +bool CSpecialFX::bLiftCam; bool CSpecialFX::bSnapShotActive; int32 CSpecialFX::SnapShotFrames; +static RwTexture* gpSmokeTrailTexture; + void CSpecialFX::Init(void) { CBulletTraces::Init(); + RwIm3DVertexSetU(&TraceVertices[0], 0.0); + RwIm3DVertexSetV(&TraceVertices[0], 0.0); + RwIm3DVertexSetU(&TraceVertices[1], 1.0); + RwIm3DVertexSetV(&TraceVertices[1], 0.0); + RwIm3DVertexSetU(&TraceVertices[2], 1.0); + RwIm3DVertexSetV(&TraceVertices[2], 0.0); + RwIm3DVertexSetU(&TraceVertices[3], 1.0); + RwIm3DVertexSetV(&TraceVertices[3], 0.0); + RwIm3DVertexSetU(&TraceVertices[4], 1.0); + RwIm3DVertexSetV(&TraceVertices[4], 0.0); + RwIm3DVertexSetU(&TraceVertices[5], 0.0); + RwIm3DVertexSetU(&TraceVertices[6], 1.0); + RwIm3DVertexSetU(&TraceVertices[7], 1.0); + RwIm3DVertexSetU(&TraceVertices[8], 1.0); + RwIm3DVertexSetU(&TraceVertices[9], 1.0); + RwIm3DVertexSetU(&StreakVertices[0], 0.0f); RwIm3DVertexSetV(&StreakVertices[0], 0.0f); RwIm3DVertexSetU(&StreakVertices[1], 1.0f); @@ -47,7 +66,6 @@ CSpecialFX::Init(void) RwIm3DVertexSetV(&StreakVertices[2], 0.0f); RwIm3DVertexSetU(&StreakVertices[3], 1.0f); RwIm3DVertexSetV(&StreakVertices[3], 0.0f); - StreakIndexList[0] = 0; StreakIndexList[1] = 1; StreakIndexList[2] = 2; @@ -61,43 +79,20 @@ CSpecialFX::Init(void) StreakIndexList[10] = 2; StreakIndexList[11] = 3; - RwIm3DVertexSetRGBA(&TraceVertices[0], 20, 20, 20, 255); - RwIm3DVertexSetRGBA(&TraceVertices[1], 20, 20, 20, 255); - RwIm3DVertexSetRGBA(&TraceVertices[2], 70, 70, 70, 255); - RwIm3DVertexSetRGBA(&TraceVertices[3], 70, 70, 70, 255); - RwIm3DVertexSetRGBA(&TraceVertices[4], 10, 10, 10, 255); - RwIm3DVertexSetRGBA(&TraceVertices[5], 10, 10, 10, 255); - RwIm3DVertexSetU(&TraceVertices[0], 0.0); - RwIm3DVertexSetV(&TraceVertices[0], 0.0); - RwIm3DVertexSetU(&TraceVertices[1], 1.0); - RwIm3DVertexSetV(&TraceVertices[1], 0.0); - RwIm3DVertexSetU(&TraceVertices[2], 0.0); - RwIm3DVertexSetV(&TraceVertices[2], 0.5); - RwIm3DVertexSetU(&TraceVertices[3], 1.0); - RwIm3DVertexSetV(&TraceVertices[3], 0.5); - RwIm3DVertexSetU(&TraceVertices[4], 0.0); - RwIm3DVertexSetV(&TraceVertices[4], 1.0); - RwIm3DVertexSetU(&TraceVertices[5], 1.0); - RwIm3DVertexSetV(&TraceVertices[5], 1.0); - - TraceIndexList[0] = 0; - TraceIndexList[1] = 2; - TraceIndexList[2] = 1; - TraceIndexList[3] = 1; - TraceIndexList[4] = 2; - TraceIndexList[5] = 3; - TraceIndexList[6] = 2; - TraceIndexList[7] = 4; - TraceIndexList[8] = 3; - TraceIndexList[9] = 3; - TraceIndexList[10] = 4; - TraceIndexList[11] = 5; - CMotionBlurStreaks::Init(); - CBrightLights::Init(); CShinyTexts::Init(); + CBrightLights::Init(); CMoneyMessages::Init(); C3dMarkers::Init(); + CSpecialFX::bSnapShotActive = false; + CSpecialFX::bVideoCam = false; + CSpecialFX::SnapShotFrames = 0; + CSpecialFX::bLiftCam = false; + CTxdStore::PushCurrentTxd(); + CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("particle")); + if(gpSmokeTrailTexture == nil) + gpSmokeTrailTexture = RwTextureRead("smoketrail", 0); + CTxdStore::PopCurrentTxd(); } RwObject* @@ -119,23 +114,16 @@ CSpecialFX::Update(void) { CMotionBlurStreaks::Update(); CBulletTraces::Update(); - - if(FindPlayerPed() && - FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_BASEBALLBAT && - FindPlayerPed()->GetWeapon()->m_eWeaponState == WEAPONSTATE_FIRING){ -#ifdef PED_SKIN - if(IsClumpSkinned(FindPlayerPed()->GetClump())){ - LookForBatCB((RwObject*)FindPlayerPed()->m_pWeaponModel, CModelInfo::GetModelInfo(MI_BASEBALL_BAT)); - }else -#endif - RwFrameForAllObjects(FindPlayerPed()->m_pFrames[PED_HANDR]->frame, LookForBatCB, CModelInfo::GetModelInfo(MI_BASEBALL_BAT)); - } } void CSpecialFX::Shutdown(void) { C3dMarkers::Shutdown(); + if (gpSmokeTrailTexture) { + RwTextureDestroy(gpSmokeTrailTexture); + gpSmokeTrailTexture = nil; + } } void @@ -149,6 +137,80 @@ CSpecialFX::Render(void) C3dMarkers::Render(); } +void +CSpecialFX::Render2DFXs(void) +{ + if (CSpecialFX::bVideoCam) { + CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); + CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreOff(); + CFont::SetPropOn(); + CFont::SetColor(CRGBA(0, 255, 0, 200)); + CFont::SetFontStyle(FONT_STANDARD); + sprintf(gString, "%d", CTimer::GetFrameCounter() & 0x3F); // mb % 63 + AsciiToUnicode(gString, gUString); + CFont::PrintString(SCREEN_WIDTH * 8 / 10, SCREEN_HEIGHT * 8 / 10, gUString); + for (int32 i = 0; i < SCREEN_HEIGHT; i += 4) { + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE); + CSprite2d::Draw2DPolygon(0.0f, i, SCREEN_WIDTH, i, 0.0f, i+1, SCREEN_WIDTH, i+1, CRGBA(0, 100, 0, 100)); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + CSprite2d::Draw2DPolygon(0.0f, i+2, SCREEN_WIDTH, i+2, 0.0f, i+3, SCREEN_WIDTH, i+3, CRGBA(0, 0, 0, 150)); + } + int32 tmp = (CTimer::GetTimeInMilliseconds() & 0x7ff) * (SCREEN_HEIGHT + 70.0f) / 2048 - 70.0f; //mb % 2048 + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + CSprite2d::Draw2DPolygon(0.0, tmp, SCREEN_WIDTH, tmp, 0.0, tmp + 70.0f, SCREEN_WIDTH, tmp + 70.0f , CRGBA(0, 100, 0, 60)); + } + if (CSpecialFX::bLiftCam) { + CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); + CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreOff(); + CFont::SetPropOn(); + CFont::SetColor(CRGBA(100, 100, 100, 200)); + CFont::SetFontStyle(FONT_STANDARD); + CFont::PrintString(SCREEN_WIDTH * 8 / 10, SCREEN_HEIGHT * 8 / 10, gUString); + for (int32 i = 0; i < SCREEN_HEIGHT; i += 4) { + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + CSprite2d::Draw2DPolygon(0.0f, i, SCREEN_WIDTH, i, 0.0f, i + 1, SCREEN_WIDTH, i + 1, CRGBA(100, 100, 100, 100)); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + CSprite2d::Draw2DPolygon(0.0f, i + 2, SCREEN_WIDTH, i + 2, 0.0f, i + 3, SCREEN_WIDTH, i + 3, CRGBA(0, 0, 0, 150)); + } + int32 tmp = (CTimer::GetTimeInMilliseconds() & 0x7ff) * (SCREEN_HEIGHT + 70.0f) / 2048 - 70.0f; //mb % 2048 + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + CSprite2d::Draw2DPolygon(0.0, tmp, SCREEN_WIDTH, tmp, 0.0, tmp + 70.0f, SCREEN_WIDTH, tmp + 70.0f, CRGBA(100, 100, 100, 60)); + for (int32 i = 0; i < 200; i++) { + int32 posX = CGeneral::GetRandomNumber() % (int32)SCREEN_WIDTH; + int32 posY = CGeneral::GetRandomNumber() % (int32)SCREEN_HEIGHT; + CSprite2d::DrawRect(CRect(posX, posY + 2, posX+20, posY), CRGBA(255, 255, 255, 64)); + } + } + if (CSpecialFX::bSnapShotActive) { + if (++CSpecialFX::SnapShotFrames > 20) { + CSpecialFX::bSnapShotActive = false; + CTimer::SetTimeScale(1.0f); + } else { + CTimer::SetTimeScale(0.0f); //in andro it's 0.00001 + if (CSpecialFX::SnapShotFrames < 10) { + int32 tmp = (1 - CSpecialFX::SnapShotFrames / 10) * 255 * 0.65f; + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + CSprite2d::Draw2DPolygon(0.0f, 0.0f, SCREEN_WIDTH, 0.0f, 0.0f, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, CRGBA(tmp, tmp, tmp, tmp)); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + } + } + } +} + CRegisteredMotionBlurStreak CMotionBlurStreaks::aStreaks[NUMMBLURSTREAKS]; void @@ -299,43 +361,43 @@ void CBulletTraces::AddTrace(CVector* vecStart, CVector* vecTarget) void CBulletTraces::Render(void) { - for (int i = 0; i < NUMBULLETTRACES; i++) { - if (!aTraces[i].m_bInUse) - continue; - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); -#ifdef FIX_BUGS - // Raster has no transparent pixels so it relies on the raster format having alpha - // to turn on blending. librw image conversion might get rid of it right now so let's - // just force it on. - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); -#endif - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpShadowExplosionTex)); - CVector inf = aTraces[i].m_vecCurrentPos; - CVector sup = aTraces[i].m_vecTargetPos; - CVector center = (inf + sup) / 2; - CVector width = CrossProduct(TheCamera.GetForward(), (sup - inf)); - width.Normalise(); - width /= 20; - uint8 intensity = aTraces[i].m_lifeTime; - for (int i = 0; i < ARRAY_SIZE(TraceVertices); i++) - RwIm3DVertexSetRGBA(&TraceVertices[i], intensity, intensity, intensity, 0xFF); - RwIm3DVertexSetPos(&TraceVertices[0], inf.x + width.x, inf.y + width.y, inf.z + width.z); - RwIm3DVertexSetPos(&TraceVertices[1], inf.x - width.x, inf.y - width.y, inf.z - width.z); - RwIm3DVertexSetPos(&TraceVertices[2], center.x + width.x, center.y + width.y, center.z + width.z); - RwIm3DVertexSetPos(&TraceVertices[3], center.x - width.x, center.y - width.y, center.z - width.z); - RwIm3DVertexSetPos(&TraceVertices[4], sup.x + width.x, sup.y + width.y, sup.z + width.z); - RwIm3DVertexSetPos(&TraceVertices[5], sup.x - width.x, sup.y - width.y, sup.z - width.z); - LittleTest(); - if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { - RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); - RwIm3DEnd(); - } - } - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); +// for (int i = 0; i < NUMBULLETTRACES; i++) { +// if (!aTraces[i].m_bInUse) +// continue; +// RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); +//#ifdef FIX_BUGS +// // Raster has no transparent pixels so it relies on the raster format having alpha +// // to turn on blending. librw image conversion might get rid of it right now so let's +// // just force it on. +// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +//#endif +// RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); +// RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); +// RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpShadowExplosionTex)); +// CVector inf = aTraces[i].m_vecCurrentPos; +// CVector sup = aTraces[i].m_vecTargetPos; +// CVector center = (inf + sup) / 2; +// CVector width = CrossProduct(TheCamera.GetForward(), (sup - inf)); +// width.Normalise(); +// width /= 20; +// uint8 intensity = aTraces[i].m_lifeTime; +// for (int i = 0; i < ARRAY_SIZE(TraceVertices); i++) +// RwIm3DVertexSetRGBA(&TraceVertices[i], intensity, intensity, intensity, 0xFF); +// RwIm3DVertexSetPos(&TraceVertices[0], inf.x + width.x, inf.y + width.y, inf.z + width.z); +// RwIm3DVertexSetPos(&TraceVertices[1], inf.x - width.x, inf.y - width.y, inf.z - width.z); +// RwIm3DVertexSetPos(&TraceVertices[2], center.x + width.x, center.y + width.y, center.z + width.z); +// RwIm3DVertexSetPos(&TraceVertices[3], center.x - width.x, center.y - width.y, center.z - width.z); +// RwIm3DVertexSetPos(&TraceVertices[4], sup.x + width.x, sup.y + width.y, sup.z + width.z); +// RwIm3DVertexSetPos(&TraceVertices[5], sup.x - width.x, sup.y - width.y, sup.z - width.z); +// LittleTest(); +// if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { +// RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); +// RwIm3DEnd(); +// } +// } +// RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); +// RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); } void CBulletTraces::Update(void) @@ -348,23 +410,8 @@ void CBulletTraces::Update(void) void CBulletTrace::Update(void) { - if (m_framesInUse == 0) { - m_framesInUse++; - return; - } - if (m_framesInUse > 60) { + if (CTimer::GetTimeInMilliseconds() - m_nCreationTime >= m_nLifeTime) m_bInUse = false; - return; - } - CVector diff = m_vecCurrentPos - m_vecTargetPos; - float remaining = diff.Magnitude(); - if (remaining > 0.8f) - m_vecCurrentPos = m_vecTargetPos + (remaining - 0.8f) / remaining * diff; - else - m_bInUse = false; - if (--m_lifeTime == 0) - m_bInUse = false; - m_framesInUse++; } RpAtomic * @@ -1056,8 +1103,9 @@ CMoneyMessage::Render() { const float MAX_SCALE = 4.0f; uint32 nLifeTime = CTimer::GetTimeInMilliseconds() - m_nTimeRegistered; - if (nLifeTime >= MONEY_MESSAGE_LIFETIME_MS) m_nTimeRegistered = 0; - else { + if (nLifeTime >= MONEY_MESSAGE_LIFETIME_MS) { + m_nTimeRegistered = 0; + } else { float fLifeTime = (float)nLifeTime / MONEY_MESSAGE_LIFETIME_MS; RwV3d vecOut; float fDistX, fDistY; @@ -1066,13 +1114,8 @@ CMoneyMessage::Render() fDistY *= (0.7 * fLifeTime + 2.0) * m_fSize; CFont::SetPropOn(); CFont::SetBackgroundOff(); - - float fScaleY = fDistY / 100.0f; - if (fScaleY > MAX_SCALE) fScaleY = MAX_SCALE; - - float fScaleX = fDistX / 100.0f; - if (fScaleX > MAX_SCALE) fScaleX = MAX_SCALE; - + float fScaleY = Min(fDistY / 100.0f, MAX_SCALE); + float fScaleX = Min(fDistX / 100.0f, MAX_SCALE); CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here? CFont::SetCentreOn(); CFont::SetCentreSize(SCREEN_WIDTH); diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 8bd0d5e1..3e989d1d 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -3,13 +3,17 @@ class CSpecialFX { public: + static bool bVideoCam; + static bool bLiftCam; static bool bSnapShotActive; static int32 SnapShotFrames; - static void Render(void); - static void Update(void); - static void Init(void); - static void Shutdown(void); + static void Render(void); //done + static void Update(void); //done + static void Init(void); //done + static void Shutdown(void); //done + static void AddWeaponStreak(int type); + static void Render2DFXs(); //done }; class CRegisteredMotionBlurStreak @@ -23,7 +27,7 @@ public: CVector m_pos2[3]; bool m_isValid[3]; - void Update(void); + void Update(void); //done void Render(void); }; @@ -32,7 +36,7 @@ class CMotionBlurStreaks static CRegisteredMotionBlurStreak aStreaks[NUMMBLURSTREAKS]; public: static void Init(void); - static void Update(void); + static void Update(void); //done static void RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2); static void Render(void); }; @@ -42,10 +46,15 @@ struct CBulletTrace CVector m_vecCurrentPos; CVector m_vecTargetPos; bool m_bInUse; + uint32 m_nCreationTime; + uint32 m_nLifeTime; + uint32 field_24; + uint8 field_28; + uint8 m_framesInUse; uint8 m_lifeTime; - void Update(void); + void Update(void); //done }; class CBulletTraces @@ -56,7 +65,7 @@ public: static void Init(void); static void AddTrace(CVector*, CVector*); static void Render(void); - static void Update(void); + static void Update(void); //done //TODO(MIAMI) static void AddTrace(CVector *, CVector *, float, unsigned int, unsigned char) {} @@ -213,7 +222,7 @@ class CMoneyMessage float m_fSize; float m_fOpacity; public: - void Render(); + void Render(); //done }; class CMoneyMessages @@ -221,7 +230,7 @@ class CMoneyMessages static CMoneyMessage aMoneyMessages[NUMMONEYMESSAGES]; public: static void Init(); - static void Render(); + static void Render(); //done static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); }; -- cgit v1.2.3 From 7a3e1ef19a67a16d75d22144a012b1780b400f78 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 11 Oct 2020 21:40:11 +0300 Subject: SpecialFX almost done --- src/control/Replay.cpp | 8 +- src/render/SpecialFX.cpp | 303 +++++++++++++++++++++++++++++++++++++++-------- src/render/SpecialFX.h | 81 ++++++------- 3 files changed, 296 insertions(+), 96 deletions(-) (limited to 'src') diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 45f1a143..796e4cab 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -393,8 +393,8 @@ void CReplay::RecordThisFrame(void) tBulletTracePacket* bt = (tBulletTracePacket*)&Record.m_pBase[Record.m_nOffset]; bt->type = REPLAYPACKET_BULLET_TRACES; bt->index = i; - bt->frames = CBulletTraces::aTraces[i].m_framesInUse; - bt->lifetime = CBulletTraces::aTraces[i].m_lifeTime; +// bt->frames = CBulletTraces::aTraces[i].m_framesInUse; +// bt->lifetime = CBulletTraces::aTraces[i].m_lifeTime; bt->inf = CBulletTraces::aTraces[i].m_vecCurrentPos; bt->sup = CBulletTraces::aTraces[i].m_vecTargetPos; Record.m_nOffset += sizeof(*bt); @@ -1140,8 +1140,8 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo { tBulletTracePacket* pb = (tBulletTracePacket*)&ptr[offset]; CBulletTraces::aTraces[pb->index].m_bInUse = true; - CBulletTraces::aTraces[pb->index].m_framesInUse = pb->frames; - CBulletTraces::aTraces[pb->index].m_lifeTime = pb->lifetime; +// CBulletTraces::aTraces[pb->index].m_framesInUse = pb->frames; +// CBulletTraces::aTraces[pb->index].m_lifeTime = pb->lifetime; CBulletTraces::aTraces[pb->index].m_vecCurrentPos = pb->inf; CBulletTraces::aTraces[pb->index].m_vecTargetPos = pb->sup; buffer->m_nOffset += sizeof(tBulletTracePacket); diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 69733aaa..b0506929 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -24,11 +24,15 @@ #include "ColStore.h" #include "Coronas.h" #include "Script.h" +#include "DMAudio.h" RwIm3DVertex StreakVertices[4]; RwImVertexIndex StreakIndexList[12]; RwIm3DVertex TraceVertices[10]; +static RwImVertexIndex TraceIndexList[48] = {0, 5, 7, 0, 7, 2, 0, 7, 5, 0, 2, 7, 0, 4, 9, 0, + 9, 5, 0, 9, 4, 0, 5, 9, 0, 1, 6, 0, 6, 5, 0, 6, + 1, 0, 5, 6, 0, 3, 8, 0, 8, 5, 0, 8, 3, 0, 5, 8 }; bool CSpecialFX::bVideoCam; bool CSpecialFX::bLiftCam; @@ -95,6 +99,37 @@ CSpecialFX::Init(void) CTxdStore::PopCurrentTxd(); } +void +CSpecialFX::AddWeaponStreak(int type) +{ + static CMatrix matrix; + CVector start; + CVector end; + + if (FindPlayerPed() != nil && FindPlayerPed()->m_pWeaponModel != nil) { + switch (type) { + case WEAPONTYPE_BASEBALLBAT: + matrix = RwFrameGetLTM(RpAtomicGetFrame(FindPlayerPed()->m_pWeaponModel)); + start = matrix * CVector(0.02f, 0.05f, 0.07f); + end = matrix * CVector(0.246f, 0.0325f, 0.796f); + break; + case WEAPONTYPE_GOLFCLUB: + matrix = RwFrameGetLTM(RpAtomicGetFrame(FindPlayerPed()->m_pWeaponModel)); + start = matrix * CVector(0.02f, 0.05f, 0.07f); + end = matrix * CVector(-0.054f, 0.0325f, 0.796f); + break; + case WEAPONTYPE_KATANA: + matrix = RwFrameGetLTM(RpAtomicGetFrame(FindPlayerPed()->m_pWeaponModel)); + start = matrix * CVector(0.02f, 0.05f, 0.07f); + end = matrix * CVector(0.096f, -0.0175f, 1.096f); + break; + default: + break; + } + CMotionBlurStreaks::RegisterStreak((uintptr)FindPlayerPed()->m_pWeaponModel, 100, 100, 100, start, end); + } +} + RwObject* LookForBatCB(RwObject *object, void *data) { @@ -279,6 +314,7 @@ void CMotionBlurStreaks::RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2) { int i; + for(i = 0; i < NUMMBLURSTREAKS; i++){ if(aStreaks[i].m_id == id){ // Found a streak from last frame, update @@ -291,10 +327,12 @@ CMotionBlurStreaks::RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVecto return; } } + // Find free slot - for(i = 0; aStreaks[i].m_id; i++) + for(i = 0; aStreaks[i].m_id != nil ; i++) if(i == NUMMBLURSTREAKS-1) return; + // Create a new streak aStreaks[i].m_id = id; aStreaks[i].m_red = r; @@ -313,7 +351,7 @@ CMotionBlurStreaks::Render(void) bool setRenderStates = false; int i; for(i = 0; i < NUMMBLURSTREAKS; i++) - if(aStreaks[i].m_id){ + if(aStreaks[i].m_id != nil){ if(!setRenderStates){ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); @@ -343,61 +381,222 @@ void CBulletTraces::Init(void) aTraces[i].m_bInUse = false; } -void CBulletTraces::AddTrace(CVector* vecStart, CVector* vecTarget) +void CBulletTraces::AddTrace(CVector* start, CVector* end, float thicknes, uint32 lifeTime, uint8 visibility) { - int index; - for (index = 0; index < NUMBULLETTRACES; index++) { - if (!aTraces[index].m_bInUse) - break; + int32 enabledCount; + uint32 modifiedLifeTime; + int32 nextSlot; + + enabledCount = 0; + for (int i = 0; i < NUMBULLETTRACES; i++) + if (aTraces[i].m_bInUse) + enabledCount++; + if (enabledCount >= 10) + modifiedLifeTime = lifeTime / 4; + else if (enabledCount >= 5) + modifiedLifeTime = lifeTime / 2; + else + modifiedLifeTime = lifeTime; + + nextSlot = 0; + for (int i = 0; nextSlot < NUMBULLETTRACES && aTraces[i].m_bInUse; i++) + nextSlot++; + if (nextSlot < 16) { + aTraces[nextSlot].m_vecCurrentPos = *start; + aTraces[nextSlot].m_vecTargetPos = *end; + aTraces[nextSlot].m_bInUse = true; + aTraces[nextSlot].m_nCreationTime = CTimer::GetTimeInMilliseconds(); + aTraces[nextSlot].m_fVisibility = visibility; + aTraces[nextSlot].m_fThicknes = thicknes; + aTraces[nextSlot].m_nLifeTime = modifiedLifeTime; + } + + float upDotProd = DotProduct(TheCamera.GetUp(), *start - TheCamera.GetPosition()); + float forwardDotProd = DotProduct(TheCamera.GetForward(), *start - TheCamera.GetPosition()); + float upDotProdEnd = DotProduct(TheCamera.GetUp(), *end - TheCamera.GetPosition()); + float forwardDotProdEnd = DotProduct(TheCamera.GetForward(), *end - TheCamera.GetPosition()); + if (forwardDotProd*forwardDotProdEnd < 0.0f) { + float tmp = Abs(forwardDotProd) / (Abs(forwardDotProd) + Abs(forwardDotProdEnd)); + float tmp2 = (upDotProdEnd - upDotProd) * tmp + upDotProd; + float dotProdEndRight = DotProduct(TheCamera.GetRight(), *end - TheCamera.GetPosition()); + float dotProdRight = DotProduct(TheCamera.GetRight(), *start - TheCamera.GetPosition()); + float tmp3 = (dotProdEndRight - dotProdRight) * tmp + dotProdRight; + float dist = Sqrt(SQR(tmp2) + SQR(tmp3)); + if (dist < 2.0f) { + if(tmp3 < 0.0f) + DMAudio.PlayFrontEndSound(SOUND_BULLETTRACE_2, 127 * (1.0f - dist * 0.5f)); + else + DMAudio.PlayFrontEndSound(SOUND_BULLETTRACE_1, 127 * (1.0f - dist * 0.5f)); + } + } +} + +void CBulletTraces::AddTrace(CVector* start, CVector* end, int32 weaponType, class CEntity* shooter) +{ + CPhysical* player; + float speed; + int16 camMode; + + if (shooter == (CEntity*)FindPlayerPed() || (FindPlayerVehicle() != nil && FindPlayerVehicle() == (CVehicle*)shooter)) { + camMode = TheCamera.Cams[TheCamera.ActiveCam].Mode; + if (camMode == CCam::MODE_M16_1STPERSON + || camMode == CCam::MODE_CAMERA + || camMode == CCam::MODE_SNIPER + || camMode == CCam::MODE_M16_1STPERSON_RUNABOUT +#ifdef MOBILE_IMPROVEMENTS + || camMode == CCam::MODE_ROCKETLAUNCHER + || camMode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT +#endif + || camMode == CCam::MODE_SNIPER_RUNABOUT + || camMode == CCam::MODE_HELICANNON_1STPERSON) { + + player = FindPlayerVehicle() ? (CPhysical*)FindPlayerVehicle() : (CPhysical*)FindPlayerPed(); + speed = player->m_vecMoveSpeed.Magnitude(); + if (speed < 0.05f) + return; + } + } + + switch (weaponType) { + case WEAPONTYPE_PYTHON: + case WEAPONTYPE_SHOTGUN: + case WEAPONTYPE_SPAS12_SHOTGUN: + case WEAPONTYPE_STUBBY_SHOTGUN: + CBulletTraces::AddTrace(start, end, 0.7f, 1000, 200); + break; + case WEAPONTYPE_M4: + case WEAPONTYPE_RUGER: + case WEAPONTYPE_SNIPERRIFLE: + case WEAPONTYPE_LASERSCOPE: + case WEAPONTYPE_M60: + case WEAPONTYPE_MINIGUN: + case WEAPONTYPE_HELICANNON: + CBulletTraces::AddTrace(start, end, 1.0f, 2000, 220); + break; + default: + CBulletTraces::AddTrace(start, end, 0.4f, 750, 150); + break; } - if (index == NUMBULLETTRACES) - return; - aTraces[index].m_vecCurrentPos = *vecStart; - aTraces[index].m_vecTargetPos = *vecTarget; - aTraces[index].m_bInUse = true; - aTraces[index].m_framesInUse = 0; - aTraces[index].m_lifeTime = 25 + CGeneral::GetRandomNumber() % 32; } void CBulletTraces::Render(void) { -// for (int i = 0; i < NUMBULLETTRACES; i++) { -// if (!aTraces[i].m_bInUse) -// continue; -// RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); -//#ifdef FIX_BUGS -// // Raster has no transparent pixels so it relies on the raster format having alpha -// // to turn on blending. librw image conversion might get rid of it right now so let's -// // just force it on. -// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); -//#endif -// RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); -// RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); -// RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpShadowExplosionTex)); -// CVector inf = aTraces[i].m_vecCurrentPos; -// CVector sup = aTraces[i].m_vecTargetPos; -// CVector center = (inf + sup) / 2; -// CVector width = CrossProduct(TheCamera.GetForward(), (sup - inf)); -// width.Normalise(); -// width /= 20; -// uint8 intensity = aTraces[i].m_lifeTime; -// for (int i = 0; i < ARRAY_SIZE(TraceVertices); i++) -// RwIm3DVertexSetRGBA(&TraceVertices[i], intensity, intensity, intensity, 0xFF); -// RwIm3DVertexSetPos(&TraceVertices[0], inf.x + width.x, inf.y + width.y, inf.z + width.z); -// RwIm3DVertexSetPos(&TraceVertices[1], inf.x - width.x, inf.y - width.y, inf.z - width.z); -// RwIm3DVertexSetPos(&TraceVertices[2], center.x + width.x, center.y + width.y, center.z + width.z); -// RwIm3DVertexSetPos(&TraceVertices[3], center.x - width.x, center.y - width.y, center.z - width.z); -// RwIm3DVertexSetPos(&TraceVertices[4], sup.x + width.x, sup.y + width.y, sup.z + width.z); -// RwIm3DVertexSetPos(&TraceVertices[5], sup.x - width.x, sup.y - width.y, sup.z - width.z); -// LittleTest(); -// if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { -// RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); -// RwIm3DEnd(); -// } -// } -// RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); -// RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); -// RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + for (int i = 0; i < NUMBULLETTRACES; i++) { + if (!aTraces[i].m_bInUse) + continue; + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpSmokeTrailTexture)); + + float nTimeOfLiving = CTimer::GetTimeInMilliseconds() - aTraces[i].m_nCreationTime; + + float traceThicknes = aTraces[i].m_fThicknes * nTimeOfLiving / aTraces[i].m_nLifeTime; + CVector vecOffset = aTraces[i].m_vecTargetPos - aTraces[i].m_vecCurrentPos; + vecOffset.Normalise(); + vecOffset *= traceThicknes; + uint8 nAlphaValue = aTraces[i].m_fVisibility * (aTraces[i].m_nLifeTime - nTimeOfLiving) / aTraces[i].m_nLifeTime; + + CVector currentPos = aTraces[i].m_vecCurrentPos; + CVector targetPos = aTraces[i].m_vecTargetPos; + float dotProdCur = DotProduct(currentPos - TheCamera.GetPosition(), TheCamera.GetForward()) - 0.7f; + float dotProdTar = DotProduct(targetPos - TheCamera.GetPosition(), TheCamera.GetForward()) - 0.7f; + if (dotProdCur >= 0.0f || dotProdTar >= 0.0f) { + if (dotProdCur < 0.0f) { + float absDotProdCur = Abs(dotProdCur); + float absDotProdTar = Abs(dotProdTar); + currentPos = (absDotProdTar * currentPos + absDotProdCur * targetPos) / (absDotProdCur + absDotProdTar); + } else if (dotProdTar < 0.0f){ + float absDotProdCur = Abs(dotProdCur); + float absDotProdTar = Abs(dotProdTar); + targetPos = (absDotProdTar * currentPos + absDotProdCur * targetPos) / (absDotProdCur + absDotProdTar); + } + RwIm3DVertexSetV(&TraceVertices[5], 10.0f); + RwIm3DVertexSetV(&TraceVertices[6], 10.0f); + RwIm3DVertexSetV(&TraceVertices[7], 10.0f); + RwIm3DVertexSetV(&TraceVertices[8], 10.0f); + RwIm3DVertexSetV(&TraceVertices[9], 10.0f); + + RwIm3DVertexSetRGBA(&TraceVertices[0], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[1], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[2], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[3], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[5], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[6], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[7], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[8], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[9], 255, 255, 255, nAlphaValue); + + CVector currentPos2 = (7.0f * currentPos + targetPos) / 8; + CVector targetPos2 = (7.0f * targetPos + currentPos) / 8; + RwIm3DVertexSetPos(&TraceVertices[0], currentPos2.x, currentPos2.y, currentPos2.z); + RwIm3DVertexSetPos(&TraceVertices[1], currentPos2.x, currentPos2.y, currentPos2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[2], currentPos2.x + vecOffset.y, currentPos2.y - vecOffset.x, currentPos2.z); + RwIm3DVertexSetPos(&TraceVertices[3], currentPos2.x, currentPos2.y, currentPos2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[4], currentPos2.x - vecOffset.y, currentPos2.y - vecOffset.y, currentPos2.z); + + RwIm3DVertexSetPos(&TraceVertices[5], targetPos2.x, targetPos2.y, targetPos2.z); + RwIm3DVertexSetPos(&TraceVertices[6], targetPos2.x, targetPos2.y, targetPos2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[7], targetPos2.x + vecOffset.y, targetPos2.y - vecOffset.x, targetPos2.z); + RwIm3DVertexSetPos(&TraceVertices[8], targetPos2.x, targetPos2.y, targetPos2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[9], targetPos2.x - vecOffset.y, targetPos2.y - vecOffset.y, targetPos2.z); + + if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); + RwIm3DEnd(); + } + + + RwIm3DVertexSetV(&TraceVertices[5], 2.0f); + RwIm3DVertexSetV(&TraceVertices[6], 2.0f); + RwIm3DVertexSetV(&TraceVertices[7], 2.0f); + RwIm3DVertexSetV(&TraceVertices[8], 2.0f); + RwIm3DVertexSetV(&TraceVertices[9], 2.0f); + RwIm3DVertexSetRGBA(&TraceVertices[0], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[1], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[2], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[3], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, 0); + + RwIm3DVertexSetPos(&TraceVertices[0], currentPos.x, currentPos.y, currentPos.z); + RwIm3DVertexSetPos(&TraceVertices[1], currentPos.x, currentPos.y, currentPos.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[2], currentPos.x + vecOffset.y, currentPos.y - vecOffset.x, currentPos.z); + RwIm3DVertexSetPos(&TraceVertices[3], currentPos.x, currentPos.y, currentPos.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[4], currentPos.x - vecOffset.y, currentPos.y - vecOffset.y, currentPos.z); + + RwIm3DVertexSetPos(&TraceVertices[5], currentPos2.x, currentPos2.y, currentPos2.z); + RwIm3DVertexSetPos(&TraceVertices[6], currentPos2.x, currentPos2.y, currentPos2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[7], currentPos2.x + vecOffset.y, currentPos2.y - vecOffset.x, currentPos2.z); + RwIm3DVertexSetPos(&TraceVertices[8], currentPos2.x, currentPos2.y, currentPos2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[9], currentPos2.x - vecOffset.y, currentPos2.y - vecOffset.y, currentPos2.z); + + if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); + RwIm3DEnd(); + } + + RwIm3DVertexSetPos(&TraceVertices[1], targetPos.x, targetPos.y, targetPos.z); + RwIm3DVertexSetPos(&TraceVertices[2], targetPos.x, targetPos.y, targetPos.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[3], targetPos.x + vecOffset.y, targetPos.y - vecOffset.x, targetPos.z); + RwIm3DVertexSetPos(&TraceVertices[4], targetPos.x, targetPos.y, targetPos.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[5], targetPos.x - vecOffset.y, targetPos.y - vecOffset.y, targetPos.z); + + RwIm3DVertexSetPos(&TraceVertices[5], targetPos2.x, targetPos2.y, targetPos2.z); + RwIm3DVertexSetPos(&TraceVertices[6], targetPos2.x, targetPos2.y, targetPos2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[7], targetPos2.x + vecOffset.y, targetPos2.y - vecOffset.x, targetPos2.z); + RwIm3DVertexSetPos(&TraceVertices[8], targetPos2.x, targetPos2.y, targetPos2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[9], targetPos2.x - vecOffset.y, targetPos2.y - vecOffset.y, targetPos2.z); + + if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); + RwIm3DEnd(); + } + } + } + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); } void CBulletTraces::Update(void) @@ -563,7 +762,7 @@ C3dMarkers::Render() CCoronas::RegisterCorona((uintptr)&m_aMarkerArray[i], SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, 192, m_aMarkerArray[i].m_Matrix.GetPosition(), 1.2f * m_aMarkerArray[i].m_fSize, 50.0f * TheCamera.LODDistMultiplier, - CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f, false); + CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f, false, 1.5f); } } NumActiveMarkers++; diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 3e989d1d..0284126c 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -1,5 +1,6 @@ #pragma once +//done class CSpecialFX { public: @@ -12,10 +13,11 @@ public: static void Update(void); //done static void Init(void); //done static void Shutdown(void); //done - static void AddWeaponStreak(int type); + static void AddWeaponStreak(int type); //done static void Render2DFXs(); //done }; +//done class CRegisteredMotionBlurStreak { public: @@ -28,19 +30,21 @@ public: bool m_isValid[3]; void Update(void); //done - void Render(void); + void Render(void); //done }; +//done class CMotionBlurStreaks { static CRegisteredMotionBlurStreak aStreaks[NUMMBLURSTREAKS]; public: - static void Init(void); + static void Init(void); //done static void Update(void); //done - static void RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2); - static void Render(void); + static void RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2); //done + static void Render(void); //done }; +//done struct CBulletTrace { CVector m_vecCurrentPos; @@ -48,31 +52,23 @@ struct CBulletTrace bool m_bInUse; uint32 m_nCreationTime; uint32 m_nLifeTime; - uint32 field_24; - uint8 field_28; - - uint8 m_framesInUse; - uint8 m_lifeTime; + float m_fThicknes; + uint8 m_fVisibility; void Update(void); //done }; +//done class CBulletTraces { public: static CBulletTrace aTraces[NUMBULLETTRACES]; - static void Init(void); - static void AddTrace(CVector*, CVector*); - static void Render(void); + static void Init(void); //done + static void Render(void); //done static void Update(void); //done - -//TODO(MIAMI) - static void AddTrace(CVector *, CVector *, float, unsigned int, unsigned char) {} - static void AddTrace(CVector *a, CVector *b, int32 weapontype, class CEntity *shooter) - { - AddTrace(a, b); //TODO: temp - } + static void AddTrace(CVector* start, CVector* end, float thickness, uint32 lifeTime, uint8 visibility); //done + static void AddTrace(CVector* start, CVector* end, int32 weaponType, class CEntity* shooter); //done }; enum @@ -87,7 +83,7 @@ enum MARKERTYPE_INVALID = 0x101 }; - +//done class C3dMarker { public: @@ -108,20 +104,20 @@ public: float m_fBrightness; float m_fCameraRange; - bool AddMarker(uint32 identifier, uint16 type, float fSize, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); - void DeleteMarkerObject(); - void Render(); + bool AddMarker(uint32 identifier, uint16 type, float fSize, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done + void DeleteMarkerObject(); //done + void Render(); //done }; class C3dMarkers { public: - static void Init(); - static void Shutdown(); + static void Init(); //done + static void Shutdown(); //done static C3dMarker *PlaceMarker(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); - static void PlaceMarkerSet(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); - static void Render(); - static void Update(); + static void PlaceMarkerSet(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done + static void Render(); //done + static void Update(); //done static C3dMarker m_aMarkerArray[NUM3DMARKERS]; static int32 NumActiveMarkers; @@ -153,6 +149,7 @@ enum BRIGHTLIGHT_REAR = BRIGHTLIGHT_REAR_LONG, }; +//done class CBrightLight { public: @@ -172,11 +169,11 @@ class CBrightLights static int NumBrightLights; static CBrightLight aBrightLights[NUMBRIGHTLIGHTS]; public: - static void Init(void); + static void Init(void); //done static void RegisterOne(CVector pos, CVector up, CVector side, CVector front, - uint8 type, uint8 red = 0, uint8 green = 0, uint8 blue = 0); - static void Render(void); - static void RenderOutGeometryBuffer(void); + uint8 type, uint8 red = 0, uint8 green = 0, uint8 blue = 0); //done + static void Render(void); //looks similad but needs recheck + static void RenderOutGeometryBuffer(void); //done }; @@ -186,6 +183,7 @@ enum SHINYTEXT_FLAT }; +//done class CShinyText { public: @@ -198,19 +196,21 @@ public: uint8 m_blue; }; -class CShinyTexts +//done +class CShinyTexts { static int NumShinyTexts; static CShinyText aShinyTexts[NUMSHINYTEXTS]; public: - static void Init(void); + static void Init(void); //done static void RegisterOne(CVector p0, CVector p1, CVector p2, CVector p3, float u0, float v0, float u1, float v1, float u2, float v2, float u3, float v3, - uint8 type, uint8 red, uint8 green, uint8 blue, float maxDist); - static void Render(void); - static void RenderOutGeometryBuffer(void); + uint8 type, uint8 red, uint8 green, uint8 blue, float maxDist); //done, not used + static void Render(void); //done + static void RenderOutGeometryBuffer(void); //done }; +//done class CMoneyMessage { friend class CMoneyMessages; @@ -225,13 +225,14 @@ public: void Render(); //done }; +//done class CMoneyMessages { static CMoneyMessage aMoneyMessages[NUMMONEYMESSAGES]; public: - static void Init(); + static void Init(); //done static void Render(); //done - static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); + static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); //done }; class CSpecialParticleStuff -- cgit v1.2.3 From ca1d899413d95c8c7ccf936d4e0ab8f02ec223f5 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 11 Oct 2020 22:29:49 +0300 Subject: final step --- src/render/SpecialFX.cpp | 20 +++++--------------- src/render/SpecialFX.h | 12 +++++++----- 2 files changed, 12 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index b0506929..dcf795f5 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -824,7 +824,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size } else { pMarker->m_fStdSize = size; } - } else if (type == MARKERTYPE_CYLINDER) { + } else { if (dist < size + 12.0f) { if (dist > size + 1.0f) pMarker->m_Color.alpha = (1.0f - (size + 12.0f - dist) * 0.7f / 11.0f) * (float)a; @@ -837,15 +837,9 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size float someSin = Sin(TWOPI * (float)((pMarker->m_nPulsePeriod - 1) & (CTimer::GetTimeInMilliseconds() - pMarker->m_nStartTime)) / (float)pMarker->m_nPulsePeriod); pMarker->m_fSize = pMarker->m_fStdSize - pulseFraction * pMarker->m_fStdSize * someSin; - if (type == MARKERTYPE_ARROW) { + if (type == MARKERTYPE_ARROW) pos.z += 0.25f * pMarker->m_fStdSize * someSin; - } else if (type == MARKERTYPE_0) { - if (someSin > 0.0f) - pMarker->m_Color.alpha = (float)a * 0.7f * someSin + a; - else - pMarker->m_Color.alpha = (float)a * 0.4f * someSin + a; - } - if (pMarker->m_nRotateRate) { + if (pMarker->m_nRotateRate != 0) { RwV3d pos = pMarker->m_Matrix.m_matrix.pos; pMarker->m_Matrix.RotateZ(DEGTORAD(pMarker->m_nRotateRate * CTimer::GetTimeStep())); pMarker->m_Matrix.GetPosition() = pos; @@ -869,7 +863,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size pMarker->DeleteMarkerObject(); pMarker->AddMarker(identifier, type, size, r, g, b, a, pulsePeriod, pulseFraction, rotateRate); - if (type == MARKERTYPE_CYLINDER || type == MARKERTYPE_0 || type == MARKERTYPE_2) { + if (type == MARKERTYPE_CYLINDER) { if ((playerPos - pos).MagnitudeSqr() < sq(100.f) && CColStore::HasCollisionLoaded(CVector2D(pos))) { float z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z + 1.0f, nil); if (z != 0.0f) @@ -880,10 +874,6 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size } } pMarker->m_Matrix.SetTranslate(pos.x, pos.y, pos.z); - if (type == MARKERTYPE_2) { - pMarker->m_Matrix.RotateX(PI); - pMarker->m_Matrix.GetPosition() = pos; - } pMarker->m_Matrix.UpdateRW(); if (type == MARKERTYPE_ARROW) { if (dist < 25.0f) { @@ -894,7 +884,7 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size } else { pMarker->m_fStdSize = size; } - } else if (type == MARKERTYPE_CYLINDER) { + } else { if (dist < size + 12.0f) { if (dist > size + 1.0f) pMarker->m_Color.alpha = (1.0f - (size + 12.0f - dist) * 0.7f / 11.0f) * (float)a; diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 0284126c..897d8b92 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -109,12 +109,13 @@ public: void Render(); //done }; +//done class C3dMarkers { public: static void Init(); //done static void Shutdown(); //done - static C3dMarker *PlaceMarker(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); + static C3dMarker *PlaceMarker(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done static void PlaceMarkerSet(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done static void Render(); //done static void Update(); //done @@ -172,7 +173,7 @@ public: static void Init(void); //done static void RegisterOne(CVector pos, CVector up, CVector side, CVector front, uint8 type, uint8 red = 0, uint8 green = 0, uint8 blue = 0); //done - static void Render(void); //looks similad but needs recheck + static void Render(void); //looks similad but needs recheck !!!!!!!!!!!!!!!!! static void RenderOutGeometryBuffer(void); //done }; @@ -235,11 +236,12 @@ public: static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); //done }; +//done class CSpecialParticleStuff { static uint32 BoatFromStart; public: - static void CreateFoamAroundObject(CMatrix*, float, float, float, int32); - static void StartBoatFoamAnimation(); - static void UpdateBoatFoamAnimation(CMatrix*); + static void CreateFoamAroundObject(CMatrix*, float, float, float, int32); //done, not used + static void StartBoatFoamAnimation(); //done, not used + static void UpdateBoatFoamAnimation(CMatrix*); //done, not used }; -- cgit v1.2.3 From e6a1ea9d4ff72f31e1726a344b3810b4c3e8d747 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 12 Oct 2020 13:28:06 +0300 Subject: CBrightLight::render --- src/render/SpecialFX.cpp | 30 ++++++++++++++++++++++++++++-- src/render/SpecialFX.h | 3 ++- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index dcf795f5..8403e173 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -988,6 +988,9 @@ CBrightLights::Render(void) RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + TempBufferVerticesStored = 0; + TempBufferIndicesStored = 0; + for(i = 0; i < NumBrightLights; i++){ if(TempBufferIndicesStored > TEMPBUFFERINDEXSIZE-40 || TempBufferVerticesStored > TEMPBUFFERVERTSIZE-40) RenderOutGeometryBuffer(); @@ -1024,6 +1027,13 @@ CBrightLights::Render(void) g = aBrightLights[i].m_green; b = aBrightLights[i].m_blue; break; + default: +#ifdef FIX_BUGS //just to make sure that color never will be undefined + r = 0; + g = 0; + b = 0; +#endif + break; } if(aBrightLights[i].m_camDist < BRIGHTLIGHTS_FADE_DIST) @@ -1087,6 +1097,22 @@ CBrightLights::Render(void) TempBufferIndicesStored += 12*3; break; + case BRIGHTLIGHT_FRONT_BIG: + case BRIGHTLIGHT_REAR_BIG: + for (j = 0; j < 8; j++) { + pos = BigCarHeadLightsSide[j] * aBrightLights[i].m_side + + BigCarHeadLightsUp[j] * aBrightLights[i].m_up + + BigCarHeadLightsFront[j] * aBrightLights[i].m_front + + aBrightLights[i].m_pos; + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + j], r, g, b, a); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + j], pos.x, pos.y, pos.z); + } + for (j = 0; j < 12 * 3; j++) + TempBufferRenderIndexList[TempBufferIndicesStored + j] = CubeIndices[j] + TempBufferVerticesStored; + TempBufferVerticesStored += 8; + TempBufferIndicesStored += 12 * 3; + break; + case BRIGHTLIGHT_FRONT_TALL: case BRIGHTLIGHT_REAR_TALL: for(j = 0; j < 8; j++){ @@ -1105,8 +1131,8 @@ CBrightLights::Render(void) case BRIGHTLIGHT_SIREN: for(j = 0; j < 6; j++){ - pos = SirenLightsSide[j]*aBrightLights[i].m_side + - SirenLightsUp[j]*aBrightLights[i].m_up + + pos = SirenLightsSide[j]*TheCamera.GetRight() + + SirenLightsUp[j]* TheCamera.GetUp() + aBrightLights[i].m_pos; RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored+j], r, g, b, a); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored+j], pos.x, pos.y, pos.z); diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 897d8b92..bf3197dc 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -165,6 +165,7 @@ public: uint8 m_blue; }; +//done class CBrightLights { static int NumBrightLights; @@ -173,7 +174,7 @@ public: static void Init(void); //done static void RegisterOne(CVector pos, CVector up, CVector side, CVector front, uint8 type, uint8 red = 0, uint8 green = 0, uint8 blue = 0); //done - static void Render(void); //looks similad but needs recheck !!!!!!!!!!!!!!!!! + static void Render(void); //done static void RenderOutGeometryBuffer(void); //done }; -- cgit v1.2.3 From 56bb7d721a13550cf940c58ff60a00b9b4ad0209 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 12 Oct 2020 13:41:57 +0300 Subject: mark file and fix screen offset --- src/render/SpecialFX.cpp | 10 ++--- src/render/SpecialFX.h | 113 ++++++++++++++++++++++++----------------------- 2 files changed, 62 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 8403e173..b614fae0 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -179,11 +179,11 @@ CSpecialFX::Render2DFXs(void) CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); CFont::SetCentreOff(); CFont::SetPropOn(); CFont::SetColor(CRGBA(0, 255, 0, 200)); - CFont::SetFontStyle(FONT_STANDARD); + FONT_LOCALE(FONT_STANDARD); sprintf(gString, "%d", CTimer::GetFrameCounter() & 0x3F); // mb % 63 AsciiToUnicode(gString, gUString); CFont::PrintString(SCREEN_WIDTH * 8 / 10, SCREEN_HEIGHT * 8 / 10, gUString); @@ -204,11 +204,11 @@ CSpecialFX::Render2DFXs(void) CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); CFont::SetCentreOff(); CFont::SetPropOn(); CFont::SetColor(CRGBA(100, 100, 100, 200)); - CFont::SetFontStyle(FONT_STANDARD); + FONT_LOCALE(FONT_STANDARD); CFont::PrintString(SCREEN_WIDTH * 8 / 10, SCREEN_HEIGHT * 8 / 10, gUString); for (int32 i = 0; i < SCREEN_HEIGHT; i += 4) { RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); @@ -1337,7 +1337,7 @@ CMoneyMessage::Render() CFont::SetJustifyOff(); CFont::SetColor(CRGBA(m_Colour.r, m_Colour.g, m_Colour.b, (255.0f - 255.0f * fLifeTime) * m_fOpacity)); CFont::SetBackGroundOnlyTextOff(); - CFont::SetFontStyle(FONT_STANDARD); + FONT_LOCALE(FONT_STANDARD); CFont::PrintString(vecOut.x, vecOut.y, m_aText); } } diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index bf3197dc..e09d840f 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -1,6 +1,7 @@ #pragma once -//done +//file done + class CSpecialFX { public: @@ -9,15 +10,15 @@ public: static bool bSnapShotActive; static int32 SnapShotFrames; - static void Render(void); //done - static void Update(void); //done - static void Init(void); //done - static void Shutdown(void); //done - static void AddWeaponStreak(int type); //done - static void Render2DFXs(); //done + static void Render(void); + static void Update(void); + static void Init(void); + static void Shutdown(void); + static void AddWeaponStreak(int type); + static void Render2DFXs(); }; -//done + class CRegisteredMotionBlurStreak { public: @@ -29,22 +30,22 @@ public: CVector m_pos2[3]; bool m_isValid[3]; - void Update(void); //done - void Render(void); //done + void Update(void); + void Render(void); }; -//done + class CMotionBlurStreaks { static CRegisteredMotionBlurStreak aStreaks[NUMMBLURSTREAKS]; public: - static void Init(void); //done - static void Update(void); //done - static void RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2); //done - static void Render(void); //done + static void Init(void); + static void Update(void); + static void RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2); + static void Render(void); }; -//done + struct CBulletTrace { CVector m_vecCurrentPos; @@ -55,20 +56,20 @@ struct CBulletTrace float m_fThicknes; uint8 m_fVisibility; - void Update(void); //done + void Update(void); }; -//done + class CBulletTraces { public: static CBulletTrace aTraces[NUMBULLETTRACES]; - static void Init(void); //done - static void Render(void); //done - static void Update(void); //done - static void AddTrace(CVector* start, CVector* end, float thickness, uint32 lifeTime, uint8 visibility); //done - static void AddTrace(CVector* start, CVector* end, int32 weaponType, class CEntity* shooter); //done + static void Init(void); + static void Render(void); + static void Update(void); + static void AddTrace(CVector* start, CVector* end, float thickness, uint32 lifeTime, uint8 visibility); + static void AddTrace(CVector* start, CVector* end, int32 weaponType, class CEntity* shooter); }; enum @@ -83,7 +84,7 @@ enum MARKERTYPE_INVALID = 0x101 }; -//done + class C3dMarker { public: @@ -104,21 +105,21 @@ public: float m_fBrightness; float m_fCameraRange; - bool AddMarker(uint32 identifier, uint16 type, float fSize, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done - void DeleteMarkerObject(); //done - void Render(); //done + bool AddMarker(uint32 identifier, uint16 type, float fSize, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); + void DeleteMarkerObject(); + void Render(); }; -//done + class C3dMarkers { public: - static void Init(); //done - static void Shutdown(); //done - static C3dMarker *PlaceMarker(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done - static void PlaceMarkerSet(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); //done - static void Render(); //done - static void Update(); //done + static void Init(); + static void Shutdown(); + static C3dMarker *PlaceMarker(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); + static void PlaceMarkerSet(uint32 id, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate); + static void Render(); + static void Update(); static C3dMarker m_aMarkerArray[NUM3DMARKERS]; static int32 NumActiveMarkers; @@ -150,7 +151,7 @@ enum BRIGHTLIGHT_REAR = BRIGHTLIGHT_REAR_LONG, }; -//done + class CBrightLight { public: @@ -165,17 +166,17 @@ public: uint8 m_blue; }; -//done + class CBrightLights { static int NumBrightLights; static CBrightLight aBrightLights[NUMBRIGHTLIGHTS]; public: - static void Init(void); //done + static void Init(void); static void RegisterOne(CVector pos, CVector up, CVector side, CVector front, - uint8 type, uint8 red = 0, uint8 green = 0, uint8 blue = 0); //done - static void Render(void); //done - static void RenderOutGeometryBuffer(void); //done + uint8 type, uint8 red = 0, uint8 green = 0, uint8 blue = 0); + static void Render(void); + static void RenderOutGeometryBuffer(void); }; @@ -185,7 +186,7 @@ enum SHINYTEXT_FLAT }; -//done + class CShinyText { public: @@ -198,21 +199,21 @@ public: uint8 m_blue; }; -//done + class CShinyTexts { static int NumShinyTexts; static CShinyText aShinyTexts[NUMSHINYTEXTS]; public: - static void Init(void); //done + static void Init(void); static void RegisterOne(CVector p0, CVector p1, CVector p2, CVector p3, float u0, float v0, float u1, float v1, float u2, float v2, float u3, float v3, - uint8 type, uint8 red, uint8 green, uint8 blue, float maxDist); //done, not used - static void Render(void); //done - static void RenderOutGeometryBuffer(void); //done + uint8 type, uint8 red, uint8 green, uint8 blue, float maxDist); //not used + static void Render(void); + static void RenderOutGeometryBuffer(void); }; -//done + class CMoneyMessage { friend class CMoneyMessages; @@ -224,25 +225,25 @@ class CMoneyMessage float m_fSize; float m_fOpacity; public: - void Render(); //done + void Render(); }; -//done + class CMoneyMessages { static CMoneyMessage aMoneyMessages[NUMMONEYMESSAGES]; public: - static void Init(); //done - static void Render(); //done - static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); //done + static void Init(); + static void Render(); + static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); }; -//done + class CSpecialParticleStuff { static uint32 BoatFromStart; public: - static void CreateFoamAroundObject(CMatrix*, float, float, float, int32); //done, not used - static void StartBoatFoamAnimation(); //done, not used - static void UpdateBoatFoamAnimation(CMatrix*); //done, not used + static void CreateFoamAroundObject(CMatrix*, float, float, float, int32); //not used + static void StartBoatFoamAnimation(); //not used + static void UpdateBoatFoamAnimation(CMatrix*); //not used }; -- cgit v1.2.3 From 34b4efe242bc6304f2e340dfe32273062e0ed73e Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Thu, 15 Oct 2020 15:42:10 +0300 Subject: fix bullet traces rener and some renaming --- src/control/Replay.cpp | 12 +-- src/render/SpecialFX.cpp | 267 +++++++++++++++++++++++++---------------------- src/render/SpecialFX.h | 4 +- 3 files changed, 150 insertions(+), 133 deletions(-) (limited to 'src') diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 034cfe4d..ad2aad7e 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -394,10 +394,8 @@ void CReplay::RecordThisFrame(void) tBulletTracePacket* bt = (tBulletTracePacket*)&Record.m_pBase[Record.m_nOffset]; bt->type = REPLAYPACKET_BULLET_TRACES; bt->index = i; -// bt->frames = CBulletTraces::aTraces[i].m_framesInUse; -// bt->lifetime = CBulletTraces::aTraces[i].m_lifeTime; - bt->inf = CBulletTraces::aTraces[i].m_vecCurrentPos; - bt->sup = CBulletTraces::aTraces[i].m_vecTargetPos; + bt->inf = CBulletTraces::aTraces[i].m_vecStartPos; + bt->sup = CBulletTraces::aTraces[i].m_vecEndPos; Record.m_nOffset += sizeof(*bt); } tMiscPacket* misc = (tMiscPacket*)&Record.m_pBase[Record.m_nOffset]; @@ -1141,10 +1139,8 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo { tBulletTracePacket* pb = (tBulletTracePacket*)&ptr[offset]; CBulletTraces::aTraces[pb->index].m_bInUse = true; -// CBulletTraces::aTraces[pb->index].m_framesInUse = pb->frames; -// CBulletTraces::aTraces[pb->index].m_lifeTime = pb->lifetime; - CBulletTraces::aTraces[pb->index].m_vecCurrentPos = pb->inf; - CBulletTraces::aTraces[pb->index].m_vecTargetPos = pb->sup; + CBulletTraces::aTraces[pb->index].m_vecStartPos = pb->inf; + CBulletTraces::aTraces[pb->index].m_vecEndPos = pb->sup; buffer->m_nOffset += sizeof(tBulletTracePacket); break; } diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index b614fae0..4c69f749 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -84,8 +84,8 @@ CSpecialFX::Init(void) StreakIndexList[11] = 3; CMotionBlurStreaks::Init(); - CShinyTexts::Init(); CBrightLights::Init(); + CShinyTexts::Init(); CMoneyMessages::Init(); C3dMarkers::Init(); CSpecialFX::bSnapShotActive = false; @@ -124,7 +124,7 @@ CSpecialFX::AddWeaponStreak(int type) end = matrix * CVector(0.096f, -0.0175f, 1.096f); break; default: - break; + return; } CMotionBlurStreaks::RegisterStreak((uintptr)FindPlayerPed()->m_pWeaponModel, 100, 100, 100, start, end); } @@ -235,7 +235,7 @@ CSpecialFX::Render2DFXs(void) } else { CTimer::SetTimeScale(0.0f); //in andro it's 0.00001 if (CSpecialFX::SnapShotFrames < 10) { - int32 tmp = (1 - CSpecialFX::SnapShotFrames / 10) * 255 * 0.65f; + int32 tmp = (255 - 255 * CSpecialFX::SnapShotFrames / 10) * 0.65f; RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); CSprite2d::Draw2DPolygon(0.0f, 0.0f, SCREEN_WIDTH, 0.0f, 0.0f, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, CRGBA(tmp, tmp, tmp, tmp)); @@ -329,7 +329,7 @@ CMotionBlurStreaks::RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVecto } // Find free slot - for(i = 0; aStreaks[i].m_id != nil ; i++) + for(i = 0; aStreaks[i].m_id != 0 ; i++) if(i == NUMMBLURSTREAKS-1) return; @@ -402,8 +402,8 @@ void CBulletTraces::AddTrace(CVector* start, CVector* end, float thicknes, uint3 for (int i = 0; nextSlot < NUMBULLETTRACES && aTraces[i].m_bInUse; i++) nextSlot++; if (nextSlot < 16) { - aTraces[nextSlot].m_vecCurrentPos = *start; - aTraces[nextSlot].m_vecTargetPos = *end; + aTraces[nextSlot].m_vecStartPos = *start; + aTraces[nextSlot].m_vecEndPos = *end; aTraces[nextSlot].m_bInUse = true; aTraces[nextSlot].m_nCreationTime = CTimer::GetTimeInMilliseconds(); aTraces[nextSlot].m_fVisibility = visibility; @@ -411,19 +411,22 @@ void CBulletTraces::AddTrace(CVector* start, CVector* end, float thicknes, uint3 aTraces[nextSlot].m_nLifeTime = modifiedLifeTime; } - float upDotProd = DotProduct(TheCamera.GetUp(), *start - TheCamera.GetPosition()); - float forwardDotProd = DotProduct(TheCamera.GetForward(), *start - TheCamera.GetPosition()); - float upDotProdEnd = DotProduct(TheCamera.GetUp(), *end - TheCamera.GetPosition()); - float forwardDotProdEnd = DotProduct(TheCamera.GetForward(), *end - TheCamera.GetPosition()); - if (forwardDotProd*forwardDotProdEnd < 0.0f) { - float tmp = Abs(forwardDotProd) / (Abs(forwardDotProd) + Abs(forwardDotProdEnd)); - float tmp2 = (upDotProdEnd - upDotProd) * tmp + upDotProd; - float dotProdEndRight = DotProduct(TheCamera.GetRight(), *end - TheCamera.GetPosition()); - float dotProdRight = DotProduct(TheCamera.GetRight(), *start - TheCamera.GetPosition()); - float tmp3 = (dotProdEndRight - dotProdRight) * tmp + dotProdRight; - float dist = Sqrt(SQR(tmp2) + SQR(tmp3)); + float startProjFwd = DotProduct(TheCamera.GetForward(), *start - TheCamera.GetPosition()); + float endProjFwd = DotProduct(TheCamera.GetForward(), *end - TheCamera.GetPosition()); + if (startProjFwd * endProjFwd < 0.0f) { //if one of point behind us and second before us + float fStartDistFwd = Abs(startProjFwd) / (Abs(startProjFwd) + Abs(endProjFwd)); + + float startProjUp = DotProduct(TheCamera.GetUp(), *start - TheCamera.GetPosition()); + float endProjUp = DotProduct(TheCamera.GetUp(), *end - TheCamera.GetPosition()); + float distUp = (endProjUp - startProjUp) * fStartDistFwd + startProjUp; + + float startProjRight = DotProduct(TheCamera.GetRight(), *end - TheCamera.GetPosition()); + float startProjRight = DotProduct(TheCamera.GetRight(), *start - TheCamera.GetPosition()); + float distRight = (startProjRight - startProjRight) * fStartDistFwd + startProjRight; + + float dist = Sqrt(SQR(distUp) + SQR(distRight)); if (dist < 2.0f) { - if(tmp3 < 0.0f) + if(distRight < 0.0f) DMAudio.PlayFrontEndSound(SOUND_BULLETTRACE_2, 127 * (1.0f - dist * 0.5f)); else DMAudio.PlayFrontEndSound(SOUND_BULLETTRACE_1, 127 * (1.0f - dist * 0.5f)); @@ -443,10 +446,8 @@ void CBulletTraces::AddTrace(CVector* start, CVector* end, int32 weaponType, cla || camMode == CCam::MODE_CAMERA || camMode == CCam::MODE_SNIPER || camMode == CCam::MODE_M16_1STPERSON_RUNABOUT -#ifdef MOBILE_IMPROVEMENTS || camMode == CCam::MODE_ROCKETLAUNCHER || camMode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT -#endif || camMode == CCam::MODE_SNIPER_RUNABOUT || camMode == CCam::MODE_HELICANNON_1STPERSON) { @@ -489,109 +490,130 @@ void CBulletTraces::Render(void) RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpSmokeTrailTexture)); - float nTimeOfLiving = CTimer::GetTimeInMilliseconds() - aTraces[i].m_nCreationTime; - - float traceThicknes = aTraces[i].m_fThicknes * nTimeOfLiving / aTraces[i].m_nLifeTime; - CVector vecOffset = aTraces[i].m_vecTargetPos - aTraces[i].m_vecCurrentPos; - vecOffset.Normalise(); - vecOffset *= traceThicknes; - uint8 nAlphaValue = aTraces[i].m_fVisibility * (aTraces[i].m_nLifeTime - nTimeOfLiving) / aTraces[i].m_nLifeTime; - - CVector currentPos = aTraces[i].m_vecCurrentPos; - CVector targetPos = aTraces[i].m_vecTargetPos; - float dotProdCur = DotProduct(currentPos - TheCamera.GetPosition(), TheCamera.GetForward()) - 0.7f; - float dotProdTar = DotProduct(targetPos - TheCamera.GetPosition(), TheCamera.GetForward()) - 0.7f; - if (dotProdCur >= 0.0f || dotProdTar >= 0.0f) { - if (dotProdCur < 0.0f) { - float absDotProdCur = Abs(dotProdCur); - float absDotProdTar = Abs(dotProdTar); - currentPos = (absDotProdTar * currentPos + absDotProdCur * targetPos) / (absDotProdCur + absDotProdTar); - } else if (dotProdTar < 0.0f){ - float absDotProdCur = Abs(dotProdCur); - float absDotProdTar = Abs(dotProdTar); - targetPos = (absDotProdTar * currentPos + absDotProdCur * targetPos) / (absDotProdCur + absDotProdTar); - } - RwIm3DVertexSetV(&TraceVertices[5], 10.0f); - RwIm3DVertexSetV(&TraceVertices[6], 10.0f); - RwIm3DVertexSetV(&TraceVertices[7], 10.0f); - RwIm3DVertexSetV(&TraceVertices[8], 10.0f); - RwIm3DVertexSetV(&TraceVertices[9], 10.0f); - - RwIm3DVertexSetRGBA(&TraceVertices[0], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[1], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[2], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[3], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[5], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[6], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[7], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[8], 255, 255, 255, nAlphaValue); - RwIm3DVertexSetRGBA(&TraceVertices[9], 255, 255, 255, nAlphaValue); - - CVector currentPos2 = (7.0f * currentPos + targetPos) / 8; - CVector targetPos2 = (7.0f * targetPos + currentPos) / 8; - RwIm3DVertexSetPos(&TraceVertices[0], currentPos2.x, currentPos2.y, currentPos2.z); - RwIm3DVertexSetPos(&TraceVertices[1], currentPos2.x, currentPos2.y, currentPos2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[2], currentPos2.x + vecOffset.y, currentPos2.y - vecOffset.x, currentPos2.z); - RwIm3DVertexSetPos(&TraceVertices[3], currentPos2.x, currentPos2.y, currentPos2.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[4], currentPos2.x - vecOffset.y, currentPos2.y - vecOffset.y, currentPos2.z); - - RwIm3DVertexSetPos(&TraceVertices[5], targetPos2.x, targetPos2.y, targetPos2.z); - RwIm3DVertexSetPos(&TraceVertices[6], targetPos2.x, targetPos2.y, targetPos2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[7], targetPos2.x + vecOffset.y, targetPos2.y - vecOffset.x, targetPos2.z); - RwIm3DVertexSetPos(&TraceVertices[8], targetPos2.x, targetPos2.y, targetPos2.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[9], targetPos2.x - vecOffset.y, targetPos2.y - vecOffset.y, targetPos2.z); - - if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { - RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); - RwIm3DEnd(); - } + float timeAlive = CTimer::GetTimeInMilliseconds() - aTraces[i].m_nCreationTime; + float traceThicknes = aTraces[i].m_fThicknes * timeAlive / aTraces[i].m_nLifeTime; + CVector horizontalOffset = aTraces[i].m_vecEndPos - aTraces[i].m_vecStartPos; + horizontalOffset.Normalise(); + horizontalOffset *= traceThicknes; - RwIm3DVertexSetV(&TraceVertices[5], 2.0f); - RwIm3DVertexSetV(&TraceVertices[6], 2.0f); - RwIm3DVertexSetV(&TraceVertices[7], 2.0f); - RwIm3DVertexSetV(&TraceVertices[8], 2.0f); - RwIm3DVertexSetV(&TraceVertices[9], 2.0f); - RwIm3DVertexSetRGBA(&TraceVertices[0], 255, 255, 255, 0); - RwIm3DVertexSetRGBA(&TraceVertices[1], 255, 255, 255, 0); - RwIm3DVertexSetRGBA(&TraceVertices[2], 255, 255, 255, 0); - RwIm3DVertexSetRGBA(&TraceVertices[3], 255, 255, 255, 0); - RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, 0); - - RwIm3DVertexSetPos(&TraceVertices[0], currentPos.x, currentPos.y, currentPos.z); - RwIm3DVertexSetPos(&TraceVertices[1], currentPos.x, currentPos.y, currentPos.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[2], currentPos.x + vecOffset.y, currentPos.y - vecOffset.x, currentPos.z); - RwIm3DVertexSetPos(&TraceVertices[3], currentPos.x, currentPos.y, currentPos.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[4], currentPos.x - vecOffset.y, currentPos.y - vecOffset.y, currentPos.z); - - RwIm3DVertexSetPos(&TraceVertices[5], currentPos2.x, currentPos2.y, currentPos2.z); - RwIm3DVertexSetPos(&TraceVertices[6], currentPos2.x, currentPos2.y, currentPos2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[7], currentPos2.x + vecOffset.y, currentPos2.y - vecOffset.x, currentPos2.z); - RwIm3DVertexSetPos(&TraceVertices[8], currentPos2.x, currentPos2.y, currentPos2.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[9], currentPos2.x - vecOffset.y, currentPos2.y - vecOffset.y, currentPos2.z); - - if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { - RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); - RwIm3DEnd(); - } + //then closer trace to die then it more transparent + uint8 nAlphaValue = aTraces[i].m_fVisibility * (aTraces[i].m_nLifeTime - timeAlive) / aTraces[i].m_nLifeTime; - RwIm3DVertexSetPos(&TraceVertices[1], targetPos.x, targetPos.y, targetPos.z); - RwIm3DVertexSetPos(&TraceVertices[2], targetPos.x, targetPos.y, targetPos.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[3], targetPos.x + vecOffset.y, targetPos.y - vecOffset.x, targetPos.z); - RwIm3DVertexSetPos(&TraceVertices[4], targetPos.x, targetPos.y, targetPos.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[5], targetPos.x - vecOffset.y, targetPos.y - vecOffset.y, targetPos.z); + CVector start = aTraces[i].m_vecStartPos; + CVector end = aTraces[i].m_vecEndPos; + float startProj = DotProduct(start - TheCamera.GetPosition(), TheCamera.GetForward()) - 0.7f; + float endProj = DotProduct(end - TheCamera.GetPosition(), TheCamera.GetForward()) - 0.7f; + if (startProj < 0.0f && endProj < 0.0f) //we dont need render trace behind us + continue; - RwIm3DVertexSetPos(&TraceVertices[5], targetPos2.x, targetPos2.y, targetPos2.z); - RwIm3DVertexSetPos(&TraceVertices[6], targetPos2.x, targetPos2.y, targetPos2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[7], targetPos2.x + vecOffset.y, targetPos2.y - vecOffset.x, targetPos2.z); - RwIm3DVertexSetPos(&TraceVertices[8], targetPos2.x, targetPos2.y, targetPos2.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[9], targetPos2.x - vecOffset.y, targetPos2.y - vecOffset.y, targetPos2.z); + if (startProj < 0.0f) { //if strat behind us move it closer + float absStartProj = Abs(startProj); + float absEndProj = Abs(endProj); + start = (absEndProj * start + absStartProj * end) / (absStartProj + absEndProj); + } else if (endProj < 0.0f) { + float absStartProj = Abs(startProj); + float absEndProj = Abs(endProj); + end = (absEndProj * start + absStartProj * end) / (absStartProj + absEndProj); + } - if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { - RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); - RwIm3DEnd(); - } + //we divide trace at three parts + CVector start2 = (7.0f * start + end) / 8; + CVector end2 = (7.0f * end + start) / 8; + + RwIm3DVertexSetV(&TraceVertices[5], 10.0f); + RwIm3DVertexSetV(&TraceVertices[6], 10.0f); + RwIm3DVertexSetV(&TraceVertices[7], 10.0f); + RwIm3DVertexSetV(&TraceVertices[8], 10.0f); + RwIm3DVertexSetV(&TraceVertices[9], 10.0f); + + RwIm3DVertexSetRGBA(&TraceVertices[0], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[1], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[2], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[3], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[5], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[6], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[7], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[8], 255, 255, 255, nAlphaValue); + RwIm3DVertexSetRGBA(&TraceVertices[9], 255, 255, 255, nAlphaValue); + //two points in center + RwIm3DVertexSetPos(&TraceVertices[0], start2.x, start2.y, start2.z); + RwIm3DVertexSetPos(&TraceVertices[5], end2.x, end2.y, end2.z); + //vetrical planes + RwIm3DVertexSetPos(&TraceVertices[1], start2.x, start2.y, start2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[3], start2.x, start2.y, start2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[6], end2.x, end2.y, end2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[8], end2.x, end2.y, end2.z - traceThicknes); + //horizontal planes + RwIm3DVertexSetPos(&TraceVertices[2], start2.x + horizontalOffset.y, start2.y - horizontalOffset.x, start2.z); + RwIm3DVertexSetPos(&TraceVertices[7], end2.x + horizontalOffset.y, end2.y - horizontalOffset.x, end2.z); +#ifdef FIX_BUGS //this point calcilated wrong for some reason + RwIm3DVertexSetPos(&TraceVertices[4], start2.x - horizontalOffset.y, start2.y + horizontalOffset.x, start2.z); + RwIm3DVertexSetPos(&TraceVertices[9], end2.x - horizontalOffset.y, end2.y + horizontalOffset.x, end2.z); +#else + RwIm3DVertexSetPos(&TraceVertices[4], start2.x - horizontalOffset.y, start2.y - horizontalOffset.y, start2.z); + RwIm3DVertexSetPos(&TraceVertices[9], end2.x - horizontalOffset.y, end2.y - horizontalOffset.y, end2.z); +#endif + + if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); + RwIm3DEnd(); + } + + RwIm3DVertexSetV(&TraceVertices[5], 2.0f); + RwIm3DVertexSetV(&TraceVertices[6], 2.0f); + RwIm3DVertexSetV(&TraceVertices[7], 2.0f); + RwIm3DVertexSetV(&TraceVertices[8], 2.0f); + RwIm3DVertexSetV(&TraceVertices[9], 2.0f); + RwIm3DVertexSetRGBA(&TraceVertices[0], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[1], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[2], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[3], 255, 255, 255, 0); + RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, 0); + + RwIm3DVertexSetPos(&TraceVertices[0], start.x, start.y, start.z); + RwIm3DVertexSetPos(&TraceVertices[1], start.x, start.y, start.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[3], start.x, start.y, start.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[2], start.x + horizontalOffset.y, start.y - horizontalOffset.x, start.z); + + RwIm3DVertexSetPos(&TraceVertices[5], start2.x, start2.y, start2.z); + RwIm3DVertexSetPos(&TraceVertices[6], start2.x, start2.y, start2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[8], start2.x, start2.y, start2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[7], start2.x + horizontalOffset.y, start2.y - horizontalOffset.x, start2.z); +#ifdef FIX_BUGS + RwIm3DVertexSetPos(&TraceVertices[4], start.x - horizontalOffset.y, start.y + horizontalOffset.x, start.z); + RwIm3DVertexSetPos(&TraceVertices[9], start2.x - horizontalOffset.y, start2.y + horizontalOffset.x, start2.z); +#else + RwIm3DVertexSetPos(&TraceVertices[4], start.x - horizontalOffset.y, start.y - horizontalOffset.y, start.z); + RwIm3DVertexSetPos(&TraceVertices[9], start2.x - horizontalOffset.y, start2.y - horizontalOffset.y, start2.z); +#endif + + if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, rwIM3D_VERTEXUV)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); + RwIm3DEnd(); + } + + RwIm3DVertexSetPos(&TraceVertices[1], end.x, end.y, end.z); + RwIm3DVertexSetPos(&TraceVertices[2], end.x, end.y, end.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[4], end.x, end.y, end.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[3], end.x + horizontalOffset.y, end.y - horizontalOffset.x, end.z); + + RwIm3DVertexSetPos(&TraceVertices[5], end2.x, end2.y, end2.z); + RwIm3DVertexSetPos(&TraceVertices[6], end2.x, end2.y, end2.z + traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[8], end2.x, end2.y, end2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[7], end2.x + horizontalOffset.y, end2.y - horizontalOffset.x, end2.z); +#ifdef FIX_BUGS + RwIm3DVertexSetPos(&TraceVertices[5], end.x - horizontalOffset.y, end.y + horizontalOffset.x, end.z); + RwIm3DVertexSetPos(&TraceVertices[9], end2.x - horizontalOffset.y, end2.y + horizontalOffset.x, end2.z); +#else + RwIm3DVertexSetPos(&TraceVertices[5], end.x - horizontalOffset.y, end.y - horizontalOffset.y, end.z); + RwIm3DVertexSetPos(&TraceVertices[9], end2.x - horizontalOffset.y, end2.y - horizontalOffset.y, end2.z); +#endif + + if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, rwIM3D_VERTEXUV)) { + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); + RwIm3DEnd(); } } RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); @@ -762,7 +784,7 @@ C3dMarkers::Render() CCoronas::RegisterCorona((uintptr)&m_aMarkerArray[i], SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, 192, m_aMarkerArray[i].m_Matrix.GetPosition(), 1.2f * m_aMarkerArray[i].m_fSize, 50.0f * TheCamera.LODDistMultiplier, - CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f, false, 1.5f); + CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f, false); } } NumActiveMarkers++; @@ -1029,11 +1051,10 @@ CBrightLights::Render(void) break; default: #ifdef FIX_BUGS //just to make sure that color never will be undefined - r = 0; - g = 0; - b = 0; -#endif + return; +#else break; +#endif } if(aBrightLights[i].m_camDist < BRIGHTLIGHTS_FADE_DIST) diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index e09d840f..3281eee1 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -48,8 +48,8 @@ public: struct CBulletTrace { - CVector m_vecCurrentPos; - CVector m_vecTargetPos; + CVector m_vecStartPos; + CVector m_vecEndPos; bool m_bInUse; uint32 m_nCreationTime; uint32 m_nLifeTime; -- cgit v1.2.3 From 63c2b98c5ed9988373d42b2318b1398fd0937bbf Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Thu, 15 Oct 2020 16:04:03 +0300 Subject: fix build --- src/render/SpecialFX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 4c69f749..25a33d4d 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -420,9 +420,9 @@ void CBulletTraces::AddTrace(CVector* start, CVector* end, float thicknes, uint3 float endProjUp = DotProduct(TheCamera.GetUp(), *end - TheCamera.GetPosition()); float distUp = (endProjUp - startProjUp) * fStartDistFwd + startProjUp; - float startProjRight = DotProduct(TheCamera.GetRight(), *end - TheCamera.GetPosition()); float startProjRight = DotProduct(TheCamera.GetRight(), *start - TheCamera.GetPosition()); - float distRight = (startProjRight - startProjRight) * fStartDistFwd + startProjRight; + float endProjRight = DotProduct(TheCamera.GetRight(), *end - TheCamera.GetPosition()); + float distRight = (endProjRight - startProjRight) * fStartDistFwd + startProjRight; float dist = Sqrt(SQR(distUp) + SQR(distRight)); if (dist < 2.0f) { -- cgit v1.2.3 From 3cbccd2ad343bf2581b68bff91ffaef249171d4e Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sat, 17 Oct 2020 19:05:41 +0300 Subject: typo fixes --- src/render/SpecialFX.cpp | 40 +++++++++++++++++++--------------------- src/render/SpecialFX.h | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 25a33d4d..9af4c9e4 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -381,7 +381,7 @@ void CBulletTraces::Init(void) aTraces[i].m_bInUse = false; } -void CBulletTraces::AddTrace(CVector* start, CVector* end, float thicknes, uint32 lifeTime, uint8 visibility) +void CBulletTraces::AddTrace(CVector* start, CVector* end, float thickness, uint32 lifeTime, uint8 visibility) { int32 enabledCount; uint32 modifiedLifeTime; @@ -407,7 +407,7 @@ void CBulletTraces::AddTrace(CVector* start, CVector* end, float thicknes, uint3 aTraces[nextSlot].m_bInUse = true; aTraces[nextSlot].m_nCreationTime = CTimer::GetTimeInMilliseconds(); aTraces[nextSlot].m_fVisibility = visibility; - aTraces[nextSlot].m_fThicknes = thicknes; + aTraces[nextSlot].m_fThickness = thickness; aTraces[nextSlot].m_nLifeTime = modifiedLifeTime; } @@ -492,10 +492,10 @@ void CBulletTraces::Render(void) float timeAlive = CTimer::GetTimeInMilliseconds() - aTraces[i].m_nCreationTime; - float traceThicknes = aTraces[i].m_fThicknes * timeAlive / aTraces[i].m_nLifeTime; + float traceThickness = aTraces[i].m_fThickness * timeAlive / aTraces[i].m_nLifeTime; CVector horizontalOffset = aTraces[i].m_vecEndPos - aTraces[i].m_vecStartPos; horizontalOffset.Normalise(); - horizontalOffset *= traceThicknes; + horizontalOffset *= traceThickness; //then closer trace to die then it more transparent uint8 nAlphaValue = aTraces[i].m_fVisibility * (aTraces[i].m_nLifeTime - timeAlive) / aTraces[i].m_nLifeTime; @@ -540,15 +540,15 @@ void CBulletTraces::Render(void) //two points in center RwIm3DVertexSetPos(&TraceVertices[0], start2.x, start2.y, start2.z); RwIm3DVertexSetPos(&TraceVertices[5], end2.x, end2.y, end2.z); - //vetrical planes - RwIm3DVertexSetPos(&TraceVertices[1], start2.x, start2.y, start2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[3], start2.x, start2.y, start2.z - traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[6], end2.x, end2.y, end2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[8], end2.x, end2.y, end2.z - traceThicknes); + //vertical planes + RwIm3DVertexSetPos(&TraceVertices[1], start2.x, start2.y, start2.z + traceThickness); + RwIm3DVertexSetPos(&TraceVertices[3], start2.x, start2.y, start2.z - traceThickness); + RwIm3DVertexSetPos(&TraceVertices[6], end2.x, end2.y, end2.z + traceThickness); + RwIm3DVertexSetPos(&TraceVertices[8], end2.x, end2.y, end2.z - traceThickness); //horizontal planes RwIm3DVertexSetPos(&TraceVertices[2], start2.x + horizontalOffset.y, start2.y - horizontalOffset.x, start2.z); RwIm3DVertexSetPos(&TraceVertices[7], end2.x + horizontalOffset.y, end2.y - horizontalOffset.x, end2.z); -#ifdef FIX_BUGS //this point calcilated wrong for some reason +#ifdef FIX_BUGS //this point calculated wrong for some reason RwIm3DVertexSetPos(&TraceVertices[4], start2.x - horizontalOffset.y, start2.y + horizontalOffset.x, start2.z); RwIm3DVertexSetPos(&TraceVertices[9], end2.x - horizontalOffset.y, end2.y + horizontalOffset.x, end2.z); #else @@ -573,13 +573,13 @@ void CBulletTraces::Render(void) RwIm3DVertexSetRGBA(&TraceVertices[4], 255, 255, 255, 0); RwIm3DVertexSetPos(&TraceVertices[0], start.x, start.y, start.z); - RwIm3DVertexSetPos(&TraceVertices[1], start.x, start.y, start.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[3], start.x, start.y, start.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[1], start.x, start.y, start.z + traceThickness); + RwIm3DVertexSetPos(&TraceVertices[3], start.x, start.y, start.z - traceThickness); RwIm3DVertexSetPos(&TraceVertices[2], start.x + horizontalOffset.y, start.y - horizontalOffset.x, start.z); RwIm3DVertexSetPos(&TraceVertices[5], start2.x, start2.y, start2.z); - RwIm3DVertexSetPos(&TraceVertices[6], start2.x, start2.y, start2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[8], start2.x, start2.y, start2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[6], start2.x, start2.y, start2.z + traceThickness); + RwIm3DVertexSetPos(&TraceVertices[8], start2.x, start2.y, start2.z - traceThickness); RwIm3DVertexSetPos(&TraceVertices[7], start2.x + horizontalOffset.y, start2.y - horizontalOffset.x, start2.z); #ifdef FIX_BUGS RwIm3DVertexSetPos(&TraceVertices[4], start.x - horizontalOffset.y, start.y + horizontalOffset.x, start.z); @@ -595,13 +595,13 @@ void CBulletTraces::Render(void) } RwIm3DVertexSetPos(&TraceVertices[1], end.x, end.y, end.z); - RwIm3DVertexSetPos(&TraceVertices[2], end.x, end.y, end.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[4], end.x, end.y, end.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[2], end.x, end.y, end.z + traceThickness); + RwIm3DVertexSetPos(&TraceVertices[4], end.x, end.y, end.z - traceThickness); RwIm3DVertexSetPos(&TraceVertices[3], end.x + horizontalOffset.y, end.y - horizontalOffset.x, end.z); RwIm3DVertexSetPos(&TraceVertices[5], end2.x, end2.y, end2.z); - RwIm3DVertexSetPos(&TraceVertices[6], end2.x, end2.y, end2.z + traceThicknes); - RwIm3DVertexSetPos(&TraceVertices[8], end2.x, end2.y, end2.z - traceThicknes); + RwIm3DVertexSetPos(&TraceVertices[6], end2.x, end2.y, end2.z + traceThickness); + RwIm3DVertexSetPos(&TraceVertices[8], end2.x, end2.y, end2.z - traceThickness); RwIm3DVertexSetPos(&TraceVertices[7], end2.x + horizontalOffset.y, end2.y - horizontalOffset.x, end2.z); #ifdef FIX_BUGS RwIm3DVertexSetPos(&TraceVertices[5], end.x - horizontalOffset.y, end.y + horizontalOffset.x, end.z); @@ -1049,11 +1049,9 @@ CBrightLights::Render(void) g = aBrightLights[i].m_green; b = aBrightLights[i].m_blue; break; - default: #ifdef FIX_BUGS //just to make sure that color never will be undefined + default: return; -#else - break; #endif } diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 3281eee1..f163d8ca 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -53,7 +53,7 @@ struct CBulletTrace bool m_bInUse; uint32 m_nCreationTime; uint32 m_nLifeTime; - float m_fThicknes; + float m_fThickness; uint8 m_fVisibility; void Update(void); -- cgit v1.2.3