Revision: 6772 http://playerstage.svn.sourceforge.net/playerstage/?rev=6772&view=rev Author: alexcb Date: 2008-07-04 17:59:26 -0700 (Fri, 04 Jul 2008)
Log Message: ----------- fixed picker bug introduced by camera model Modified Paths: -------------- code/stage/trunk/libstage/camera.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/camera.cc =================================================================== --- code/stage/trunk/libstage/camera.cc 2008-07-05 00:43:45 UTC (rev 6771) +++ code/stage/trunk/libstage/camera.cc 2008-07-05 00:59:26 UTC (rev 6772) @@ -105,18 +105,27 @@ } -void StgOrthoCamera::SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ) const +void StgOrthoCamera::SetProjection( void ) const { glMatrixMode (GL_PROJECTION); glLoadIdentity (); - - glOrtho( -pixels_width/2.0 / _scale, pixels_width/2.0 / _scale, - -pixels_height/2.0 / _scale, pixels_height/2.0 / _scale, - y_min * _scale * 2, y_max * _scale * 2 ); - + + glOrtho( -_pixels_width/2.0 / _scale, _pixels_width/2.0 / _scale, + -_pixels_height/2.0 / _scale, _pixels_height/2.0 / _scale, + _y_min * _scale * 2, _y_max * _scale * 2 ); + glMatrixMode (GL_MODELVIEW); } +void StgOrthoCamera::SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ) +{ + _pixels_width = pixels_width; + _pixels_height = pixels_height; + _y_min = y_min; + _y_max = y_max; + SetProjection(); +} + //TODO re-evaluate the way the camera is shifted when the mouse zooms - it might be possible to simplify void StgOrthoCamera::scale( float scale, float shift_x, float w, float shift_y, float h ) { Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-07-05 00:43:45 UTC (rev 6771) +++ code/stage/trunk/libstage/canvas.cc 2008-07-05 00:59:26 UTC (rev 6772) @@ -93,8 +93,10 @@ glClearColor ( 1,1,1,1 ); // white glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + glLoadIdentity(); + current_camera->SetProjection(); + current_camera->Draw(); - glDisable(GL_DITHER); glDisable(GL_BLEND); // turns off alpha blending, so we read back // exactly what we write to a pixel @@ -155,6 +157,8 @@ glEnable(GL_BLEND); glClearColor ( 0.7, 0.7, 0.8, 1.0); + Screenshot(); + return mod; } @@ -284,7 +288,6 @@ clicked_empty_space = ( mod == NULL ); empty_space_startx = startx; empty_space_starty = starty; - std::cout << "clicked: " << startx << " " << Fl::event_x() << std::endl; if( mod ) { // clicked a model if ( Fl::event_state( FL_SHIFT ) ) { Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-07-05 00:43:45 UTC (rev 6771) +++ code/stage/trunk/libstage/stage.hh 2008-07-05 00:59:26 UTC (rev 6772) @@ -1791,6 +1791,7 @@ virtual ~StgCamera() { } virtual void Draw( void ) const = 0; + virtual void SetProjection( void ) const = 0; inline float yaw( void ) const { return _yaw; } inline float pitch( void ) const { return _pitch; } @@ -1857,10 +1858,16 @@ private: float _scale; + float _pixels_width; + float _pixels_height; + float _y_min; + float _y_max; + public: StgOrthoCamera( void ) : _scale( 15 ) { } virtual void Draw() const; - virtual void SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ) const; + virtual void SetProjection( float pixels_width, float pixels_height, float y_min, float y_max ); + virtual void SetProjection( void ) const; inline void move( float x, float y ) { //convert screen points into world points This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit