4 #include <msp/datafile/objectloader.h>
7 #include "vertexarray.h"
8 #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 *);
74 void use_buffers(bool);
76 void create_buffers();
79 const VertexArray &get_vertices() const { return vertices; }
80 const VertexSetup *get_vertex_setup() const { return vtx_setup; }
81 const Buffer *get_index_buffer() const { return ibuf; }
82 unsigned get_n_vertices() const;
83 float *modify_vertex(unsigned);
85 void add_batch(const Batch &b);
86 const std::vector<Batch> &get_batches() const { return batches; }
88 void set_winding(const WindingTest *);
91 void draw(Renderer &) const;
92 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
94 /** Binds the mesh for rendering. The vertex array is applied using generic
95 attributes only. Uses vertex array object if possible. */
100 virtual int get_load_priority() const { return 1; }
101 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
102 virtual UInt64 get_data_size() const;
103 virtual void unload();