michaeleggers / Bayernstein

Game/Engine code for project Bayernstein
0 stars 1 forks source link

feat: lightmap integration #21

Open michaeleggers opened 1 week ago

michaeleggers commented 1 week ago
michaeleggers commented 6 days ago

The Quake MAP data structures have changed a bit:

struct QuakeMapVertex {
    glm::f64vec3  pos;
    glm::vec2     uv;
};

struct MapPolygon
{
    std::vector<QuakeMapVertex> vertices;
    glm::f64vec3                normal;
    std::string                 textureName;  // located in /game/textures/<*.png>
    uint64_t                    surfaceFlags; // eg. transparency, emissiveness, ...
    uint64_t                    contentFlags; // eg. water, slime, lava, ...
};

The functions

std::vector<MapPolygon> createPolysoup(Map map, SoupFlags soupFlags = SOUP_GET_WORLDSPAWN_ONLY); 
std::vector<MapPolygon> createPolysoup(const Brush& brush);

To get the polygons just for static MAP geometry (which is needed for the lightmapper) just call the first of the two functions with the default flag. If you want all of the geometry (including brush entities and invisible stuff) call it with SOUP_GET_ALL. A function to get only brush entities could be added but probably not very useful because they will be available by iterating over the entity list anyways.

Now process the Polygons in a way so they include both the texturename and UV coordinates that have already been converted from 3d relative texture space to concrete UVs, ranged from 0..1 on both axis.

Important