diff --git a/main.cpp b/main.cpp index 3e57c3a..6836a91 100644 --- a/main.cpp +++ b/main.cpp @@ -118,10 +118,10 @@ int process_faces(const world_t* world, const std::vector& tex // Sum all vertices to calculate an average center point vertexSum = vertexSum + vertexPoint; - // TODO: face vertex indices will have to be updated to match the tesselator's vertex list - //ps1bsp_facevertex_t faceVertex = { 0 }; - //faceVertex.index = vertIndex; - //outFaceVertices.push_back(faceVertex); + // TODO: compute texture color * light at this vertex + ps1bsp_facevertex_t faceVertex = { 0 }; + faceVertex.index = (unsigned short)tesselator.addVertex(vertexPoint); + outFaceVertices.push_back(faceVertex); } faceBounds[face] = bounds; @@ -132,7 +132,7 @@ int process_faces(const world_t* world, const std::vector& tex outFace.numFaceVertices = (unsigned char)(outFaceVertices.size() - outFace.firstFaceVertex); outFace.center = convertWorldPosition(vertexSum / face->ledge_num); - float area = computeFaceArea(world, face); + float area = computeFaceArea(world, face); // TODO: divide by number of polygons outFace.center.pad = (short)(sqrt(area)); outFaces.push_back(outFace); } @@ -196,6 +196,8 @@ int process_faces(const world_t* world, const std::vector& tex outPolygons.push_back(outPoly); } + // TODO: calculate average face lighting * color from texture data + outFace->numPolygons = (unsigned char)(outPolygons.size() - outFace->firstPolygon); } @@ -293,8 +295,8 @@ int process_faces(const world_t* world, const std::vector& tex fwrite(&outHeader, sizeof(ps1bsp_header_t), 1, fbsp); fclose(fbsp); - printf("PS1BSP: wrote %d vertices, %d faces, %d face verts, %d planes, %d nodes, %d leaves, %d leaf faces\n", - outVertices.size(), outFaces.size(), outFaceVertices.size(), + printf("PS1BSP: wrote %d vertices, %d faces, %d polygons, %d planes, %d nodes, %d leaves, %d leaf faces\n", + outVertices.size(), outFaces.size(), outPolygons.size(), outPlanes.size(), outNodes.size(), outLeaves.size(), outLeafFaces.size()); return 1; diff --git a/ps1bsp.h b/ps1bsp.h index 8c16883..43959eb 100644 --- a/ps1bsp.h +++ b/ps1bsp.h @@ -57,7 +57,7 @@ typedef struct } ps1bsp_vertex_t; // Texture UV and lighting data for a vertex on a particular polygon. -// TODO: break up into poly vertex (index + uv) and surface vertex (index + light) shared between polygons. +// TODO: break up into poly vertex (index + uv) and surface vertex (index + light) shared between polygons. Will reduce this struct size to 4 bytes and eliminate duplicate light values. typedef struct { unsigned short index; diff --git a/texture.cpp b/texture.cpp index e7ef734..8dfd53d 100644 --- a/texture.cpp +++ b/texture.cpp @@ -73,7 +73,7 @@ static bool generate_clut(const char* paletteFile, tim::PARAM* outTim) return true; } -bool process_textures(const world_t* world, std::vector& outTextures) +bool process_textures(const world_t* world, std::vector& outTextures) // TODO: return TextureDescriptor structs, including average texture color { using spaces_type = rectpack2D::empty_spaces; using rect_type = rectpack2D::output_rect_t;