I've been writing some C++ code to generate Horde resource files from within some of my tools lately, and I was wondering if this code would be useful to someone - like a library for Horde tool programmers?
I'm trying to keep this as simple as possible (no dependencies so far, not even Horde), so this is the kind of code I will be writing:
Code:
struct Material
{
struct TexUnit
{
std::string name;
ubyte index;
bool cube;
bool useCompression;
bool useFiltering;
bool useMipMaps;
bool repeat;
};
struct Uniform
{
std::string name;
float a,b,c,d;
};
std::string className;
std::string link;
std::string shader;
std::vector<TexUnit> textures;
std::vector<Uniform> uniforms;
};
std::ostream& operator<<( std::ostream& xml, const Material m )
{
xml << "<Material class=\""<<m.className<<"\" link=\""<<m.link<<"\">\n";
xml << " <Shader source=\""<<m.shader<<"\"/>\n";
for( std::vector<Material::TexUnit>::const_iterator it = m.textures.begin();
it != m.textures.end(); ++it )
{
xml << " <TexUnit unit=\""<<it->index<<"\" map=\""<<it->name<<"\" />\n";
}
for( std::vector<Material::Uniform>::const_iterator it = m.uniforms.begin();
it != m.uniforms.end(); ++it )
{
xml << " <Uniform name=\""<<it->name<<"\" a=\""<<it->a<<"\" b=\""<<it->b<<"\" c=\""<<it->c<<"\" d=\""<<it->d<<"\" />\n";
}
xml << "</Material>\n";
}