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_
13 #include "objectpass.h"
14 #include "renderable.h"
26 Stores a Mesh together with a Technique to determine its appearance.
28 It is possible to use a single Object for rendering multiple identical or
29 similar objects. See class ObjectInstance.
31 class Object: public Renderable
34 std::vector<const Mesh *> meshes;
36 const Technique *technique;
39 class Loader: public DataFile::CollectionObjectLoader<Object>
42 Loader(Object &, Collection &);
45 void lod_mesh(unsigned, const std::string &);
46 void mesh(const std::string &);
53 const Technique *get_technique() const { return technique; }
56 Renders the object. A tag can be provided to render a non-default pass.
58 virtual void render(const Tag &tag=Tag()) const;
61 Renders the object with an instance. The instance's hook functions are
62 called before and after drawing the mesh. A tag may also be given to render
65 virtual void render(const ObjectInstance &, const Tag &tag=Tag()) const;
68 Renders multiple instances of the object in one go. This may improve
69 performance, as the object-specific render setup only has to be done once.
70 Each instance's hook functions will be called before and after drawing the
73 template<typename Iter>
74 void render(Iter begin, Iter end, const Tag &tag=Tag()) const
76 const RenderPass *pass=get_pass(tag);
81 for(Iter i=begin; i!=end; ++i)
82 render_instance(**i, tag);
85 const RenderPass *get_pass(const Tag &) const;
86 void render_instance(const ObjectInstance &, const Tag &) const;