1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-25 18:05:27 +00:00

CClouds; disabled object clipping for SA cam

This commit is contained in:
aap 2020-05-12 16:27:26 +02:00
parent 4b566c26a3
commit 40829b5242
14 changed files with 158 additions and 123 deletions

View file

@ -5101,7 +5101,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
CColPoint foundCol; CColPoint foundCol;
CEntity* foundEnt; CEntity* foundEnt;
CWorld::pIgnoreEntity = CamTargetEntity; CWorld::pIgnoreEntity = CamTargetEntity;
if (CWorld::ProcessLineOfSight(TargetCoors, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false)) { if (CWorld::ProcessLineOfSight(TargetCoors, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
float obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude(); float obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
float obstacleCamDist = newDistance - obstacleTargetDist; float obstacleCamDist = newDistance - obstacleTargetDist;
if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) { if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) {
@ -5110,7 +5110,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f)); RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f));
} }
} else { } else {
if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false)) { if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
float lessClip = obstacleCamDist - 0.35f; float lessClip = obstacleCamDist - 0.35f;
if (lessClip <= DEFAULT_NEAR) if (lessClip <= DEFAULT_NEAR)
RwCameraSetNearClipPlane(Scene.camera, lessClip); RwCameraSetNearClipPlane(Scene.camera, lessClip);

View file

@ -661,6 +661,13 @@ void CGame::Process(void)
} }
} }
bool
CGame::CanSeeOutSideFromCurrArea(void)
{
return currArea == AREA_MAIN_MAP || currArea == AREA_MALL ||
currArea == AREA_MANSION || currArea == AREA_HOTEL;
}
void CGame::DrasticTidyUpMemory(bool) void CGame::DrasticTidyUpMemory(bool)
{ {
#ifdef PS2 #ifdef PS2

View file

@ -60,6 +60,7 @@ public:
static void Process(void); static void Process(void);
static bool IsInInterior(void) { return currArea != AREA_MAIN_MAP; } static bool IsInInterior(void) { return currArea != AREA_MAIN_MAP; }
static bool CanSeeOutSideFromCurrArea(void);
// NB: these do something on PS2 // NB: these do something on PS2
static void TidyUpMemory(bool, bool); static void TidyUpMemory(bool, bool);

View file

@ -3,6 +3,7 @@
#include "Sprite.h" #include "Sprite.h"
#include "Sprite2d.h" #include "Sprite2d.h"
#include "General.h" #include "General.h"
#include "Game.h"
#include "Coronas.h" #include "Coronas.h"
#include "Camera.h" #include "Camera.h"
#include "TxdStore.h" #include "TxdStore.h"
@ -23,8 +24,10 @@ uint32 CClouds::IndividualRotation;
float CClouds::ms_cameraRoll; float CClouds::ms_cameraRoll;
float CClouds::ms_horizonZ; float CClouds::ms_horizonZ;
float CClouds::ms_HorizonTilt;
CRGBA CClouds::ms_colourTop; CRGBA CClouds::ms_colourTop;
CRGBA CClouds::ms_colourBottom; CRGBA CClouds::ms_colourBottom;
CRGBA CClouds::ms_colourBkGrd;
void void
CClouds::Init(void) CClouds::Init(void)
@ -44,33 +47,23 @@ void
CClouds::Shutdown(void) CClouds::Shutdown(void)
{ {
RwTextureDestroy(gpCloudTex[0]); RwTextureDestroy(gpCloudTex[0]);
#ifdef GTA3_1_1_PATCH
gpCloudTex[0] = nil; gpCloudTex[0] = nil;
#endif
RwTextureDestroy(gpCloudTex[1]); RwTextureDestroy(gpCloudTex[1]);
#ifdef GTA3_1_1_PATCH
gpCloudTex[1] = nil; gpCloudTex[1] = nil;
#endif
RwTextureDestroy(gpCloudTex[2]); RwTextureDestroy(gpCloudTex[2]);
#ifdef GTA3_1_1_PATCH
gpCloudTex[2] = nil; gpCloudTex[2] = nil;
#endif
RwTextureDestroy(gpCloudTex[3]); RwTextureDestroy(gpCloudTex[3]);
#ifdef GTA3_1_1_PATCH
gpCloudTex[3] = nil; gpCloudTex[3] = nil;
#endif
RwTextureDestroy(gpCloudTex[4]); RwTextureDestroy(gpCloudTex[4]);
#ifdef GTA3_1_1_PATCH
gpCloudTex[4] = nil; gpCloudTex[4] = nil;
#endif
} }
void void
CClouds::Update(void) CClouds::Update(void)
{ {
float s = Sin(TheCamera.Orientation - 0.85f); float s = Sin(TheCamera.Orientation - 0.85f);
CloudRotation += CWeather::Wind*s*0.0025f; CloudRotation += CWeather::Wind*s*0.001f;
IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f; IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep()*0.5f + 0.3f) * 60.0f;
} }
void void
@ -81,6 +74,9 @@ CClouds::Render(void)
RwV3d screenpos; RwV3d screenpos;
RwV3d worldpos; RwV3d worldpos;
if(!CGame::CanSeeOutSideFromCurrArea())
return;
CCoronas::SunBlockedByClouds = false; CCoronas::SunBlockedByClouds = false;
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
@ -90,26 +86,21 @@ CClouds::Render(void)
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
CSprite::InitSpriteBuffer(); CSprite::InitSpriteBuffer();
int minute = CClock::GetHours()*60 + CClock::GetMinutes(); float minute = CClock::GetHours()*60 + CClock::GetMinutes() + CClock::GetSeconds()/60.0f;
RwV3d campos = *(RwV3d*)&TheCamera.GetPosition(); RwV3d campos = *(RwV3d*)&TheCamera.GetPosition();
float coverage = CWeather::CloudCoverage <= CWeather::Foggyness ? CWeather::Foggyness : CWeather::CloudCoverage; float coverage = Max(CWeather::Foggyness, CWeather::Foggyness);
// Moon // Moon
int moonfadeout = Abs(minute - 180); // fully visible at 3AM float moonfadeout = Abs(minute - 180.0f); // fully visible at 3AM
if(moonfadeout < 180){ // fade in/out 3 hours if((int)moonfadeout < 180){ // fade in/out 3 hours
int brightness = (1.0f - coverage) * (180 - moonfadeout); int brightness = (1.0f - coverage) * (180 - (int)moonfadeout);
RwV3d pos = { 0.0f, -100.0f, 15.0f }; RwV3d pos = { 0.0f, -100.0f, 15.0f };
RwV3dAdd(&worldpos, &campos, &pos); RwV3dAdd(&worldpos, &campos, &pos);
if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){ if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[2])); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[2]));
if(CCoronas::bSmallMoon){ szx *= CCoronas::MoonSize*2.0f + 4.0f;
szx *= 4.0f; szy *= CCoronas::MoonSize*2.0f + 4.0f;
szy *= 4.0f;
}else{
szx *= 10.0f;
szy *= 10.0f;
}
CSprite::RenderOneXLUSprite(screenpos.x, screenpos.y, screenpos.z, CSprite::RenderOneXLUSprite(screenpos.x, screenpos.y, screenpos.z,
szx, szy, brightness, brightness, brightness, 255, 1.0f/screenpos.z, 255); szx, szy, brightness, brightness, brightness, 255, 1.0f/screenpos.z, 255);
} }
@ -127,7 +118,7 @@ CClouds::Render(void)
starintens = 255 * (60 - CClock::GetMinutes())/60.0f; starintens = 255 * (60 - CClock::GetMinutes())/60.0f;
if(starintens != 0){ if(starintens != 0){
// R // R
static float StarCoorsX[9] = { 0.0f, 0.05f, 0.12f, 0.5f, 0.8f, 0.6f, 0.27f, 0.55f, 0.75f }; 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 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 }; static float StarSizes[9] = { 1.0f, 1.4f, 0.9f, 1.0f, 0.6f, 1.5f, 1.3f, 1.0f, 0.8f };
int brightness = (1.0f - coverage) * starintens; int brightness = (1.0f - coverage) * starintens;
@ -165,7 +156,7 @@ CClouds::Render(void)
1.0f, 0.7f, 0.4f, 0.4f, -0.8f, -0.8f }; 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, 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 }; 0.9f, 0.4f, 1.3f, 1.4f, 1.2f, 1.7f };
float lowcloudintensity = 1.0f - coverage; float lowcloudintensity = 1.0f - Max(coverage, CWeather::ExtraSunnyness);
int r = CTimeCycle::GetLowCloudsRed() * lowcloudintensity; int r = CTimeCycle::GetLowCloudsRed() * lowcloudintensity;
int g = CTimeCycle::GetLowCloudsGreen() * lowcloudintensity; int g = CTimeCycle::GetLowCloudsGreen() * lowcloudintensity;
int b = CTimeCycle::GetLowCloudsBlue() * lowcloudintensity; int b = CTimeCycle::GetLowCloudsBlue() * lowcloudintensity;
@ -186,7 +177,7 @@ CClouds::Render(void)
// Fluffy clouds // Fluffy clouds
float rot_sin = Sin(CloudRotation); float rot_sin = Sin(CloudRotation);
float rot_cos = Cos(CloudRotation); float rot_cos = Cos(CloudRotation);
int fluffyalpha = 160 * (1.0f - CWeather::Foggyness); int fluffyalpha = 160 * (1.0f - Max(CWeather::Foggyness, CWeather::ExtraSunnyness));
if(fluffyalpha != 0){ if(fluffyalpha != 0){
static float CoorsOffsetX[37] = { static float CoorsOffsetX[37] = {
0.0f, 60.0f, 72.0f, 48.0f, 21.0f, 12.0f, 0.0f, 60.0f, 72.0f, 48.0f, 21.0f, 12.0f,
@ -213,7 +204,7 @@ CClouds::Render(void)
2.0f, 2.0f, 1.5f, 1.2f, 1.7f, 1.5f, 2.1f 2.0f, 2.0f, 1.5f, 1.2f, 1.7f, 1.5f, 2.1f
}; };
static bool bCloudOnScreen[37]; static bool bCloudOnScreen[37];
float hilight; float sundist, hilight;
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
@ -225,15 +216,16 @@ CClouds::Render(void)
worldpos.z = pos.z; worldpos.z = pos.z;
if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){ if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){
float sundist = Sqrt(sq(screenpos.x-CCoronas::SunScreenX) + sq(screenpos.y-CCoronas::SunScreenY)); sundist = Sqrt(sq(screenpos.x-CCoronas::SunScreenX) + sq(screenpos.y-CCoronas::SunScreenY));
int tr = CTimeCycle::GetFluffyCloudsTopRed(); int tr = CTimeCycle::GetFluffyCloudsTopRed();
int tg = CTimeCycle::GetFluffyCloudsTopGreen(); int tg = CTimeCycle::GetFluffyCloudsTopGreen();
int tb = CTimeCycle::GetFluffyCloudsTopBlue(); int tb = CTimeCycle::GetFluffyCloudsTopBlue();
int br = CTimeCycle::GetFluffyCloudsBottomRed(); int br = CTimeCycle::GetFluffyCloudsBottomRed();
int bg = CTimeCycle::GetFluffyCloudsBottomGreen(); int bg = CTimeCycle::GetFluffyCloudsBottomGreen();
int bb = CTimeCycle::GetFluffyCloudsBottomBlue(); int bb = CTimeCycle::GetFluffyCloudsBottomBlue();
if(sundist < SCREEN_WIDTH/2){ int distLimit = (3*SCREEN_WIDTH)/4;
hilight = (1.0f - coverage) * (1.0f - sundist/(SCREEN_WIDTH/2)); if(sundist < distLimit){
hilight = (1.0f - coverage) * (1.0f - sundist/(float)distLimit);
tr = tr*(1.0f-hilight) + 255*hilight; tr = tr*(1.0f-hilight) + 255*hilight;
tg = tg*(1.0f-hilight) + 190*hilight; tg = tg*(1.0f-hilight) + 190*hilight;
tb = tb*(1.0f-hilight) + 190*hilight; tb = tb*(1.0f-hilight) + 190*hilight;
@ -267,8 +259,7 @@ CClouds::Render(void)
worldpos.y = campos.x*rot_sin + campos.y*rot_cos + pos.y; worldpos.y = campos.x*rot_sin + campos.y*rot_cos + pos.y;
worldpos.z = pos.z; worldpos.z = pos.z;
if(bCloudOnScreen[i] && CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){ if(bCloudOnScreen[i] && CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){
// BUG: this is stupid....would have to do this for each cloud individually if(sundist < SCREEN_WIDTH/3){
if(hilight > 0.0f){
CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(screenpos.x, screenpos.y, screenpos.z, CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(screenpos.x, screenpos.y, screenpos.z,
szx*30.0f, szy*30.0f, szx*30.0f, szy*30.0f,
200*hilight, 0, 0, 255, 1.0f/screenpos.z, 200*hilight, 0, 0, 255, 1.0f/screenpos.z,
@ -308,22 +299,24 @@ CClouds::Render(void)
bool bool
UseDarkBackground(void) UseDarkBackground(void)
{ {
return RwFrameGetLTM(RwCameraGetFrame(TheCamera.m_pRwCamera))->up.z < -0.9f || return TheCamera.GetForward().z < -0.9f || gbShowCollisionPolys;
gbShowCollisionPolys;
} }
void void
CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
int16 botred, int16 botgreen, int16 botblue, int16 alpha) int16 botred, int16 botgreen, int16 botblue, int16 alpha)
{ {
RwMatrix *mat = RwFrameGetLTM(RwCameraGetFrame(TheCamera.m_pRwCamera)); CVector right = CrossProduct(TheCamera.GetUp(), TheCamera.GetForward());
float c = Sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y); right.Normalise();
float c = right.Magnitude2D();
if(c > 1.0f) if(c > 1.0f)
c = 1.0f; c = 1.0f;
ms_cameraRoll = Acos(c); ms_cameraRoll = Acos(c);
if(mat->right.z < 0.0f) if(right.z < 0.0f)
ms_cameraRoll = -ms_cameraRoll; ms_cameraRoll = -ms_cameraRoll;
ms_HorizonTilt = SCREEN_WIDTH/2.0f * Tan(ms_cameraRoll);
if(UseDarkBackground()){ if(UseDarkBackground()){
ms_colourTop.r = 50; ms_colourTop.r = 50;
ms_colourTop.g = 50; ms_colourTop.g = 50;
@ -346,75 +339,74 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
}else{ }else{
ms_horizonZ = CSprite::CalcHorizonCoors(); ms_horizonZ = CSprite::CalcHorizonCoors();
int fogr = (topred + 2 * botred) / 3;
int fogg = (topgreen + 2 * botgreen) / 3;
int fogb = (topblue + 2 * botblue) / 3;
// Draw top/bottom gradient // Draw top/bottom gradient
float gradheight = SCREEN_HEIGHT/2.0f; float gradheight = SCREEN_HEIGHT/2.0f;
float topedge = ms_horizonZ - gradheight;
float botpos, toppos; ms_colourTop.r = topred;
if(ms_horizonZ > 0.0f && topedge < SCREEN_HEIGHT){ ms_colourTop.g = topgreen;
ms_colourTop.b = topblue;
ms_colourTop.a = alpha;
ms_colourBottom.r = botred;
ms_colourBottom.g = botgreen;
ms_colourBottom.b = botblue;
ms_colourBottom.a = alpha;
float botright = ms_horizonZ - ms_HorizonTilt;
float botleft = ms_horizonZ + ms_HorizonTilt;
float topright = botright - gradheight;
float topleft = botleft - gradheight;
CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
ms_colourTop, ms_colourTop, ms_colourBottom, ms_colourBottom);
// draw the small stripe (whatever it's supposed to be)
ms_colourTop.r = fogr;
ms_colourTop.g = fogg;
ms_colourTop.b = fogb;
ms_colourTop.a = alpha;
topright = ms_horizonZ - ms_HorizonTilt;
topleft = ms_horizonZ + ms_HorizonTilt;
botright = topright + SMALLSTRIPHEIGHT;
botleft = topleft + SMALLSTRIPHEIGHT;
CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
ms_colourTop, ms_colourTop, ms_colourTop, ms_colourTop);
// Only top
if(ms_horizonZ + ms_HorizonTilt - gradheight > 0.0f ||
ms_horizonZ - ms_HorizonTilt - gradheight > 0.0f){
ms_colourTop.r = topred; ms_colourTop.r = topred;
ms_colourTop.g = topgreen; ms_colourTop.g = topgreen;
ms_colourTop.b = topblue; ms_colourTop.b = topblue;
ms_colourTop.a = alpha; ms_colourTop.a = alpha;
ms_colourBottom.r = botred;
ms_colourBottom.g = botgreen;
ms_colourBottom.b = botblue;
ms_colourBottom.a = alpha;
if(ms_horizonZ < SCREEN_HEIGHT) if(ms_horizonZ - Abs(ms_HorizonTilt) - gradheight > SCREEN_HEIGHT){
botpos = ms_horizonZ; // only top is visible
else{ topleft = 0.0f;
float f = (ms_horizonZ - SCREEN_HEIGHT)/gradheight; topright = 0.0f;
ms_colourBottom.r = topred*f + (1.0f-f)*botred; botleft = SCREEN_HEIGHT;
ms_colourBottom.g = topgreen*f + (1.0f-f)*botgreen; botright = SCREEN_HEIGHT;
ms_colourBottom.b = topblue*f + (1.0f-f)*botblue; }else{
botpos = SCREEN_HEIGHT; botright = ms_horizonZ - ms_HorizonTilt - gradheight;
botleft = ms_horizonZ + ms_HorizonTilt - gradheight;
topright = Min(ms_horizonZ - ms_HorizonTilt - 2*SCREEN_HEIGHT, 0.0f);
topleft = Min(ms_horizonZ + ms_HorizonTilt - 2*SCREEN_HEIGHT, 0.0f);
} }
if(topedge >= 0.0f)
toppos = topedge;
else{
float f = (0.0f - topedge)/gradheight;
ms_colourTop.r = botred*f + (1.0f-f)*topred;
ms_colourTop.g = botgreen*f + (1.0f-f)*topgreen;
ms_colourTop.b = botblue*f + (1.0f-f)*topblue;
toppos = 0.0f;
}
CSprite2d::DrawRect(CRect(0, toppos, SCREEN_WIDTH, botpos),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}
// draw the small stripe (whatever it's supposed to be) CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
if(ms_horizonZ > -SMALLSTRIPHEIGHT && ms_horizonZ < SCREEN_HEIGHT){
// Same colour as fog
ms_colourTop.r = (topred + 2 * botred) / 3;
ms_colourTop.g = (topgreen + 2 * botgreen) / 3;
ms_colourTop.b = (topblue + 2 * botblue) / 3;
CSprite2d::DrawRect(CRect(0, ms_horizonZ, SCREEN_WIDTH, ms_horizonZ+SMALLSTRIPHEIGHT),
ms_colourTop, ms_colourTop, ms_colourTop, ms_colourTop); ms_colourTop, ms_colourTop, ms_colourTop, ms_colourTop);
} }
// Only top
if(topedge > 0.0f){
ms_colourTop.r = topred;
ms_colourTop.g = topgreen;
ms_colourTop.b = topblue;
ms_colourTop.a = alpha;
ms_colourBottom.r = topred;
ms_colourBottom.g = topgreen;
ms_colourBottom.b = topblue;
ms_colourBottom.a = alpha;
botpos = Min(SCREEN_HEIGHT, topedge);
CSprite2d::DrawRect(CRect(0, 0, SCREEN_WIDTH, botpos),
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
}
// Set both to fog colour for RenderHorizon // Set both to fog colour for RenderHorizon
ms_colourTop.r = (topred + 2 * botred) / 3; ms_colourTop.r = fogr;
ms_colourTop.g = (topgreen + 2 * botgreen) / 3; ms_colourTop.g = fogg;
ms_colourTop.b = (topblue + 2 * botblue) / 3; ms_colourTop.b = fogb;
ms_colourBottom.r = (topred + 2 * botred) / 3; ms_colourBottom.r = fogr;
ms_colourBottom.g = (topgreen + 2 * botgreen) / 3; ms_colourBottom.g = fogg;
ms_colourBottom.b = (topblue + 2 * botblue) / 3; ms_colourBottom.b = fogb;
} }
} }
@ -427,21 +419,35 @@ CClouds::RenderHorizon(void)
ms_colourBottom.a = 230; ms_colourBottom.a = 230;
ms_colourTop.a = 80; ms_colourTop.a = 80;
if(ms_horizonZ > SCREEN_HEIGHT) float topright = ms_horizonZ - ms_HorizonTilt;
return; float topleft = ms_horizonZ + ms_HorizonTilt;
float botright = topright + SMALLSTRIPHEIGHT;
float botleft = topleft + SMALLSTRIPHEIGHT;
float z1 = Min(ms_horizonZ + SMALLSTRIPHEIGHT, SCREEN_HEIGHT); CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
CSprite2d::DrawRectXLU(CRect(0, ms_horizonZ, SCREEN_WIDTH, z1), ms_colourTop, ms_colourTop, ms_colourBottom, ms_colourBottom);
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop);
// This is just weird
float a = SCREEN_HEIGHT/400.0f * HORIZSTRIPHEIGHT + ms_colourBkGrd.r = 128.0f*CTimeCycle::GetAmbientRed();
SCREEN_HEIGHT/300.0f * Max(TheCamera.GetPosition().z, 0.0f); ms_colourBkGrd.g = 128.0f*CTimeCycle::GetAmbientGreen();
float b = TheCamera.GetUp().z < 0.0f ? ms_colourBkGrd.b = 128.0f*CTimeCycle::GetAmbientBlue();
SCREEN_HEIGHT : ms_colourBkGrd.a = 255;
SCREEN_HEIGHT * Abs(TheCamera.GetRight().z);
float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier; float horzstrip = SCREEN_STRETCH_Y(HORIZSTRIPHEIGHT);
z2 = Min(z2, SCREEN_HEIGHT); topright = botright;
CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2), topleft = botleft;
ms_colourBottom, ms_colourBottom, ms_colourTop, ms_colourTop); botright = topright + horzstrip;
botleft = topleft + horzstrip;
CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
ms_colourBottom, ms_colourBottom, ms_colourBkGrd, ms_colourBkGrd);
topright = botright;
topleft = botleft;
botright = Max(topright, SCREEN_HEIGHT);
botleft = Max(topleft, SCREEN_HEIGHT);
CSprite2d::DrawAnyRect(0.0f, topleft, SCREEN_WIDTH, topright, 0.0f, botleft, SCREEN_WIDTH, botright,
ms_colourBkGrd, ms_colourBkGrd, ms_colourBkGrd, ms_colourBkGrd);
} }

