Skip to content

Commit

Permalink
Fix Grouping .obj
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Mar 21, 2024
1 parent c37a41a commit eb8a264
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9553,6 +9553,8 @@ void Bsp::ExportToObjWIP(const std::string& path, int iscale, bool lightmapmode,
std::map<std::string, std::stringstream> group_textures;
std::map<std::string, std::stringstream> group_objects;

std::map<std::string, int> group_vert_groups;

std::vector<std::string> group_list;

for (int i = 0; i < faceCount; i++)
Expand Down Expand Up @@ -9724,8 +9726,6 @@ void Bsp::ExportToObjWIP(const std::string& path, int iscale, bool lightmapmode,
//print_log(PRINT_RED, "Entity {} angles {}\n", tmpentid, rendEnt->angles.toKeyvalueString());
}



mat4x4 angle_mat;
angle_mat.loadIdentity();

Expand Down Expand Up @@ -9796,6 +9796,10 @@ void Bsp::ExportToObjWIP(const std::string& path, int iscale, bool lightmapmode,

if (lastmaterialid != materialid)
{
group_vert_groups[groupname]++;

group_objects[groupname] << "g " << groupname << "_face" << group_vert_groups[groupname] << "\n";

group_objects[groupname] << "usemtl " << materialid << "\n";
}
lastmaterialid = materialid;
Expand Down Expand Up @@ -9823,16 +9827,14 @@ void Bsp::ExportToObjWIP(const std::string& path, int iscale, bool lightmapmode,

for (auto& group : group_list)
{
obj_file << "o " << groupname << "\n";
obj_file << "o " << group << "\n";

obj_file << group_verts[group].str();

obj_file << group_normals[group].str();

obj_file << group_textures[group].str();


obj_file << "g " << groupname << "\n";
obj_file << group_objects[group].str();
}

Expand Down

0 comments on commit eb8a264

Please sign in to comment.