From ae0600f7c3df5b6ef46992b1423888dd0e9a5026 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 17 May 2009 11:26:52 +0000 Subject: [PATCH] Support using a mesh as a background Fix various input problems --- source/designer/designer.cpp | 14 +++++++++++++- source/designer/designer.h | 2 ++ source/designer/manipulator.cpp | 7 +++++-- source/libmarklin/layout.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index 180ed50..2913aea 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -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(x)*2/screen_w-1; - float yf=1-static_cast(y)*2/screen_h; + float yf=static_cast(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) diff --git a/source/designer/designer.h b/source/designer/designer.h index c2c949e..598c1ae 100644 --- a/source/designer/designer.h +++ b/source/designer/designer.h @@ -14,6 +14,7 @@ Distributed under the GPL #include #include #include +#include #include #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; diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 34aaf31..798e99f 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -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::iterator i=neighbors.begin(); i!=neighbors.end(); ++i) for(vector::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::iterator i=tracks.begin(); i!=tracks.end(); ++i) + i->rot=i->track->get_rotation(); + update_neighbors(); signal_done.emit(true); diff --git a/source/libmarklin/layout.h b/source/libmarklin/layout.h index ada287c..ae03cef 100644 --- a/source/libmarklin/layout.h +++ b/source/libmarklin/layout.h @@ -45,6 +45,7 @@ public: Layout(Catalogue &); ~Layout(); + const std::string &get_base() const { return base; } const std::set &get_tracks() const { return tracks; } void add_track(Track &); void remove_track(Track &); -- 2.45.2