From 658f94f15591b6cb4c73f51ec5e2f7e3e99462e7 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 7 Aug 2020 13:13:04 +0200 Subject: little emergecy fix for shadows with librw --- src/render/Shadows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index 9b864d27..0ee63b9a 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -853,7 +853,7 @@ CShadows::StoreShadowForPed(CPed *pPed, float fDisplacementX, float fDisplacemen { if ( CTimeCycle::GetShadowStrength() != 0 ) { - #if 1 + #ifndef LIBRW CCutsceneShadow *pShadow = pPed->m_pRTShadow; if (pShadow) -- cgit v1.2.3 From 1a7270190352d23bc7c8a9ea1952b1cf606ad37b Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sat, 8 Aug 2020 18:14:01 +0300 Subject: Revert "little emergecy fix for shadows with librw" This reverts commit 658f94f15591b6cb4c73f51ec5e2f7e3e99462e7. --- src/render/Shadows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index 0ee63b9a..9b864d27 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -853,7 +853,7 @@ CShadows::StoreShadowForPed(CPed *pPed, float fDisplacementX, float fDisplacemen { if ( CTimeCycle::GetShadowStrength() != 0 ) { - #ifndef LIBRW + #if 1 CCutsceneShadow *pShadow = pPed->m_pRTShadow; if (pShadow) -- cgit v1.2.3 From b02c7cdc442af117659df6cd5fc39f9184279c0d Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 9 Aug 2020 13:17:48 +0200 Subject: coronas done --- src/render/Coronas.cpp | 188 ++++++++++++++++++++++++++++++++++++++++++------- src/render/Coronas.h | 26 +++---- 2 files changed, 176 insertions(+), 38 deletions(-) (limited to 'src/render') diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index efe486fe..df5dfadb 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -2,6 +2,7 @@ #include "main.h" #include "General.h" +#include "RenderBuffer.h" #include "TxdStore.h" #include "Camera.h" #include "Sprite.h" @@ -12,6 +13,8 @@ #include "Timecycle.h" #include "Coronas.h" +//--MIAMI: file done + struct FlareDef { float position; @@ -130,13 +133,21 @@ void CCoronas::RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, RwTexture *tex, int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, - bool longDist, float nearDist) + bool useNearDist, float nearDist) { int i; if(sq(drawDist) < (TheCamera.GetPosition() - coors).MagnitudeSqr2D()) return; + if(useNearDist){ + float dist = (TheCamera.GetPosition() - coors).Magnitude(); + if(dist < 35.0f) + return; + if(dist < 50.0f) + alpha *= (dist - 35.0f)/(50.0f - 35.0f); + } + for(i = 0; i < NUMCORONAS; i++) if(aCoronas[i].id == id) break; @@ -189,17 +200,19 @@ CCoronas::RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 al aCoronas[i].reflection = reflection; aCoronas[i].LOScheck = LOScheck; aCoronas[i].drawStreak = drawStreak; + aCoronas[i].useNearDist = useNearDist; + aCoronas[i].nearDist = nearDist; } void CCoronas::RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, uint8 type, int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, - bool longDist, float nearDist) + bool useNearDist, float nearDist) { RegisterCorona(id, red, green, blue, alpha, coors, size, drawDist, gpCoronaTexture[type], flareType, reflection, LOScheck, drawStreak, someAngle, - longDist, nearDist); + useNearDist, nearDist); } void @@ -258,7 +271,10 @@ CCoronas::Render(void) CVector spriteCoors; float spritew, spriteh; - if(CSprite::CalcScreenCoors(aCoronas[i].coors, spriteCoors, &spritew, &spriteh, true)){ + if(!CSprite::CalcScreenCoors(aCoronas[i].coors, spriteCoors, &spritew, &spriteh, true)){ + aCoronas[i].offScreen = true; + aCoronas[i].sightClear = false; + }else{ aCoronas[i].offScreen = false; if(spriteCoors.x < 0.0f || spriteCoors.y < 0.0f || @@ -292,10 +308,7 @@ CCoronas::Render(void) } - if(aCoronas[i].fadeAlpha == 0) - continue; - - if(spriteCoors.z < aCoronas[i].drawDist){ + if(aCoronas[i].fadeAlpha && spriteCoors.z < aCoronas[i].drawDist){ float recipz = 1.0f/spriteCoors.z; float fadeDistance = aCoronas[i].drawDist / 2.0f; float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance; @@ -312,7 +325,7 @@ CCoronas::Render(void) if(CCoronas::aCoronas[i].id == SUN_CORE) spriteCoors.z = 0.95f * RwCameraGetFarClipPlane(Scene.camera); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(aCoronas[i].texture)); - spriteCoors.z -= 1.5f; + spriteCoors.z -= aCoronas[i].nearDist; if(aCoronas[i].texture == gpCoronaTexture[8]){ // what's this? @@ -370,14 +383,11 @@ CCoronas::Render(void) recipz, 255); } } - }else{ - aCoronas[i].offScreen = true; - aCoronas[i].sightClear = false; } } } - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); @@ -393,23 +403,24 @@ CCoronas::Render(void) if(!aCoronas[i].hasValue[j] || !aCoronas[i].hasValue[j+1]) continue; - int mod1 = (float)(6 - j) / 6 * 128; - int mod2 = (float)(6 - (j+1)) / 6 * 128; + int alpha1 = (float)(6 - j) / 6 * 128; + int alpha2 = (float)(6 - (j+1)) / 6 * 128; RwIm2DVertexSetScreenX(&vertexbufferX[0], aCoronas[i].prevX[j]); RwIm2DVertexSetScreenY(&vertexbufferX[0], aCoronas[i].prevY[j]); - RwIm2DVertexSetIntRGBA(&vertexbufferX[0], aCoronas[i].prevRed[j] * mod1 / 256, aCoronas[i].prevGreen[j] * mod1 / 256, aCoronas[i].prevBlue[j] * mod1 / 256, 255); + RwIm2DVertexSetIntRGBA(&vertexbufferX[0], aCoronas[i].prevRed[j] * alpha1 / 256, aCoronas[i].prevGreen[j] * alpha1 / 256, aCoronas[i].prevBlue[j] * alpha1 / 256, 255); RwIm2DVertexSetScreenX(&vertexbufferX[1], aCoronas[i].prevX[j+1]); RwIm2DVertexSetScreenY(&vertexbufferX[1], aCoronas[i].prevY[j+1]); - RwIm2DVertexSetIntRGBA(&vertexbufferX[1], aCoronas[i].prevRed[j+1] * mod2 / 256, aCoronas[i].prevGreen[j+1] * mod2 / 256, aCoronas[i].prevBlue[j+1] * mod2 / 256, 255); + RwIm2DVertexSetIntRGBA(&vertexbufferX[1], aCoronas[i].prevRed[j+1] * alpha2 / 256, aCoronas[i].prevGreen[j+1] * alpha2 / 256, aCoronas[i].prevBlue[j+1] * alpha2 / 256, 255); - // BUG: game doesn't do this +#ifdef FIX_BUGS RwIm2DVertexSetScreenZ(&vertexbufferX[0], RwIm2DGetNearScreenZ()); RwIm2DVertexSetCameraZ(&vertexbufferX[0], RwCameraGetNearClipPlane(Scene.camera)); RwIm2DVertexSetRecipCameraZ(&vertexbufferX[0], 1.0f/RwCameraGetNearClipPlane(Scene.camera)); RwIm2DVertexSetScreenZ(&vertexbufferX[1], RwIm2DGetNearScreenZ()); RwIm2DVertexSetCameraZ(&vertexbufferX[1], RwCameraGetNearClipPlane(Scene.camera)); RwIm2DVertexSetRecipCameraZ(&vertexbufferX[1], 1.0f/RwCameraGetNearClipPlane(Scene.camera)); +#endif RwIm2DRenderLine(vertexbufferX, 2, 0, 1); } @@ -428,6 +439,8 @@ CCoronas::RenderReflections(void) CEntity *entity; if(CWeather::WetRoads > 0.0f){ + CSprite::InitSpriteBuffer(); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); @@ -438,7 +451,8 @@ CCoronas::RenderReflections(void) for(i = 0; i < NUMCORONAS; i++){ if(aCoronas[i].id == 0 || - aCoronas[i].fadeAlpha == 0 && aCoronas[i].alpha == 0) + aCoronas[i].fadeAlpha == 0 && aCoronas[i].alpha == 0 || + aCoronas[i].reflection == 0) continue; // check if we want a reflection on this corona @@ -453,11 +467,8 @@ CCoronas::RenderReflections(void) } } - if(!aCoronas[i].renderReflection) - continue; - // Don't draw if reflection is too high - if(aCoronas[i].heightAboveRoad < 20.0f){ + if(aCoronas[i].renderReflection && aCoronas[i].heightAboveRoad < 20.0f){ // don't draw if camera is below road if(CCoronas::aCoronas[i].coors.z - aCoronas[i].heightAboveRoad > TheCamera.GetPosition().z) continue; @@ -469,13 +480,14 @@ CCoronas::RenderReflections(void) float spritew, spriteh; if(CSprite::CalcScreenCoors(coors, spriteCoors, &spritew, &spriteh, true)){ float drawDist = 0.75f * aCoronas[i].drawDist; - drawDist = Min(drawDist, 50.0f); + drawDist = Min(drawDist, 55.0f); if(spriteCoors.z < drawDist){ float fadeDistance = drawDist / 2.0f; float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance; distanceFade = clamp(distanceFade, 0.0f, 1.0f); float recipz = 1.0f/RwCameraGetNearClipPlane(Scene.camera); - int intensity = (20.0f - aCoronas[i].heightAboveRoad) * 230.0 * distanceFade*CWeather::WetRoads * 0.05f; + float heightFade = (20.0f - aCoronas[i].heightAboveRoad)/20.0f; + int intensity = distanceFade*heightFade * 230.0 * CWeather::WetRoads; CSprite::RenderBufferedOneXLUSprite( spriteCoors.x, spriteCoors.y, RwIm2DGetNearScreenZ(), @@ -504,6 +516,130 @@ CCoronas::RenderReflections(void) } } +void +CCoronas::RenderSunReflection(void) +{ + float sunZDir = CTimeCycle::GetSunDirection().z; + if(sunZDir > -0.05f){ + float intensity = (0.3f - Abs(sunZDir - 0.25f))/0.3f * + (1.0f - CWeather::CloudCoverage) * + (1.0f - CWeather::Foggyness) * + (1.0f - CWeather::Wind); + if(intensity > 0.0f){ + int r = (CTimeCycle::GetSunCoreRed() + CTimeCycle::GetSunCoronaRed())*intensity*0.25f; + int g = (CTimeCycle::GetSunCoreGreen() + CTimeCycle::GetSunCoronaGreen())*intensity*0.25f; + int b = (CTimeCycle::GetSunCoreBlue() + CTimeCycle::GetSunCoronaBlue())*intensity*0.25f; + + CVector sunPos = 40.0f*CTimeCycle::GetSunDirection() + TheCamera.GetPosition(); + sunPos.z = 0.5f*CWeather::Wind + 6.1f; + CVector sunDir = CTimeCycle::GetSunDirection(); + sunDir.z = 0.0; + sunDir.Normalise(); + + TempBufferIndicesStored = 6; + TempBufferRenderIndexList[0] = 2; + TempBufferRenderIndexList[1] = 1; + TempBufferRenderIndexList[2] = 0; + TempBufferRenderIndexList[3] = 2; + TempBufferRenderIndexList[4] = 3; + TempBufferRenderIndexList[5] = 1; + + // 60 unit square in sun direction + TempBufferVerticesStored = 4; + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[0], r, g, b, 255); + RwIm3DVertexSetPos(&TempBufferRenderVertices[0], + sunPos.x + 30.0f*sunDir.y, + sunPos.y - 30.0f*sunDir.x, + sunPos.z); + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[1], r, g, b, 255); + RwIm3DVertexSetPos(&TempBufferRenderVertices[1], + sunPos.x - 30.0f*sunDir.y, + sunPos.y + 30.0f*sunDir.x, + sunPos.z); + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[2], r, g, b, 255); + RwIm3DVertexSetPos(&TempBufferRenderVertices[2], + sunPos.x + 60.0f*sunDir.x + 30.0f*sunDir.y, + sunPos.y + 60.0f*sunDir.y - 30.0f*sunDir.x, + sunPos.z); + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[3], r, g, b, 255); + RwIm3DVertexSetPos(&TempBufferRenderVertices[3], + sunPos.x + 60.0f*sunDir.x - 30.0f*sunDir.y, + sunPos.y + 60.0f*sunDir.y + 30.0f*sunDir.x, + sunPos.z); + + RwIm3DVertexSetU(&TempBufferRenderVertices[0], 0.0f); + RwIm3DVertexSetV(&TempBufferRenderVertices[0], 1.0f); + RwIm3DVertexSetU(&TempBufferRenderVertices[1], 1.0f); + RwIm3DVertexSetV(&TempBufferRenderVertices[1], 1.0f); + RwIm3DVertexSetU(&TempBufferRenderVertices[2], 0.0f); + RwIm3DVertexSetV(&TempBufferRenderVertices[2], 0.5f); + RwIm3DVertexSetU(&TempBufferRenderVertices[3], 1.0f); + RwIm3DVertexSetV(&TempBufferRenderVertices[3], 0.5f); + + int timeInc = 0; + int sideInc = 0; + int fwdInc = 0; + for(int i = 0; i < 20; i++){ + TempBufferRenderIndexList[TempBufferIndicesStored + 0] = TempBufferVerticesStored; + TempBufferRenderIndexList[TempBufferIndicesStored + 1] = TempBufferVerticesStored-1; + TempBufferRenderIndexList[TempBufferIndicesStored + 2] = TempBufferVerticesStored-2; + TempBufferRenderIndexList[TempBufferIndicesStored + 3] = TempBufferVerticesStored; + TempBufferRenderIndexList[TempBufferIndicesStored + 4] = TempBufferVerticesStored+1; + TempBufferRenderIndexList[TempBufferIndicesStored + 5] = TempBufferVerticesStored-1; + TempBufferIndicesStored += 6; + + // What a weird way to do it... + float fwdLen = fwdInc/20 + 60; + float sideLen = sideInc/20 + 30; + sideLen += 10.0f*Sin((float)(CTimer::GetTimeInMilliseconds()+timeInc & 0x7FF)/0x800*TWOPI); + timeInc += 900; + sideInc += 970; + fwdInc += 1440; + + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored+0], r, g, b, 255); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored+0], + sunPos.x + fwdLen*sunDir.x + sideLen*sunDir.y, + sunPos.y + fwdLen*sunDir.y - sideLen*sunDir.x, + sunPos.z); + + RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored+1], r, g, b, 255); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored+1], + sunPos.x + fwdLen*sunDir.x - sideLen*sunDir.x, + sunPos.y + fwdLen*sunDir.y + sideLen*sunDir.y, + sunPos.z); + + RwIm3DVertexSetU(&TempBufferRenderVertices[TempBufferVerticesStored+0], 0.0f); + RwIm3DVertexSetV(&TempBufferRenderVertices[TempBufferVerticesStored+0], 0.5f); + RwIm3DVertexSetU(&TempBufferRenderVertices[TempBufferVerticesStored+1], 1.0f); + RwIm3DVertexSetV(&TempBufferRenderVertices[TempBufferVerticesStored+1], 0.5f); + TempBufferVerticesStored += 2; + } + + + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEFOGTYPE, (void*)rwFOGTYPELINEAR); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[4])); + if(RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){ + RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored); + RwIm3DEnd(); + } + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + TempBufferVerticesStored = 0; + TempBufferIndicesStored = 0; + } + } +} + void CCoronas::DoSunAndMoon(void) { @@ -520,7 +656,7 @@ CCoronas::DoSunAndMoon(void) 255, sunCoors, size, 999999.88f, TYPE_STAR, FLARE_NONE, REFLECTION_OFF, LOSCHECK_OFF, STREAK_OFF, 0.0f); - if(CTimeCycle::GetSunDirection().z > 0.0f) + if(CTimeCycle::GetSunDirection().z > 0.0f && !CGame::IsInInterior()) RegisterCorona(SUN_CORONA, CTimeCycle::GetSunCoronaRed(), CTimeCycle::GetSunCoronaGreen(), CTimeCycle::GetSunCoronaBlue(), 255, sunCoors, 25.0f * CTimeCycle::GetSunSize(), diff --git a/src/render/Coronas.h b/src/render/Coronas.h index cb4e8583..45f027d8 100644 --- a/src/render/Coronas.h +++ b/src/render/Coronas.h @@ -4,19 +4,21 @@ extern RwTexture *gpCoronaTexture[9]; struct CRegisteredCorona { + CVector coors; uint32 id; uint32 lastLOScheck; RwTexture *texture; + float size; + float someAngle; + float drawDist; + float nearDist; + float heightAboveRoad; uint8 red; uint8 green; uint8 blue; uint8 alpha; // alpha when fully visible uint8 fadeAlpha; // actual value used for rendering, faded - CVector coors; - float size; - float someAngle; bool registeredThisFrame; - float drawDist; int8 flareType; int8 reflection; @@ -25,12 +27,11 @@ struct CRegisteredCorona uint8 firstUpdate : 1; uint8 drawStreak : 1; uint8 sightClear : 1; + uint8 useNearDist : 1; + uint8 renderReflection : 1; - bool renderReflection; - float heightAboveRoad; - - float prevX[6]; - float prevY[6]; + int16 prevX[6]; + int16 prevY[6]; uint8 prevRed[6]; uint8 prevGreen[6]; uint8 prevBlue[6]; @@ -39,7 +40,7 @@ struct CRegisteredCorona void Update(void); }; -VALIDATE_SIZE(CRegisteredCorona, 0x80); +VALIDATE_SIZE(CRegisteredCorona, 0x68); class CCoronas { @@ -91,13 +92,14 @@ public: static void RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, RwTexture *tex, int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, - bool longDist = false, float nearClip = 1.5f); + bool useNearDist = false, float nearDist = 1.5f); static void RegisterCorona(uint32 id, uint8 red, uint8 green, uint8 blue, uint8 alpha, const CVector &coors, float size, float drawDist, uint8 type, int8 flareType, uint8 reflection, uint8 LOScheck, uint8 drawStreak, float someAngle, - bool longDist = false, float nearClip = 1.5f); + bool useNearDist = false, float nearDist = 1.5f); static void UpdateCoronaCoors(uint32 id, const CVector &coors, float drawDist, float someAngle); static void Render(void); static void RenderReflections(void); + static void RenderSunReflection(void); static void DoSunAndMoon(void); }; -- cgit v1.2.3 From 6514bc6b39faf5cfd6ecb1d45370e2c9c50e8f43 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 9 Aug 2020 15:45:38 +0200 Subject: pointlights done --- src/render/Fluff.cpp | 5 +++- src/render/PointLights.cpp | 68 +++++++++++++++++++++++++++++++++++++--------- src/render/PointLights.h | 5 ++++ 3 files changed, 64 insertions(+), 14 deletions(-) (limited to 'src/render') diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 5d8ccf47..14c80a63 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -7,6 +7,7 @@ #include "Camera.h" #include "Sprite.h" #include "Coronas.h" +#include "PointLights.h" #include "Rubbish.h" #include "Timecycle.h" #include "General.h" @@ -391,7 +392,7 @@ void CMovingThings::Init() CPlaneTrails::Init(); CSmokeTrails::Init(); CPlaneBanners::Init(); - CEscalators::Init(); + CPointLights::Init(); StartCloseList.m_pNext = &CMovingThings::EndCloseList; StartCloseList.m_pPrev = nil; @@ -399,6 +400,8 @@ void CMovingThings::Init() EndCloseList.m_pPrev = &CMovingThings::StartCloseList; Num = 0; + CEscalators::Init(); + #ifndef MIAMI // something is still used here actually // Initialize scroll bars aScrollBars[0].Init(CVector( 228.3f, -669.0f, 39.0f ), SCROLL_BUSINESS, 0.0f, 0.5f, 0.5f, 255, 128, 0, 0.3f); diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index 88b9aaea..b09b07bd 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -1,6 +1,7 @@ #include "common.h" #include "main.h" +#include "CutsceneMgr.h" #include "Lights.h" #include "Camera.h" #include "Weather.h" @@ -10,8 +11,23 @@ #include "Timer.h" #include "PointLights.h" +//--MIAMI: file done + int16 CPointLights::NumLights; CRegisteredPointLight CPointLights::aLights[NUMPOINTLIGHTS]; +CVector CPointLights::aCachedMapReads[32]; +float CPointLights::aCachedMapReadResults[32]; +int32 CPointLights::NextCachedValue; + +void +CPointLights::Init(void) +{ + for(int i = 0; i < ARRAY_SIZE(aCachedMapReads); i++){ + aCachedMapReads[i] = CVector(0.0f, 0.0f, 0.0f); + aCachedMapReadResults[i] = 0.0f; + } + NextCachedValue = 0; +} void CPointLights::InitPerFrame(void) @@ -86,12 +102,11 @@ CPointLights::GenerateLightsAffectingObject(Const CVector *objCoors) ret *= distNorm; }else{ float intensity; + // distance fade if(distNorm < 0.5f) - // near enough intensity = 1.0f; else - // attenuate - intensity = 1.0f - (distNorm - 0.5f)*2.0f; + intensity = 1.0f - (distNorm - 0.5f)/(1.0f - 0.5f); if(distance != 0.0f){ CVector dir = dist / distance; @@ -143,17 +158,22 @@ CPointLights::RenderFogEffect(void) CVector spriteCoors; float spritew, spriteh; + if(CCutsceneMgr::IsRunning()) + return; + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpPointlightRaster); + CSprite::InitSpriteBuffer(); + for(i = 0; i < NumLights; i++){ if(aLights[i].fogType != FOG_NORMAL && aLights[i].fogType != FOG_ALWAYS) continue; - fogginess = aLights[i].fogType == FOG_ALWAYS ? 1.0f : CWeather::Foggyness; + fogginess = aLights[i].fogType == FOG_NORMAL ? CWeather::Foggyness : 1.0f; if(fogginess == 0.0f) continue; @@ -198,7 +218,7 @@ CPointLights::RenderFogEffect(void) float distsq = sq(dx) + sq(dy); float linedistsq = distsq - sq(dot); if(dot > 0.0f && dot < FOG_AREA_LENGTH && linedistsq < sq(FOG_AREA_WIDTH)){ - CVector fogcoors(xi, yi, aLights[i].coors.z + 1.0f); + CVector fogcoors(xi, yi, aLights[i].coors.z + 10.0f); if(CWorld::ProcessVerticalLine(fogcoors, fogcoors.z - 20.0f, point, entity, true, false, false, false, true, false, nil)){ // Now same check again in xyz @@ -220,9 +240,9 @@ CPointLights::RenderFogEffect(void) intensity *= 1.0f - sq(Sqrt(linedistsq) / FOG_AREA_WIDTH); if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){ - float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x1FFF; + float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x2000; float size = FogSizes[r>>1]; - CSprite::RenderOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z, + CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * size, spriteh * size, aLights[i].red * intensity, aLights[i].green * intensity, aLights[i].blue * intensity, intensity, 1/spriteCoors.z, rotation, 255); @@ -234,9 +254,8 @@ CPointLights::RenderFogEffect(void) } }else if(aLights[i].type == LIGHT_POINT || aLights[i].type == LIGHT_FOGONLY || aLights[i].type == LIGHT_FOGONLY_ALWAYS){ - if(CWorld::ProcessVerticalLine(aLights[i].coors, aLights[i].coors.z - 20.0f, - point, entity, true, false, false, false, true, false, nil)){ - + float groundZ; + if(ProcessVerticalLineUsingCache(aLights[i].coors, &groundZ)){ xmin = aLights[i].coors.x - FOG_AREA_RADIUS; ymin = aLights[i].coors.y - FOG_AREA_RADIUS; xmax = aLights[i].coors.x + FOG_AREA_RADIUS; @@ -267,11 +286,11 @@ CPointLights::RenderFogEffect(void) // more intensity the closer to light source intensity *= 1.0f - sq(lightdist / FOG_AREA_RADIUS); - CVector fogcoors(xi, yi, point.point.z + 1.6f); + CVector fogcoors(xi, yi, groundZ + 1.6f); if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){ - float rotation = (CTimer::GetTimeInMilliseconds()&0x3FFF) * 2*3.14f / 0x3FFF; + float rotation = (CTimer::GetTimeInMilliseconds()&0x3FFF) * 2*3.14f / 0x4000; float size = FogSizes[r>>1]; - CSprite::RenderOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z, + CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * size, spriteh * size, aLights[i].red * intensity, aLights[i].green * intensity, aLights[i].blue * intensity, intensity, 1/spriteCoors.z, rotation, 255); @@ -283,4 +302,27 @@ CPointLights::RenderFogEffect(void) } } } + + CSprite::FlushSpriteBuffer(); +} + +bool +CPointLights::ProcessVerticalLineUsingCache(CVector coors, float *groundZ) +{ + for(int i = 0; i < ARRAY_SIZE(aCachedMapReads); i++) + if(aCachedMapReads[i] == coors){ + *groundZ = aCachedMapReadResults[i]; + return true; + } + + CColPoint point; + CEntity *entity; + if(CWorld::ProcessVerticalLine(coors, coors.z - 20.0f, point, entity, true, false, false, false, true, false, nil)){ + aCachedMapReads[NextCachedValue] = coors; + aCachedMapReadResults[NextCachedValue] = point.point.z; + NextCachedValue = (NextCachedValue+1) % ARRAY_SIZE(aCachedMapReads); + *groundZ = point.point.z; + return true; + } + return false; } diff --git a/src/render/PointLights.h b/src/render/PointLights.h index 9e94328f..827200b9 100644 --- a/src/render/PointLights.h +++ b/src/render/PointLights.h @@ -20,6 +20,9 @@ class CPointLights public: static int16 NumLights; static CRegisteredPointLight aLights[NUMPOINTLIGHTS]; + static CVector aCachedMapReads[32]; + static float aCachedMapReadResults[32]; + static int32 NextCachedValue; enum { LIGHT_POINT, @@ -37,9 +40,11 @@ public: FOG_ALWAYS }; + static void Init(void); static void InitPerFrame(void); static void AddLight(uint8 type, CVector coors, CVector dir, float radius, float red, float green, float blue, uint8 fogType, bool castExtraShadows); static float GenerateLightsAffectingObject(Const CVector *objCoors); static void RemoveLightsAffectingObject(void); static void RenderFogEffect(void); + static bool ProcessVerticalLineUsingCache(CVector coors, float *groundZ); }; -- cgit v1.2.3 From 0bb46f3f8c3db1d378a2f7f87de1519576e26d1d Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 9 Aug 2020 16:49:15 +0200 Subject: rubbish done --- src/render/Antennas.cpp | 2 ++ src/render/Rubbish.cpp | 67 +++++++++++++++++++++---------------------------- 2 files changed, 30 insertions(+), 39 deletions(-) (limited to 'src/render') diff --git a/src/render/Antennas.cpp b/src/render/Antennas.cpp index 452069a0..b9da95cb 100644 --- a/src/render/Antennas.cpp +++ b/src/render/Antennas.cpp @@ -2,6 +2,8 @@ #include "Antennas.h" +//--MIAMI: file done + CAntenna CAntennas::aAntennas[NUMANTENNAS]; void diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp index bfd50c07..dada2439 100644 --- a/src/render/Rubbish.cpp +++ b/src/render/Rubbish.cpp @@ -8,17 +8,18 @@ #include "World.h" #include "Vehicle.h" #include "ZoneCull.h" +#include "Stats.h" #include "TxdStore.h" #include "RenderBuffer.h" #include "Rubbish.h" -#define RUBBISH_MAX_DIST (18.0f) -#define RUBBISH_FADE_DIST (16.5f) +//--MIAMI: file done + +#define RUBBISH_MAX_DIST (23.0f) +#define RUBBISH_FADE_DIST (20.0f) RwTexture *gpRubbishTexture[4]; RwImVertexIndex RubbishIndexList[6]; -RwImVertexIndex RubbishIndexList2[6]; // unused -RwIm3DVertex RubbishVertices[4]; bool CRubbish::bRubbishInvisible; int CRubbish::RubbishVisibility; COneSheet CRubbish::aSheets[NUM_RUBBISH_SHEETS]; @@ -52,12 +53,16 @@ CRubbish::Render(void) { int type; + if(RubbishVisibility == 0) + return; + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); for(type = 0; type < 4; type++){ - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRubbishTexture[type])); + if(type < 3 || CStats::PamphletMissionPassed) + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRubbishTexture[type])); TempBufferIndicesStored = 0; TempBufferVerticesStored = 0; @@ -69,7 +74,7 @@ CRubbish::Render(void) if(sheet->m_state == 0) continue; - uint32 alpha = 128; + uint32 alpha = 100; CVector pos; if(sheet->m_state == 1){ pos = sheet->m_basePos; @@ -82,7 +87,7 @@ CRubbish::Render(void) float t = (float)(CTimer::GetTimeInMilliseconds() - sheet->m_moveStart)/sheet->m_moveDuration; float f1 = sheet->m_isVisible ? 1.0f-t : 0.0f; float f2 = sheet->m_targetIsVisible ? t : 0.0f; - alpha = 128 * (f1+f2); + alpha = 100 * (f1+f2); } } @@ -92,17 +97,27 @@ CRubbish::Render(void) alpha -= alpha*(camDist-RUBBISH_FADE_DIST)/(RUBBISH_MAX_DIST-RUBBISH_FADE_DIST); alpha = (RubbishVisibility*alpha)/256; - float vx = Sin(sheet->m_angle) * 0.4f; - float vy = Cos(sheet->m_angle) * 0.4f; + float vx1, vy1, vx2, vy2; + if(type == 0 || type == 1){ + vx1 = 0.9f*Sin(sheet->m_angle); + vy1 = 0.9f*Cos(sheet->m_angle); + vx2 = 0.3f*Cos(sheet->m_angle); + vy2 = -0.3f*Sin(sheet->m_angle); + }else{ + vx1 = 0.3f*Sin(sheet->m_angle); + vy1 = 0.3f*Cos(sheet->m_angle); + vx2 = 0.3f*Cos(sheet->m_angle); + vy2 = -0.3f*Sin(sheet->m_angle); + } int v = TempBufferVerticesStored; - RwIm3DVertexSetPos(&TempBufferRenderVertices[v+0], pos.x + vx, pos.y + vy, pos.z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[v+0], pos.x + vx1 + vx2, pos.y + vy1 + vy2, pos.z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[v+1], pos.x + vx1 - vx2, pos.y + vy1 - vy2, pos.z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[v+2], pos.x - vx1 + vx2, pos.y - vy1 + vy2, pos.z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[v+3], pos.x - vx1 - vx2, pos.y - vy1 - vy2, pos.z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[v+0], 255, 255, 255, alpha); - RwIm3DVertexSetPos(&TempBufferRenderVertices[v+1], pos.x - vy, pos.y + vx, pos.z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[v+1], 255, 255, 255, alpha); - RwIm3DVertexSetPos(&TempBufferRenderVertices[v+2], pos.x + vy, pos.y - vx, pos.z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[v+2], 255, 255, 255, alpha); - RwIm3DVertexSetPos(&TempBufferRenderVertices[v+3], pos.x - vx, pos.y - vy, pos.z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[v+3], 255, 255, 255, alpha); RwIm3DVertexSetU(&TempBufferRenderVertices[v+0], 0.0f); RwIm3DVertexSetV(&TempBufferRenderVertices[v+0], 0.0f); @@ -373,24 +388,6 @@ CRubbish::Init(void) EndMoversList.m_next = nil; EndMoversList.m_prev = &StartMoversList; - // unused - RwIm3DVertexSetU(&RubbishVertices[0], 0.0f); - RwIm3DVertexSetV(&RubbishVertices[0], 0.0f); - RwIm3DVertexSetU(&RubbishVertices[1], 1.0f); - RwIm3DVertexSetV(&RubbishVertices[1], 0.0f); - RwIm3DVertexSetU(&RubbishVertices[2], 0.0f); - RwIm3DVertexSetV(&RubbishVertices[2], 1.0f); - RwIm3DVertexSetU(&RubbishVertices[3], 1.0f); - RwIm3DVertexSetV(&RubbishVertices[3], 1.0f); - - // unused - RubbishIndexList2[0] = 0; - RubbishIndexList2[1] = 2; - RubbishIndexList2[2] = 1; - RubbishIndexList2[3] = 1; - RubbishIndexList2[4] = 2; - RubbishIndexList2[5] = 3; - RubbishIndexList[0] = 0; RubbishIndexList[1] = 1; RubbishIndexList[2] = 2; @@ -414,19 +411,11 @@ void CRubbish::Shutdown(void) { RwTextureDestroy(gpRubbishTexture[0]); -#ifdef GTA3_1_1_PATCH gpRubbishTexture[0] = nil; -#endif RwTextureDestroy(gpRubbishTexture[1]); -#ifdef GTA3_1_1_PATCH gpRubbishTexture[1] = nil; -#endif RwTextureDestroy(gpRubbishTexture[2]); -#ifdef GTA3_1_1_PATCH gpRubbishTexture[2] = nil; -#endif RwTextureDestroy(gpRubbishTexture[3]); -#ifdef GTA3_1_1_PATCH gpRubbishTexture[3] = nil; -#endif } -- cgit v1.2.3 From 4118d2aa5552223c02ff094e7d4e9f103daaac94 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 9 Aug 2020 17:14:24 +0200 Subject: finished skidmarks --- src/render/Skidmarks.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/render') diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp index efd88387..f2a66db1 100644 --- a/src/render/Skidmarks.cpp +++ b/src/render/Skidmarks.cpp @@ -6,6 +6,8 @@ #include "Replay.h" #include "Skidmarks.h" +//--MIAMI: file done + CSkidmark CSkidmarks::aSkidmarks[NUMSKIDMARKS]; RwImVertexIndex SkidmarkIndexList[SKIDMARK_LENGTH * 6]; @@ -37,13 +39,6 @@ CSkidmarks::Init(void) SkidmarkIndexList[i*6+5] = ix+3; ix += 2; } - - for(i = 0; i < SKIDMARK_LENGTH; i++){ - RwIm3DVertexSetU(&SkidmarkVertices[i*2 + 0], 0.0f); - RwIm3DVertexSetV(&SkidmarkVertices[i*2 + 0], i*5.01f); - RwIm3DVertexSetU(&SkidmarkVertices[i*2 + 1], 1.0f); - RwIm3DVertexSetV(&SkidmarkVertices[i*2 + 1], i*5.01f); - } } void @@ -141,8 +136,12 @@ CSkidmarks::Render(void) p2.y -= aSkidmarks[i].m_sideY[j]; RwIm3DVertexSetRGBA(&SkidmarkVertices[j*2+0], color.red, color.green, color.blue, alpha); RwIm3DVertexSetPos(&SkidmarkVertices[j*2+0], p1.x, p1.y, p1.z+0.1f); + RwIm3DVertexSetU(&SkidmarkVertices[j*2+0], 0.0f); + RwIm3DVertexSetV(&SkidmarkVertices[j*2+0], j*5.01f); RwIm3DVertexSetRGBA(&SkidmarkVertices[j*2+1], color.red, color.green, color.blue, alpha); RwIm3DVertexSetPos(&SkidmarkVertices[j*2+1], p2.x, p2.y, p2.z+0.1f); + RwIm3DVertexSetU(&SkidmarkVertices[j*2+1], 1.0f); + RwIm3DVertexSetV(&SkidmarkVertices[j*2+1], j*5.01f); } LittleTest(); -- cgit v1.2.3 From 43bf8543741e6c153cb8ddc9fc5f1594b332e9d8 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 9 Aug 2020 19:11:44 +0200 Subject: timecycle done --- src/render/Timecycle.cpp | 325 +++++++++++++++++++++++++++++++++-------------- src/render/Timecycle.h | 238 +++++++++++++++++----------------- src/render/Weather.h | 4 +- 3 files changed, 353 insertions(+), 214 deletions(-) (limited to 'src/render') diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index fe898412..7e8ad5e5 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -10,60 +10,60 @@ #include "FileMgr.h" #include "Timecycle.h" -// TODO(MIAMI): change some of the types here - -int CTimeCycle::m_nAmbientRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientRed_Obj[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientGreen_Obj[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientBlue_Obj[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientRed_Bl[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientGreen_Bl[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientBlue_Bl[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientRed_Obj_Bl[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientGreen_Obj_Bl[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nAmbientBlue_Obj_Bl[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nDirectionalRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nDirectionalGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nDirectionalBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSkyTopRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSkyTopGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSkyTopBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSkyBottomRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSkyBottomGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSkyBottomBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSunCoreRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSunCoreGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSunCoreBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSunCoronaRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSunCoronaGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nSunCoronaBlue[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fSunSize[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fSpriteSize[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fSpriteBrightness[NUMHOURS][NUMWEATHERS]; -short CTimeCycle::m_nShadowStrength[NUMHOURS][NUMWEATHERS]; -short CTimeCycle::m_nLightShadowStrength[NUMHOURS][NUMWEATHERS]; -short CTimeCycle::m_nPoleShadowStrength[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fFogStart[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fFarClip[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fLightsOnGroundBrightness[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nLowCloudsRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nLowCloudsGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nLowCloudsBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nFluffyCloudsTopRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nFluffyCloudsTopGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nFluffyCloudsTopBlue[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nFluffyCloudsBottomRed[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nFluffyCloudsBottomGreen[NUMHOURS][NUMWEATHERS]; -int CTimeCycle::m_nFluffyCloudsBottomBlue[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fBlurRed[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fBlurGreen[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fBlurBlue[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fWaterRed[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fWaterGreen[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fWaterBlue[NUMHOURS][NUMWEATHERS]; -float CTimeCycle::m_fWaterAlpha[NUMHOURS][NUMWEATHERS]; +//--MIAMI: done + +uint8 CTimeCycle::m_nAmbientRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientRed_Obj[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientGreen_Obj[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientBlue_Obj[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientRed_Bl[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientGreen_Bl[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientBlue_Bl[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientRed_Obj_Bl[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientGreen_Obj_Bl[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nAmbientBlue_Obj_Bl[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nDirectionalRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nDirectionalGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nDirectionalBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSkyTopRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSkyTopGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSkyTopBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSkyBottomRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSkyBottomGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSkyBottomBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSunCoreRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSunCoreGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSunCoreBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSunCoronaRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSunCoronaGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nSunCoronaBlue[NUMHOURS][NUMWEATHERS]; +int8 CTimeCycle::m_fSunSize[NUMHOURS][NUMWEATHERS]; +int8 CTimeCycle::m_fSpriteSize[NUMHOURS][NUMWEATHERS]; +int8 CTimeCycle::m_fSpriteBrightness[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nShadowStrength[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nLightShadowStrength[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nPoleShadowStrength[NUMHOURS][NUMWEATHERS]; +int16 CTimeCycle::m_fFogStart[NUMHOURS][NUMWEATHERS]; +int16 CTimeCycle::m_fFarClip[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fLightsOnGroundBrightness[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nLowCloudsRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nLowCloudsGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nLowCloudsBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nFluffyCloudsTopRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nFluffyCloudsTopGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nFluffyCloudsTopBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nFluffyCloudsBottomRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nFluffyCloudsBottomGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_nFluffyCloudsBottomBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fBlurRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fBlurGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fBlurBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fWaterRed[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fWaterGreen[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fWaterBlue[NUMHOURS][NUMWEATHERS]; +uint8 CTimeCycle::m_fWaterAlpha[NUMHOURS][NUMWEATHERS]; float CTimeCycle::m_fCurrentAmbientRed; @@ -81,36 +81,36 @@ float CTimeCycle::m_fCurrentAmbientBlue_Obj_Bl; float CTimeCycle::m_fCurrentDirectionalRed; float CTimeCycle::m_fCurrentDirectionalGreen; float CTimeCycle::m_fCurrentDirectionalBlue; -int CTimeCycle::m_nCurrentSkyTopRed; -int CTimeCycle::m_nCurrentSkyTopGreen; -int CTimeCycle::m_nCurrentSkyTopBlue; -int CTimeCycle::m_nCurrentSkyBottomRed; -int CTimeCycle::m_nCurrentSkyBottomGreen; -int CTimeCycle::m_nCurrentSkyBottomBlue; -int CTimeCycle::m_nCurrentSunCoreRed; -int CTimeCycle::m_nCurrentSunCoreGreen; -int CTimeCycle::m_nCurrentSunCoreBlue; -int CTimeCycle::m_nCurrentSunCoronaRed; -int CTimeCycle::m_nCurrentSunCoronaGreen; -int CTimeCycle::m_nCurrentSunCoronaBlue; +int32 CTimeCycle::m_nCurrentSkyTopRed; +int32 CTimeCycle::m_nCurrentSkyTopGreen; +int32 CTimeCycle::m_nCurrentSkyTopBlue; +int32 CTimeCycle::m_nCurrentSkyBottomRed; +int32 CTimeCycle::m_nCurrentSkyBottomGreen; +int32 CTimeCycle::m_nCurrentSkyBottomBlue; +int32 CTimeCycle::m_nCurrentSunCoreRed; +int32 CTimeCycle::m_nCurrentSunCoreGreen; +int32 CTimeCycle::m_nCurrentSunCoreBlue; +int32 CTimeCycle::m_nCurrentSunCoronaRed; +int32 CTimeCycle::m_nCurrentSunCoronaGreen; +int32 CTimeCycle::m_nCurrentSunCoronaBlue; float CTimeCycle::m_fCurrentSunSize; float CTimeCycle::m_fCurrentSpriteSize; float CTimeCycle::m_fCurrentSpriteBrightness; -int CTimeCycle::m_nCurrentShadowStrength; -int CTimeCycle::m_nCurrentLightShadowStrength; -int CTimeCycle::m_nCurrentPoleShadowStrength; +int32 CTimeCycle::m_nCurrentShadowStrength; +int32 CTimeCycle::m_nCurrentLightShadowStrength; +int32 CTimeCycle::m_nCurrentPoleShadowStrength; float CTimeCycle::m_fCurrentFogStart; float CTimeCycle::m_fCurrentFarClip; float CTimeCycle::m_fCurrentLightsOnGroundBrightness; -int CTimeCycle::m_nCurrentLowCloudsRed; -int CTimeCycle::m_nCurrentLowCloudsGreen; -int CTimeCycle::m_nCurrentLowCloudsBlue; -int CTimeCycle::m_nCurrentFluffyCloudsTopRed; -int CTimeCycle::m_nCurrentFluffyCloudsTopGreen; -int CTimeCycle::m_nCurrentFluffyCloudsTopBlue; -int CTimeCycle::m_nCurrentFluffyCloudsBottomRed; -int CTimeCycle::m_nCurrentFluffyCloudsBottomGreen; -int CTimeCycle::m_nCurrentFluffyCloudsBottomBlue; +int32 CTimeCycle::m_nCurrentLowCloudsRed; +int32 CTimeCycle::m_nCurrentLowCloudsGreen; +int32 CTimeCycle::m_nCurrentLowCloudsBlue; +int32 CTimeCycle::m_nCurrentFluffyCloudsTopRed; +int32 CTimeCycle::m_nCurrentFluffyCloudsTopGreen; +int32 CTimeCycle::m_nCurrentFluffyCloudsTopBlue; +int32 CTimeCycle::m_nCurrentFluffyCloudsBottomRed; +int32 CTimeCycle::m_nCurrentFluffyCloudsBottomGreen; +int32 CTimeCycle::m_nCurrentFluffyCloudsBottomBlue; float CTimeCycle::m_fCurrentBlurRed; float CTimeCycle::m_fCurrentBlurGreen; float CTimeCycle::m_fCurrentBlurBlue; @@ -118,13 +118,16 @@ float CTimeCycle::m_fCurrentWaterRed; float CTimeCycle::m_fCurrentWaterGreen; float CTimeCycle::m_fCurrentWaterBlue; float CTimeCycle::m_fCurrentWaterAlpha; -int CTimeCycle::m_nCurrentFogColourRed; -int CTimeCycle::m_nCurrentFogColourGreen; -int CTimeCycle::m_nCurrentFogColourBlue; +int32 CTimeCycle::m_nCurrentFogColourRed; +int32 CTimeCycle::m_nCurrentFogColourGreen; +int32 CTimeCycle::m_nCurrentFogColourBlue; -int CTimeCycle::m_FogReduction; +int32 CTimeCycle::m_FogReduction; +bool CTimeCycle::m_bExtraColourOn; +int32 CTimeCycle::m_ExtraColour; +float CTimeCycle::m_ExtraColourInter; -int CTimeCycle::m_CurrentStoredValue; +int32 CTimeCycle::m_CurrentStoredValue; CVector CTimeCycle::m_VectorToSun[16]; float CTimeCycle::m_fShadowFrontX[16]; float CTimeCycle::m_fShadowFrontY[16]; @@ -133,7 +136,6 @@ float CTimeCycle::m_fShadowSideY[16]; float CTimeCycle::m_fShadowDisplacementX[16]; float CTimeCycle::m_fShadowDisplacementY[16]; - void CTimeCycle::Initialise(void) { @@ -233,15 +235,15 @@ CTimeCycle::Initialise(void) m_nSunCoronaRed[h][w] = sunCoronaR; m_nSunCoronaGreen[h][w] = sunCoronaG; m_nSunCoronaBlue[h][w] = sunCoronaB; - m_fSunSize[h][w] = sunSz; - m_fSpriteSize[h][w] = sprSz; - m_fSpriteBrightness[h][w] = sprBght; + m_fSunSize[h][w] = sunSz * 10.0f; + m_fSpriteSize[h][w] = sprSz * 10.0f; + m_fSpriteBrightness[h][w] = sprBght * 10.0f; m_nShadowStrength[h][w] = shad; m_nLightShadowStrength[h][w] = lightShad; m_nPoleShadowStrength[h][w] = poleShad; m_fFarClip[h][w] = farClp; m_fFogStart[h][w] = fogSt; - m_fLightsOnGroundBrightness[h][w] = lightGnd; + m_fLightsOnGroundBrightness[h][w] = lightGnd * 10.0f; m_nLowCloudsRed[h][w] = cloudR; m_nLowCloudsGreen[h][w] = cloudG; m_nLowCloudsBlue[h][w] = cloudB; @@ -265,6 +267,51 @@ CTimeCycle::Initialise(void) debug("CTimeCycle ready\n"); } +static float interp_c0, interp_c1, interp_c2, interp_c3; + +float CTimeCycle::Interpolate(int8 *a, int8 *b) +{ + return a[CWeather::OldWeatherType] * interp_c0 + + b[CWeather::OldWeatherType] * interp_c1 + + a[CWeather::NewWeatherType] * interp_c2 + + b[CWeather::NewWeatherType] * interp_c3; +} + +float CTimeCycle::Interpolate(uint8 *a, uint8 *b) +{ + return a[CWeather::OldWeatherType] * interp_c0 + + b[CWeather::OldWeatherType] * interp_c1 + + a[CWeather::NewWeatherType] * interp_c2 + + b[CWeather::NewWeatherType] * interp_c3; +} + +float CTimeCycle::Interpolate(int16 *a, int16 *b) +{ + return a[CWeather::OldWeatherType] * interp_c0 + + b[CWeather::OldWeatherType] * interp_c1 + + a[CWeather::NewWeatherType] * interp_c2 + + b[CWeather::NewWeatherType] * interp_c3; +} + +void +CTimeCycle::StartExtraColour(int32 c, bool fade) +{ + m_bExtraColourOn = true; + m_ExtraColour = c; + if(fade) + m_ExtraColourInter = 0.0f; + else + m_ExtraColourInter = 1.0f; +} + +void +CTimeCycle::StopExtraColour(bool fade) +{ + m_bExtraColourOn = false; + if(!fade) + m_ExtraColourInter = 0.0f; +} + void CTimeCycle::Update(void) { @@ -274,12 +321,12 @@ CTimeCycle::Update(void) int w2 = CWeather::NewWeatherType; float timeInterp = (CClock::GetMinutes() + CClock::GetSeconds()/60.0f)/60.0f; // coefficients for a bilinear interpolation - float c0 = (1.0f-timeInterp) * (1.0f-CWeather::InterpolationValue); - float c1 = timeInterp * (1.0f-CWeather::InterpolationValue); - float c2 = (1.0f-timeInterp) * CWeather::InterpolationValue; - float c3 = timeInterp * CWeather::InterpolationValue; + interp_c0 = (1.0f-timeInterp) * (1.0f-CWeather::InterpolationValue); + interp_c1 = timeInterp * (1.0f-CWeather::InterpolationValue); + interp_c2 = (1.0f-timeInterp) * CWeather::InterpolationValue; + interp_c3 = timeInterp * CWeather::InterpolationValue; -#define INTERP(v) v[h1][w1]*c0 + v[h2][w1]*c1 + v[h1][w2]*c2 + v[h2][w2]*c3; +#define INTERP(v) Interpolate(v[h1], v[h2]) m_nCurrentSkyTopRed = INTERP(m_nSkyTopRed); m_nCurrentSkyTopGreen = INTERP(m_nSkyTopGreen); @@ -317,15 +364,15 @@ CTimeCycle::Update(void) m_nCurrentSunCoronaGreen = INTERP(m_nSunCoronaGreen); m_nCurrentSunCoronaBlue = INTERP(m_nSunCoronaBlue); - m_fCurrentSunSize = INTERP(m_fSunSize); - m_fCurrentSpriteSize = INTERP(m_fSpriteSize); - m_fCurrentSpriteBrightness = INTERP(m_fSpriteBrightness); + m_fCurrentSunSize = INTERP(m_fSunSize)/10.0f; + m_fCurrentSpriteSize = INTERP(m_fSpriteSize)/10.0f; + m_fCurrentSpriteBrightness = INTERP(m_fSpriteBrightness)/10.0f; m_nCurrentShadowStrength = INTERP(m_nShadowStrength); m_nCurrentLightShadowStrength = INTERP(m_nLightShadowStrength); m_nCurrentPoleShadowStrength = INTERP(m_nPoleShadowStrength); m_fCurrentFarClip = INTERP(m_fFarClip); m_fCurrentFogStart = INTERP(m_fFogStart); - m_fCurrentLightsOnGroundBrightness = INTERP(m_fLightsOnGroundBrightness); + m_fCurrentLightsOnGroundBrightness = INTERP(m_fLightsOnGroundBrightness)/10.0f; m_nCurrentLowCloudsRed = INTERP(m_nLowCloudsRed); m_nCurrentLowCloudsGreen = INTERP(m_nLowCloudsGreen); @@ -347,6 +394,7 @@ CTimeCycle::Update(void) m_fCurrentWaterGreen = INTERP(m_fWaterGreen); m_fCurrentWaterBlue = INTERP(m_fWaterBlue); m_fCurrentWaterAlpha = INTERP(m_fWaterAlpha); +#undef INTERP if(m_FogReduction != 0) m_fCurrentFarClip = Max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f); @@ -360,7 +408,88 @@ CTimeCycle::Update(void) sunPos.z = 0.2f - Cos(sunAngle); sunPos.Normalise(); - // TODO(MIAMI): extra colours + if(m_bExtraColourOn) + m_ExtraColourInter = Min(1.0f, m_ExtraColourInter + CTimer::GetTimeStep()/120.0f); + else + m_ExtraColourInter = Max(-.0f, m_ExtraColourInter - CTimer::GetTimeStep()/120.0f); + if(m_ExtraColourInter > 0.0f){ +#define INTERP(extra,cur) (m_ExtraColourInter*extra[m_ExtraColour][WEATHER_EXTRACOLOURS] + (1.0f-m_ExtraColourInter)*cur) +#define INTERPscl(extra,scl,cur) (m_ExtraColourInter*extra[m_ExtraColour][WEATHER_EXTRACOLOURS]/scl + (1.0f-m_ExtraColourInter)*cur) + if(m_nSkyTopRed[m_ExtraColour][WEATHER_EXTRACOLOURS] != 0 || + m_nSkyTopGreen[m_ExtraColour][WEATHER_EXTRACOLOURS] != 0 || + m_nSkyTopBlue[m_ExtraColour][WEATHER_EXTRACOLOURS] != 0){ + m_nCurrentSkyTopRed = INTERP(m_nSkyTopRed,m_nCurrentSkyTopRed); + m_nCurrentSkyTopGreen = INTERP(m_nSkyTopGreen,m_nCurrentSkyTopGreen); + m_nCurrentSkyTopBlue = INTERP(m_nSkyTopBlue,m_nCurrentSkyTopBlue); + + m_nCurrentSkyBottomRed = INTERP(m_nSkyBottomRed,m_nCurrentSkyBottomRed); + m_nCurrentSkyBottomGreen = INTERP(m_nSkyBottomGreen,m_nCurrentSkyBottomGreen); + m_nCurrentSkyBottomBlue = INTERP(m_nSkyBottomBlue,m_nCurrentSkyBottomBlue); + + m_nCurrentSunCoreRed = INTERP(m_nSunCoreRed,m_nCurrentSunCoreRed); + m_nCurrentSunCoreGreen = INTERP(m_nSunCoreGreen,m_nCurrentSunCoreGreen); + m_nCurrentSunCoreBlue = INTERP(m_nSunCoreBlue,m_nCurrentSunCoreBlue); + + m_nCurrentSunCoronaRed = INTERP(m_nSunCoronaRed,m_nCurrentSunCoronaRed); + m_nCurrentSunCoronaGreen = INTERP(m_nSunCoronaGreen,m_nCurrentSunCoronaGreen); + m_nCurrentSunCoronaBlue = INTERP(m_nSunCoronaBlue,m_nCurrentSunCoronaBlue); + + m_fCurrentSunSize = INTERPscl(m_fSunSize,10.0f,m_fCurrentSunSize); + + m_nCurrentLowCloudsRed = INTERP(m_nLowCloudsRed,m_nCurrentLowCloudsRed); + m_nCurrentLowCloudsGreen = INTERP(m_nLowCloudsGreen,m_nCurrentLowCloudsGreen); + m_nCurrentLowCloudsBlue = INTERP(m_nLowCloudsBlue,m_nCurrentLowCloudsBlue); + + m_nCurrentFluffyCloudsTopRed = INTERP(m_nFluffyCloudsTopRed,m_nCurrentFluffyCloudsTopRed); + m_nCurrentFluffyCloudsTopGreen = INTERP(m_nFluffyCloudsTopGreen,m_nCurrentFluffyCloudsTopGreen); + m_nCurrentFluffyCloudsTopBlue = INTERP(m_nFluffyCloudsTopBlue,m_nCurrentFluffyCloudsTopBlue); + + m_nCurrentFluffyCloudsBottomRed = INTERP(m_nFluffyCloudsBottomRed,m_nCurrentFluffyCloudsBottomRed); + m_nCurrentFluffyCloudsBottomGreen = INTERP(m_nFluffyCloudsBottomGreen,m_nCurrentFluffyCloudsBottomGreen); + m_nCurrentFluffyCloudsBottomBlue = INTERP(m_nFluffyCloudsBottomBlue,m_nCurrentFluffyCloudsBottomBlue); + + m_fCurrentWaterRed = INTERP(m_fWaterRed,m_fCurrentWaterRed); + m_fCurrentWaterGreen = INTERP(m_fWaterGreen,m_fCurrentWaterGreen); + m_fCurrentWaterBlue = INTERP(m_fWaterBlue,m_fCurrentWaterBlue); + m_fCurrentWaterAlpha = INTERP(m_fWaterAlpha,m_fCurrentWaterAlpha); + } + + m_fCurrentAmbientRed = INTERP(m_nAmbientRed,m_fCurrentAmbientRed); + m_fCurrentAmbientGreen = INTERP(m_nAmbientGreen,m_fCurrentAmbientGreen); + m_fCurrentAmbientBlue = INTERP(m_nAmbientBlue,m_fCurrentAmbientBlue); + + m_fCurrentAmbientRed_Obj = INTERP(m_nAmbientRed_Obj,m_fCurrentAmbientRed_Obj); + m_fCurrentAmbientGreen_Obj = INTERP(m_nAmbientGreen_Obj,m_fCurrentAmbientGreen_Obj); + m_fCurrentAmbientBlue_Obj = INTERP(m_nAmbientBlue_Obj,m_fCurrentAmbientBlue_Obj); + + m_fCurrentAmbientRed_Bl = INTERP(m_nAmbientRed_Bl,m_fCurrentAmbientRed_Bl); + m_fCurrentAmbientGreen_Bl = INTERP(m_nAmbientGreen_Bl,m_fCurrentAmbientGreen_Bl); + m_fCurrentAmbientBlue_Bl = INTERP(m_nAmbientBlue_Bl,m_fCurrentAmbientBlue_Bl); + + m_fCurrentAmbientRed_Obj_Bl = INTERP(m_nAmbientRed_Obj_Bl,m_fCurrentAmbientRed_Obj_Bl); + m_fCurrentAmbientGreen_Obj_Bl = INTERP(m_nAmbientGreen_Obj_Bl,m_fCurrentAmbientGreen_Obj_Bl); + m_fCurrentAmbientBlue_Obj_Bl = INTERP(m_nAmbientBlue_Obj_Bl,m_fCurrentAmbientBlue_Obj_Bl); + + m_fCurrentDirectionalRed = INTERP(m_nDirectionalRed,m_fCurrentDirectionalRed); + m_fCurrentDirectionalGreen = INTERP(m_nDirectionalGreen,m_fCurrentDirectionalGreen); + m_fCurrentDirectionalBlue = INTERP(m_nDirectionalBlue,m_fCurrentDirectionalBlue); + + m_fCurrentSpriteSize = INTERPscl(m_fSpriteSize,10.0f,m_fCurrentSpriteSize); + m_fCurrentSpriteBrightness = INTERPscl(m_fSpriteBrightness,10.0f,m_fCurrentSpriteBrightness); + m_nCurrentShadowStrength = INTERP(m_nShadowStrength,m_nCurrentShadowStrength); + m_nCurrentLightShadowStrength = INTERP(m_nLightShadowStrength,m_nCurrentLightShadowStrength); + m_nCurrentPoleShadowStrength = INTERP(m_nPoleShadowStrength,m_nCurrentPoleShadowStrength); + m_fCurrentFarClip = INTERP(m_fFarClip,m_fCurrentFarClip); + m_fCurrentFogStart = INTERP(m_fFogStart,m_fCurrentFogStart); + m_fCurrentLightsOnGroundBrightness = INTERPscl(m_fLightsOnGroundBrightness,10.0f,m_fCurrentLightsOnGroundBrightness); + + m_fCurrentBlurRed = INTERP(m_fBlurRed,m_fCurrentBlurRed); + m_fCurrentBlurGreen = INTERP(m_fBlurGreen,m_fCurrentBlurGreen); + m_fCurrentBlurBlue = INTERP(m_fBlurBlue,m_fCurrentBlurBlue); + +#undef INTERP +#undef INTERPscl + } if(TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE) TheCamera.SetMotionBlur(m_fCurrentBlurRed, m_fCurrentBlurGreen, m_fCurrentBlurBlue, 5, MOTION_BLUR_LIGHT_SCENE); diff --git a/src/render/Timecycle.h b/src/render/Timecycle.h index 832b36e2..ad079a95 100644 --- a/src/render/Timecycle.h +++ b/src/render/Timecycle.h @@ -2,58 +2,58 @@ class CTimeCycle { - static int m_nAmbientRed[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientRed_Obj[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientGreen_Obj[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientBlue_Obj[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientRed_Bl[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientGreen_Bl[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientBlue_Bl[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientRed_Obj_Bl[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientGreen_Obj_Bl[NUMHOURS][NUMWEATHERS]; - static int m_nAmbientBlue_Obj_Bl[NUMHOURS][NUMWEATHERS]; - static int m_nDirectionalRed[NUMHOURS][NUMWEATHERS]; - static int m_nDirectionalGreen[NUMHOURS][NUMWEATHERS]; - static int m_nDirectionalBlue[NUMHOURS][NUMWEATHERS]; - static int m_nSkyTopRed[NUMHOURS][NUMWEATHERS]; - static int m_nSkyTopGreen[NUMHOURS][NUMWEATHERS]; - static int m_nSkyTopBlue[NUMHOURS][NUMWEATHERS]; - static int m_nSkyBottomRed[NUMHOURS][NUMWEATHERS]; - static int m_nSkyBottomGreen[NUMHOURS][NUMWEATHERS]; - static int m_nSkyBottomBlue[NUMHOURS][NUMWEATHERS]; - static int m_nSunCoreRed[NUMHOURS][NUMWEATHERS]; - static int m_nSunCoreGreen[NUMHOURS][NUMWEATHERS]; - static int m_nSunCoreBlue[NUMHOURS][NUMWEATHERS]; - static int m_nSunCoronaRed[NUMHOURS][NUMWEATHERS]; - static int m_nSunCoronaGreen[NUMHOURS][NUMWEATHERS]; - static int m_nSunCoronaBlue[NUMHOURS][NUMWEATHERS]; - static float m_fSunSize[NUMHOURS][NUMWEATHERS]; - static float m_fSpriteSize[NUMHOURS][NUMWEATHERS]; - static float m_fSpriteBrightness[NUMHOURS][NUMWEATHERS]; - static short m_nShadowStrength[NUMHOURS][NUMWEATHERS]; - static short m_nLightShadowStrength[NUMHOURS][NUMWEATHERS]; - static short m_nPoleShadowStrength[NUMHOURS][NUMWEATHERS]; - static float m_fFogStart[NUMHOURS][NUMWEATHERS]; - static float m_fFarClip[NUMHOURS][NUMWEATHERS]; - static float m_fLightsOnGroundBrightness[NUMHOURS][NUMWEATHERS]; - static int m_nLowCloudsRed[NUMHOURS][NUMWEATHERS]; - static int m_nLowCloudsGreen[NUMHOURS][NUMWEATHERS]; - static int m_nLowCloudsBlue[NUMHOURS][NUMWEATHERS]; - static int m_nFluffyCloudsTopRed[NUMHOURS][NUMWEATHERS]; - static int m_nFluffyCloudsTopGreen[NUMHOURS][NUMWEATHERS]; - static int m_nFluffyCloudsTopBlue[NUMHOURS][NUMWEATHERS]; - static int m_nFluffyCloudsBottomRed[NUMHOURS][NUMWEATHERS]; - static int m_nFluffyCloudsBottomGreen[NUMHOURS][NUMWEATHERS]; - static int m_nFluffyCloudsBottomBlue[NUMHOURS][NUMWEATHERS]; - static float m_fBlurRed[NUMHOURS][NUMWEATHERS]; - static float m_fBlurGreen[NUMHOURS][NUMWEATHERS]; - static float m_fBlurBlue[NUMHOURS][NUMWEATHERS]; - static float m_fWaterRed[NUMHOURS][NUMWEATHERS]; - static float m_fWaterGreen[NUMHOURS][NUMWEATHERS]; - static float m_fWaterBlue[NUMHOURS][NUMWEATHERS]; - static float m_fWaterAlpha[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientRed_Obj[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientGreen_Obj[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientBlue_Obj[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientRed_Bl[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientGreen_Bl[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientBlue_Bl[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientRed_Obj_Bl[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientGreen_Obj_Bl[NUMHOURS][NUMWEATHERS]; + static uint8 m_nAmbientBlue_Obj_Bl[NUMHOURS][NUMWEATHERS]; + static uint8 m_nDirectionalRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nDirectionalGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nDirectionalBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSkyTopRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSkyTopGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSkyTopBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSkyBottomRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSkyBottomGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSkyBottomBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSunCoreRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSunCoreGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSunCoreBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSunCoronaRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSunCoronaGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nSunCoronaBlue[NUMHOURS][NUMWEATHERS]; + static int8 m_fSunSize[NUMHOURS][NUMWEATHERS]; + static int8 m_fSpriteSize[NUMHOURS][NUMWEATHERS]; + static int8 m_fSpriteBrightness[NUMHOURS][NUMWEATHERS]; + static uint8 m_nShadowStrength[NUMHOURS][NUMWEATHERS]; + static uint8 m_nLightShadowStrength[NUMHOURS][NUMWEATHERS]; + static uint8 m_nPoleShadowStrength[NUMHOURS][NUMWEATHERS]; + static int16 m_fFogStart[NUMHOURS][NUMWEATHERS]; + static int16 m_fFarClip[NUMHOURS][NUMWEATHERS]; + static uint8 m_fLightsOnGroundBrightness[NUMHOURS][NUMWEATHERS]; + static uint8 m_nLowCloudsRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nLowCloudsGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nLowCloudsBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nFluffyCloudsTopRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nFluffyCloudsTopGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nFluffyCloudsTopBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_nFluffyCloudsBottomRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_nFluffyCloudsBottomGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_nFluffyCloudsBottomBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_fBlurRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_fBlurGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_fBlurBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_fWaterRed[NUMHOURS][NUMWEATHERS]; + static uint8 m_fWaterGreen[NUMHOURS][NUMWEATHERS]; + static uint8 m_fWaterBlue[NUMHOURS][NUMWEATHERS]; + static uint8 m_fWaterAlpha[NUMHOURS][NUMWEATHERS]; static float m_fCurrentAmbientRed; static float m_fCurrentAmbientGreen; @@ -70,36 +70,36 @@ class CTimeCycle static float m_fCurrentDirectionalRed; static float m_fCurrentDirectionalGreen; static float m_fCurrentDirectionalBlue; - static int m_nCurrentSkyTopRed; - static int m_nCurrentSkyTopGreen; - static int m_nCurrentSkyTopBlue; - static int m_nCurrentSkyBottomRed; - static int m_nCurrentSkyBottomGreen; - static int m_nCurrentSkyBottomBlue; - static int m_nCurrentSunCoreRed; - static int m_nCurrentSunCoreGreen; - static int m_nCurrentSunCoreBlue; - static int m_nCurrentSunCoronaRed; - static int m_nCurrentSunCoronaGreen; - static int m_nCurrentSunCoronaBlue; + static int32 m_nCurrentSkyTopRed; + static int32 m_nCurrentSkyTopGreen; + static int32 m_nCurrentSkyTopBlue; + static int32 m_nCurrentSkyBottomRed; + static int32 m_nCurrentSkyBottomGreen; + static int32 m_nCurrentSkyBottomBlue; + static int32 m_nCurrentSunCoreRed; + static int32 m_nCurrentSunCoreGreen; + static int32 m_nCurrentSunCoreBlue; + static int32 m_nCurrentSunCoronaRed; + static int32 m_nCurrentSunCoronaGreen; + static int32 m_nCurrentSunCoronaBlue; static float m_fCurrentSunSize; static float m_fCurrentSpriteSize; static float m_fCurrentSpriteBrightness; - static int m_nCurrentShadowStrength; - static int m_nCurrentLightShadowStrength; - static int m_nCurrentPoleShadowStrength; + static int32 m_nCurrentShadowStrength; + static int32 m_nCurrentLightShadowStrength; + static int32 m_nCurrentPoleShadowStrength; static float m_fCurrentFogStart; static float m_fCurrentFarClip; static float m_fCurrentLightsOnGroundBrightness; - static int m_nCurrentLowCloudsRed; - static int m_nCurrentLowCloudsGreen; - static int m_nCurrentLowCloudsBlue; - static int m_nCurrentFluffyCloudsTopRed; - static int m_nCurrentFluffyCloudsTopGreen; - static int m_nCurrentFluffyCloudsTopBlue; - static int m_nCurrentFluffyCloudsBottomRed; - static int m_nCurrentFluffyCloudsBottomGreen; - static int m_nCurrentFluffyCloudsBottomBlue; + static int32 m_nCurrentLowCloudsRed; + static int32 m_nCurrentLowCloudsGreen; + static int32 m_nCurrentLowCloudsBlue; + static int32 m_nCurrentFluffyCloudsTopRed; + static int32 m_nCurrentFluffyCloudsTopGreen; + static int32 m_nCurrentFluffyCloudsTopBlue; + static int32 m_nCurrentFluffyCloudsBottomRed; + static int32 m_nCurrentFluffyCloudsBottomGreen; + static int32 m_nCurrentFluffyCloudsBottomBlue; static float m_fCurrentBlurRed; static float m_fCurrentBlurGreen; static float m_fCurrentBlurBlue; @@ -107,14 +107,17 @@ class CTimeCycle static float m_fCurrentWaterGreen; static float m_fCurrentWaterBlue; static float m_fCurrentWaterAlpha; - static int m_nCurrentFogColourRed; - static int m_nCurrentFogColourGreen; - static int m_nCurrentFogColourBlue; + static int32 m_nCurrentFogColourRed; + static int32 m_nCurrentFogColourGreen; + static int32 m_nCurrentFogColourBlue; - static int m_FogReduction; + static int32 m_FogReduction; public: - static int m_CurrentStoredValue; + static bool m_bExtraColourOn; + static int32 m_ExtraColour; + static float m_ExtraColourInter; + static int32 m_CurrentStoredValue; static CVector m_VectorToSun[16]; static float m_fShadowFrontX[16]; static float m_fShadowFrontY[16]; @@ -138,51 +141,56 @@ public: static float GetDirectionalRed(void) { return m_fCurrentDirectionalRed; } static float GetDirectionalGreen(void) { return m_fCurrentDirectionalGreen; } static float GetDirectionalBlue(void) { return m_fCurrentDirectionalBlue; } - static int GetSkyTopRed(void) { return m_nCurrentSkyTopRed; } - static int GetSkyTopGreen(void) { return m_nCurrentSkyTopGreen; } - static int GetSkyTopBlue(void) { return m_nCurrentSkyTopBlue; } - static int GetSkyBottomRed(void) { return m_nCurrentSkyBottomRed; } - static int GetSkyBottomGreen(void) { return m_nCurrentSkyBottomGreen; } - static int GetSkyBottomBlue(void) { return m_nCurrentSkyBottomBlue; } - static int GetSunCoreRed(void) { return m_nCurrentSunCoreRed; } - static int GetSunCoreGreen(void) { return m_nCurrentSunCoreGreen; } - static int GetSunCoreBlue(void) { return m_nCurrentSunCoreBlue; } - static int GetSunCoronaRed(void) { return m_nCurrentSunCoronaRed; } - static int GetSunCoronaGreen(void) { return m_nCurrentSunCoronaGreen; } - static int GetSunCoronaBlue(void) { return m_nCurrentSunCoronaBlue; } + static int32 GetSkyTopRed(void) { return m_nCurrentSkyTopRed; } + static int32 GetSkyTopGreen(void) { return m_nCurrentSkyTopGreen; } + static int32 GetSkyTopBlue(void) { return m_nCurrentSkyTopBlue; } + static int32 GetSkyBottomRed(void) { return m_nCurrentSkyBottomRed; } + static int32 GetSkyBottomGreen(void) { return m_nCurrentSkyBottomGreen; } + static int32 GetSkyBottomBlue(void) { return m_nCurrentSkyBottomBlue; } + static int32 GetSunCoreRed(void) { return m_nCurrentSunCoreRed; } + static int32 GetSunCoreGreen(void) { return m_nCurrentSunCoreGreen; } + static int32 GetSunCoreBlue(void) { return m_nCurrentSunCoreBlue; } + static int32 GetSunCoronaRed(void) { return m_nCurrentSunCoronaRed; } + static int32 GetSunCoronaGreen(void) { return m_nCurrentSunCoronaGreen; } + static int32 GetSunCoronaBlue(void) { return m_nCurrentSunCoronaBlue; } static float GetSunSize(void) { return m_fCurrentSunSize; } static float GetSpriteBrightness(void) { return m_fCurrentSpriteBrightness; } static float GetSpriteSize(void) { return m_fCurrentSpriteSize; } - static int GetShadowStrength(void) { return m_nCurrentShadowStrength; } - static int GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; } + static int32 GetShadowStrength(void) { return m_nCurrentShadowStrength; } + static int32 GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; } static float GetLightOnGroundBrightness(void) { return m_fCurrentLightsOnGroundBrightness; } static float GetFarClip(void) { return m_fCurrentFarClip; } static float GetFogStart(void) { return m_fCurrentFogStart; } - static int GetLowCloudsRed(void) { return m_nCurrentLowCloudsRed; } - static int GetLowCloudsGreen(void) { return m_nCurrentLowCloudsGreen; } - static int GetLowCloudsBlue(void) { return m_nCurrentLowCloudsBlue; } - static int GetFluffyCloudsTopRed(void) { return m_nCurrentFluffyCloudsTopRed; } - static int GetFluffyCloudsTopGreen(void) { return m_nCurrentFluffyCloudsTopGreen; } - static int GetFluffyCloudsTopBlue(void) { return m_nCurrentFluffyCloudsTopBlue; } - static int GetFluffyCloudsBottomRed(void) { return m_nCurrentFluffyCloudsBottomRed; } - static int GetFluffyCloudsBottomGreen(void) { return m_nCurrentFluffyCloudsBottomGreen; } - static int GetFluffyCloudsBottomBlue(void) { return m_nCurrentFluffyCloudsBottomBlue; } - static int GetFogRed(void) { return m_nCurrentFogColourRed; } - static int GetFogGreen(void) { return m_nCurrentFogColourGreen; } - static int GetFogBlue(void) { return m_nCurrentFogColourBlue; } - static int GetFogReduction(void) { return m_FogReduction; } + static int32 GetLowCloudsRed(void) { return m_nCurrentLowCloudsRed; } + static int32 GetLowCloudsGreen(void) { return m_nCurrentLowCloudsGreen; } + static int32 GetLowCloudsBlue(void) { return m_nCurrentLowCloudsBlue; } + static int32 GetFluffyCloudsTopRed(void) { return m_nCurrentFluffyCloudsTopRed; } + static int32 GetFluffyCloudsTopGreen(void) { return m_nCurrentFluffyCloudsTopGreen; } + static int32 GetFluffyCloudsTopBlue(void) { return m_nCurrentFluffyCloudsTopBlue; } + static int32 GetFluffyCloudsBottomRed(void) { return m_nCurrentFluffyCloudsBottomRed; } + static int32 GetFluffyCloudsBottomGreen(void) { return m_nCurrentFluffyCloudsBottomGreen; } + static int32 GetFluffyCloudsBottomBlue(void) { return m_nCurrentFluffyCloudsBottomBlue; } + static int32 GetFogRed(void) { return m_nCurrentFogColourRed; } + static int32 GetFogGreen(void) { return m_nCurrentFogColourGreen; } + static int32 GetFogBlue(void) { return m_nCurrentFogColourBlue; } + static int32 GetFogReduction(void) { return m_FogReduction; } - static int GetBlurRed(void) { return m_fCurrentBlurRed; } - static int GetBlurGreen(void) { return m_fCurrentBlurGreen; } - static int GetBlurBlue(void) { return m_fCurrentBlurBlue; } - static int GetWaterRed(void) { return m_fCurrentWaterRed; } - static int GetWaterGreen(void) { return m_fCurrentWaterGreen; } - static int GetWaterBlue(void) { return m_fCurrentWaterBlue; } - static int GetWaterAlpha(void) { return m_fCurrentWaterAlpha; } + static int32 GetBlurRed(void) { return m_fCurrentBlurRed; } + static int32 GetBlurGreen(void) { return m_fCurrentBlurGreen; } + static int32 GetBlurBlue(void) { return m_fCurrentBlurBlue; } + static int32 GetWaterRed(void) { return m_fCurrentWaterRed; } + static int32 GetWaterGreen(void) { return m_fCurrentWaterGreen; } + static int32 GetWaterBlue(void) { return m_fCurrentWaterBlue; } + static int32 GetWaterAlpha(void) { return m_fCurrentWaterAlpha; } static void Initialise(void); static void Update(void); + static float Interpolate(int8 *a, int8 *b); + static float Interpolate(uint8 *a, uint8 *b); + static float Interpolate(int16 *a, int16 *b); + static void StartExtraColour(int32 c, bool fade); + static void StopExtraColour(bool fade); static CVector &GetSunDirection(void) { return m_VectorToSun[m_CurrentStoredValue]; } static float GetShadowFrontX(void) { return m_fShadowFrontX[m_CurrentStoredValue]; } static float GetShadowFrontY(void) { return m_fShadowFrontY[m_CurrentStoredValue]; } diff --git a/src/render/Weather.h b/src/render/Weather.h index ae09e5d1..809bb787 100644 --- a/src/render/Weather.h +++ b/src/render/Weather.h @@ -6,7 +6,9 @@ enum { WEATHER_FOGGY, WEATHER_EXTRA_SUNNY, WEATHER_HURRICANE, - WEATHER_TOTAL + WEATHER_TOTAL, + + WEATHER_EXTRACOLOURS = 6 }; class CWeather -- cgit v1.2.3 From e57d4508098a9a930724d018a2132a4e704b1cf1 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 9 Aug 2020 19:51:16 +0200 Subject: drunk blur done --- src/render/MBlur.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index 568a0bc1..4c805d25 100644 --- a/src/render/MBlur.cpp +++ b/src/render/MBlur.cpp @@ -255,6 +255,11 @@ CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, u #endif } +static uint8 DrunkBlurRed = 128; +static uint8 DrunkBlurGreen = 128; +static uint8 DrunkBlurBlue = 128; +static int32 DrunkBlurIncrement = 1; + void CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, int32 bluralpha) { @@ -367,7 +372,36 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, } } - // TODO(MIAMI): drunkness + int DrunkBlurAlpha = 175.0f * Drunkness; + if(DrunkBlurAlpha != 0){ + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + if(BlurOn){ + RwIm2DVertexSetIntRGBA(&Vertex[0], 255, 255, 255, DrunkBlurAlpha); + RwIm2DVertexSetIntRGBA(&Vertex[1], 255, 255, 255, DrunkBlurAlpha); + RwIm2DVertexSetIntRGBA(&Vertex[2], 255, 255, 255, DrunkBlurAlpha); + RwIm2DVertexSetIntRGBA(&Vertex[3], 255, 255, 255, DrunkBlurAlpha); + }else{ + RwIm2DVertexSetIntRGBA(&Vertex[0], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha); + RwIm2DVertexSetIntRGBA(&Vertex[1], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha); + RwIm2DVertexSetIntRGBA(&Vertex[2], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha); + RwIm2DVertexSetIntRGBA(&Vertex[3], DrunkBlurRed, DrunkBlurGreen, DrunkBlurBlue, DrunkBlurAlpha); + if(DrunkBlurIncrement){ + if(DrunkBlurRed < 255) DrunkBlurRed++; + if(DrunkBlurGreen < 255) DrunkBlurGreen++; + if(DrunkBlurBlue < 255) DrunkBlurBlue++; + if(DrunkBlurRed == 255) + DrunkBlurIncrement = 0; + }else{ + if(DrunkBlurRed > 128) DrunkBlurRed--; + if(DrunkBlurGreen > 128) DrunkBlurGreen--; + if(DrunkBlurBlue > 128) DrunkBlurBlue--; + if(DrunkBlurRed == 128) + DrunkBlurIncrement = 1; + } + } + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); + } // TODO(MIAMI): OverlayRenderFx -- cgit v1.2.3 From b73b6b8e130a545687aad4024465fc977e3f01ee Mon Sep 17 00:00:00 2001 From: majestic Date: Tue, 4 Aug 2020 19:11:42 -0700 Subject: CWindModifiers --- src/render/WindModifiers.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- src/render/WindModifiers.h | 7 +++++-- 2 files changed, 46 insertions(+), 5 deletions(-) (limited to 'src/render') diff --git a/src/render/WindModifiers.cpp b/src/render/WindModifiers.cpp index 49e7c96a..2061df6a 100644 --- a/src/render/WindModifiers.cpp +++ b/src/render/WindModifiers.cpp @@ -1,13 +1,51 @@ #include "common.h" #include "WindModifiers.h" +#include "Camera.h" +#include "General.h" + +#define MAX_HEIGHT_DIST 40.0f +#define MIN_FADE_DIST 20.0f +#define MAX_FADE_DIST 50.0f + +CWindModifiers Array[16]; +int32 CWindModifiers::Number; void -CWindModifiers::RegisterOne(CVector pos, int32 unk) +CWindModifiers::RegisterOne(CVector pos, int32 type = 1) { + if (CWindModifiers::Number < 16 && (pos - TheCamera.GetPosition()).Magnitude() < 100.0f) { + Array[Number].m_pos = pos; + Array[Number].m_type = type; + Number++; + } } -int32 +bool CWindModifiers::FindWindModifier(CVector pos, float *x, float *y) { - return 0; + bool bWasWindModifierFound = false; + CVector2D dir; + for (int i = 0; i < Number; i++) { + if (Array[i].m_type == 1) { + float zDist = Abs(15.0f + pos.z - Array[i].m_pos.z); + + if (zDist < MAX_HEIGHT_DIST) { + float dist = (pos - Array[i].m_pos).Magnitude(); + if (dist < MAX_FADE_DIST) { + float distFade = dist < MIN_FADE_DIST ? 1.0f : 1.0f - (dist - MIN_FADE_DIST) / (MAX_FADE_DIST - MIN_FADE_DIST); + float heightFade = 1.0f - zDist / MAX_HEIGHT_DIST; + dir = (pos - Array[i].m_pos) * heightFade / dist; + bWasWindModifierFound = true; + } + } + } + } + + if (bWasWindModifierFound) { + float directionMult = ((CGeneral::GetRandomNumber() & 0x1F) - 16) * 0.0035f + 1.0f; + *x += dir.x * directionMult; + *y += dir.y * directionMult; + } + + return bWasWindModifierFound; } diff --git a/src/render/WindModifiers.h b/src/render/WindModifiers.h index c42e185d..7c2e57bd 100644 --- a/src/render/WindModifiers.h +++ b/src/render/WindModifiers.h @@ -2,7 +2,10 @@ class CWindModifiers { + CVector m_pos; + int32 m_type; public: - static void RegisterOne(CVector pos, int32 unk); - static int32 FindWindModifier(CVector pos, float *x, float *y); + static int32 Number; + static void RegisterOne(CVector pos, int32 windSourceType); + static bool FindWindModifier(CVector pos, float *x, float *y); }; -- cgit v1.2.3 From 2f987e315e11ee1d93b5f3c2cda3f593c254b373 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 10 Aug 2020 17:04:57 +0200 Subject: update librw (shadows are working now) --- src/render/ShadowCamera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/ShadowCamera.cpp b/src/render/ShadowCamera.cpp index ae94f8ac..f69c234f 100644 --- a/src/render/ShadowCamera.cpp +++ b/src/render/ShadowCamera.cpp @@ -160,7 +160,7 @@ CShadowCamera::SetCenter(RwV3d *center) ASSERT(m_pCamera != nil); RwFrame *camFrame = RwCameraGetFrame(m_pCamera); - RwMatrix *camMatrix = RwFrameGetMatrix(camFrame); + RwMatrix *camMatrix = RwFrameGetMatrix(camFrame); *RwMatrixGetPos(camMatrix) = *center; @@ -188,7 +188,7 @@ CShadowCamera::Update(RpClump *clump) if ( RwCameraBeginUpdate(m_pCamera) ) { - geometry = GetFirstAtomic(clump)->geometry; + geometry = RpAtomicGetGeometry(GetFirstAtomic(clump)); ASSERT(geometry != nil); flags = RpGeometryGetFlags(geometry); -- cgit v1.2.3 From b468d010a8a185bd04cdb1fb41810a189971e583 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 11 Aug 2020 18:39:53 +0200 Subject: implemented extended postfx --- src/render/MBlur.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/render') diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index 4c805d25..08298a1f 100644 --- a/src/render/MBlur.cpp +++ b/src/render/MBlur.cpp @@ -11,6 +11,7 @@ #include "Camera.h" #include "MBlur.h" #include "Timer.h" +#include "postfx.h" // Originally taken from RW example 'mblur' @@ -30,6 +31,10 @@ extern "C" D3DCAPS8 _RwD3D8DeviceCaps; RwBool CMBlur::MotionBlurOpen(RwCamera *cam) { +#ifdef EXTENDED_COLOURFILTER + CPostFX::Open(cam); + return TRUE; +#else #ifdef GTA_PS2 RwRect rect = {0, 0, 0, 0}; @@ -130,18 +135,22 @@ CMBlur::MotionBlurOpen(RwCamera *cam) return TRUE; #endif +#endif } RwBool CMBlur::MotionBlurClose(void) { +#ifdef EXTENDED_COLOURFILTER + CPostFX::Close(); +#else if(pFrontBuffer){ RwRasterDestroy(pFrontBuffer); pFrontBuffer = nil; return TRUE; } - +#endif return FALSE; } @@ -197,8 +206,8 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect) RwIm2DVertexSetIntRGBA(&Vertex[3], 255, 255, 255, 255); - RwIm2DVertexSetScreenX(&Vertex2[0], zero); - RwIm2DVertexSetScreenY(&Vertex2[0], zero); + RwIm2DVertexSetScreenX(&Vertex2[0], zero + 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[0], zero + 2.0f); RwIm2DVertexSetScreenZ(&Vertex2[0], RwIm2DGetNearScreenZ()); RwIm2DVertexSetCameraZ(&Vertex2[0], RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetRecipCameraZ(&Vertex2[0], 1.0f/RwCameraGetNearClipPlane(cam)); @@ -206,8 +215,8 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect) RwIm2DVertexSetV(&Vertex2[0], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetIntRGBA(&Vertex2[0], 255, 255, 255, 255); - RwIm2DVertexSetScreenX(&Vertex2[1], zero); - RwIm2DVertexSetScreenY(&Vertex2[1], ymax); + RwIm2DVertexSetScreenX(&Vertex2[1], 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[1], ymax + 2.0f); RwIm2DVertexSetScreenZ(&Vertex2[1], RwIm2DGetNearScreenZ()); RwIm2DVertexSetCameraZ(&Vertex2[1], RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetRecipCameraZ(&Vertex2[1], 1.0f/RwCameraGetNearClipPlane(cam)); @@ -215,8 +224,8 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect) RwIm2DVertexSetV(&Vertex2[1], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetIntRGBA(&Vertex2[1], 255, 255, 255, 255); - RwIm2DVertexSetScreenX(&Vertex2[2], xmax); - RwIm2DVertexSetScreenY(&Vertex2[2], ymax); + RwIm2DVertexSetScreenX(&Vertex2[2], xmax + 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[2], ymax + 2.0f); RwIm2DVertexSetScreenZ(&Vertex2[2], RwIm2DGetNearScreenZ()); RwIm2DVertexSetCameraZ(&Vertex2[2], RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetRecipCameraZ(&Vertex2[2], 1.0f/RwCameraGetNearClipPlane(cam)); @@ -224,20 +233,22 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect) RwIm2DVertexSetV(&Vertex2[2], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetIntRGBA(&Vertex2[2], 255, 255, 255, 255); - RwIm2DVertexSetScreenX(&Vertex2[3], xmax); - RwIm2DVertexSetScreenY(&Vertex2[3], zero); + RwIm2DVertexSetScreenX(&Vertex2[3], xmax + 2.0f); + RwIm2DVertexSetScreenY(&Vertex2[3], zero + 2.0f); RwIm2DVertexSetScreenZ(&Vertex2[3], RwIm2DGetNearScreenZ()); RwIm2DVertexSetCameraZ(&Vertex2[3], RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetRecipCameraZ(&Vertex2[3], 1.0f/RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetU(&Vertex2[3], 1.0f, 1.0f/RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetV(&Vertex2[3], 0.0f, 1.0f/RwCameraGetNearClipPlane(cam)); RwIm2DVertexSetIntRGBA(&Vertex2[3], 255, 255, 255, 255); - } void CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha) { +#ifdef EXTENDED_COLOURFILTER + CPostFX::Render(cam, red, green, blue, blur, type, bluralpha); +#else RwRGBA color = { (RwUInt8)red, (RwUInt8)green, (RwUInt8)blue, (RwUInt8)blur }; #ifdef GTA_PS2 if( pFrontBuffer ) @@ -253,6 +264,7 @@ CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, u RwRasterPopContext(); } #endif +#endif } static uint8 DrunkBlurRed = 128; -- cgit v1.2.3 From 878ffa8998f7fc78064d0e38795f26ee0de57688 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 12 Aug 2020 10:48:00 +0200 Subject: sun reflection fix --- src/render/Coronas.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index df5dfadb..2d621d18 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -604,8 +604,8 @@ CCoronas::RenderSunReflection(void) RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored+1], r, g, b, 255); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored+1], - sunPos.x + fwdLen*sunDir.x - sideLen*sunDir.x, - sunPos.y + fwdLen*sunDir.y + sideLen*sunDir.y, + sunPos.x + fwdLen*sunDir.x - sideLen*sunDir.y, + sunPos.y + fwdLen*sunDir.y + sideLen*sunDir.x, sunPos.z); RwIm3DVertexSetU(&TempBufferRenderVertices[TempBufferVerticesStored+0], 0.0f); -- cgit v1.2.3 From 0d8fcb41eec5da54ef0ec9e4c861f5281794b0a9 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 13 Aug 2020 16:29:42 +0200 Subject: fix render poly bug --- src/render/Renderer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 03ef1064..66c12dd9 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -908,8 +908,13 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL a2 = i; } } +#ifdef FIX_BUGS + y = Floor(miny); + yend = Floor(maxy); +#else y = miny; yend = maxy; +#endif // Go left in poly to find first edge b b2 = a2; @@ -947,8 +952,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL while(y <= yend && y < NUMSECTORS_Y){ // scan one x-line if(y >= 0 && xstart < NUMSECTORS_X) - for(x = xstart; x <= xend; x++) - if(x >= 0 && x != NUMSECTORS_X) + for(x = xstart; x <= xend && x != NUMSECTORS_X; x++) + if(x >= 0) scanfunc(CWorld::GetSector(x, y)->m_lists); // advance one scan line -- cgit v1.2.3 From cdebea71f39377418355efdc86e2d6501cbf292f Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 13 Aug 2020 18:47:39 +0200 Subject: fixes to HUD and sprite2d --- src/render/Hud.cpp | 62 +++++++------ src/render/Sprite2d.cpp | 234 ++++++++++++++++++++---------------------------- src/render/Sprite2d.h | 3 +- 3 files changed, 136 insertions(+), 163 deletions(-) (limited to 'src/render') diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 10408355..cbf3c7f2 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -205,7 +205,8 @@ void CHud::Draw() rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f); rect.bottom = f3rdY + SCREEN_SCALE_Y(32.0f * 0.6f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } else { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.4f); @@ -213,7 +214,8 @@ void CHud::Draw() rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.4f); rect.bottom = f3rdY + SCREEN_SCALE_Y(32.0f * 0.4f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } } else { if (Mode == CCam::MODE_M16_1STPERSON || @@ -223,7 +225,8 @@ void CHud::Draw() rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(32.0f); rect.right = (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(32.0f); rect.bottom = (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(32.0f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } else if (Mode == CCam::MODE_1STPERSON_RUNABOUT) { rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(32.0f * 0.7f); @@ -231,7 +234,8 @@ void CHud::Draw() rect.right = (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(32.0f * 0.7f); rect.bottom = (SCREEN_HEIGHT / 2) + SCREEN_SCALE_Y(32.0f * 0.7f); - Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } else if (Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT) { RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); @@ -248,29 +252,33 @@ void CHud::Draw() // TODO(Miami) // Sniper - rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f); - rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f); - rect.right = SCREEN_WIDTH / 2; - rect.bottom = SCREEN_HEIGHT / 2; - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); - - rect.right = (SCREEN_WIDTH / 2); - rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f); - rect.left = SCREEN_SCALE_X(210.0f) + (SCREEN_WIDTH / 2); - rect.bottom = SCREEN_HEIGHT / 2; - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); - - rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f); - rect.bottom = (SCREEN_HEIGHT / 2); - rect.right = (SCREEN_WIDTH / 2); - rect.top = SCREEN_SCALE_Y(210.0f) + (SCREEN_HEIGHT / 2); - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); - - rect.right = (SCREEN_WIDTH / 2); - rect.bottom = (SCREEN_HEIGHT / 2); - rect.left = SCREEN_SCALE_X(210.0f) + (SCREEN_WIDTH / 2); - rect.top = SCREEN_SCALE_Y(210.0f) + (SCREEN_HEIGHT / 2); - Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); + rect.left = SCREEN_WIDTH/2 - SCREEN_SCALE_X(210.0f); + rect.top = SCREEN_HEIGHT/2 - SCREEN_SCALE_Y(210.0f); + rect.right = SCREEN_WIDTH/2; + rect.bottom = SCREEN_HEIGHT/2; + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.01f, 0.01f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f); + + rect.left = SCREEN_WIDTH/2; + rect.top = SCREEN_HEIGHT/2 - SCREEN_SCALE_Y(210.0f); + rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); + rect.bottom = SCREEN_HEIGHT/2; + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.99f, 0.0f, 0.01f, 0.01f, 0.99f, 1.0f, 0.01f, 1.0f); + + rect.left = SCREEN_WIDTH/2 - SCREEN_SCALE_X(210.0f); + rect.top = SCREEN_HEIGHT/2; + rect.right = SCREEN_WIDTH/2; + rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.01f, 0.99f, 1.0f, 0.99f, 0.01f, 0.01f, 1.0f, 0.01f); + + rect.left = SCREEN_WIDTH/2; + rect.top = SCREEN_HEIGHT/2; + rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); + rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); + Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), + 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.1f, 0.01f); } } RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index cba64e7a..7dcedb26 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -9,6 +9,7 @@ float CSprite2d::RecipNearClip; float CSprite2d::NearScreenZ; +float CSprite2d::NearCamZ; int CSprite2d::nextBufferVertex; int CSprite2d::nextBufferIndex; RwIm2DVertex CSprite2d::maVertices[8]; @@ -26,6 +27,9 @@ CSprite2d::InitPerFrame(void) nextBufferIndex = 0; RecipNearClip = 1.0f / RwCameraGetNearClipPlane(Scene.camera); NearScreenZ = RwIm2DGetNearScreenZ(); + // not original but you're supposed to set camera z too + // wrapping all this in FIX_BUGS is too ugly + NearCamZ = RwCameraGetNearClipPlane(Scene.camera); } void CSprite2d::Delete(void) @@ -71,7 +75,7 @@ CSprite2d::SetRenderState(void) void CSprite2d::Draw(float x, float y, float w, float h, const CRGBA &col) { - SetVertices(CRect(x, y, x + w, y + h), col, col, col, col, 0); + SetVertices(CRect(x, y, x + w, y + h), col, col, col, col); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } @@ -79,7 +83,7 @@ CSprite2d::Draw(float x, float y, float w, float h, const CRGBA &col) void CSprite2d::Draw(const CRect &rect, const CRGBA &col) { - SetVertices(rect, col, col, col, col, 0); + SetVertices(rect, col, col, col, col); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } @@ -96,7 +100,7 @@ CSprite2d::Draw(const CRect &rect, const CRGBA &col, void CSprite2d::Draw(const CRect &rect, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - SetVertices(rect, c0, c1, c2, c3, 0); + SetVertices(rect, c0, c1, c2, c3); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } @@ -114,178 +118,149 @@ CSprite2d::Draw(float x1, float y1, float x2, float y2, float x3, float y3, floa // | | // 0---1 void -CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, uint32 far) +CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - float screenz, z, recipz; - - if(far){ - screenz = RwIm2DGetFarScreenZ(); - z = RwCameraGetFarClipPlane(Scene.camera); - }else{ - screenz = NearScreenZ; - z = 1.0f/RecipNearClip; - } - recipz = 1.0f/z; - // This is what we draw: // 0---1 // | / | // 3---2 RwIm2DVertexSetScreenX(&maVertices[0], r.left); RwIm2DVertexSetScreenY(&maVertices[0], r.top); - RwIm2DVertexSetScreenZ(&maVertices[0], screenz); - RwIm2DVertexSetCameraZ(&maVertices[0], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[0], recipz); + RwIm2DVertexSetScreenZ(&maVertices[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[0], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[0], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], r.right); RwIm2DVertexSetScreenY(&maVertices[1], r.top); - RwIm2DVertexSetScreenZ(&maVertices[1], screenz); - RwIm2DVertexSetCameraZ(&maVertices[1], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[1], recipz); + RwIm2DVertexSetScreenZ(&maVertices[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[1], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[1], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], r.right); RwIm2DVertexSetScreenY(&maVertices[2], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[2], screenz); - RwIm2DVertexSetCameraZ(&maVertices[2], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[2], recipz); + RwIm2DVertexSetScreenZ(&maVertices[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[2], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[2], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], 1.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], r.left); RwIm2DVertexSetScreenY(&maVertices[3], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[3], screenz); - RwIm2DVertexSetCameraZ(&maVertices[3], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[3], recipz); + RwIm2DVertexSetScreenZ(&maVertices[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[3], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[3], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], 1.0f, RecipNearClip); } void CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2) { - float screenz, z, recipz; - - screenz = NearScreenZ; - z = 1.0f/RecipNearClip; - recipz = 1.0f/z; - // This is what we draw: // 0---1 // | / | // 3---2 RwIm2DVertexSetScreenX(&maVertices[0], r.left); RwIm2DVertexSetScreenY(&maVertices[0], r.top); - RwIm2DVertexSetScreenZ(&maVertices[0], screenz); - RwIm2DVertexSetCameraZ(&maVertices[0], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[0], recipz); + RwIm2DVertexSetScreenZ(&maVertices[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], u0, recipz); - RwIm2DVertexSetV(&maVertices[0], v0, recipz); + RwIm2DVertexSetU(&maVertices[0], u0, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], v0, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], r.right); RwIm2DVertexSetScreenY(&maVertices[1], r.top); - RwIm2DVertexSetScreenZ(&maVertices[1], screenz); - RwIm2DVertexSetCameraZ(&maVertices[1], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[1], recipz); + RwIm2DVertexSetScreenZ(&maVertices[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], u1, recipz); - RwIm2DVertexSetV(&maVertices[1], v1, recipz); + RwIm2DVertexSetU(&maVertices[1], u1, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], v1, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], r.right); RwIm2DVertexSetScreenY(&maVertices[2], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[2], screenz); - RwIm2DVertexSetCameraZ(&maVertices[2], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[2], recipz); + RwIm2DVertexSetScreenZ(&maVertices[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], u2, recipz); - RwIm2DVertexSetV(&maVertices[2], v2, recipz); + RwIm2DVertexSetU(&maVertices[2], u2, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], v2, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], r.left); RwIm2DVertexSetScreenY(&maVertices[3], r.bottom); - RwIm2DVertexSetScreenZ(&maVertices[3], screenz); - RwIm2DVertexSetCameraZ(&maVertices[3], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[3], recipz); + RwIm2DVertexSetScreenZ(&maVertices[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], u3, recipz); - RwIm2DVertexSetV(&maVertices[3], v3, recipz); + RwIm2DVertexSetU(&maVertices[3], u3, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], v3, RecipNearClip); } void CSprite2d::SetVertices(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - float screenz, recipz; - float z = RwCameraGetNearClipPlane(Scene.camera); // not done by game - - screenz = NearScreenZ; - recipz = RecipNearClip; - RwIm2DVertexSetScreenX(&maVertices[0], x3); RwIm2DVertexSetScreenY(&maVertices[0], y3); - RwIm2DVertexSetScreenZ(&maVertices[0], screenz); - RwIm2DVertexSetCameraZ(&maVertices[0], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[0], recipz); + RwIm2DVertexSetScreenZ(&maVertices[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[0], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[0], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], x4); RwIm2DVertexSetScreenY(&maVertices[1], y4); - RwIm2DVertexSetScreenZ(&maVertices[1], screenz); - RwIm2DVertexSetCameraZ(&maVertices[1], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[1], recipz); + RwIm2DVertexSetScreenZ(&maVertices[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[1], 0.0f, recipz); + RwIm2DVertexSetU(&maVertices[1], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], 0.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], x2); RwIm2DVertexSetScreenY(&maVertices[2], y2); - RwIm2DVertexSetScreenZ(&maVertices[2], screenz); - RwIm2DVertexSetCameraZ(&maVertices[2], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[2], recipz); + RwIm2DVertexSetScreenZ(&maVertices[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], 1.0f, recipz); - RwIm2DVertexSetV(&maVertices[2], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[2], 1.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], 1.0f, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], x1); RwIm2DVertexSetScreenY(&maVertices[3], y1); - RwIm2DVertexSetScreenZ(&maVertices[3], screenz); - RwIm2DVertexSetCameraZ(&maVertices[3], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[3], recipz); + RwIm2DVertexSetScreenZ(&maVertices[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], 0.0f, recipz); - RwIm2DVertexSetV(&maVertices[3], 1.0f, recipz); + RwIm2DVertexSetU(&maVertices[3], 0.0f, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], 1.0f, RecipNearClip); } void CSprite2d::SetVertices(int n, float *positions, float *uvs, const CRGBA &col) { int i; - float screenz, recipz, z; - - screenz = NearScreenZ; - recipz = RecipNearClip; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game - for(i = 0; i < n; i++){ RwIm2DVertexSetScreenX(&maVertices[i], positions[i*2 + 0]); RwIm2DVertexSetScreenY(&maVertices[i], positions[i*2 + 1]); - RwIm2DVertexSetScreenZ(&maVertices[i], screenz + 0.0001f); - RwIm2DVertexSetCameraZ(&maVertices[i], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[i], recipz); + RwIm2DVertexSetScreenZ(&maVertices[i], NearScreenZ + 0.0001f); + RwIm2DVertexSetCameraZ(&maVertices[i], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[i], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[i], col.r, col.g, col.b, col.a); - RwIm2DVertexSetU(&maVertices[i], uvs[i*2 + 0], recipz); - RwIm2DVertexSetV(&maVertices[i], uvs[i*2 + 1], recipz); + RwIm2DVertexSetU(&maVertices[i], uvs[i*2 + 0], RecipNearClip); + RwIm2DVertexSetV(&maVertices[i], uvs[i*2 + 1], RecipNearClip); } } @@ -293,18 +268,13 @@ void CSprite2d::SetMaskVertices(int n, float *positions) { int i; - float screenz, recipz, z; - - screenz = NearScreenZ; - recipz = RecipNearClip; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game for(i = 0; i < n; i++){ RwIm2DVertexSetScreenX(&maVertices[i], positions[i*2 + 0]); RwIm2DVertexSetScreenY(&maVertices[i], positions[i*2 + 1]); - RwIm2DVertexSetScreenZ(&maVertices[i], screenz); - RwIm2DVertexSetCameraZ(&maVertices[i], z); - RwIm2DVertexSetRecipCameraZ(&maVertices[i], recipz); + RwIm2DVertexSetScreenZ(&maVertices[i], NearScreenZ); + RwIm2DVertexSetCameraZ(&maVertices[i], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&maVertices[i], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[i], 255, 255, 255, 255); // 0, 0, 0, 0 on PC } } @@ -313,53 +283,47 @@ void CSprite2d::SetVertices(RwIm2DVertex *verts, const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2) { - float screenz, recipz, z; - - screenz = NearScreenZ; - recipz = RecipNearClip; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game - RwIm2DVertexSetScreenX(&verts[0], r.left); RwIm2DVertexSetScreenY(&verts[0], r.top); - RwIm2DVertexSetScreenZ(&verts[0], screenz); - RwIm2DVertexSetCameraZ(&verts[0], z); - RwIm2DVertexSetRecipCameraZ(&verts[0], recipz); + RwIm2DVertexSetScreenZ(&verts[0], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[0], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&verts[0], u0, recipz); - RwIm2DVertexSetV(&verts[0], v0, recipz); + RwIm2DVertexSetU(&verts[0], u0, RecipNearClip); + RwIm2DVertexSetV(&verts[0], v0, RecipNearClip); RwIm2DVertexSetScreenX(&verts[1], r.right); RwIm2DVertexSetScreenY(&verts[1], r.top); - RwIm2DVertexSetScreenZ(&verts[1], screenz); - RwIm2DVertexSetCameraZ(&verts[1], z); - RwIm2DVertexSetRecipCameraZ(&verts[1], recipz); + RwIm2DVertexSetScreenZ(&verts[1], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[1], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&verts[1], u1, recipz); - RwIm2DVertexSetV(&verts[1], v1, recipz); + RwIm2DVertexSetU(&verts[1], u1, RecipNearClip); + RwIm2DVertexSetV(&verts[1], v1, RecipNearClip); RwIm2DVertexSetScreenX(&verts[2], r.right); RwIm2DVertexSetScreenY(&verts[2], r.bottom); - RwIm2DVertexSetScreenZ(&verts[2], screenz); - RwIm2DVertexSetCameraZ(&verts[2], z); - RwIm2DVertexSetRecipCameraZ(&verts[2], recipz); + RwIm2DVertexSetScreenZ(&verts[2], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[2], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&verts[2], u2, recipz); - RwIm2DVertexSetV(&verts[2], v2, recipz); + RwIm2DVertexSetU(&verts[2], u2, RecipNearClip); + RwIm2DVertexSetV(&verts[2], v2, RecipNearClip); RwIm2DVertexSetScreenX(&verts[3], r.left); RwIm2DVertexSetScreenY(&verts[3], r.bottom); - RwIm2DVertexSetScreenZ(&verts[3], screenz); - RwIm2DVertexSetCameraZ(&verts[3], z); - RwIm2DVertexSetRecipCameraZ(&verts[3], recipz); + RwIm2DVertexSetScreenZ(&verts[3], NearScreenZ); + RwIm2DVertexSetCameraZ(&verts[3], NearCamZ); + RwIm2DVertexSetRecipCameraZ(&verts[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&verts[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&verts[3], u3, recipz); - RwIm2DVertexSetV(&verts[3], v3, recipz); + RwIm2DVertexSetU(&verts[3], u3, RecipNearClip); + RwIm2DVertexSetV(&verts[3], v3, RecipNearClip); } void CSprite2d::DrawRect(const CRect &r, const CRGBA &col) { - SetVertices(r, col, col, col, col, false); + SetVertices(r, col, col, col, col); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); @@ -374,7 +338,7 @@ CSprite2d::DrawRect(const CRect &r, const CRGBA &col) void CSprite2d::DrawRect(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - SetVertices(r, c0, c1, c2, c3, false); + SetVertices(r, c0, c1, c2, c3); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); @@ -387,7 +351,7 @@ CSprite2d::DrawRect(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGB void CSprite2d::DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { - SetVertices(r, c0, c1, c2, c3, false); + SetVertices(r, c0, c1, c2, c3); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); diff --git a/src/render/Sprite2d.h b/src/render/Sprite2d.h index 1adb5d49..5abd8d71 100644 --- a/src/render/Sprite2d.h +++ b/src/render/Sprite2d.h @@ -4,6 +4,7 @@ class CSprite2d { static float RecipNearClip; static float NearScreenZ; + static float NearCamZ; // not original static int nextBufferVertex; static int nextBufferIndex; static RwIm2DVertex maVertices[8]; @@ -27,7 +28,7 @@ public: void Draw(const CRect &rect, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); void Draw(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &col); - static void SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, uint32 far); + static void SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); static void SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3, float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2); static void SetVertices(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, -- cgit v1.2.3 From b54bb62c944f8f3e8d85501fbb762915fdc6569b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 13 Aug 2020 23:39:55 +0300 Subject: Stats(except displaying), PlayerInfo, marker fix --- src/render/SpecialFX.cpp | 40 ++++++++++++++++++++++++++++++++++------ src/render/SpecialFX.h | 1 + src/render/Timecycle.cpp | 2 +- src/render/Timecycle.h | 2 +- 4 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src/render') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 4133e2fb..e9079bef 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -21,6 +21,9 @@ #include "Camera.h" #include "Shadows.h" #include "main.h" +#include "ColStore.h" +#include "Coronas.h" +#include "Script.h" RwIm3DVertex StreakVertices[4]; RwImVertexIndex StreakIndexList[12]; @@ -370,6 +373,8 @@ MarkerAtomicCB(RpAtomic *atomic, void *data) return atomic; } +// --MIAMI: C3dMarker and C3dMarkers done + bool C3dMarker::AddMarker(uint32 identifier, uint16 type, float fSize, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate) { @@ -414,6 +419,7 @@ C3dMarker::DeleteMarkerObject() m_nIdentifier = 0; m_nStartTime = 0; m_bIsUsed = false; + m_bFindZOnNextPlacement = false; m_nType = MARKERTYPE_INVALID; frame = RpAtomicGetFrame(m_pAtomic); @@ -457,6 +463,7 @@ C3dMarkers::Init() m_aMarkerArray[i].m_pAtomic = nil; m_aMarkerArray[i].m_nType = MARKERTYPE_INVALID; m_aMarkerArray[i].m_bIsUsed = false; + m_aMarkerArray[i].m_bFindZOnNextPlacement = false; m_aMarkerArray[i].m_nIdentifier = 0; m_aMarkerArray[i].m_Color.red = 255; m_aMarkerArray[i].m_Color.green = 255; @@ -502,8 +509,15 @@ C3dMarkers::Render() ActivateDirectional(); for (int i = 0; i < NUM3DMARKERS; i++) { if (m_aMarkerArray[i].m_bIsUsed) { - if (m_aMarkerArray[i].m_fCameraRange < 120.0f) + if (m_aMarkerArray[i].m_fCameraRange < 150.0f) { m_aMarkerArray[i].Render(); + if (m_aMarkerArray[i].m_nType == MARKERTYPE_ARROW) { + 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); + } + } NumActiveMarkers++; m_aMarkerArray[i].m_bIsUsed = false; } else if (m_aMarkerArray[i].m_pAtomic != nil) { @@ -516,9 +530,9 @@ C3dMarker * C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate) { C3dMarker *pMarker; - + CVector2D playerPos = FindPlayerCentreOfWorld(0); pMarker = nil; - float dist = Sqrt((pos.x - FindPlayerCentreOfWorld(0).x) * (pos.x - FindPlayerCentreOfWorld(0).x) + (pos.y - FindPlayerCentreOfWorld(0).y) * (pos.y - FindPlayerCentreOfWorld(0).y)); + float dist = ((CVector2D)pos - playerPos).Magnitude(); if (type != MARKERTYPE_ARROW && type != MARKERTYPE_CYLINDER) return nil; @@ -591,6 +605,15 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size } if (type == MARKERTYPE_ARROW) pMarker->m_Matrix.GetPosition() = pos; + + if (pMarker->m_bFindZOnNextPlacement) { + 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) + pMarker->m_Matrix.GetPosition().z = z - 0.05f * size; + pMarker->m_bFindZOnNextPlacement = false; + } + } pMarker->m_bIsUsed = true; return pMarker; } @@ -600,9 +623,14 @@ C3dMarkers::PlaceMarker(uint32 identifier, uint16 type, CVector &pos, float size pMarker->AddMarker(identifier, type, size, r, g, b, a, pulsePeriod, pulseFraction, rotateRate); if (type == MARKERTYPE_CYLINDER || type == MARKERTYPE_0 || type == MARKERTYPE_2) { - float z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z + 1.0f, nil); - if (z != 0.0f) - pos.z = z - 0.05f * size; + 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) + pos.z = z - 0.05f * size; + pMarker->m_bFindZOnNextPlacement = false; + } else { + pMarker->m_bFindZOnNextPlacement = true; + } } pMarker->m_Matrix.SetTranslate(pos.x, pos.y, pos.z); if (type == MARKERTYPE_2) { diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 7bc3750a..8c79856b 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -79,6 +79,7 @@ public: RpMaterial *m_pMaterial; uint16 m_nType; bool m_bIsUsed; + bool m_bFindZOnNextPlacement; uint32 m_nIdentifier; RwRGBA m_Color; uint16 m_nPulsePeriod; diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index 7e8ad5e5..b20a2443 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -123,7 +123,7 @@ int32 CTimeCycle::m_nCurrentFogColourGreen; int32 CTimeCycle::m_nCurrentFogColourBlue; int32 CTimeCycle::m_FogReduction; -bool CTimeCycle::m_bExtraColourOn; +int32 CTimeCycle::m_bExtraColourOn; int32 CTimeCycle::m_ExtraColour; float CTimeCycle::m_ExtraColourInter; diff --git a/src/render/Timecycle.h b/src/render/Timecycle.h index ad079a95..da911b75 100644 --- a/src/render/Timecycle.h +++ b/src/render/Timecycle.h @@ -114,7 +114,7 @@ class CTimeCycle static int32 m_FogReduction; public: - static bool m_bExtraColourOn; + static int32 m_bExtraColourOn; static int32 m_ExtraColour; static float m_ExtraColourInter; static int32 m_CurrentStoredValue; -- cgit v1.2.3 From 85d76dc1718a1399a08693cba2cc299f90f21a15 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 14 Aug 2020 09:28:17 +0200 Subject: fixed clouds render --- src/render/Clouds.cpp | 84 ++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) (limited to 'src/render') diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index c6ba0f10..15bae90b 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -71,6 +71,43 @@ CClouds::Update(void) #endif } +float StarCoorsX[9] = { 0.0f, 0.05f, 0.13f, 0.4f, 0.7f, 0.6f, 0.27f, 0.55f, 0.75f }; +float StarCoorsY[9] = { 0.0f, 0.45f, 0.9f, 1.0f, 0.85f, 0.52f, 0.48f, 0.35f, 0.2f }; +float StarSizes[9] = { 1.0f, 1.4f, 0.9f, 1.0f, 0.6f, 1.5f, 1.3f, 1.0f, 0.8f }; + +float LowCloudsX[12] = { 1.0f, 0.7f, 0.0f, -0.7f, -1.0f, -0.7f, 0.0f, 0.7f, 0.8f, -0.8f, 0.4f, -0.4f }; +float LowCloudsY[12] = { 0.0f, -0.7f, -1.0f, -0.7f, 0.0f, 0.7f, 1.0f, 0.7f, 0.4f, 0.4f, -0.8f, -0.8f }; +float LowCloudsZ[12] = { 0.0f, 1.0f, 0.5f, 0.0f, 1.0f, 0.3f, 0.9f, 0.4f, 1.3f, 1.4f, 1.2f, 1.7f }; + +float CoorsOffsetX[37] = { + 0.0f, 60.0f, 72.0f, 48.0f, 21.0f, 12.0f, + 9.0f, -3.0f, -8.4f, -18.0f, -15.0f, -36.0f, + -40.0f, -48.0f, -60.0f, -24.0f, 100.0f, 100.0f, + 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, + 100.0f, 100.0f, -30.0f, -20.0f, 10.0f, 30.0f, + 0.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f +}; +float CoorsOffsetY[37] = { + 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, + 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, + 100.0f, 100.0f, 100.0f, 100.0f, -30.0f, 10.0f, + -25.0f, -5.0f, 28.0f, -10.0f, 10.0f, 0.0f, + 15.0f, 40.0f, -100.0f, -100.0f, -100.0f, -100.0f, + -100.0f, -40.0f, -20.0f, 0.0f, 10.0f, 30.0f, 35.0f +}; +float CoorsOffsetZ[37] = { + 2.0f, 1.0f, 0.0f, 0.3f, 0.7f, 1.4f, + 1.7f, 0.24f, 0.7f, 1.3f, 1.6f, 1.0f, + 1.2f, 0.3f, 0.7f, 1.4f, 0.0f, 0.1f, + 0.5f, 0.4f, 0.55f, 0.75f, 1.0f, 1.4f, + 1.7f, 2.0f, 2.0f, 2.3f, 1.9f, 2.4f, + 2.0f, 2.0f, 1.5f, 1.2f, 1.7f, 1.5f, 2.1f +}; + +uint8 BowRed[6] = { 30, 30, 30, 10, 0, 15 }; +uint8 BowGreen[6] = { 0, 15, 30, 30, 0, 0 }; +uint8 BowBlue[6] = { 0, 0, 0, 10, 30, 30 }; + void CClouds::Render(void) { @@ -94,11 +131,10 @@ CClouds::Render(void) float minute = CClock::GetHours()*60 + CClock::GetMinutes() + CClock::GetSeconds()/60.0f; RwV3d campos = *(RwV3d*)&TheCamera.GetPosition(); - float coverage = Max(CWeather::Foggyness, CWeather::Foggyness); - // Moon float moonfadeout = Abs(minute - 180.0f); // fully visible at 3AM if((int)moonfadeout < 180){ // fade in/out 3 hours + float coverage = Max(CWeather::Foggyness, CWeather::CloudCoverage); int brightness = (1.0f - coverage) * (180 - (int)moonfadeout); RwV3d pos = { 0.0f, -100.0f, 15.0f }; RwV3dAdd(&worldpos, &campos, &pos); @@ -122,11 +158,10 @@ CClouds::Render(void) else if(CClock::GetHours() == 5) starintens = 255 * (60 - CClock::GetMinutes())/60.0f; if(starintens != 0){ - // R - static float StarCoorsX[9] = { 0.0f, 0.05f, 0.13f, 0.4f, 0.7f, 0.6f, 0.27f, 0.55f, 0.75f }; - static float StarCoorsY[9] = { 0.0f, 0.45f, 0.9f, 1.0f, 0.85f, 0.52f, 0.48f, 0.35f, 0.2f }; - static float StarSizes[9] = { 1.0f, 1.4f, 0.9f, 1.0f, 0.6f, 1.5f, 1.3f, 1.0f, 0.8f }; + float coverage = Max(CWeather::Foggyness, CWeather::CloudCoverage); int brightness = (1.0f - coverage) * starintens; + + // R RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[0])); for(i = 0; i < 11; i++){ RwV3d pos = { 100.0f, 0.0f, 10.0f }; @@ -155,13 +190,7 @@ CClouds::Render(void) } // Low clouds - static float LowCloudsX[12] = { 1.0f, 0.7f, 0.0f, -0.7f, -1.0f, -0.7f, - 0.0f, 0.7f, 0.8f, -0.8f, 0.4f, -0.4f }; - static float LowCloudsY[12] = { 0.0f, -0.7f, -1.0f, -0.7f, 0.0f, 0.7f, - 1.0f, 0.7f, 0.4f, 0.4f, -0.8f, -0.8f }; - static float LowCloudsZ[12] = { 0.0f, 1.0f, 0.5f, 0.0f, 1.0f, 0.3f, - 0.9f, 0.4f, 1.3f, 1.4f, 1.2f, 1.7f }; - float lowcloudintensity = 1.0f - Max(coverage, CWeather::ExtraSunnyness); + float lowcloudintensity = 1.0f - Max(Max(CWeather::Foggyness, CWeather::CloudCoverage), CWeather::ExtraSunnyness); int r = CTimeCycle::GetLowCloudsRed() * lowcloudintensity; int g = CTimeCycle::GetLowCloudsGreen() * lowcloudintensity; int b = CTimeCycle::GetLowCloudsBlue() * lowcloudintensity; @@ -184,30 +213,6 @@ CClouds::Render(void) float rot_cos = Cos(CloudRotation); int fluffyalpha = 160 * (1.0f - Max(CWeather::Foggyness, CWeather::ExtraSunnyness)); if(fluffyalpha != 0){ - static float CoorsOffsetX[37] = { - 0.0f, 60.0f, 72.0f, 48.0f, 21.0f, 12.0f, - 9.0f, -3.0f, -8.4f, -18.0f, -15.0f, -36.0f, - -40.0f, -48.0f, -60.0f, -24.0f, 100.0f, 100.0f, - 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, - 100.0f, 100.0f, -30.0f, -20.0f, 10.0f, 30.0f, - 0.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f, -100.0f - }; - static float CoorsOffsetY[37] = { - 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, - 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, 100.0f, - 100.0f, 100.0f, 100.0f, 100.0f, -30.0f, 10.0f, - -25.0f, -5.0f, 28.0f, -10.0f, 10.0f, 0.0f, - 15.0f, 40.0f, -100.0f, -100.0f, -100.0f, -100.0f, - -100.0f, -40.0f, -20.0f, 0.0f, 10.0f, 30.0f, 35.0f - }; - static float CoorsOffsetZ[37] = { - 2.0f, 1.0f, 0.0f, 0.3f, 0.7f, 1.4f, - 1.7f, 0.24f, 0.7f, 1.3f, 1.6f, 1.0f, - 1.2f, 0.3f, 0.7f, 1.4f, 0.0f, 0.1f, - 0.5f, 0.4f, 0.55f, 0.75f, 1.0f, 1.4f, - 1.7f, 2.0f, 2.0f, 2.3f, 1.9f, 2.4f, - 2.0f, 2.0f, 1.5f, 1.2f, 1.7f, 1.5f, 2.1f - }; static bool bCloudOnScreen[37]; float sundist, hilight; @@ -230,7 +235,7 @@ CClouds::Render(void) int bb = CTimeCycle::GetFluffyCloudsBottomBlue(); int distLimit = (3*SCREEN_WIDTH)/4; if(sundist < distLimit){ - hilight = (1.0f - coverage) * (1.0f - sundist/(float)distLimit); + hilight = (1.0f - Max(CWeather::Foggyness, CWeather::CloudCoverage)) * (1.0f - sundist/(float)distLimit); tr = tr*(1.0f-hilight) + 255*hilight; tg = tg*(1.0f-hilight) + 190*hilight; tb = tb*(1.0f-hilight) + 190*hilight; @@ -277,9 +282,6 @@ CClouds::Render(void) // Rainbow if(CWeather::Rainbow != 0.0f){ - static uint8 BowRed[6] = { 30, 30, 30, 10, 0, 15 }; - static uint8 BowGreen[6] = { 0, 15, 30, 30, 0, 0 }; - static uint8 BowBlue[6] = { 0, 0, 0, 10, 30, 30 }; RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[0])); for(i = 0; i < 6; i++){ RwV3d pos = { i*1.5f, 100.0f, 5.0f }; -- cgit v1.2.3 From 827ba62671c6e2efe96259a0f130a4d167d14c2a Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 19 Aug 2020 16:10:22 +0200 Subject: neo pipelines; postfx fix --- src/render/Renderer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 66c12dd9..a6673135 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -21,6 +21,7 @@ #include "PointLights.h" #include "Occlusion.h" #include "Renderer.h" +#include "custompipes.h" //--MIAMI: file done @@ -243,6 +244,11 @@ CRenderer::RenderEverythingBarRoads(void) if(IsRoad(e)) continue; +#ifdef EXTENDED_PIPELINES + if(CustomPipes::bRenderingEnvMap && (e->IsPed() || e->IsVehicle())) + continue; +#endif + if(e->IsVehicle() || e->IsPed() && CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255){ if(e->IsVehicle() && PutIntoSortedVehicleList((CVehicle*)e)){ -- cgit v1.2.3 From bb948904b69d6a4c49c0a0fadd69e867292b1d9e Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 19 Aug 2020 21:58:00 +0200 Subject: small stuff --- src/render/Shadows.cpp | 2 +- src/render/Shadows.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index 5bb6a734..a964ceb6 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -715,7 +715,7 @@ CShadows::StoreShadowForVehicle(CVehicle *pCar, VEH_SHD_TYPE type) } void -CShadows::StoreCarLightShadow(CAutomobile *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, +CShadows::StoreCarLightShadow(CVehicle *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle) { diff --git a/src/render/Shadows.h b/src/render/Shadows.h index 94b2981f..937ff4eb 100644 --- a/src/render/Shadows.h +++ b/src/render/Shadows.h @@ -159,7 +159,7 @@ public: static void StoreShadowToBeRendered ( uint8 ShadowType, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue); static void StoreShadowToBeRendered ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, bool bDrawOnWater, float fScale, CCutsceneShadow *pShadow, bool bDrawOnBuildings); static void StoreShadowForVehicle (CVehicle *pCar, VEH_SHD_TYPE type); - static void StoreCarLightShadow (CAutomobile *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle); + static void StoreCarLightShadow (CVehicle *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle); static void StoreShadowForPed (CPed *pPed, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY); static void StoreShadowForPedObject (CEntity *pPedObject, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY); static void StoreShadowForCutscenePedObject(CCutsceneObject *pObject, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY); -- cgit v1.2.3 From 03c90b7c4028d0db1e6eddf6c63c0842c136517a Mon Sep 17 00:00:00 2001 From: majestic Date: Wed, 19 Aug 2020 11:11:19 -0700 Subject: stable CScriptPaths --- src/render/Fluff.cpp | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/render/Fluff.h | 32 ++++++++- 2 files changed, 223 insertions(+), 2 deletions(-) (limited to 'src/render') diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 14c80a63..77d2af2a 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -1520,4 +1520,197 @@ CEscalators::Shutdown(void) { aEscalators[i].SwitchOff(); } NumEscalators = 0; +} + + +CScriptPath CScriptPaths::aArray[3]; + +void CScriptPath::FindCoorsFromDistanceOnPath(float t, float *pX, float *pY, float *pZ) +{ + int32 i; + for (i = 0; m_pNode[i + 1].t < t; i++) + if (i == m_numNodes - 1) { + // don't go beyond last node + *pX = m_pNode[m_numNodes - 1].p.x; + *pY = m_pNode[m_numNodes - 1].p.y; + *pZ = m_pNode[m_numNodes - 1].p.z; + return; + } + float f = (t - m_pNode[i].t) / (m_pNode[i + 1].t - m_pNode[i].t); + *pX = (1.0f - f)*m_pNode[i].p.x + f*m_pNode[i + 1].p.x; + *pY = (1.0f - f)*m_pNode[i].p.y + f*m_pNode[i + 1].p.y; + *pZ = (1.0f - f)*m_pNode[i].p.z + f*m_pNode[i + 1].p.z; +} + +void CScriptPath::Update(void) { + if (m_state != SCRIPT_PATH_ACTIVE) + return; + + m_fPosition += m_fSpeed * CTimer::GetTimeStepInSeconds(); + m_fPosition = clamp(m_fPosition, 0.0f, m_fTotalLength); + + if (m_pObjects[0] || m_pObjects[1] || m_pObjects[2] || m_pObjects[3] + || m_pObjects[4] || m_pObjects[5]) { + + float t1, t2; + CVector pos1, pos2; + + t1 = Max(m_fPosition - m_fObjectLength / 2.0f, 0.0f); + FindCoorsFromDistanceOnPath(t1, &pos1.x, &pos1.y, &pos1.z); + t2 = Min(m_fPosition + m_fObjectLength / 2.0f, m_fTotalLength); + FindCoorsFromDistanceOnPath(t2, &pos2.x, &pos2.y, &pos2.z); + + CVector newForward, newUp(0.0f, 0.0f, 1.0f), newRight; + + newForward = pos2 - pos1; + newForward.Normalise(); + newRight = CrossProduct(newForward, newUp); + newRight.Normalise(); + newUp = CrossProduct(newRight, newForward); + + for (int i = 0; i < 6; i++) { + if (m_pObjects[i]) { + CMatrix prevMat(m_pObjects[i]->GetMatrix()); + CVector prevPosition = m_pObjects[i]->GetPosition(); + + m_pObjects[i]->SetPosition((pos1 + pos2) / 2.0f); + m_pObjects[i]->GetRight() = newRight; + m_pObjects[i]->GetUp() = newUp; + m_pObjects[i]->GetForward() = newForward; + m_pObjects[i]->GetMatrix().UpdateRW(); + m_pObjects[i]->UpdateRwFrame(); + + if (!m_pObjects[i]->bIsBIGBuilding && prevPosition != m_pObjects[i]->GetPosition()) + m_pObjects[i]->RemoveAndAdd(); + + m_pObjects[i]->GetMatrix().UpdateRW(); + m_pObjects[i]->UpdateRwFrame(); + + m_pObjects[i]->m_vecMoveSpeed = (m_pObjects[i]->GetPosition() - prevMat.GetPosition()) / CTimer::GetTimeStep(); + + float deltaAngle = m_pObjects[i]->GetForward().Heading() - prevMat.GetForward().Heading(); + while (deltaAngle < (float)PI) deltaAngle += (float)TWOPI; + while (deltaAngle > (float)PI) deltaAngle -= (float)TWOPI; + float zTurnSpeed = deltaAngle / CTimer::GetTimeStep(); + + m_pObjects[i]->m_vecTurnSpeed = CVector(0.0f, 0.0f, zTurnSpeed); + m_pObjects[i]->m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f); + m_pObjects[i]->m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f); + } + } + } +} + +void CScriptPath::Clear(void) { + if (m_pNode) + delete m_pNode; + m_pNode = nil; + m_numNodes = 0; + for (int i = 0; i < 6; i++) + m_pObjects[i] = nil; + m_state = SCRIPT_PATH_DISABLED; +} + +void CScriptPath::InitialiseOne(int32 numNodes, float width) { + char Dest[32]; + sprintf(Dest, "data\\paths\\spath%d.dat", numNodes); + m_pNode = CPlane::LoadPath(Dest, m_numNodes, m_fTotalLength, false); + m_fSpeed = 1.0f; + m_fPosition = 0.0f; + m_fObjectLength = width; + m_state = SCRIPT_PATH_INITIALIZED; +} + +void CScriptPath::SetObjectToControl(CObject *pObj) { + int32 i = 0; + while (i < 6 && m_pObjects[i]) + i++; + m_pObjects[i] = pObj; + pObj->RegisterReference((CEntity**)&m_pObjects[i]); + pObj->m_phy_flagA08 = false; + m_state = SCRIPT_PATH_ACTIVE; +} + +void CScriptPaths::Init(void) { + for (int i = 0; i < 3; i++) + aArray[i].Clear(); +} + +void CScriptPaths::Shutdown(void) { + for (int i = 0; i < 3; i++) + aArray[i].Clear(); +} + +void CScriptPaths::Update(void) { + for (int i = 0; i < 3; i++) + aArray[i].Update(); +} + +bool CScriptPaths::IsOneActive(void) { + for (int i = 0; i < 3; i++) + if (aArray[i].m_state == SCRIPT_PATH_ACTIVE && aArray[i].m_fSpeed != 0.0f) + return true; + + return false; +} + +void CScriptPaths::Load(uint8 *buf, uint32 size) { +INITSAVEBUF + for (int32 i = 0; i < 3; i++) + aArray[i].Clear(); + + for (int32 i = 0; i < 3; i++) { + aArray[i] = ReadSaveBuf(buf); + + for (int32 j = 0; j < 6; j++) { + CScriptPath *pPath = &aArray[i]; + if (pPath->m_pObjects[j] != nil) { + pPath->m_pObjects[j] = CPools::GetObjectPool()->GetSlot((uintptr)pPath->m_pObjects[j] - 1); + pPath->m_pObjects[j]->m_phy_flagA08 = false; + } + } + + aArray[i].m_pNode = new CPlaneNode[aArray[i].m_numNodes]; + for (int32 j = 0; j < aArray[i].m_numNodes; j++) { + aArray[i].m_pNode[j] = ReadSaveBuf(buf); + } + } +VALIDATESAVEBUF(size) +} + +void CScriptPaths::Save(uint8 *buf, uint32 *size) { + *size = sizeof(aArray); +INITSAVEBUF + for (int32 i = 0; i < 3; i++) { + CScriptPath *pPath = WriteSaveBuf(buf, aArray[i]); + + for (int32 j = 0; j < 6; j++) { + if (pPath->m_pObjects[j] != nil) + pPath->m_pObjects[j] = (CObject*)(CPools::GetObjectPool()->GetJustIndex(pPath->m_pObjects[j]) + 1); + } + + for (int32 j = 0; j < aArray[i].m_numNodes; j++) { + WriteSaveBuf(buf, aArray[i].m_pNode[j]); + *size += sizeof(aArray[i].m_pNode[j]); + } + } +VALIDATESAVEBUF(*size); +} + +CObject* g_pScriptPathObjects[18]; + +void CScriptPaths::Load_ForReplay(void) { + for (int i = 0; i < 3; i++) { + for (int32 j = 0; j < 6; j++) { + aArray[i].m_pObjects[j] = g_pScriptPathObjects[6 * i + j]; + } + } +} + +void CScriptPaths::Save_ForReplay(void) { + for (int i = 0; i < 3; i++) { + for (int32 j = 0; j < 6; j++) { + g_pScriptPathObjects[6 * i + j] = aArray[i].m_pObjects[j]; + } + } } \ No newline at end of file diff --git a/src/render/Fluff.h b/src/render/Fluff.h index a938a4fe..a31ac335 100644 --- a/src/render/Fluff.h +++ b/src/render/Fluff.h @@ -2,17 +2,45 @@ #include "common.h" #include "Vector.h" #include "Object.h" +#include "Plane.h" + +enum { + SCRIPT_PATH_DISABLED = 0, + SCRIPT_PATH_INITIALIZED, + SCRIPT_PATH_ACTIVE +}; -// TODO class CScriptPath { public: + int32 m_numNodes; + CPlaneNode *m_pNode; + float m_fTotalLength; + float m_fSpeed; + float m_fPosition; + float m_fObjectLength; + int32 m_state; + CObject *m_pObjects[6]; + + void Clear(void); + void Update(void); + void InitialiseOne(int32 numNodes, float width); + void FindCoorsFromDistanceOnPath(float t, float *pX, float *pY, float *pZ); + void SetObjectToControl(CObject *pObj); }; -// TODO class CScriptPaths { public: + static CScriptPath aArray[3]; + static void Init(void); + static void Shutdown(void); + static void Update(void); + static bool IsOneActive(void); + static void Save(uint8 *buf, uint32 *size); + static void Load(uint8 *buf, uint32 size); + static void Save_ForReplay(); + static void Load_ForReplay(); }; class CPlaneTrail -- cgit v1.2.3 From 23c52c1c86620f4204371c034ce1c4d5c5e93b39 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 21 Aug 2020 09:40:31 +0200 Subject: fixed CRenderer::ScanSectorPoly again --- src/render/Renderer.cpp | 83 +++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 41 deletions(-) (limited to 'src/render') diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a6673135..3b996b55 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -889,6 +889,12 @@ CalcNewDelta(RwV2d *a, RwV2d *b) return (b->x - a->x) / (b->y - a->y); } +#ifdef FIX_BUGS +#define TOINT(x) ((int)Floor(x)) +#else +#define TOINT(x) ((int)(x)) +#endif + void CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrList *)) { @@ -914,13 +920,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL a2 = i; } } -#ifdef FIX_BUGS - y = Floor(miny); - yend = Floor(maxy); -#else - y = miny; - yend = maxy; -#endif + y = TOINT(miny); + yend = TOINT(maxy); // Go left in poly to find first edge b b2 = a2; @@ -928,8 +929,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL b1 = b2--; if(b2 < 0) b2 = numVertices-1; if(poly[b1].x < xstart) - xstart = poly[b1].x; - if((int)poly[b1].y != (int)poly[b2].y) + xstart = TOINT(poly[b1].x); + if(TOINT(poly[b1].y) != TOINT(poly[b2].y)) break; } // Go right to find first edge a @@ -937,8 +938,8 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL a1 = a2++; if(a2 == numVertices) a2 = 0; if(poly[a1].x > xend) - xend = poly[a1].x; - if((int)poly[a1].y != (int)poly[a2].y) + xend = TOINT(poly[a1].x); + if(TOINT(poly[a1].y) != TOINT(poly[a2].y)) break; } @@ -949,10 +950,10 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x; if(y != yend){ - if(deltaB < 0.0f && (int)xB < xstart) - xstart = xB; - if(deltaA >= 0.0f && (int)xA > xend) - xend = xA; + if(deltaB < 0.0f && TOINT(xB) < xstart) + xstart = TOINT(xB); + if(deltaA >= 0.0f && TOINT(xA) > xend) + xend = TOINT(xA); } while(y <= yend && y < NUMSECTORS_Y){ @@ -968,74 +969,74 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL xB += deltaB; // update left side - if(y == (int)poly[b2].y){ + if(y == TOINT(poly[b2].y)){ // reached end of edge if(y == yend){ if(deltaB < 0.0f){ do{ - xstart = poly[b2--].x; + xstart = TOINT(poly[b2--].x); if(b2 < 0) b2 = numVertices-1; - }while(xstart > (int)poly[b2].x); + }while(xstart > TOINT(poly[b2].x)); }else - xstart = xB - deltaB; + xstart = TOINT(xB - deltaB); }else{ // switch edges if(deltaB < 0.0f) - xstart = poly[b2].x; + xstart = TOINT(poly[b2].x); else - xstart = xB - deltaB; + xstart = TOINT(xB - deltaB); do{ b1 = b2--; if(b2 < 0) b2 = numVertices-1; - if((int)poly[b1].x < xstart) - xstart = poly[b1].x; - }while(y == (int)poly[b2].y); + if(TOINT(poly[b1].x) < xstart) + xstart = TOINT(poly[b1].x); + }while(y == TOINT(poly[b2].y)); deltaB = CalcNewDelta(&poly[b1], &poly[b2]); xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x; - if(deltaB < 0.0f && (int)xB < xstart) - xstart = xB; + if(deltaB < 0.0f && TOINT(xB) < xstart) + xstart = TOINT(xB); } }else{ if(deltaB < 0.0f) - xstart = xB; + xstart = TOINT(xB); else - xstart = xB - deltaB; + xstart = TOINT(xB - deltaB); } // update right side - if(y == (int)poly[a2].y){ + if(y == TOINT(poly[a2].y)){ // reached end of edge if(y == yend){ if(deltaA < 0.0f) - xend = xA - deltaA; + xend = TOINT(xA - deltaA); else{ do{ - xend = poly[a2++].x; + xend = TOINT(poly[a2++].x); if(a2 == numVertices) a2 = 0; - }while(xend < (int)poly[a2].x); + }while(xend < TOINT(poly[a2].x)); } }else{ // switch edges if(deltaA < 0.0f) - xend = xA - deltaA; + xend = TOINT(xA - deltaA); else - xend = poly[a2].x; + xend = TOINT(poly[a2].x); do{ a1 = a2++; if(a2 == numVertices) a2 = 0; - if((int)poly[a1].x > xend) - xend = poly[a1].x; - }while(y == (int)poly[a2].y); + if(TOINT(poly[a1].x) > xend) + xend = TOINT(poly[a1].x); + }while(y == TOINT(poly[a2].y)); deltaA = CalcNewDelta(&poly[a1], &poly[a2]); xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x; - if(deltaA >= 0.0f && (int)xA > xend) - xend = xA; + if(deltaA >= 0.0f && TOINT(xA) > xend) + xend = TOINT(xA); } }else{ if(deltaA < 0.0f) - xend = xA - deltaA; + xend = TOINT(xA - deltaA); else - xend = xA; + xend = TOINT(xA); } } } -- cgit v1.2.3 From 38a01a59fab9f95f8413166e79e4a34ff77fbbb0 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 23 Aug 2020 13:27:37 +0200 Subject: CWeather done --- src/render/Weather.cpp | 308 +++++++++++++++++++++++++++++-------------------- src/render/Weather.h | 3 + 2 files changed, 189 insertions(+), 122 deletions(-) (limited to 'src/render') diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index 945e1f5e..3f242362 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -19,6 +19,9 @@ #include "World.h" #include "ZoneCull.h" #include "SpecialFX.h" +#include "Replay.h" + +//--MIAMI: file done int32 CWeather::SoundHandle = -1; @@ -33,6 +36,7 @@ uint32 CWeather::LightningStart; uint32 CWeather::LightningFlashLastChange; uint32 CWeather::WhenToPlayLightningSound; uint32 CWeather::LightningDuration; +int32 CWeather::StreamAfterRainTimer; float CWeather::ExtraSunnyness; float CWeather::Foggyness; @@ -88,7 +92,7 @@ const int16 WeatherTypesList_WithHurricanes[] = { WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY, WEATHER_EXTRA_SUNNY }; -const float Windiness[] = { +const float Windyness[] = { 0.25f,// WEATHER_SUNNY 0.7f, // WEATHER_CLOUDY 1.0f, // WEATHER_RAINY @@ -140,22 +144,27 @@ void CWeather::Init(void) void CWeather::Update(void) { - float fNewInterpolation = CClock::GetMinutes() * 1.0f / 60; - if (fNewInterpolation < InterpolationValue) { - // new hour - OldWeatherType = NewWeatherType; - if (ForcedWeatherType >= 0) - NewWeatherType = ForcedWeatherType; - else { - WeatherTypeInList = (WeatherTypeInList + 1) % ARRAY_SIZE(WeatherTypesList); - NewWeatherType = CStats::NoMoreHurricanes ? WeatherTypesList[WeatherTypeInList] : WeatherTypesList_WithHurricanes[WeatherTypeInList]; + if(!CReplay::IsPlayingBack()){ + float fNewInterpolation = (CClock::GetMinutes() + CClock::GetSeconds()/60.0f)/60.0f; + if (fNewInterpolation < InterpolationValue) { + // new hour + OldWeatherType = NewWeatherType; + if (ForcedWeatherType >= 0) + NewWeatherType = ForcedWeatherType; + else { + WeatherTypeInList = (WeatherTypeInList + 1) % ARRAY_SIZE(WeatherTypesList); + NewWeatherType = CStats::NoMoreHurricanes ? WeatherTypesList[WeatherTypeInList] : WeatherTypesList_WithHurricanes[WeatherTypeInList]; + } } + InterpolationValue = fNewInterpolation; } - InterpolationValue = fNewInterpolation; + +#ifndef FINAL if (CPad::GetPad(1)->GetRightShockJustDown()) { NewWeatherType = (NewWeatherType + 1) % WEATHER_TOTAL; OldWeatherType = NewWeatherType; } +#endif // Lightning if (NewWeatherType != WEATHER_RAINY || OldWeatherType != WEATHER_RAINY) { @@ -227,6 +236,7 @@ void CWeather::Update(void) // if rain is ongoing for >24 minutes, values: 0.25, 0.5, 0.75, 1.0, switching every ~16.5s fNewRain = 0.25f + ((uint16)CTimer::GetTimeInMilliseconds() >> 14) * 0.25f; } + fNewRain = Max(fNewRain, 0.5f); } else fNewRain = 0.0f; @@ -257,7 +267,7 @@ void CWeather::Update(void) ExtraSunnyness += InterpolationValue; // Rainbow - if (OldWeatherType == WEATHER_RAINY && (NewWeatherType == WEATHER_SUNNY || NewWeatherType == WEATHER_EXTRA_SUNNY) && + if (OldWeatherType == WEATHER_CLOUDY && (NewWeatherType == WEATHER_SUNNY || NewWeatherType == WEATHER_EXTRA_SUNNY) && InterpolationValue < 0.5f && CClock::GetHours() > 6 && CClock::GetHours() < 21) Rainbow = 1.0f - 4.0f * Abs(InterpolationValue - 0.25f) / 4.0f; else @@ -278,18 +288,21 @@ void CWeather::Update(void) SunGlare *= (1.0f - (CGeneral::GetRandomNumber()&0x1F)*0.007f); } - Wind = InterpolationValue * Windiness[NewWeatherType] + (1.0f - InterpolationValue) * Windiness[OldWeatherType]; + Wind = InterpolationValue * Windyness[NewWeatherType] + (1.0f - InterpolationValue) * Windyness[OldWeatherType]; WindClipped = Min(1.0f, Wind); - if (CClock::GetHours() == 20) + if (CClock::GetHours() > 20) + TrafficLightBrightness = 1.0f; + else if (CClock::GetHours() > 19) TrafficLightBrightness = CClock::GetMinutes() / 60.0f; - else if (CClock::GetHours() > 6 && CClock::GetHours() < 20) + else if (CClock::GetHours() > 6) TrafficLightBrightness = 0.0f; - else if (CClock::GetHours() == 6) + else if (CClock::GetHours() > 5) TrafficLightBrightness = 1.0f - CClock::GetMinutes() / 60.0f; else TrafficLightBrightness = 1.0f; TrafficLightBrightness = Max(WetRoads, TrafficLightBrightness); + TrafficLightBrightness = Max(Foggyness, TrafficLightBrightness); TrafficLightBrightness = Max(Rain, TrafficLightBrightness); AddRain(); @@ -312,12 +325,32 @@ void CWeather::Update(void) void CWeather::AddHeatHaze() { - /* TODO(MIAMI) */ + if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || + TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) + return; + CVector pos; + pos.x = SCREEN_WIDTH*0.5f; + if(TheCamera.GetLookingForwardFirstPerson()) + pos.y = CGeneral::GetRandomNumberInRange(SCREEN_HEIGHT*0.25f, SCREEN_HEIGHT*0.9f); + else + pos.y = CGeneral::GetRandomNumberInRange(SCREEN_HEIGHT*0.4f, SCREEN_HEIGHT*0.9f); + pos.z = 100.0f; + CParticle::AddParticle(PARTICLE_HEATHAZE_IN_DIST, pos, CVector(0.0f, 0.0f, 0.0f)); } void CWeather::AddBeastie() { - /* TODO(MIAMI) */ + if(FindPlayerVehicle() || CTimer::GetFrameCounter()%10 || (CGeneral::GetRandomNumber()&5) == 0) + return; + CVector pos = TheCamera.GetPosition(); + float dist = CGeneral::GetRandomNumberInRange(90.0f, 60.0f); + int angle = CGeneral::GetRandomNumber() % CParticle::SIN_COS_TABLE_SIZE; + float c = CParticle::m_CosTable[angle]; + float s = CParticle::m_SinTable[angle]; + pos.x += dist*(c - s); + pos.y += dist*(c + s); + pos.z += CGeneral::GetRandomNumberInRange(7.5f, 30.0f); + CParticle::AddParticle(PARTICLE_BEASTIE, pos, CVector(0.0f, 0.0f, 0.0f)); } void CWeather::ForceWeather(int16 weather) @@ -337,6 +370,62 @@ void CWeather::ReleaseWeather() ForcedWeatherType = -1; } +void CWeather::AddSplashesDuringHurricane() +{ + RwRGBA colour = { 255, 255, 255, 32 }; + CVector pos = TheCamera.pTargetEntity ? TheCamera.pTargetEntity->GetPosition() : TheCamera.GetPosition(); + bool foundGround; + float groundZ = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &foundGround) + 0.1f; + if(!foundGround) + groundZ = pos.z + 0.5f; + for(int i = 0; i < 20; i++){ + float dist = (CGeneral::GetRandomNumber()&0xFF)/255.0f + + CGeneral::GetRandomNumberInRange(-10.0f, 30.0f); + float angle; + uint8 rnd = CGeneral::GetRandomNumber(); + if(rnd&1) + angle = (CGeneral::GetRandomNumber()&0x7F)/128.0f * TWOPI; + else + angle = TheCamera.Orientation + (rnd-128)/160.0f; + pos.x = TheCamera.GetPosition().x + dist*Sin(angle); + pos.y = TheCamera.GetPosition().y + dist*Cos(angle); + pos.z = groundZ; + if(foundGround) + CParticle::AddParticle(PARTICLE_GROUND_STEAM, pos, CVector(-0.002f, -0.002f, 0.015f), nil, 0.0f, colour); + } +} + +static int startStreamAfterRain; + +void CWeather::AddStreamAfterRain() +{ + if(CClock::GetHours() > 6 && CClock::GetHours() < 18){ + RwRGBA colour = { 255, 255, 255, 24 }; + CVector pos = TheCamera.pTargetEntity ? TheCamera.pTargetEntity->GetPosition() : TheCamera.GetPosition(); + bool foundGround; + float groundZ = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &foundGround) + 0.2f; + if(!foundGround) + groundZ = pos.z + 0.75f; + for(int i = 0; i < 20; i++){ + float dist = (CGeneral::GetRandomNumber()&0xFF)/255.0f + + CGeneral::GetRandomNumberInRange(-10.0f, 30.0f); + float angle; + uint8 rnd = CGeneral::GetRandomNumber(); + if(rnd&1) + angle = (CGeneral::GetRandomNumber()&0x7F)/128.0f * TWOPI; + else + angle = TheCamera.Orientation + (rnd-128)/160.0f; + pos.x = TheCamera.GetPosition().x + dist*Sin(angle); + pos.y = TheCamera.GetPosition().y + dist*Cos(angle); + pos.z = groundZ; + CParticle::AddParticle(PARTICLE_GROUND_STEAM, pos, CVector(0.0f, 0.0f, 0.015f), nil, 0.0f, colour); + } + }else{ + startStreamAfterRain = 0; + StreamAfterRainTimer = 800; + } +} + void CWeather::AddRain() { if (CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) @@ -348,104 +437,77 @@ void CWeather::AddRain() return; } } + + if(Rain > 0.0){ + startStreamAfterRain = 1; + StreamAfterRainTimer = 800; + }else if(startStreamAfterRain){ + if(StreamAfterRainTimer > 0){ + AddStreamAfterRain(); + StreamAfterRainTimer--; + }else{ + startStreamAfterRain = 0; + StreamAfterRainTimer = 800; + } + } + + if (Wind > 1.1f) + AddSplashesDuringHurricane(); + if (Rain <= 0.1f) return; static RwRGBA colour; - float screen_width = RsGlobal.width; - float screen_height = RsGlobal.height; - int cur_frame = (int)(3 * Rain) & 3; - int num_drops = (int)(2 * Rain) + 2; - static int STATIC_RAIN_ANGLE = -45; - static int count = 1500; - static int add_angle = 1; - if (--count == 0) { - count = 1; - if (add_angle) { - STATIC_RAIN_ANGLE += 12; - if (STATIC_RAIN_ANGLE > 45) { - count = 1500; - add_angle = !add_angle; - } - } - else { - STATIC_RAIN_ANGLE -= 12; - if (STATIC_RAIN_ANGLE < -45) { - count = 1500; - add_angle = !add_angle; - } - } - } - float rain_angle = DEGTORAD(STATIC_RAIN_ANGLE + ((STATIC_RAIN_ANGLE < 0) ? 360 : 0)); - float sin_angle = Sin(rain_angle); - float cos_angle = Cos(rain_angle); - float base_x = 0.0f * cos_angle - 1.0f * sin_angle; - float base_y = 1.0f * cos_angle + 0.0f * sin_angle; - CVector xpos(0.0f, 0.0f, 0.0f); - for (int i = 0; i < 2 * num_drops; i++) { - CVector dir; - dir.x = (CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) + base_x) * CGeneral::GetRandomNumberInRange(10.0f, 25.0f); - dir.y = (CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) + base_y) * CGeneral::GetRandomNumberInRange(10.0f, 25.0f); - dir.z = 0; - CParticle::AddParticle(PARTICLE_RAINDROP_2D, xpos, dir, nil, CGeneral::GetRandomNumberInRange(0.5f, 0.9f), - colour, 0, rain_angle + CGeneral::GetRandomNumberInRange(-10, 10), cur_frame); - xpos.x += screen_width / (2 * num_drops); - xpos.x += CGeneral::GetRandomNumberInRange(-25.0f, 25.0f); - } - CVector ypos(0.0f, 0.0f, 0.0f); - for (int i = 0; i < num_drops; i++) { - CVector dir; - dir.x = (CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) + base_x) * CGeneral::GetRandomNumberInRange(10.0f, 25.0f); - dir.y = (CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) + base_y) * CGeneral::GetRandomNumberInRange(10.0f, 25.0f); - dir.z = 0; - CParticle::AddParticle(PARTICLE_RAINDROP_2D, ypos, dir, nil, CGeneral::GetRandomNumberInRange(0.5f, 0.9f), - colour, 0, rain_angle + CGeneral::GetRandomNumberInRange(-10, 10), cur_frame); - ypos.y += screen_width / num_drops; - ypos.y += CGeneral::GetRandomNumberInRange(-25.0f, 25.0f); - } - CVector ypos2(0.0f, 0.0f, 0.0f); - for (int i = 0; i < num_drops; i++) { - CVector dir; - dir.x = (CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) + base_x) * CGeneral::GetRandomNumberInRange(10.0f, 25.0f); - dir.y = (CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) + base_y) * CGeneral::GetRandomNumberInRange(10.0f, 25.0f); - dir.z = 0; - CParticle::AddParticle(PARTICLE_RAINDROP_2D, ypos2, dir, nil, CGeneral::GetRandomNumberInRange(0.5f, 0.9f), - colour, 0, rain_angle + CGeneral::GetRandomNumberInRange(-10, 10), cur_frame); - ypos2.y += screen_width / num_drops; - ypos2.y += CGeneral::GetRandomNumberInRange(-25.0f, 25.0f); - } - for (int i = 0; i < num_drops; i++) { - CVector pos; - pos.x = CGeneral::GetRandomNumberInRange(DROPLETS_LEFT_OFFSET, screen_width - DROPLETS_RIGHT_OFFSET); - pos.y = CGeneral::GetRandomNumberInRange(DROPLETS_TOP_OFFSET, screen_height - DROPLETS_TOP_OFFSET); + int numDrops = 5.0f * Rain; + int numSplashes = 2.0f * Rain; + CVector pos, dir; + for(int i = 0; i < numDrops; i++){ + pos.x = CGeneral::GetRandomNumberInRange(0, (int)SCREEN_WIDTH); + pos.y = CGeneral::GetRandomNumberInRange(0, (int)SCREEN_HEIGHT/5); + pos.z = 0.0f; + dir.x = 0.0f; + dir.y = CGeneral::GetRandomNumberInRange(30.0f, 40.0f); + dir.z = 0.0f; + CParticle::AddParticle(PARTICLE_RAINDROP_2D, pos, dir, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.75f), 0, 0, (int)Rain&3, 0); + + pos.x = CGeneral::GetRandomNumberInRange(0, (int)SCREEN_WIDTH); + pos.y = CGeneral::GetRandomNumberInRange((int)SCREEN_HEIGHT/5, (int)SCREEN_HEIGHT/2); + pos.z = 0.0f; + dir.x = 0.0f; + dir.y = CGeneral::GetRandomNumberInRange(30.0f, 40.0f); + dir.z = 0.0f; + CParticle::AddParticle(PARTICLE_RAINDROP_2D, pos, dir, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.75f), 0, 0, (int)Rain&3, 0); + + pos.x = CGeneral::GetRandomNumberInRange(0, (int)SCREEN_WIDTH); + pos.y = 0.0f; + pos.z = 0.0f; + dir.x = 0.0f; + dir.y = CGeneral::GetRandomNumberInRange(30.0f, 40.0f); + dir.z = 0.0f; + CParticle::AddParticle(PARTICLE_RAINDROP_2D, pos, dir, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.75f), 0, 0, (int)Rain&3, 0); + + float dist = CGeneral::GetRandomNumberInRange(0.0f, Max(10.0f*Rain, 40.0f)/2.0f); + float angle; + uint8 rnd = CGeneral::GetRandomNumber(); + if(rnd&1) + angle = (CGeneral::GetRandomNumber()&0x7F)/128.0f * TWOPI; + else + angle = TheCamera.Orientation + (rnd-128)/160.0f; + pos.x = TheCamera.GetPosition().x + dist*Sin(angle); + pos.y = TheCamera.GetPosition().y + dist*Cos(angle); pos.z = 0.0f; - CParticle::AddParticle(PARTICLE_RAINDROP_2D, pos, CVector(0.0f, 0.0f, 0.0f), nil, CGeneral::GetRandomNumberInRange(0.5f, 0.9f), - colour, CGeneral::GetRandomNumberInRange(-10, 10), 360 - rain_angle + CGeneral::GetRandomNumberInRange(-30, 30), cur_frame, 0); - } - int num_splash_attempts = (int)(3 * Rain) + 1; - int num_splashes = (int)(3 * Rain) + 4; - CVector splash_points[4]; - splash_points[0] = CVector(-RwCameraGetViewWindow(TheCamera.m_pRwCamera)->x, RwCameraGetViewWindow(TheCamera.m_pRwCamera)->y, 1.0f) * - RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) / (RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) * *(CVector2D*)RwCameraGetViewWindow(TheCamera.m_pRwCamera)).Magnitude(); - splash_points[1] = CVector(RwCameraGetViewWindow(TheCamera.m_pRwCamera)->x, RwCameraGetViewWindow(TheCamera.m_pRwCamera)->y, 1.0f) * - RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) / (RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) * *(CVector2D*)RwCameraGetViewWindow(TheCamera.m_pRwCamera)).Magnitude(); - splash_points[2] = 4.0f * CVector(-RwCameraGetViewWindow(TheCamera.m_pRwCamera)->x, RwCameraGetViewWindow(TheCamera.m_pRwCamera)->y, 1.0f) * - RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) / (RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) * *(CVector2D*)RwCameraGetViewWindow(TheCamera.m_pRwCamera)).Magnitude(); - splash_points[3] = 4.0f * CVector(RwCameraGetViewWindow(TheCamera.m_pRwCamera)->x, RwCameraGetViewWindow(TheCamera.m_pRwCamera)->y, 1.0f) * - RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) / (RwCameraGetFarClipPlane(TheCamera.m_pRwCamera) * *(CVector2D*)RwCameraGetViewWindow(TheCamera.m_pRwCamera)).Magnitude(); - RwV3dTransformPoints((RwV3d*)splash_points, (RwV3d*)splash_points, 4, RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera))); - CVector fp = (splash_points[0] + splash_points[1] + splash_points[2] + splash_points[3]) / 4; - for (int i = 0; i < num_splash_attempts; i++) { CColPoint point; - CEntity* entity; - CVector np = fp + CVector(CGeneral::GetRandomNumberInRange(-SPLASH_CHECK_RADIUS, SPLASH_CHECK_RADIUS), CGeneral::GetRandomNumberInRange(-SPLASH_CHECK_RADIUS, SPLASH_CHECK_RADIUS), 0.0f); - if (CWorld::ProcessVerticalLine(np + CVector(0.0f, 0.0f, 40.0f), -40.0f, point, entity, true, false, false, false, true, false, nil)) { - for (int j = 0; j < num_splashes; j++) - CParticle::AddParticle((CGeneral::GetRandomTrueFalse() ? PARTICLE_RAIN_SPLASH : PARTICLE_RAIN_SPLASHUP), - CVector( - np.x + CGeneral::GetRandomNumberInRange(-SPLASH_OFFSET_RADIUS, SPLASH_OFFSET_RADIUS), - np.y + CGeneral::GetRandomNumberInRange(-SPLASH_OFFSET_RADIUS, SPLASH_OFFSET_RADIUS), - point.point.z + 0.1f), - CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, colour); + CEntity *ent; + if(CWorld::ProcessVerticalLine(pos+CVector(0.0f, 0.0f, 40.0f), -40.0f, point, ent, true, false, false, false, true, false, nil)){ + pos.z = point.point.z; + for(int j = 0; j < numSplashes+15; j++){ + CVector pos2 = pos; + pos2.x += CGeneral::GetRandomNumberInRange(-15.0f, 15.0f); + pos2.y += CGeneral::GetRandomNumberInRange(-15.0f, 15.0f); + if(CGeneral::GetRandomNumber() & 1) + CParticle::AddParticle(PARTICLE_RAIN_SPLASH, pos2, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, colour); + else + CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, pos2, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, colour); + } } } } @@ -470,11 +532,11 @@ void RenderOneRainStreak(CVector pos, CVector unused, int intensity, bool scale, RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 0], 0, 0, 0, 0); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 0], pos.x + 11.0f * TheCamera.GetUp().x, pos.y + 11.0f * TheCamera.GetUp().y, pos.z + 11.0f * TheCamera.GetUp().z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 1], 0, 0, 0, 0); - RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 1], pos.x - 9.0f * TheCamera.GetRight().x, pos.y - 9.0f * TheCamera.GetRight().y, pos.z - 9.0f * TheCamera.GetUp().z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 1], pos.x - 9.0f * TheCamera.GetRight().x, pos.y - 9.0f * TheCamera.GetRight().y, pos.z - 9.0f * TheCamera.GetRight().z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 2], RAIN_COLOUR_R * intensity / 256, RAIN_COLOUR_G * intensity / 256, RAIN_COLOUR_B * intensity / 256, RAIN_ALPHA); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 2], pos.x, pos.y, pos.z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 3], 0, 0, 0, 0); - RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 3], pos.x + 9.0f * TheCamera.GetRight().x, pos.y + 9.0f * TheCamera.GetRight().y, pos.z + 9.0f * TheCamera.GetUp().z); + RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 3], pos.x + 9.0f * TheCamera.GetRight().x, pos.y + 9.0f * TheCamera.GetRight().y, pos.z + 9.0f * TheCamera.GetRight().z); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + 4], 0, 0, 0, 0); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + 4], pos.x - 11.0f * TheCamera.GetUp().x, pos.y - 11.0f * TheCamera.GetUp().y, pos.z - 11.0f * TheCamera.GetUp().z); float u = STREAK_U; @@ -493,9 +555,9 @@ void RenderOneRainStreak(CVector pos, CVector unused, int intensity, bool scale, u *= distance_coefficient; v *= distance_coefficient; if (!CTimer::GetIsPaused()) { - RandomTex = ((CGeneral::GetRandomNumber() & 255) - 128) * 0.01f; - RandomTexX = (CGeneral::GetRandomNumber() & 127) * 0.01f; - RandomTexY = (CGeneral::GetRandomNumber() & 127) * 0.01f; + RandomTex = 0.0f; + RandomTexX = 0.0f; + RandomTexY = 0.0f; } RwIm3DVertexSetU(&TempBufferRenderVertices[TempBufferVerticesStored + 0], 0.5f * u - RandomTex + RandomTexX); RwIm3DVertexSetV(&TempBufferRenderVertices[TempBufferVerticesStored + 0], -v * 0.5f + RandomTexY); @@ -518,6 +580,8 @@ void CWeather::RenderRainStreaks(void) int base_intensity = (64.0f - CTimeCycle::GetFogReduction()) / 64.0f * int(255 * Rain); if (base_intensity == 0) return; + if (TheCamera.m_CameraAverageSpeed > 1.75f) + return; TempBufferIndicesStored = 0; TempBufferVerticesStored = 0; for (int i = 0; i < NUM_RAIN_STREAKS; i++) { @@ -528,11 +592,11 @@ void CWeather::RenderRainStreaks(void) else{ int intensity; if (secondsElapsed < STREAK_INTEROLATION_TIME) - intensity = base_intensity * 0.5f * secondsElapsed / STREAK_INTEROLATION_TIME; + intensity = base_intensity * 0.25f * secondsElapsed / STREAK_INTEROLATION_TIME; else if (secondsElapsed > (STREAK_LIFETIME - STREAK_INTEROLATION_TIME)) - intensity = (STREAK_LIFETIME - secondsElapsed) * 0.5f * base_intensity / STREAK_INTEROLATION_TIME; + intensity = (STREAK_LIFETIME - secondsElapsed) * 0.25f * base_intensity / STREAK_INTEROLATION_TIME; else - intensity = base_intensity * 0.5f; + intensity = base_intensity * 0.25f; CVector dir = Streaks[i].direction; dir.Normalise(); CVector pos = Streaks[i].position + secondsElapsed * Streaks[i].direction; @@ -546,7 +610,7 @@ void CWeather::RenderRainStreaks(void) } else if ((CGeneral::GetRandomNumber() & 0xF00) == 0){ // 1/16 probability - Streaks[i].direction = CVector(4.0f, 4.0f, -4.0f); + Streaks[i].direction = CVector(0.0f, 0.0f, -12.0f); Streaks[i].position = 6.0f * TheCamera.GetForward() + TheCamera.GetPosition() + CVector(-1.8f * Streaks[i].direction.x, -1.8f * Streaks[i].direction.y, 8.0f); if (!CCutsceneMgr::IsRunning()) { Streaks[i].position.x += 2.0f * FindPlayerSpeed().x * 60.0f; @@ -554,8 +618,8 @@ void CWeather::RenderRainStreaks(void) } else Streaks[i].position += (TheCamera.GetPosition() - TheCamera.m_RealPreviousCameraPosition) * 20.0f; - Streaks[i].position.x += ((CGeneral::GetRandomNumber() & 255) - 128) * 0.08f; - Streaks[i].position.y += ((CGeneral::GetRandomNumber() & 255) - 128) * 0.08f; + Streaks[i].position.x += ((CGeneral::GetRandomNumber() & 255) - 128) * 0.04f; + Streaks[i].position.y += ((CGeneral::GetRandomNumber() & 255) - 128) * 0.04f; Streaks[i].timer = CTimer::GetTimeInMilliseconds(); } } diff --git a/src/render/Weather.h b/src/render/Weather.h index 809bb787..ef62ebb6 100644 --- a/src/render/Weather.h +++ b/src/render/Weather.h @@ -27,6 +27,7 @@ public: static uint32 LightningFlashLastChange; static uint32 WhenToPlayLightningSound; static uint32 LightningDuration; + static int32 StreamAfterRainTimer; static float ExtraSunnyness; static float Foggyness; @@ -49,6 +50,8 @@ public: static void ReleaseWeather(); static void ForceWeather(int16); static void ForceWeatherNow(int16); + static void AddSplashesDuringHurricane(); + static void AddStreamAfterRain(); static void AddRain(); static void AddHeatHaze(); static void AddBeastie(); -- cgit v1.2.3 From 0a19925e99ac32366a9193dbad6ddc5d6e2a3bd1 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 24 Aug 2020 14:26:17 +0200 Subject: finished sprites --- src/render/Sprite.cpp | 6 +++--- src/render/Sprite2d.cpp | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/render') diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index f26f8e63..401eebd0 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -148,10 +148,10 @@ CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, fl // Fade out when too near // why not in buffered version? - if(z < 3.0f){ - if(z < 1.5f) + if(z < 2.3f){ + if(z < 1.3f) return; - int f = (z - 1.5f)/1.5f * 255; + int f = (z - 1.3f)/(2.3f-1.3f) * 255; r = f*r >> 8; g = f*g >> 8; b = f*b >> 8; diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 7dcedb26..0cd0e8bb 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -120,6 +120,8 @@ CSprite2d::Draw(float x1, float y1, float x2, float y2, float x3, float y3, floa void CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3) { + float offset = 1.0f/1024.0f; + // This is what we draw: // 0---1 // | / | @@ -130,8 +132,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[0], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[0], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[0], c2.r, c2.g, c2.b, c2.a); - RwIm2DVertexSetU(&maVertices[0], 0.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[0], 0.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[0], 0.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[0], 0.0f+offset, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[1], r.right); RwIm2DVertexSetScreenY(&maVertices[1], r.top); @@ -139,8 +141,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[1], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[1], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[1], c3.r, c3.g, c3.b, c3.a); - RwIm2DVertexSetU(&maVertices[1], 1.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[1], 0.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[1], 1.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[1], 0.0f+offset, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[2], r.right); RwIm2DVertexSetScreenY(&maVertices[2], r.bottom); @@ -148,8 +150,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[2], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[2], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[2], c1.r, c1.g, c1.b, c1.a); - RwIm2DVertexSetU(&maVertices[2], 1.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[2], 1.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[2], 1.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[2], 1.0f+offset, RecipNearClip); RwIm2DVertexSetScreenX(&maVertices[3], r.left); RwIm2DVertexSetScreenY(&maVertices[3], r.bottom); @@ -157,8 +159,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C RwIm2DVertexSetCameraZ(&maVertices[3], NearCamZ); RwIm2DVertexSetRecipCameraZ(&maVertices[3], RecipNearClip); RwIm2DVertexSetIntRGBA(&maVertices[3], c0.r, c0.g, c0.b, c0.a); - RwIm2DVertexSetU(&maVertices[3], 0.0f, RecipNearClip); - RwIm2DVertexSetV(&maVertices[3], 1.0f, RecipNearClip); + RwIm2DVertexSetU(&maVertices[3], 0.0f+offset, RecipNearClip); + RwIm2DVertexSetV(&maVertices[3], 1.0f+offset, RecipNearClip); } void -- cgit v1.2.3 From 041d342faf492e4ceb46b997b522579ecfbdadfb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 24 Aug 2020 22:37:38 +0300 Subject: PlayerSkin done --- src/render/PlayerSkin.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/render') diff --git a/src/render/PlayerSkin.cpp b/src/render/PlayerSkin.cpp index d66f7ce4..b3e82cd9 100644 --- a/src/render/PlayerSkin.cpp +++ b/src/render/PlayerSkin.cpp @@ -15,6 +15,8 @@ #include "Timer.h" #include "Lights.h" +//--MIAMI: file done + RpClump *gpPlayerClump; float gOldFov; @@ -109,9 +111,7 @@ CPlayerSkin::GetSkinTexture(const char *texName) tex = RwTextureCreate(raster); RwTextureSetName(tex, texName); -#ifdef FIX_BUGS - RwTextureSetFilterMode(tex, rwFILTERLINEAR); // filtering bugfix from VC -#endif + RwTextureSetFilterMode(tex, rwFILTERLINEAR); RwTexDictionaryAddTexture(CTxdStore::GetSlot(m_txdSlot)->texDict, tex); RwImageDestroy(image); @@ -143,8 +143,7 @@ CPlayerSkin::RenderFrontendSkinEdit(void) static float rotation = 0.0f; RwRGBAReal AmbientColor = { 0.65f, 0.65f, 0.65f, 1.0f }; const RwV3d pos = { 1.35f, 0.35f, 7.725f }; - const RwV3d axis1 = { 1.0f, 0.0f, 0.0f }; - const RwV3d axis2 = { 0.0f, 0.0f, 1.0f }; + const RwV3d axis = { 0.0f, 1.0f, 0.0f }; static uint32 LastFlash = 0; RwFrame *frame = RpClumpGetFrame(gpPlayerClump); @@ -157,8 +156,7 @@ CPlayerSkin::RenderFrontendSkinEdit(void) } RwFrameTransform(frame, RwFrameGetMatrix(RwCameraGetFrame(Scene.camera)), rwCOMBINEREPLACE); RwFrameTranslate(frame, &pos, rwCOMBINEPRECONCAT); - RwFrameRotate(frame, &axis1, -90.0f, rwCOMBINEPRECONCAT); - RwFrameRotate(frame, &axis2, rotation, rwCOMBINEPRECONCAT); + RwFrameRotate(frame, &axis, rotation, rwCOMBINEPRECONCAT); RwFrameUpdateObjects(frame); SetAmbientColours(&AmbientColor); RpClumpRender(gpPlayerClump); -- cgit v1.2.3