]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/cameracontroller.cpp
Rename the project to R²C²
[r2c2.git] / source / designer / cameracontroller.cpp
index bd7edbb530d540e73ac32296b80c6c57a3106180..6b98f3dba1bb32cda7aed57acc4bad688ce42a02 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$
 
-This file is part of the MSP Märklin suite
+This file is part of R²C²
 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
@@ -12,7 +12,7 @@ Distributed under the GPL
 
 using namespace std;
 using namespace Msp;
-using namespace Marklin;
+using namespace R2C2;
 
 CameraController::CameraController(Designer &d, Graphics::EventSource &es, GL::Camera &c):
        designer(d),
@@ -83,7 +83,13 @@ void CameraController::adjust_distance(float delta)
 {
        const GL::Vector3 &pos = camera.get_position();
        const GL::Vector3 &look = camera.get_look_direction();
+       float dist = get_distance();
+       float low = designer.get_layout().get_catalogue().get_gauge()*5;
+       if(dist+delta<low)
+               delta = low-dist;
        camera.set_position(GL::Vector3(pos.x-look.x*delta, pos.y-look.y*delta, pos.z-look.z*delta));
+       dist += delta;
+       camera.set_depth_clip(dist*0.02, dist*50);
 }
 
 void CameraController::rotate(float angle)