3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GL_OBJECT_H_
9 #define MSP_GL_OBJECT_H_
12 #include <msp/datafile/collection.h>
13 #include "objectpass.h"
14 #include "renderable.h"
27 Stores data for a complete 3D object. This includes a mesh, a shader and data
28 for it and a number of textures. Only the mesh is mandatory, other components
31 See also class ObjectInstance.
33 class Object: public Renderable
36 std::vector<Mesh *> meshes;
37 std::vector<Texture *> textures;
38 std::map<unsigned, ObjectPass> passes;
40 ObjectPass *normal_pass;
43 class Loader: public DataFile::Loader
46 typedef DataFile::Collection Collection;
52 std::vector<std::string> textures;
55 Loader(Object &, Collection &);
58 Object &get_object() const { return obj; }
59 Collection &get_collection() const { return coll; }
61 void lod_mesh(unsigned, const std::string &);
62 void material_inline();
63 void mesh(const std::string &);
64 void pass(const std::string &);
65 void shader(const std::string &);
66 void texture(const std::string &);
72 virtual bool has_pass(const Tag &) const;
73 const ObjectPass &get_pass(const Tag &) const;
76 Renders the object. A tag can be provided to render a non-default pass.
78 virtual void render(const Tag &tag=Tag()) const;
81 Renders the object with an instance. The instance's hook functions are
82 called before and after drawing the mesh. A tag may also be given to render
85 virtual void render(const ObjectInstance &, const Tag &tag=Tag()) const;
88 Renders multiple instances of the object in one go. This may improve
89 performance, as the object-specific render setup only has to be done once.
90 Each instance's hook functions will be called before and after drawing the
93 void render(const std::list<const ObjectInstance *> &, const Tag &tag=Tag()) const;
95 void setup_render(const ObjectPass &) const;
96 void finish_render(const ObjectPass &) const;
97 void render(const ObjectPass &, const ObjectInstance *) const;
98 void render(const ObjectPass &, const std::list<const ObjectInstance *> &) const;