From dc72cabe2b0653d9f7ee01883791029c070bb852 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 29 May 2023 13:33:56 -0700 Subject: [PATCH] Test more skybox model shenanigans. --- Faceball2030/assets/worldSkyBox.png | Bin 2237 -> 8170 bytes Faceball2030/main.cpp | 53 +++++++++++++++++----------- Faceball2030/main.h | 3 +- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/Faceball2030/assets/worldSkyBox.png b/Faceball2030/assets/worldSkyBox.png index 195e6855bf897cd110dc5b89b279eb9394ef3a83..7b01807b50f6fc8baca34c514838330557a3eadd 100644 GIT binary patch literal 8170 zcmeHM2{_d2_aFNb*IG$r8cR`Q7BiTMq8VvoY}rdSs~IsfW`-HcC9SsXOHv`EDJt!u zi&AbX1|hVlZlNrdHqrfmM~ghS-@Wzw|9{W_`8`jbhk3u}J?C@I`J8j!=lz;EHy1}$ zWnE8@{j#=NtBiM;K32S&{ZJUiX2Gu>NZYbaHhqUtzn$(3m?&*+>E5pBKf}iqU{5o_ zlqilEvn4yuM6?ZNzxWtxw?|HB&$^)MG48&3s><1@n~_XK7N&7&*uGr9h~`&UfB%hBLkOlLq=58J-N0G6?{%+0 zZP+Uz^ppqD3Cd~nhiWyCi;J`_`s!td!!v|0Gj|=l)$P%nvgg3OW4q>r?HBFQtv+ZR z$OyUDrw={otu^tO`o`MzSo$fp>KI~oS8{OO7_oZYZ1=7tN7&sbuEXfj6ZE5yISM|N zVeZ`?SFAc|Dz!L;y0*NLx4!(|t4ki}*9=ITdAj4TR5mP}d4Hg#!7Tk*MG`MnZZ%4j zx;$@TaeT`|a`QR|FVw@px6sNLHOB`)Ya3(kFka;(=v`Xj&PbdE=VrpaH1`pDxbKMq zcHcgn{VI)l7wf7rbnO@2PRdP&%RnlQxtzXK+x>o`{#+24al26uqOtpi)9l;V0!^A_ z7^=90mzrB!I!?=+Q^c)tmKSd@a!c=8wP3r?H76xUc~AyCtT^eKot^&?Gn2!KE3_kK zYO5u!snRRCX13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BhqA>%u&D@YIw;7eaKyk$Xx2TJTFW+X| z=@GF&RUOWg--f7zKrsNWEC>V!KBPb(MG(jiSOH&@{LR)6s!t((7y6X?R7~HJ{d1gv z)fB{csmFjmlVJzS`MmsYUZ$e_uS)cv$~~3VG&W;EaH;R>mu~@lOZHtQnij)9H0m@b z--R9n`fJs{CHp?dQX8cIZjPpf_m?gM1EGBHL{3Ap0}TIufTyWXIf(%b|GnA%x8jsI zmadWg-^}QLQKEl)qW+75NXjT1qx2m|^1lH1|ETD{ohax#Iw9k>?xw&4IqCO2fnEg> M99;0_%QwXS5A8B`CjbBd literal 2237 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&zE~)R&4Yzkn1=v6E*A2N2Y7q;xPaaFlqu zIEGZrd3#M!$jOn1^&s!jzw2deTA!|;k@qtsBaC~o`JOhJ`KLdlq1O|o%1x5x2N1$y@EI=zbf#wP^FbJqHFerG8Di{ri(eyBy pFGkCU(QenemyData[GetID()].fireDelay; - game->bullets.push_back({ game->bullet, {pos.x,pos.y+0.15f,pos.z},rot,0.2f,1,{std::cosf(rot) * game->shotSpd,std::sinf(rot) * game->shotSpd }, YELLOW,false,GetID(),myIndex,blinking}); + game->bullets.push_back({ game->bullet, {pos.x,pos.y+0.15f,pos.z},rot,0.2f,1,true,{std::cosf(rot) * game->shotSpd,std::sinf(rot) * game->shotSpd }, YELLOW,false,GetID(),myIndex,blinking}); } void Enemy::ReloadBullet(float fElapsedTime) { @@ -436,7 +436,7 @@ void FaceBall::LoadLevel(int level) walls = { mapWalls }; MapWallsObjectIndex = objects.size()-1; objects.push_back({ mapFloor,{0,0,0},0,0 }); - objects.push_back({ worldSkyBox,{0,0,0},0,0 }); + objects.push_back({ worldSkyBox,{MAP_SIZE.x/2.f,0,MAP_SIZE.y/2.f},0,0,std::max(float(MAP_SIZE.x),float(MAP_SIZE.y))*2,false }); //objects.push_back({ game->mapExit,{(float)exitCoords.x+0.5f,0,(float)exitCoords.y+0.5f},0,0.4f }); exit = { game->mapExit,{(float)exitCoords.x + 0.5f,0.02f,(float)exitCoords.y + 0.5f},0,0.4f }; RegenerateMinimap(); @@ -955,7 +955,7 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector&vecTrianglesToRas vec3d vCameraRay = Vector_Sub(triTransformed.p[0], freeRoam ? freeRoamCamera : player.GetPos()); - if (Vector_DotProduct(normal, vCameraRay) < 0) { + if (Vector_DotProduct(normal, vCameraRay) < 0||!o.affectedByLighting) { vec3d light_dir = Vector_Mul(vLookDir, -1); light_dir = Vector_Normalise(light_dir); @@ -967,9 +967,11 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector&vecTrianglesToRas triViewed.uv[0] = triTransformed.uv[0]; triViewed.uv[1] = triTransformed.uv[1]; triViewed.uv[2] = triTransformed.uv[2]; - triViewed.col[0] = Pixel(triTransformed.col[0].r * dp * dp, triTransformed.col[0].g * dp * dp, triTransformed.col[0].b * dp * dp); - triViewed.col[1] = Pixel(triTransformed.col[1].r * dp * dp, triTransformed.col[1].g * dp * dp, triTransformed.col[1].b * dp * dp); - triViewed.col[2] = Pixel(triTransformed.col[2].r * dp * dp, triTransformed.col[2].g * dp * dp, triTransformed.col[2].b * dp * dp); + if (o.affectedByLighting) { + triViewed.col[0] = Pixel(triTransformed.col[0].r * dp * dp, triTransformed.col[0].g * dp * dp, triTransformed.col[0].b * dp * dp); + triViewed.col[1] = Pixel(triTransformed.col[1].r * dp * dp, triTransformed.col[1].g * dp * dp, triTransformed.col[1].b * dp * dp); + triViewed.col[2] = Pixel(triTransformed.col[2].r * dp * dp, triTransformed.col[2].g * dp * dp, triTransformed.col[2].b * dp * dp); + } Pixel originalCol[3] = { triViewed.col[0],triViewed.col[1],triViewed.col[2] }; float dist = std::sqrtf(std::powf((freeRoam ? freeRoamCamera : player.GetPos()).x - triTransformed.p[0].x, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).y - triTransformed.p[0].y, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).z - triTransformed.p[0].z, 2)); float dist2 = std::sqrtf(std::powf((freeRoam ? freeRoamCamera : player.GetPos()).x - triTransformed.p[1].x, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).y - triTransformed.p[1].y, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).z - triTransformed.p[1].z, 2)); @@ -977,22 +979,31 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector&vecTrianglesToRas float colorMult = dist > 5 * PI / 3 ? 0 : std::sinf(0.3 * dist + PI / 2); float colorMult2 = dist2 > 5 * PI / 3 ? 0 : std::sinf(0.3 * dist2 + PI / 2); float colorMult3 = dist3 > 5 * PI / 3 ? 0 : std::sinf(0.3 * dist3 + PI / 2); - triViewed.col[0] = Pixel(triViewed.col[0].r * colorMult, triViewed.col[0].g * colorMult, triViewed.col[0].b * colorMult); - triViewed.col[1] = Pixel(triViewed.col[1].r * colorMult2, triViewed.col[1].g * colorMult2, triViewed.col[1].b * colorMult2); - triViewed.col[2] = Pixel(triViewed.col[2].r * colorMult3, triViewed.col[2].g * colorMult3, triViewed.col[2].b * colorMult3); + if (o.affectedByLighting) { + triViewed.col[0] = Pixel(triViewed.col[0].r * colorMult, triViewed.col[0].g * colorMult, triViewed.col[0].b * colorMult); + triViewed.col[1] = Pixel(triViewed.col[1].r * colorMult2, triViewed.col[1].g * colorMult2, triViewed.col[1].b * colorMult2); + triViewed.col[2] = Pixel(triViewed.col[2].r * colorMult3, triViewed.col[2].g * colorMult3, triViewed.col[2].b * colorMult3); + } + if (!o.affectedByLighting) { + triViewed.col[0] = originalCol[0]; + triViewed.col[1] = originalCol[1]; + triViewed.col[2] = originalCol[2]; + } triViewed.tex = triTransformed.tex; - for (Bullet& b : bullets) { - float dist = std::sqrtf(std::powf(b.pos.x - triTransformed.p[0].x, 2) + std::powf(b.pos.y - triTransformed.p[0].y, 2) + std::powf(b.pos.z - triTransformed.p[0].z, 2)); - float dist2 = std::sqrtf(std::powf(b.pos.x - triTransformed.p[1].x, 2) + std::powf(b.pos.y - triTransformed.p[1].y, 2) + std::powf(b.pos.z - triTransformed.p[1].z, 2)); - float dist3 = std::sqrtf(std::powf(b.pos.x - triTransformed.p[2].x, 2) + std::powf(b.pos.y - triTransformed.p[2].y, 2) + std::powf(b.pos.z - triTransformed.p[2].z, 2)); - float colorMult = (dist < 2 ? std::sinf(0.75 * dist + PI / 2) * 4 :1); - float colorMult2 = (dist2 < 2 ? std::sinf(0.75 * dist2 + PI / 2) * 4 : 1); - float colorMult3 = (dist3 < 2 ? std::sinf(0.75 * dist3 + PI / 2) * 4 : 1); - Pixel lightCol = b.col / 2 + Pixel{ 128, 128, 128 }; - if (dist < 2) {triViewed.col[0] = Pixel(std::min(255, std::max((int)originalCol[0].r, (int)(originalCol[0].r * colorMult / float(255.f/lightCol.r)))), std::min(255, std::max((int)originalCol[0].g, (int)(originalCol[0].g * colorMult / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[0].b, (int)(originalCol[0].b * colorMult / float(255.f / lightCol.b)))));} - if (dist2 < 2) {triViewed.col[1] = Pixel(std::min(255, std::max((int)originalCol[1].r, (int)(originalCol[1].r * colorMult2 / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[1].g, (int)(originalCol[1].g * colorMult2 / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[1].b, (int)(originalCol[1].b * colorMult2 / float(255.f / lightCol.b)))));} - if (dist3 < 2) {triViewed.col[2] = Pixel(std::min(255, std::max((int)originalCol[2].r, (int)(originalCol[2].r * colorMult3 / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[2].g, (int)(originalCol[2].g * colorMult3 / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[2].b, (int)(originalCol[2].b * colorMult3 / float(255.f / lightCol.b)))));} + if (o.affectedByLighting) { + for (Bullet& b : bullets) { + float dist = std::sqrtf(std::powf(b.pos.x - triTransformed.p[0].x, 2) + std::powf(b.pos.y - triTransformed.p[0].y, 2) + std::powf(b.pos.z - triTransformed.p[0].z, 2)); + float dist2 = std::sqrtf(std::powf(b.pos.x - triTransformed.p[1].x, 2) + std::powf(b.pos.y - triTransformed.p[1].y, 2) + std::powf(b.pos.z - triTransformed.p[1].z, 2)); + float dist3 = std::sqrtf(std::powf(b.pos.x - triTransformed.p[2].x, 2) + std::powf(b.pos.y - triTransformed.p[2].y, 2) + std::powf(b.pos.z - triTransformed.p[2].z, 2)); + float colorMult = (dist < 2 ? std::sinf(0.75 * dist + PI / 2) * 4 : 1); + float colorMult2 = (dist2 < 2 ? std::sinf(0.75 * dist2 + PI / 2) * 4 : 1); + float colorMult3 = (dist3 < 2 ? std::sinf(0.75 * dist3 + PI / 2) * 4 : 1); + Pixel lightCol = b.col / 2 + Pixel{ 128, 128, 128 }; + if (dist < 2) { triViewed.col[0] = Pixel(std::min(255, std::max((int)originalCol[0].r, (int)(originalCol[0].r * colorMult / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[0].g, (int)(originalCol[0].g * colorMult / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[0].b, (int)(originalCol[0].b * colorMult / float(255.f / lightCol.b))))); } + if (dist2 < 2) { triViewed.col[1] = Pixel(std::min(255, std::max((int)originalCol[1].r, (int)(originalCol[1].r * colorMult2 / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[1].g, (int)(originalCol[1].g * colorMult2 / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[1].b, (int)(originalCol[1].b * colorMult2 / float(255.f / lightCol.b))))); } + if (dist3 < 2) { triViewed.col[2] = Pixel(std::min(255, std::max((int)originalCol[2].r, (int)(originalCol[2].r * colorMult3 / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[2].g, (int)(originalCol[2].g * colorMult3 / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[2].b, (int)(originalCol[2].b * colorMult3 / float(255.f / lightCol.b))))); } + } } //triViewed.col = triTransformed.col; @@ -1546,7 +1557,7 @@ void FaceBall::HandleKeys(float fElapsedTime) { pitch = 0; if (GetMouse(0).bPressed) { if (PlayerActiveShotCount(0) < shotLimit) { - Bullet newBullet={ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,1,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }; + Bullet newBullet={ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,1,true,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }; newBullet.playerIndex=0; bullets.push_back(newBullet); } diff --git a/Faceball2030/main.h b/Faceball2030/main.h index 0524c6c..64fbf35 100644 --- a/Faceball2030/main.h +++ b/Faceball2030/main.h @@ -145,6 +145,7 @@ struct Object { float rot = 0; float radius = 0.2f; float scale = 1.f; + bool affectedByLighting = true; }; struct Bullet : Object{ @@ -283,7 +284,7 @@ class FaceBall : public PixelGameEngine Editor editor; int MapWallsObjectIndex = -1; bool exitWallsCleared = false; - int level=3; + int level=1; int tagsRemaining = 10; int lives = 3; double gameTimer = 0;