View file

@ -8,8 +8,10 @@ public:
static float ms_cameraRoll; static float ms_cameraRoll;
static float ms_horizonZ; static float ms_horizonZ;
static float ms_HorizonTilt;
static CRGBA ms_colourTop; static CRGBA ms_colourTop;
static CRGBA ms_colourBottom; static CRGBA ms_colourBottom;
static CRGBA ms_colourBkGrd;
static void Init(void); static void Init(void);
static void Shutdown(void); static void Shutdown(void);

View file

@ -53,7 +53,7 @@ RwTexture *gpCoronaTexture[9] = { nil, nil, nil, nil, nil, nil, nil, nil, nil };
float CCoronas::LightsMult = 1.0f; float CCoronas::LightsMult = 1.0f;
float CCoronas::SunScreenX; float CCoronas::SunScreenX;
float CCoronas::SunScreenY; float CCoronas::SunScreenY;
bool CCoronas::bSmallMoon; int CCoronas::MoonSize;
bool CCoronas::SunBlockedByClouds; bool CCoronas::SunBlockedByClouds;
int CCoronas::bChangeBrightnessImmediately; int CCoronas::bChangeBrightnessImmediately;

View file

@ -81,7 +81,7 @@ public:
static float LightsMult; static float LightsMult;
static float SunScreenY; static float SunScreenY;
static float SunScreenX; static float SunScreenX;
static bool bSmallMoon; static int MoonSize;
static bool SunBlockedByClouds; static bool SunBlockedByClouds;
static int bChangeBrightnessImmediately; static int bChangeBrightnessImmediately;

