]> git.tdb.fi Git - libs/gl.git/blob - source/geometrybuilder.cpp
Initialize camera matrices in constructor
[libs/gl.git] / source / geometrybuilder.cpp
1 #include "geometrybuilder.h"
2 #include "meshbuilder.h"
3
4 namespace Msp {
5 namespace GL {
6
7 GeometryBuilder::GeometryBuilder():
8         generate_tbn(false),
9         tex_fit(STRETCH)
10 { }
11
12 GeometryBuilder &GeometryBuilder::tbn(bool t)
13 {
14         generate_tbn = t;
15         return *this;
16 }
17
18 GeometryBuilder &GeometryBuilder::texture_fit(TextureFit tf)
19 {
20         tex_fit = tf;
21         return *this;
22 }
23
24 void GeometryBuilder::adjust_texture_scale(float &u_scale, float &v_scale, float width, float height) const
25 {
26         if(tex_fit!=STRETCH)
27         {
28                 if((width<height)==(tex_fit==CROP))
29                         u_scale *= width/height;
30                 else
31                         v_scale *= height/width;
32         }
33 }
34
35 void GeometryBuilder::build(Mesh &mesh) const
36 {
37         MeshBuilder builder(mesh);
38         builder.auto_offset();
39         build(builder);
40 }
41
42 } // namespace GL
43 } // namespace Msp