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 "objectpass.h"
13 #include "renderable.h"
25 Stores data for a complete 3D object. An Object must always have a Mesh, and
26 may also have a Technique to determine its appearance. Textures and material
27 specified by the Technique may be overridden. Simple textured objects are also
28 possible without a Technique.
30 It is possible to use a single Object for rendering multiple identical or
31 similar objects. See class ObjectInstance.
33 class Object: public Renderable
36 std::vector<const Mesh *> meshes;
37 const Technique *technique;
38 std::vector<const Texture *> textures;
39 const Texture *main_texture;
40 const Material *material;
43 class Loader: public DataFile::CollectionObjectLoader<Object>
46 Loader(Object &, Collection &);
49 virtual void finish();
50 void lod_mesh(unsigned, const std::string &);
51 void material_inline();
52 void mesh(const std::string &);
53 void shader_texture(const std::string &);
54 void technique(const std::string &);
55 void texture(const std::string &);
61 const Technique *get_technique() const { return technique; }
64 Renders the object. A tag can be provided to render a non-default pass.
66 virtual void render(const Tag &tag=Tag()) const;
69 Renders the object with an instance. The instance's hook functions are
70 called before and after drawing the mesh. A tag may also be given to render
73 virtual void render(const ObjectInstance &, const Tag &tag=Tag()) const;
76 Renders multiple instances of the object in one go. This may improve
77 performance, as the object-specific render setup only has to be done once.
78 Each instance's hook functions will be called before and after drawing the
81 template<typename Iter>
82 void render(Iter begin, Iter end, const Tag &tag=Tag()) const
87 const ObjectPass *pass=get_pass(tag);
89 for(Iter i=begin; i!=end; ++i)
90 render_instance(**i, tag);
94 bool can_render(const Tag &) const;
95 const ObjectPass *get_pass(const Tag &) const;
96 void setup_render(const ObjectPass *) const;
97 void finish_render(const ObjectPass *) const;
98 void render_instance(const ObjectInstance &, const Tag &) const;