View file

@ -1542,7 +1542,7 @@ void CParticle::Render()
particle->m_fSize * 63.0f, particle->m_fSize * 63.0f,
particle->m_Color, particle->m_Color,
particle->m_nColorIntensity, particle->m_nColorIntensity,
(float)particle->m_nRotation, //DEGTORAD((float)particle->m_nRotation) ps2 DEGTORAD(particle->m_nRotation),
particle->m_nAlpha); particle->m_nAlpha);
} }
else else
@ -1582,7 +1582,7 @@ void CParticle::Render()
particle->m_Color.blue, particle->m_Color.blue,
particle->m_nColorIntensity, particle->m_nColorIntensity,
1.0f / coors.z, 1.0f / coors.z,
float(particle->m_nRotation), // DEGTORAD((float)particle->m_nRotation) ps2 DEGTORAD(particle->m_nRotation),
particle->m_nAlpha); particle->m_nAlpha);
} }
else if ( psystem->Flags & SCREEN_TRAIL ) else if ( psystem->Flags & SCREEN_TRAIL )
@ -1635,7 +1635,7 @@ void CParticle::Render()
particle->m_Color.blue, particle->m_Color.blue,
particle->m_nColorIntensity, particle->m_nColorIntensity,
1.0f / coors.z, 1.0f / coors.z,
fRotation, DEGTORAD(fRotation),
particle->m_nAlpha); particle->m_nAlpha);
particle->m_vecScreenPosition = coors; particle->m_vecScreenPosition = coors;
@ -1684,7 +1684,7 @@ void CParticle::Render()
particle->m_Color.blue, particle->m_Color.blue,
particle->m_nColorIntensity, particle->m_nColorIntensity,
1.0f / coors.z, 1.0f / coors.z,
fRotation, DEGTORAD(fRotation),
particle->m_nAlpha); particle->m_nAlpha);
} }
else if ( psystem->Flags & VERT_TRAIL ) else if ( psystem->Flags & VERT_TRAIL )

