]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/designer.cpp
Support using a mesh as a background
[r2c2.git] / source / designer / designer.cpp
index 180ed50ff1fb55ebd933302e74cfd4b9d0bdcf75..2913aea1e43ec00dff88536869259ed7e523a6b9 100644 (file)
@@ -33,6 +33,7 @@ using namespace Msp;
 Designer::Designer(int argc, char **argv):
        screen_w(1280),
        screen_h(960),
+       base_mesh(0),
        input(0),
        mode(SELECT),
        cam_yaw(M_PI/2),
@@ -80,6 +81,12 @@ Designer::Designer(int argc, char **argv):
                        else if((*i)->get_track().get_flex())
                                (*i)->set_color(GL::Color(1, 0.5, 1));
                }
+
+               if(!layout->get_base().empty())
+               {
+                       base_mesh=new GL::Mesh;
+                       DataFile::load(*base_mesh, layout->get_base());
+               }
        }
 
        selection=new Selection;
@@ -158,7 +165,7 @@ void Designer::map_pointer_coords(int x, int y, float &gx, float &gy)
        float uz=cos_pitch*0.41421;
 
        float xf=static_cast<float>(x)*2/screen_w-1;
-       float yf=1-static_cast<float>(y)*2/screen_h;
+       float yf=static_cast<float>(y)*2/screen_h-1;
 
        float vx=cos_yaw*cos_pitch + xf*rx + yf*ux;
        float vy=sin_yaw*cos_pitch + xf*ry + yf*uy;
@@ -534,6 +541,11 @@ void Designer::render()
                cat_layout_3d->render();
        else
        {
+               if(base_mesh)
+               {
+                       GL::Texture::unbind();
+                       base_mesh->draw();
+               }
                layout_3d->render(true);
                manipulator->render();
                if(mode==MEASURE)