Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/cfg/Camera.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/cfg/Camera.cpp
r12292 r13041 23 23 using namespace osgProducer; 24 24 25 Camera::Camera( void ) 25 Camera::Camera( void ) 26 26 { 27 27 _index = 0; … … 47 47 _lens->setAutoAspect(true); 48 48 _rs = new RenderSurface; 49 49 50 50 _clear_color[0] = 0.2f; 51 51 _clear_color[1] = 0.2f; 52 52 _clear_color[2] = 0.4f; 53 53 _clear_color[3] = 1.0f; 54 54 55 55 _focal_distance = 1.0; 56 56 57 57 _shareLens = true; 58 58 _shareView = true; … … 107 107 // _bottom = -0.5; 108 108 // _top = 0.5; 109 109 110 110 // Setting of the frustum which are appropriate for 111 111 // a monitor which is 26cm high, 50cm distant from the … … 138 138 } 139 139 140 void Camera::Lens::setPerspective( double hfov, double vfov, 140 void Camera::Lens::setPerspective( double hfov, double vfov, 141 141 double nearClip, double farClip ) 142 142 { … … 148 148 _farClip = farClip; 149 149 150 _left = -_nearClip * tan(_hfov/2.0); 151 _right = _nearClip * tan(_hfov/2.0); 150 _left = -_nearClip * tan(_hfov/2.0); 151 _right = _nearClip * tan(_hfov/2.0); 152 152 _bottom = -_nearClip * tan(_vfov/2.0); 153 153 _top = _nearClip * tan(_vfov/2.0); … … 157 157 } 158 158 159 void Camera::Lens::setFrustum( double left, double right, 160 double bottom, double top, 159 void Camera::Lens::setFrustum( double left, double right, 160 double bottom, double top, 161 161 double nearClip, double farClip ) 162 162 { … … 172 172 } 173 173 174 void Camera::Lens::setOrtho( double left, double right, 175 double bottom, double top, 174 void Camera::Lens::setOrtho( double left, double right, 175 double bottom, double top, 176 176 double nearClip, double farClip ) 177 177 { … … 202 202 zNear = _matrix[14] / (_matrix[10]-1.0); 203 203 zFar = _matrix[14] / (1.0+_matrix[10]); 204 204 205 205 left = zNear * (_matrix[8]-1.0) / _matrix[0]; 206 206 right = zNear * (1.0+_matrix[8]) / _matrix[0]; … … 221 221 zNear = (_matrix[14]+1.0) / _matrix[10]; 222 222 zFar = (_matrix[14]-1.0) / _matrix[10]; 223 223 224 224 left = -(1.0+_matrix[12]) / _matrix[0]; 225 225 right = (1.0-_matrix[12]) / _matrix[0]; … … 321 321 const float bottom, const float top ) 322 322 { 323 _projrectLeft = left; 324 _projrectRight = right; 325 _projrectBottom = bottom; 326 _projrectTop = top; 323 _projrectLeft = left; 324 _projrectRight = right; 325 _projrectBottom = bottom; 326 _projrectTop = top; 327 327 } 328 328 … … 336 336 } 337 337 338 void Camera::setProjectionRectangle( int x, int y, unsigned int width, unsigned int height ) 338 void Camera::setProjectionRectangle( int x, int y, unsigned int width, unsigned int height ) 339 339 { 340 340 int _x, _y; … … 410 410 411 411 412 void Camera::clear( void ) 412 void Camera::clear( void ) 413 413 { 414 414 #if 0 415 415 if( !_initialized ) _initialize(); 416 int x, y; 416 int x, y; 417 417 unsigned int w, h; 418 418 getProjectionRectangle( x, y, w, h ); … … 565 565 matrix[ 8] += -xshear; 566 566 matrix[ 9] += -yshear; 567 } 567 } 568 568 else 569 569 { … … 613 613 _done = true; 614 614 #endif 615 615 616 616 Thread::cancel(); 617 return 0; 617 return 0; 618 618 } 619 619 … … 641 641 642 642 _frameBarrier->block(); 643 643 644 644 if (_done) break; 645 645 … … 660 660 advance(); 661 661 } 662 662 663 663 // printf("Exiting Camera::run cleanly\n"); 664 664 } … … 676 676 } 677 677 678 bool Camera::removePreDrawCallback( Callback *cb ) 678 bool Camera::removePreDrawCallback( Callback *cb ) 679 679 { 680 680 return _removeCallback( preDrawCallbacks, cb ); 681 681 } 682 682 683 bool Camera::removePostDrawCallback( Callback *cb ) 683 bool Camera::removePostDrawCallback( Callback *cb ) 684 684 { 685 685 return _removeCallback( postDrawCallbacks, cb ); … … 744 744 _init(); 745 745 746 PipeTimer::instance()->begin( _pipeStatsNames[id][_pipeStatsDoubleBufferIndex] ); 747 _pipeStatsSetMask[_pipeStatsDoubleBufferIndex] |= (1<<id); 748 } 749 750 void Camera::FrameTimeStampSet::endPipeTimer() 751 { 746 PipeTimer::instance()->begin( _pipeStatsNames[id][_pipeStatsDoubleBufferIndex] ); 747 _pipeStatsSetMask[_pipeStatsDoubleBufferIndex] |= (1<<id); 748 } 749 750 void Camera::FrameTimeStampSet::endPipeTimer() 751 { 752 752 if( !_initialized ) 753 753 return; … … 771 771 772 772 const Camera::FrameTimeStampSet &Camera::getFrameStats() 773 { 774 return _frameStamps; 773 { 774 return _frameStamps; 775 775 } 776 776 #endif
