| 1156 | } |
| 1157 | |
| 1158 | void writeDrawInfoBZW(DrawInfoMeshes& drawInfoMeshes, std::string file) { |
| 1159 | if (!drawInfoMeshes.valid()) { |
| 1160 | return; |
| 1161 | } |
| 1162 | |
| 1163 | // the idea here is to go and output each of the mesh sections into |
| 1164 | // seperate buffers, bulding up the actual used vert and index lists. |
| 1165 | // then dump out those lists to a buffer, and composite the entire |
| 1166 | // thing into one bzw. |
| 1167 | // This way we can do things in any order and not worry about |
| 1168 | // duplicating indexes. |
| 1169 | std::string materialsSection; |
| 1170 | std::string inxexesSection; |
| 1171 | std::string staticGeoSection; |
| 1172 | std::string boundingGeoSection; |
| 1173 | std::string drawInfoSection; |
| 1174 | |
| 1175 | std::string invisibleMatName = "bounding.invisible"; |
| 1176 | |
| 1177 | // the 3 major lists |
| 1178 | tvVec3List verts; |
| 1179 | tvVec3List norms; |
| 1180 | tvVec2List uvs; |
| 1181 | |
| 1182 | // this is cheap, each corner is unique instance of a vert, normal, and uv coordinate. |
| 1183 | // even tho they are ints we can store them like a vert, and just cast them to ints. |
| 1184 | // to leverage the existing functions for sorting indexes. |
| 1185 | tvVec3List corners; |
| 1186 | |
| 1187 | progressLog("starting drawInfo Mesh"); |
| 1188 | |
| 1189 | // build the static geo into it's buffer |
| 1190 | if (drawInfoMeshes.staticMesh.meshes.size()) { |
| 1191 | CModel& staticModel = drawInfoMeshes.staticMesh; |
| 1192 | for (int m = 0; m < (int)staticModel.meshes.size(); m++) { |
| 1193 | CMesh& subMesh = staticModel.meshes[m]; |
| 1194 | progressLog(TextUtils::format("static model sub mesh%d", m)); |
| 1195 | |
| 1196 | for (int f = 0; f < (int)subMesh.faces.size(); f++) { |
| 1197 | CFace& face = subMesh.faces[f]; |
| 1198 | |
| 1199 | staticGeoSection += "face"; |
| 1200 | if (outputComments) { |
| 1201 | staticGeoSection += TextUtils::format("\t#%d", f); |
| 1202 | } |
| 1203 | staticGeoSection += "\n"; |
| 1204 | |
| 1205 | std::string vert = "vertices"; |
| 1206 | std::string norm = "normals"; |
| 1207 | std::string uv = "texcoords"; |
| 1208 | |
| 1209 | for (int v = 0; v < (int)face.verts.size(); v++) { |
| 1210 | vert += TextUtils::format(" %d", getNewIndex(subMesh.verts[face.verts[v]], verts)); |
| 1211 | norm += TextUtils::format(" %d", getNewIndex(subMesh.normals[face.normals[v]], norms)); |
| 1212 | if (face.texCoords.size()) { |
| 1213 | uv += TextUtils::format(" %d", getNewIndex(subMesh.texCoords[face.texCoords[v]], uvs)); |
| 1214 | } |
| 1215 | } |
no test coverage detected