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);
81 void init(ResourceManager *);
85 void storage(const VertexFormat &);
89 void check_buffers(unsigned);
92 const VertexArray &get_vertices() const { return vertices; }
93 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
94 const Buffer *get_index_buffer() const { return ibuf; }
95 unsigned get_n_vertices() const;
96 char *modify_vertex(unsigned);
98 void add_batch(const Batch &b);
99 const std::vector<Batch> &get_batches() const { return batches; }
101 void set_winding(FaceWinding);
103 void draw(Renderer &) const;
104 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
106 void draw(Renderer &, const VertexSetup *, unsigned) const;
107 void resize_buffers() const;
110 virtual int get_load_priority() const { return 1; }
111 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
112 virtual std::uint64_t get_data_size() const;
113 virtual void unload();
115 void set_debug_name(const std::string &);