4 #include <msp/datafile/objectloader.h>
7 #include "vertexarray.h"
8 #include "vertexsetup.h"
9 #include "windingtest.h"
18 Raw mesh data, consisting of a VertexArray and one or more Batches. Though a
19 Mesh can draw itself, it's usually used as part of Renderables rather than on
22 class Mesh: public Bindable<Mesh>, public Resource
24 friend class MeshBuilder;
27 class Loader: public DataFile::ObjectLoader<Mesh>
32 void vertices(const std::vector<VertexComponent> &);
33 void batch(PrimitiveType);
34 void winding(FaceWinding);
38 class AsyncLoader: public Resource::AsyncLoader
43 Bufferable::AsyncUpdater *vertex_updater;
44 Bufferable::AsyncUpdater *index_updater;
48 AsyncLoader(Mesh &, IO::Seekable &);
51 virtual bool needs_sync() const;
52 virtual bool process();
56 std::vector<Batch> batches;
59 VertexSetup vtx_setup;
62 bool disallow_rendering;
63 const WindingTest *winding;
66 Mesh(ResourceManager * = 0);
67 Mesh(const VertexFormat &, ResourceManager * = 0);
69 void init(ResourceManager *);
75 void create_buffers();
78 const VertexArray &get_vertices() const { return vertices; }
79 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
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::vector<Batch> &get_batches() const { return batches; }
87 void set_winding(const WindingTest *);
89 void draw(Renderer &) const;
90 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
92 /** Binds the mesh for rendering. The vertex array is applied using generic
93 attributes only. Uses vertex array object if possible. */
98 virtual int get_load_priority() const { return 1; }
99 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
100 virtual UInt64 get_data_size() const;
101 virtual void unload();