| 155 | void writeDrawInfoBZW(DrawInfoMeshes& drawInfoMeshes, std::string file); |
| 156 | |
| 157 | std::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 | |
| 193 | static void writeBZW(CModel& model, std::string file) { |