]> git.tdb.fi Git - libs/gl.git/blob - source/render/objectinstance.cpp
Replace the instance variables of exporters by function parameters
[libs/gl.git] / source / render / objectinstance.cpp
1 #include "objectinstance.h"
2 #include "renderer.h"
3 #include "transform.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace GL {
9
10 ObjectInstance::ObjectInstance(const Object &obj):
11         object(obj)
12 { }
13
14 void ObjectInstance::render(Renderer &renderer, Tag tag) const
15 {
16         object.render(renderer, *this, tag);
17 }
18
19 void ObjectInstance::setup_render(Renderer &renderer, Tag) const
20 {
21         renderer.transform(matrix);
22 }
23
24 unsigned ObjectInstance::get_level_of_detail(const Renderer &renderer) const
25 {
26         return renderer.get_object_lod_bias();
27 }
28
29
30 ObjectInstance::Loader::Loader(ObjectInstance &o):
31         DataFile::ObjectLoader<ObjectInstance>(o)
32 {
33         add("transform", &Loader::transform);
34 }
35
36 void ObjectInstance::Loader::transform()
37 {
38         Transform trn;
39         load_sub(trn);
40         obj.matrix = trn.to_matrix();
41 }
42
43 } // namespace GL
44 } // namespaec Msp