4 #include <msp/datafile/objectloader.h>
7 #include "vertexarray.h"
8 #include "windingtest.h"
17 Raw mesh data, consisting of a VertexArray and one or more Batches. Though a
18 Mesh can draw itself, it's usually used as part of Renderables rather than on
21 class Mesh: public Bindable<Mesh>, public Resource
23 friend class MeshBuilder;
26 class Loader: public DataFile::ObjectLoader<Mesh>
31 void vertices(const std::vector<VertexComponent> &);
32 void batch(PrimitiveType);
33 void winding(FaceWinding);
37 class AsyncLoader: public Resource::AsyncLoader
42 Bufferable::AsyncUpdater *vertex_updater;
43 Bufferable::AsyncUpdater *index_updater;
47 AsyncLoader(Mesh &, IO::Seekable &);
50 virtual bool needs_sync() const;
51 virtual bool process();
55 std::list<Batch> batches;
61 bool disallow_rendering;
62 const WindingTest *winding;
65 Mesh(ResourceManager * = 0);
66 Mesh(const VertexFormat &, ResourceManager * = 0);
68 void init(ResourceManager *);
73 void use_buffers(bool);
75 void create_buffers();
76 void setup_vao() const;
79 const VertexArray &get_vertices() const { return vertices; }
80 const Buffer *get_index_buffer() const { return ibuf; }
81 unsigned get_n_vertices() const;
82 float *modify_vertex(unsigned);
84 void add_batch(const Batch &b);
85 const std::list<Batch> &get_batches() { return batches; }
87 void set_winding(const WindingTest *);
90 void draw(Renderer &) const;
96 virtual Resource::AsyncLoader *load(IO::Seekable &);
97 virtual UInt64 get_data_size() const;
98 virtual void unload();