6 #include <msp/datafile/objectloader.h>
10 #include "vertexarray.h"
11 #include "vertexsetup.h"
20 Raw mesh data, consisting of a VertexArray and one or more Batches. Though a
21 Mesh can draw itself, it's usually used as part of Renderables rather than on
24 class Mesh: public Resource
26 friend class MeshBuilder;
29 class Loader: public DataFile::ObjectLoader<Mesh>
35 Loader(Mesh &, bool = true);
37 void storage(const std::vector<VertexAttribute> &);
39 void vertices_with_format(const std::vector<VertexAttribute> &);
40 void batch(PrimitiveType);
44 class AsyncLoader: public Resource::AsyncLoader
49 Bufferable::AsyncUpdater *vertex_updater;
50 Bufferable::AsyncUpdater *index_updater;
54 AsyncLoader(Mesh &, IO::Seekable &);
57 virtual bool needs_sync() const;
58 virtual bool process();
68 std::vector<Batch> batches;
71 VertexSetup vtx_setup;
72 mutable unsigned short dirty;
73 bool disallow_rendering;
74 FaceWinding face_winding;
75 std::string debug_name;
78 Mesh(ResourceManager * = 0);
79 Mesh(const VertexFormat &, ResourceManager * = 0);
82 void storage(const VertexFormat &);
86 void check_buffers(unsigned);
89 const VertexArray &get_vertices() const { return vertices; }
90 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
91 const Buffer *get_index_buffer() const { return ibuf; }
92 unsigned get_n_vertices() const;
93 char *modify_vertex(unsigned);
95 void add_batch(const Batch &b);
96 const std::vector<Batch> &get_batches() const { return batches; }
98 void set_winding(FaceWinding);
100 void draw(Renderer &) const;
101 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
103 void draw(Renderer &, const VertexSetup *, unsigned) const;
104 void resize_buffers() const;
107 virtual int get_load_priority() const { return 1; }
108 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
109 virtual std::uint64_t get_data_size() const;
110 virtual void unload();
112 void set_debug_name(const std::string &);