X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Flayout.cpp;h=2881e8d33c82ed23d8c5c6edcffa09e684b8f8fa;hb=374dc443d044f31c925342f339a628c860c08a7e;hp=5f015766f6367ad53ae108d379cad9ab0c94861c;hpb=1ff06c5bc46a677fa389ef86c6b26664368f1653;p=r2c2.git diff --git a/source/3d/layout.cpp b/source/3d/layout.cpp index 5f01576..2881e8d 100644 --- a/source/3d/layout.cpp +++ b/source/3d/layout.cpp @@ -1,18 +1,10 @@ /* $Id$ This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ -#include -#include -#include -#include -#include -#include -#include -#include #include "layout.h" #include "track.h" #include "vehicle.h" @@ -26,6 +18,10 @@ Layout3D::Layout3D(Layout &l): layout(l), catalogue(layout.get_catalogue()) { + // South, 15° from zenith + sun.set_position(0, -0.259, 0.966, 0); + lighting.attach(0, sun); + layout.signal_track_added.connect(sigc::mem_fun(this, &Layout3D::track_added)); layout.signal_track_removed.connect(sigc::mem_fun(this, &Layout3D::track_removed)); layout.signal_vehicle_added.connect(sigc::mem_fun(this, &Layout3D::vehicle_added)); @@ -44,6 +40,22 @@ Layout3D::~Layout3D() delete vehicles.begin()->second; } +void Layout3D::get_bounds(Vector &minp, Vector &maxp) const +{ + minp = maxp = Vector(); + + for(TrackMap::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) + { + Vector tmin; + Vector tmax; + i->second->get_bounds(0, tmin, tmax); + minp.x = min(minp.x, tmin.x); + minp.y = min(minp.y, tmin.y); + maxp.x = max(maxp.x, tmax.x); + maxp.y = max(maxp.y, tmax.y); + } +} + void Layout3D::add_track(Track3D &t) { if(tracks.count(&t.get_track())) @@ -66,42 +78,6 @@ Track3D &Layout3D::get_track(Track &t) const return *i->second; } -Track3D *Layout3D::pick_track(float x, float y, float size) const -{ - vector select_buf; - GL::select_buffer(select_buf); - GL::render_mode(GL::SELECT); - - { - GL::PushMatrix push_mat; - GL::load_identity(); - - GL::ClipPlane(1, 0, x-size, 0).apply_to(0); - GL::ClipPlane(-1, 0, -x-size, 0).apply_to(1); - GL::ClipPlane(0, 1, y-size, 0).apply_to(2); - GL::ClipPlane(0, -1, -y-size, 0).apply_to(3); - } - - scene.render(0); - - GL::ClipPlane::disable(0); - GL::ClipPlane::disable(1); - GL::ClipPlane::disable(2); - GL::ClipPlane::disable(3); - - GL::render_mode(GL::RENDER); - Track3D *track = 0; - unsigned track_depth = numeric_limits::max(); - for(vector::iterator i=select_buf.begin(); i!=select_buf.end(); ++i) - if(i->min_depthnames.empty()) - { - track = reinterpret_cast(i->names.back()); - track_depth = i->min_depth; - } - - return track; -} - void Layout3D::add_vehicle(Vehicle3D &v) { if(vehicles.count(&v.get_vehicle()))