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 Resource
24 friend class MeshBuilder;
27 class Loader: public DataFile::ObjectLoader<Mesh>
33 Loader(Mesh &, bool = true);
35 void vertices(const std::vector<VertexComponent> &);
36 void batch(PrimitiveType);
37 void winding(FaceWinding);
41 class AsyncLoader: public Resource::AsyncLoader
46 Bufferable::AsyncUpdater *vertex_updater;
47 Bufferable::AsyncUpdater *index_updater;
51 AsyncLoader(Mesh &, IO::Seekable &);
54 virtual bool needs_sync() const;
55 virtual bool process();
65 std::vector<Batch> batches;
68 VertexSetup vtx_setup;
69 mutable unsigned short dirty;
70 bool disallow_rendering;
71 const WindingTest *winding;
74 Mesh(ResourceManager * = 0);
75 Mesh(const VertexFormat &, ResourceManager * = 0);
77 void init(ResourceManager *);
83 void check_buffers(unsigned);
86 const VertexArray &get_vertices() const { return vertices; }
87 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
88 const Buffer *get_index_buffer() const { return ibuf; }
89 unsigned get_n_vertices() const;
90 float *modify_vertex(unsigned);
92 void add_batch(const Batch &b);
93 const std::vector<Batch> &get_batches() const { return batches; }
95 void set_winding(const WindingTest *);
97 void draw(Renderer &) const;
98 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
100 void draw(Renderer &, const VertexSetup *, unsigned) const;
101 void resize_buffers() const;
104 virtual int get_load_priority() const { return 1; }
105 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
106 virtual UInt64 get_data_size() const;
107 virtual void unload();