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

Function writeMaterial

tools/modeltool/modeltool.cpp:157–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155void writeDrawInfoBZW(DrawInfoMeshes& drawInfoMeshes, std::string file);
156
157std::string writeMaterial(CMaterial& material, const std::string& name) {
158 std::string out;
159
160 if (supressMats) {
161 return out;
162 }
163 out += TextUtils::format("material\n name %s\n", name.c_str());
164 if (material.texture.size()) {
165 std::string texName = texdir + material.texture;
166 // change the extension to png
167 const char* p = strrchr(texName.c_str(), '.');
168 if (p) {
169 texName.resize(p - texName.c_str());
170 texName += ".png";
171 }
172 else {
173 texName += ".png";
174 }
175 out += TextUtils::format(" texture %s\n", texName.c_str());
176 }
177 else {
178 out += TextUtils::format(" notextures\n");
179 }
180
181 if (useAmbient) { out += " ambient " + ftoa(material.ambient, 4) + "\n"; }
182 if (useDiffuse) { out += " diffuse " + ftoa(material.diffuse, 4) + "\n"; }
183 if (useEmission) { out += " emission " + ftoa(material.emission, 4) + "\n"; }
184 if (useSpecular) { out += " specular " + ftoa(material.specular, 4) + "\n"; }
185 if (useShininess) { out += " shininess " + ftoa(material.shine) + "\n"; }
186
187 out += "end\n\n";
188
189 return out;
190}
191
192
193static void writeBZW(CModel& model, std::string file) {

Callers 2

writeBZWFunction · 0.85
writeDrawInfoBZWFunction · 0.85

Calls 5

ftoaFunction · 0.85
c_strMethod · 0.80
formatFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected