]> git.tdb.fi Git - r2c2.git/commitdiff
Support using a mesh as a background
authorMikko Rasa <tdb@tdb.fi>
Sun, 17 May 2009 11:26:52 +0000 (11:26 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 17 May 2009 11:26:52 +0000 (11:26 +0000)
Fix various input problems

source/designer/designer.cpp
source/designer/designer.h
source/designer/manipulator.cpp
source/libmarklin/layout.h

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)
index c2c949eb409e706243db867eeb0115c2467c6934..598c1aebd1baf7db5c26e342989874e16bfb1c81 100644 (file)
@@ -14,6 +14,7 @@ Distributed under the GPL
 #include <msp/gbase/window.h>
 #include <msp/gbase/glcontext.h>
 #include <msp/gl/font.h>
+#include <msp/gl/mesh.h>
 #include <msp/time/timestamp.h>
 #include "libmarklin/catalogue.h"
 #include "libmarklin/layout.h"
@@ -48,6 +49,7 @@ private:
        Marklin::Layout3D  *layout_3d;
        Marklin::Layout    *cat_layout;
        Marklin::Layout3D  *cat_layout_3d;
+       Msp::GL::Mesh  *base_mesh;
        Selection      *selection;
        Manipulator    *manipulator;
        Measure        *measure;
index 34aaf31ffdca2994a876e40985f19ed8d1e3a7e4..798e99f7ebef1c95a47ede24de2daf043480aa6d 100644 (file)
@@ -221,7 +221,7 @@ void Manipulator::cancel()
                (*i)->check_slope();
 
        angle=0;
-       //snapped=0;
+       wrap_rot=0;
 
        signal_done.emit(false);
 }
@@ -234,7 +234,7 @@ void Manipulator::button_press(int, int, float, float, unsigned btn)
        {
                mode=NONE;
                update_wrap();
-               //snapped=0;
+               angle=0;
 
                for(set<Track *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
                        for(vector<MTrack>::iterator j=tracks.begin(); j!=tracks.end(); ++j)
@@ -252,6 +252,9 @@ void Manipulator::button_press(int, int, float, float, unsigned btn)
                                j->track->snap_to(**i, true);
                }
 
+               for(vector<MTrack>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+                       i->rot=i->track->get_rotation();
+
                update_neighbors();
 
                signal_done.emit(true);
index ada287cfdedb1db414162d6a9164b1f2897be7cd..ae03cef6f30a2ca970656f7a6a9662255595ef9d 100644 (file)
@@ -45,6 +45,7 @@ public:
        Layout(Catalogue &);
        ~Layout();
 
+       const std::string &get_base() const { return base; }
        const std::set<Track *> &get_tracks() const { return tracks; }
        void  add_track(Track &);
        void  remove_track(Track &);