Revision: 6687 http://playerstage.svn.sourceforge.net/playerstage/?rev=6687&view=rev Author: alexcb Date: 2008-06-25 15:21:47 -0700 (Wed, 25 Jun 2008)
Log Message: ----------- hooked up arrow keys to perspective camera 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-06-25 21:05:58 UTC (rev 6686) +++ code/stage/trunk/libstage/camera.cc 2008-06-25 22:21:47 UTC (rev 6687) @@ -71,11 +71,23 @@ } +void StgPerspectiveCamera::strafe( float amount ) +{ + _x += cos( dtor( _yaw ) ) * amount; + _y += sin( dtor( _yaw ) ) * amount; +} +void StgPerspectiveCamera::forward( float amount ) +{ + _x += -sin( dtor( _yaw ) ) * amount; + _y += cos( dtor( _yaw ) ) * amount; +} + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Ortho camera ////////////////////////////////////////////////////////////////////////////////////////////////////////////// Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-25 21:05:58 UTC (rev 6686) +++ code/stage/trunk/libstage/canvas.cc 2008-06-25 22:21:47 UTC (rev 6687) @@ -366,10 +366,18 @@ } redraw(); break; - case FL_Left: camera.move( -10, 0 ); break; - case FL_Right: camera.move( 10, 0 );; break; - case FL_Down: camera.move( 0, -10 );; break; - case FL_Up: camera.move( 0, 10 );; break; + case FL_Left: + if( use_perspective_camera == false ) { camera.move( -10, 0 ); } + else { perspective_camera.strafe( -0.5 ); } break; + case FL_Right: + if( use_perspective_camera == false ) {camera.move( 10, 0 ); } + else { perspective_camera.strafe( 0.5 ); } break; + case FL_Down: + if( use_perspective_camera == false ) {camera.move( 0, -10 ); } + else { perspective_camera.forward( -0.5 ); } break; + case FL_Up: + if( use_perspective_camera == false ) {camera.move( 0, 10 ); } + else { perspective_camera.forward( 0.5 ); } break; default: return 0; // keypress unhandled } Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-25 21:05:58 UTC (rev 6686) +++ code/stage/trunk/libstage/stage.hh 2008-06-25 22:21:47 UTC (rev 6687) @@ -1833,6 +1833,9 @@ //void SetProjection( float aspect ) const; void update( void ); + void strafe( float amount ); + void forward( float amount ); + inline void setPose( float x, float y, float z ) { _x = x; _y = y; _z = z; } inline void addPose( float x, float y, float z ) { _x += x; _y += y; _z += z; if( _z < 0.1 ) _z = 0.1; } void move( float x, float y, float z ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit