void GeometryBuilder::build(Mesh &mesh) const
{
MeshBuilder builder(mesh);
+ builder.auto_offset();
build(builder);
}
/* $Id$
This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2008, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
batch(0)
{ }
+void MeshBuilder::auto_offset()
+{
+ offset(mesh.get_vertices().size());
+}
+
void MeshBuilder::begin_()
{
batch = new Batch(type);
/* $Id$
This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2008, 2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
public:
MeshBuilder(Mesh &);
+ void auto_offset();
private:
virtual void begin_();
virtual void end_();
/* $Id$
This file is part of libmspgl
-Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions
+Copyright © 2008, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
PrimitiveBuilder::PrimitiveBuilder(VertexArray &a):
array(a),
vab(array),
- in_batch(false)
+ in_batch(false),
+ offs(0)
{ }
void PrimitiveBuilder::begin(PrimitiveType t)
end_();
}
+void PrimitiveBuilder::offset(unsigned o)
+{
+ if(o>array.size())
+ throw InvalidParameterValue("Element offset out of range");
+ offs = o;
+}
+
void PrimitiveBuilder::element(unsigned i)
{
if(!in_batch)
throw InvalidState("Element specification not between begin() and end()");
- if(i>=array.size())
+ if(offs+i>=array.size())
throw InvalidParameterValue("Element index out of range");
- element_(i);
+ element_(offs+i);
}
PrimitiveType PrimitiveBuilder::get_type() const
/* $Id$
This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2008, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
VertexArrayBuilder vab;
PrimitiveType type;
bool in_batch;
+ unsigned offs;
PrimitiveBuilder(VertexArray &);
public:
void begin(PrimitiveType);
void end();
+ void offset(unsigned);
void element(unsigned);
PrimitiveType get_type() const;
protected: