MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / writeBZW

Function writeBZW

tools/modeltool/modeltool.cpp:193–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193static void writeBZW(CModel& model, std::string file) {
194 if (model.meshes.size() < 1) {
195 return;
196 }
197
198 FILE* fp = fopen(file.c_str(), "wt");
199 if (!fp) {
200 return;
201 }
202
203 if (useMaterials) {
204 tmMaterialMap::iterator materialItr = model.materials.begin();
205 while (materialItr != model.materials.end()) {
206 fprintf(fp, "%s", writeMaterial(materialItr->second, materialItr->first).c_str());
207 materialItr++;
208 }
209 fprintf(fp, "\n");
210 }
211
212 if (groupName.size() > 0) {
213 fprintf(fp, "define %s\n", groupName.c_str());
214 }
215
216 tvMeshList::iterator meshItr = model.meshes.begin();
217 for (meshItr = model.meshes.begin(); meshItr != model.meshes.end(); ++meshItr) {
218 CMesh& mesh = *meshItr;
219
220 mesh.reindex();
221
222 fprintf(fp, "mesh\n");
223 if (!mesh.name.empty()) {
224 fprintf(fp, " name %s\n", mesh.name.c_str());
225 }
226
227 if (outputComments) {
228 fprintf(fp, "# vertices: %d\n", (int)mesh.verts.size());
229 fprintf(fp, "# normals: %d\n", (int)mesh.normals.size());
230 fprintf(fp, "# texcoords: %d\n", (int)mesh.texCoords.size());
231 fprintf(fp, "# faces: %d\n\n", (int)mesh.faces.size());
232 }
233
234 if (useSmoothBounce) {
235 fprintf(fp, " smoothbounce\n");
236 }
237
238 for (int v = 0; v < (int)mesh.verts.size(); v++) {
239 const CVector3* vert = &mesh.verts[v];
240 const std::string msg = " vertex " + ftoa(vert->x) + " "
241 + ftoa(vert->y) + " "
242 + ftoa(vert->z);
243 fprintf(fp, msg.c_str());
244 if (outputComments) {
245 fprintf(fp, "\t# %d", v);
246 }
247 fprintf(fp, "\n");
248 }
249
250 for (int n = 0; n < (int)mesh.normals.size(); n++) {

Callers 1

mainFunction · 0.85

Calls 8

writeMaterialFunction · 0.85
ftoaFunction · 0.85
c_strMethod · 0.80
reindexMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected