if self.object:
out_file.begin("mesh")
- fmt = "NORMAL3"
+ fmt = ["NORMAL3"]
if texunits:
for i, u in texunits:
if u.unit==0:
- fmt += "_TEXCOORD2"
+ fmt.append("TEXCOORD2")
else:
- fmt += "_TEXCOORD2%d"%u.unit
+ fmt.append("TEXCOORD2_%d"%u.unit)
if self.tbn_vecs:
- fmt += "_ATTRIB33_ATTRIB34"
+ fmt += ["ATTRIB3_3", "ATTRIB3_4"]
if self.export_groups:
- fmt += "_ATTRIB%d5"%(self.max_groups*2)
- fmt += "_VERTEX3"
- out_file.begin("vertices", fmt)
+ fmt.append("ATTRIB%d_5"%(self.max_groups*2))
+ fmt.append("VERTEX3")
+ out_file.begin("vertices", *fmt)
normal = None
uvs = [None]*len(texunits)
tan = None
add("winding", &Loader::winding);
}
-void Mesh::Loader::vertices(VertexFormat f)
+void Mesh::Loader::vertices(const vector<VertexComponent> &c)
{
- obj.vertices.reset(f);
+ if(c.empty())
+ throw invalid_argument("No vertex components");
+
+ VertexFormat fmt;
+ for(vector<VertexComponent>::const_iterator i=c.begin(); i!=c.end(); ++i)
+ fmt = (fmt, *i);
+ obj.vertices.reset(fmt);
load_sub(obj.vertices);
}
public:
Loader(Mesh &);
private:
- void vertices(VertexFormat);
+ void vertices(const std::vector<VertexComponent> &);
void batch(PrimitiveType);
void winding(FaceWinding);
};
throw lexical_error(format("conversion of '%s' to VertexComponent", str));
}
-// XXX This will go away eventually
-void operator>>(const LexicalConverter &conv, VertexFormat &f)
-{
- vector<string> parts = split(conv.get(), '_');
- for(vector<string>::iterator i=parts.begin(); i!=parts.end(); ++i)
- {
- if(*i=="COLOR4UB")
- *i = "COLOR4_UBYTE";
- else if(i->size()==7 && !i->compare(0, 5, "COLOR") && (*i)[6]=='F')
- *i = i->substr(0, 6)+"_FLOAT";
- else if(i->size()>=10 && !i->compare(0, 8, "TEXCOORD"))
- *i = i->substr(0, 9)+"_"+i->substr(9);
- else if(i->size()>=8 && !i->compare(0, 6, "ATTRIB"))
- *i = i->substr(0, 7)+"_"+i->substr(7);
- }
-
- for(vector<string>::iterator i=parts.begin(); i!=parts.end(); ++i)
- f = (f, lexical_cast<VertexComponent>(*i));
-}
-
} // namespace GL
} // namespace Msp
{ return f.stride(); }
void operator>>(const LexicalConverter &, VertexComponent &);
-void operator>>(const LexicalConverter &, VertexFormat &);
} // namespace GL
} // namespace Msp