Revision: 6751 http://playerstage.svn.sourceforge.net/playerstage/?rev=6751&view=rev Author: alexcb Date: 2008-07-03 14:28:20 -0700 (Thu, 03 Jul 2008)
Log Message: ----------- fixed distortion issue when tilting camera Modified Paths: -------------- code/stage/trunk/libstage/model_camera.cc Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-07-03 21:09:25 UTC (rev 6750) +++ code/stage/trunk/libstage/model_camera.cc 2008-07-03 21:28:20 UTC (rev 6751) @@ -238,16 +238,11 @@ if( _frame_data == NULL || !showCameraData ) return; - // TODO - shift to global CS? - float w_fov = _camera.horizFov(); float h_fov = _camera.vertFov(); - float center_horiz = - _yaw_offset; - float center_vert = - _pitch_offset; - - float start_fov = center_horiz + w_fov / 2.0 + 180.0; //start at right - float start_vert_fov = center_vert + h_fov / 2.0 + 90.0; //start at top + float start_fov = w_fov / 2.0 + 180.0; //start at right + float start_vert_fov = h_fov / 2.0 + 90.0; //start at top int w = _width; int h = _height; @@ -266,9 +261,21 @@ ColoredVertex* vertex = _vertexbuf_cache + index; //calculate and cache normal unit vectors of the sphere - vertex->x = -sin( dtor( vert_a ) ) * cos( dtor( a ) ); - vertex->y = -sin( dtor( vert_a ) ) * sin( dtor( a ) ); - vertex->z = -cos( dtor( vert_a ) ); + float x = -sin( dtor( vert_a ) ) * cos( dtor( a ) ); + float y = -sin( dtor( vert_a ) ) * sin( dtor( a ) ); + float z = -cos( dtor( vert_a ) ); + + //rotate them about the pitch and yaw offsets - keeping distortion of the sphere at the extremes + a = dtor( - _yaw_offset ); + vertex->x = x * cos( a ) - y * sin( a ); + vertex->y = x * sin( a ) + y * cos( a ); + vertex->z = z; + + x = vertex->x; y = vertex->y; z = vertex->z; + a = dtor( _pitch_offset ); + vertex->x = z * sin( a ) + x * cos( a ); + vertex->y = y; + vertex->z = z * cos( a ) - x * sin( a ); } } _valid_vertexbuf_cache = true; 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