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>
32 void vertices(const std::vector<VertexComponent> &);
33 void batch(PrimitiveType);
34 void winding(FaceWinding);
38 class AsyncLoader: public Resource::AsyncLoader
43 Bufferable::AsyncUpdater *vertex_updater;
44 Bufferable::AsyncUpdater *index_updater;
48 AsyncLoader(Mesh &, IO::Seekable &);
51 virtual bool needs_sync() const;
52 virtual bool process();
62 std::vector<Batch> batches;
65 VertexSetup vtx_setup;
66 mutable unsigned short dirty;
67 bool disallow_rendering;
68 const WindingTest *winding;
71 Mesh(ResourceManager * = 0);
72 Mesh(const VertexFormat &, ResourceManager * = 0);
74 void init(ResourceManager *);
80 void check_buffers(unsigned);
83 const VertexArray &get_vertices() const { return vertices; }
84 const VertexSetup &get_vertex_setup() const { return vtx_setup; }
85 const Buffer *get_index_buffer() const { return ibuf; }
86 unsigned get_n_vertices() const;
87 float *modify_vertex(unsigned);
89 void add_batch(const Batch &b);
90 const std::vector<Batch> &get_batches() const { return batches; }
92 void set_winding(const WindingTest *);
94 void draw(Renderer &) const;
95 void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
97 void draw(Renderer &, const VertexSetup *, unsigned) const;
98 void resize_buffers() const;
101 virtual int get_load_priority() const { return 1; }
102 virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
103 virtual UInt64 get_data_size() const;
104 virtual void unload();