From 7d8b306daaa9fd28ca97db1c84beba9ecc99f7be Mon Sep 17 00:00:00 2001 From: Safariminer Date: Sat, 26 Jul 2025 19:13:56 -0400 Subject: [PATCH] somewhat corrected movements(?) and texcoord caching --- mpfw/MPFW_Quake.cpp | 11 +--- mpfw/MPFW_UI.h | 10 ++++ mpfw/main.cpp | 140 ++++++++++---------------------------------- 3 files changed, 41 insertions(+), 120 deletions(-) diff --git a/mpfw/MPFW_Quake.cpp b/mpfw/MPFW_Quake.cpp index 7461a26..357890b 100644 --- a/mpfw/MPFW_Quake.cpp +++ b/mpfw/MPFW_Quake.cpp @@ -408,21 +408,12 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path) cface.glTextureHeight = data.textures[data.texInfo[data.faces[i].texinfoId].textureId].height; - for (int j = cface.vertices.size() - 1; j > 0; j--) { + for (int j = 0; j < cface.vertices.size(); j++) { - - cface.texCoords.push_back(Vector2( - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(cface.vertices[0]), data.texInfo[data.faces[i].texinfoId].vectorS) + data.texInfo[data.faces[i].texinfoId].distS) / data.textures[data.texInfo[data.faces[i].texinfoId].textureId].width, - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(cface.vertices[0]), data.texInfo[data.faces[i].texinfoId].vectorT) + data.texInfo[data.faces[i].texinfoId].distT) / data.textures[data.texInfo[data.faces[i].texinfoId].textureId].height - )); cface.texCoords.push_back(Vector2( (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(cface.vertices[j]), data.texInfo[data.faces[i].texinfoId].vectorS) + data.texInfo[data.faces[i].texinfoId].distS) / data.textures[data.texInfo[data.faces[i].texinfoId].textureId].width, (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(cface.vertices[j]), data.texInfo[data.faces[i].texinfoId].vectorT) + data.texInfo[data.faces[i].texinfoId].distT) / data.textures[data.texInfo[data.faces[i].texinfoId].textureId].height )); - cface.texCoords.push_back(Vector2( - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(cface.vertices[j - 1]), data.texInfo[data.faces[i].texinfoId].vectorS) + data.texInfo[data.faces[i].texinfoId].distS) / data.textures[data.texInfo[data.faces[i].texinfoId].textureId].width, - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(cface.vertices[j - 1]), data.texInfo[data.faces[i].texinfoId].vectorT) + data.texInfo[data.faces[i].texinfoId].distT) / data.textures[data.texInfo[data.faces[i].texinfoId].textureId].height - )); } diff --git a/mpfw/MPFW_UI.h b/mpfw/MPFW_UI.h index d48fa96..dd645d8 100644 --- a/mpfw/MPFW_UI.h +++ b/mpfw/MPFW_UI.h @@ -1,5 +1,15 @@ #pragma once namespace MPFW { + namespace UI { + + // main class that does the rendering of the UI y'know + class UIRenderer { + + }; + + + + } } \ No newline at end of file diff --git a/mpfw/main.cpp b/mpfw/main.cpp index 34f6a84..a0d5c3b 100644 --- a/mpfw/main.cpp +++ b/mpfw/main.cpp @@ -82,7 +82,7 @@ void Look() { void AirAccelerate(bool inAir) { if (IsKeyDown(KEY_W)) { - velocity += hRotation * GetFrameTime() * accelFactor * (IsKeyDown(KEY_LEFT_SHIFT) ? 2 : 1); + velocity += hRotation * GetFrameTime() * accelFactor * (IsKeyDown(KEY_LEFT_SHIFT) ? 4 : 2); } if (IsKeyDown(KEY_S)) { velocity -= hRotation * GetFrameTime() * accelFactor; @@ -91,23 +91,20 @@ void AirAccelerate(bool inAir) { Vector3 sideRotation = Vector3RotateByAxisAngle(hRotation, { 0,1,0 }, DEG2RAD * 90); if (IsKeyDown(KEY_A)) { - velocity += sideRotation * GetFrameTime() * accelFactor * (IsKeyDown(KEY_LEFT_SHIFT) ? 2 : 1); + velocity += sideRotation * GetFrameTime() * accelFactor * (IsKeyDown(KEY_LEFT_SHIFT) ? 4 : 2); } if (IsKeyDown(KEY_D)) { - velocity -= sideRotation * GetFrameTime() * accelFactor * (IsKeyDown(KEY_LEFT_SHIFT) ? 2 : 1); + velocity -= sideRotation * GetFrameTime() * accelFactor * (IsKeyDown(KEY_LEFT_SHIFT) ? 4 : 2); } - if (inAir)velocity.y -= GetFrameTime(); - velocity.x *= 16 * GetFrameTime(); - velocity.z *= 16 * GetFrameTime(); + if (inAir)velocity.y -= GetFrameTime() * 2.5; + velocity.x *= 80 * GetFrameTime(); + velocity.z *= 80 * GetFrameTime(); } void Accelerate() { - if (IsKeyDown(KEY_SPACE))velocity.y += accelFactor*0.01; + if (IsKeyDown(KEY_SPACE)) velocity.y += accelFactor * 0.0025; AirAccelerate(false); - AirAccelerate(false); - if (velocity.y < 0) velocity.y = 0; - velocity *= 16*GetFrameTime(); } @@ -196,7 +193,7 @@ int main() { SetConfigFlags(FLAG_WINDOW_RESIZABLE); InitWindow(1280, 720, TextFormat("mpfw")); - SetTargetFPS(60); + // SetTargetFPS(60); SetExitKey(0); DisableCursor(); @@ -231,9 +228,9 @@ int main() { } if(!consoleOn){ Look(); - if (camera.position.y > 6) AirAccelerate(true); + if (camera.position.y > 5) AirAccelerate(true); else Accelerate(); - + if (camera.position.y < 5) camera.position.y = 5; if (IsKeyPressed(KEY_LEFT) && indivFace > 0) indivFace--; if (IsKeyPressed(KEY_RIGHT) && indivFace < map.data.faces.size() - 1) indivFace++; @@ -250,114 +247,37 @@ int main() { BeginMode3D(camera); // DrawGrid(1000, 10); if (!indivFaceMode) { - for (int i = 0; i < map.data.vertices.size(); i++) { - // DrawPoint3D(MPFW::Quake::Maps::qVec2RLVec(map.data.vertices[i]), BLACK); - // if (i != 0) DrawLine3D(MPFW::Quake::Maps::qVec2RLVec(map.data.vertices[i]), MPFW::Quake::Maps::qVec2RLVec(map.data.vertices[i - 1]), PURPLE); - } - for (int i = 0; i < map.data.edges.size(); i++) { - // DrawLine3D(MPFW::Quake::Maps::qVec2RLVec(map.data.vertices[map.data.edges[i].vertex0]), MPFW::Quake::Maps::qVec2RLVec(map.data.vertices[map.data.edges[i].vertex1]), PURPLE); - } + + for (int i = 0; i < map.data.renderFaces.size(); i++) { + rlColor4ub(255, 255, 255, 255); + rlSetTexture(map.data.renderFaces[i].glTextureId); - for (int i = 0; i < map.data.faces.size(); i++) { - - std::vector vertices; - + for (int j = 1; j < map.data.renderFaces[i].vertices.size(); j++) { + rlBegin(RL_QUADS); // for texturing reasons because rlgl + Vector3 a = map.data.renderFaces[i].vertices[0], + b = map.data.renderFaces[i].vertices[j], + c = map.data.renderFaces[i].vertices[j - 1]; + + Vector2 at = map.data.renderFaces[i].texCoords[0], + bt = map.data.renderFaces[i].texCoords[j], + ct = map.data.renderFaces[i].texCoords[j - 1]; - // Vector3 a = MPFW::Quake::Maps::qVec2RLVec(map.data.vertices[map.data.edges[abs(map.data.ledges[map.data.faces[i].ledgeId])].vertex0]); + rlTexCoord2f(at.x, at.y); + rlVertex3f(a.x, a.y, a.z); + rlTexCoord2f(bt.x, bt.y); + rlVertex3f(b.x, b.y, b.z); + rlTexCoord2f(ct.x, ct.y); + rlVertex3f(c.x, c.y, c.z); + rlVertex3f(c.x, c.y, c.z); - for (int k = 0; k < map.data.faces[i].ledgeNum; k++) { - if (map.data.ledges[(unsigned int)(map.data.faces[i].ledgeId) + k] < 0) { - vertices.push_back(MPFW::Quake::Maps::qVec2RLVec( - map.data.vertices[ - map.data.edges[ - abs( - map.data.ledges[ - map.data.faces[i].ledgeId + k - ] - ) - ].vertex0 - ] - )); - } - else { - vertices.push_back(MPFW::Quake::Maps::qVec2RLVec( - map.data.vertices[ - map.data.edges[ - abs( - map.data.ledges[ - map.data.faces[i].ledgeId + k - ] - ) - ].vertex1 - ] - )); - } - - - /*DrawLine3D(MPFW::Quake::Maps::qVec2RLVec( - map.data.vertices[ - map.data.edges[ - abs( - map.data.ledges[ - map.data.faces[i].ledgeId + k - ] - ) - ].vertex0 - ] - ), - - MPFW::Quake::Maps::qVec2RLVec( - map.data.vertices[ - map.data.edges[ - abs( - map.data.ledges[ - map.data.faces[i].ledgeId + k - ] - ) - ].vertex1 - ] - ), RED);*/ - - } - - for(int j = vertices.size() - 1; j > 0; j--){ - // rlColor4ub(colors[i].r, colors[i].g, colors[i].b, colors[i].a); - rlColor4ub(255, 255, 255, 255); - rlSetTexture(map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].glTextureID); - rlBegin(RL_QUADS); // textures don't work well with triangles in rlgl for some reason - - // rlTexCoord2f(0, 0); - rlTexCoord2f( - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(vertices[0]), map.data.texInfo[map.data.faces[i].texinfoId].vectorS) + map.data.texInfo[map.data.faces[i].texinfoId].distS) / map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].width, - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(vertices[0]), map.data.texInfo[map.data.faces[i].texinfoId].vectorT) + map.data.texInfo[map.data.faces[i].texinfoId].distT) / map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].height - ); - rlVertex3f(vertices[0].x, vertices[0].y, vertices[0].z); - // rlTexCoord2f(0, 1); - rlTexCoord2f( - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(vertices[j]), map.data.texInfo[map.data.faces[i].texinfoId].vectorS) + map.data.texInfo[map.data.faces[i].texinfoId].distS) / map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].width, - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(vertices[j]), map.data.texInfo[map.data.faces[i].texinfoId].vectorT) + map.data.texInfo[map.data.faces[i].texinfoId].distT) / map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].height - ); - rlVertex3f(vertices[j].x, vertices[j].y, vertices[j].z); - // rlTexCoord2f(1, 1); - rlTexCoord2f( - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(vertices[j - 1]), map.data.texInfo[map.data.faces[i].texinfoId].vectorS) + map.data.texInfo[map.data.faces[i].texinfoId].distS) / map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].width, - (Vector3DotProduct(MPFW::Quake::Maps::RLVec2qVec(vertices[j - 1]), map.data.texInfo[map.data.faces[i].texinfoId].vectorT) + map.data.texInfo[map.data.faces[i].texinfoId].distT) / map.data.textures[map.data.texInfo[map.data.faces[i].texinfoId].textureId].height - ); - rlVertex3f(vertices[j - 1].x, vertices[j - 1].y, vertices[j - 1].z); - rlVertex3f(vertices[j - 1].x, vertices[j - 1].y, vertices[j - 1].z); - rlEnd(); - // rlColor4ub(255, 255, 255, 255); } - - - } } else {