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 storage(const std::vector<VertexAttribute> &);
37 void vertices_with_format(const std::vector<VertexAttribute> &);
38 void batch(PrimitiveType);
39 void winding(FaceWinding);
43 class AsyncLoader: public Resource::AsyncLoader
48 Bufferable::AsyncUpdater *vertex_updater;
49 Bufferable::AsyncUpdater *index_updater;
53 AsyncLoader(Mesh &, IO::Seekable &);
56 virtual bool needs_sync() const;
57 virtual bool process();
67 std::vector<Batch> batches;
70 VertexSetup vtx_setup;
71 mutable unsigned short dirty;
72 bool disallow_rendering;
73 const WindingTest *winding;
74 std::string debug_name;
77 Mesh(ResourceManager * = 0);
78 Mesh(const VertexFormat &, ResourceManager * = 0);
80 void init(ResourceManager *);
84 void storage(const VertexFormat &);
88 void check_buffers(unsigned);
91 const VertexArray &get_vertices() const { return vertices; }
92 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
93 const Buffer *get_index_buffer() const { return ibuf; }
94 unsigned get_n_vertices() const;
95 float *modify_vertex(unsigned);
97 void add_batch(const Batch &b);
98 const std::vector<Batch> &get_batches() const { return batches; }
100 void set_winding(const WindingTest *);
102 void draw(Renderer &) const;
103 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
105 void draw(Renderer &, const VertexSetup *, unsigned) const;
106 void resize_buffers() const;
109 virtual int get_load_priority() const { return 1; }
110 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
111 virtual UInt64 get_data_size() const;
112 virtual void unload();
114 void set_debug_name(const std::string &);