Open michaeleggers opened 1 week ago
@hm-de-paoli You can now outpout the polygons to a binary format that contains all of the information you need:
struct PolySoupDataHeader {
uint8_t magic[4]; // must be PLYS
uint8_t version[4];
uint64_t numPolys; // num of MapPolygons
uint64_t polySize; // sizeof(MapPolygon)
};
#pragma pack(push,1)
struct PolySoupData {
PolySoupDataHeader header;
MapPolygon* polys;
};
#pragma pack(pop)
As a reminder, a MapPolygon
consists of:
struct QuakeMapVertex {
glm::f64vec3 pos;
glm::vec2 uv;
};
struct MapPolygon
{
std::vector<QuakeMapVertex> vertices;
glm::f64vec3 normal;
// NOTE: (Michael): A single, solid color would be good for testing
// the lightmapper. Thus, define a few solid color textures
// to use in TrenchBroom.
std::string textureName; // located in /game/textures/<*.png>
uint64_t surfaceFlags; // eg. transparency, emissiveness, ...
uint64_t contentFlags; // eg. water, slime, lava, ...
};
Also there is a new function:
void writePolySoupBinary(std::string fileName, const std::vector<MapPolygon>& polys);
That writes out a file containing one PolySoupData
struct (see above). That should be everything you need.
The texturefiles are not included as actual pixel data. We can actually do this in the future if we think
this makes sense but it would mean that if we replace a texture in GIMP (or whatever) the whole file
has to be rewritten, making it slightly inconvenient for the artist who maybe doesn't bake a new lightmap all the time.
So for now, you have to load the textures yourself by looking in the textureName
field of a MapPolygon
.
Cheers, Michael.