View file

@ -267,8 +267,8 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z,
{ {
m_bFlushSpriteBufferSwitchZTest = 0; m_bFlushSpriteBufferSwitchZTest = 0;
// TODO: replace with lookup // TODO: replace with lookup
float c = Cos(DEGTORAD(rotation)); float c = Cos(rotation);
float s = Sin(DEGTORAD(rotation)); float s = Sin(rotation);
float xs[4]; float xs[4];
float ys[4]; float ys[4];
@ -580,8 +580,8 @@ CSprite::RenderBufferedOneXLUSprite2D_Rotate_Dimension(float x, float y, float w
{ {
m_bFlushSpriteBufferSwitchZTest = 1; m_bFlushSpriteBufferSwitchZTest = 1;
CRGBA col(intens * colour.red >> 8, intens * colour.green >> 8, intens * colour.blue >> 8, alpha); CRGBA col(intens * colour.red >> 8, intens * colour.green >> 8, intens * colour.blue >> 8, alpha);
float c = Cos(DEGTORAD(rotation)); float c = Cos(rotation);
float s = Sin(DEGTORAD(rotation)); float s = Sin(rotation);
Set6Vertices2D(&SpriteBufferVerts[6 * nSpriteBufferIndex], Set6Vertices2D(&SpriteBufferVerts[6 * nSpriteBufferIndex],
x + c*w - s*h, x + c*w - s*h,

View file

@ -151,7 +151,6 @@ CSprite2d::Draw(float x1, float y1, float x2, float y2, float x3, float y3, floa
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4);
} }
// Arguments: // Arguments:
// 2---3 // 2---3
// | | // | |
@ -461,6 +460,22 @@ CSprite2d::DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
} }
void
CSprite2d::DrawAnyRect(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)
{
SetVertices(x1, y1, x2, y2, x3, y3, x4, y4, c0, c1, c2, c3);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)(c0.alpha != 255 || c1.alpha != 255 || c2.alpha != 255 || c3.alpha != 255));
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD);
}
void CSprite2d::Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &color) void CSprite2d::Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &color)
{ {
SetVertices(x1, y1, x2, y2, x3, y3, x4, y4, color, color, color, color); SetVertices(x1, y1, x2, y2, x3, y3, x4, y4, color, color, color, color);

View file

@ -46,6 +46,8 @@ public:
static void DrawRect(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); static void DrawRect(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3);
static void DrawRect(const CRect &r, const CRGBA &col); static void DrawRect(const CRect &r, const CRGBA &col);
static void DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3); static void DrawRectXLU(const CRect &r, const CRGBA &c0, const CRGBA &c1, const CRGBA &c2, const CRGBA &c3);
static void DrawAnyRect(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);
static void Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &color); static void Draw2DPolygon(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &color);

