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<VertexAttribute> &);
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;
72 std::string debug_name;
75 Mesh(ResourceManager * = 0);
76 Mesh(const VertexFormat &, ResourceManager * = 0);
78 void init(ResourceManager *);
84 void check_buffers(unsigned);
87 const VertexArray &get_vertices() const { return vertices; }
88 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
89 const Buffer *get_index_buffer() const { return ibuf; }
90 unsigned get_n_vertices() const;
91 float *modify_vertex(unsigned);
93 void add_batch(const Batch &b);
94 const std::vector<Batch> &get_batches() const { return batches; }
96 void set_winding(const WindingTest *);
98 void draw(Renderer &) const;
99 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
101 void draw(Renderer &, const VertexSetup *, unsigned) const;
102 void resize_buffers() const;
105 virtual int get_load_priority() const { return 1; }
106 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
107 virtual UInt64 get_data_size() const;
108 virtual void unload();
110 void set_debug_name(const std::string &);