Browse Source

Export face vertex data again, to allow for simplified rendering routines

master
Nico de Poel 3 years ago
parent
commit
0df5801eba
  1. 16
      main.cpp
  2. 2
      ps1bsp.h
  3. 2
      texture.cpp

16
main.cpp

@ -118,10 +118,10 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& 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<ps1bsp_texture_t>& 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<ps1bsp_texture_t>& 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<ps1bsp_texture_t>& 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;

2
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;

2
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<ps1bsp_texture_t>& outTextures)
bool process_textures(const world_t* world, std::vector<ps1bsp_texture_t>& outTextures) // TODO: return TextureDescriptor structs, including average texture color
{
using spaces_type = rectpack2D::empty_spaces<false>;
using rect_type = rectpack2D::output_rect_t<spaces_type>;

Loading…
Cancel
Save