View file

@ -32,6 +32,7 @@ uint32 CWeather::LightningFlashLastChange;
uint32 CWeather::WhenToPlayLightningSound; uint32 CWeather::WhenToPlayLightningSound;
uint32 CWeather::LightningDuration; uint32 CWeather::LightningDuration;
float CWeather::ExtraSunnyness;
float CWeather::Foggyness; float CWeather::Foggyness;
float CWeather::CloudCoverage; float CWeather::CloudCoverage;
float CWeather::Wind; float CWeather::Wind;

View file

@ -30,6 +30,7 @@ public:
static uint32 WhenToPlayLightningSound; static uint32 WhenToPlayLightningSound;
static uint32 LightningDuration; static uint32 LightningDuration;
static float ExtraSunnyness;
static float Foggyness; static float Foggyness;
static float CloudCoverage; static float CloudCoverage;
static float Wind; static float Wind;

View file

@ -1511,7 +1511,7 @@ CWeapon::FireSniper(CEntity *shooter)
CVector dir = cam->Front; CVector dir = cam->Front;
if ( DotProduct(dir, CVector(0.0f, -0.9894f, 0.145f)) > 0.997f ) if ( DotProduct(dir, CVector(0.0f, -0.9894f, 0.145f)) > 0.997f )
CCoronas::bSmallMoon = !CCoronas::bSmallMoon; CCoronas::MoonSize = (CCoronas::MoonSize+1) & 7;
dir.Normalise(); dir.Normalise();
dir *= 16.0f; dir *= 16.0f;