Changeset 13041 for OpenSceneGraph/trunk/src/osgGA/UFOManipulator.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgGA/UFOManipulator.cpp
r11475 r13041 29 29 _shift(false), 30 30 _ctrl(false) 31 { 31 { 32 32 _minHeightAboveGround = 2.0; 33 33 _minDistanceInFront = 5.0; … … 68 68 osgUtil::IntersectionVisitor iv(lsi.get()); 69 69 iv.setTraversalMask(_intersectTraversalMask); 70 70 71 71 _node->accept(iv); 72 72 73 73 if (lsi->containsIntersections()) 74 74 { … … 83 83 _node = node; 84 84 85 if (getAutoComputeHomePosition()) 85 if (getAutoComputeHomePosition()) 86 86 computeHomePosition(); 87 87 … … 100 100 101 101 102 const char* UFOManipulator::className() const 103 { 104 return "UFO"; 105 } 106 107 void UFOManipulator::setByMatrix( const osg::Matrixd &mat ) 102 const char* UFOManipulator::className() const 103 { 104 return "UFO"; 105 } 106 107 void UFOManipulator::setByMatrix( const osg::Matrixd &mat ) 108 108 { 109 109 _inverseMatrix = mat; … … 118 118 } 119 119 120 void UFOManipulator::setByInverseMatrix( const osg::Matrixd &invmat) 120 void UFOManipulator::setByInverseMatrix( const osg::Matrixd &invmat) 121 121 { 122 122 _matrix = invmat; … … 136 136 } 137 137 138 osg::Matrixd UFOManipulator::getInverseMatrix() const 138 osg::Matrixd UFOManipulator::getInverseMatrix() const 139 139 { 140 140 return (_inverseMatrix * _offset); … … 150 150 /* 151 151 * Find the ground - Assumption: The ground is the hit of an intersection 152 * from a line segment extending from above to below the database at its 152 * from a line segment extending from above to below the database at its 153 153 * horizontal center, that intersects the database closest to zero. */ 154 154 … … 192 192 } 193 193 194 void UFOManipulator::home(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) 194 void UFOManipulator::home(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) 195 195 { 196 196 home(ea.getTime()); … … 200 200 } 201 201 202 void UFOManipulator::home(double) 203 { 204 if (getAutoComputeHomePosition()) 202 void UFOManipulator::home(double) 203 { 204 if (getAutoComputeHomePosition()) 205 205 computeHomePosition(); 206 206 … … 257 257 void UFOManipulator::getUsage(osg::ApplicationUsage& usage) const 258 258 { 259 /** Way too busy. This needs to wait until we have a scrollable window 259 /** Way too busy. This needs to wait until we have a scrollable window 260 260 usage.addKeyboardMouseBinding("UFO Manipulator: <SpaceBar>", "Reset the viewing angle to 0.0"); 261 261 usage.addKeyboardMouseBinding("UFO Manipulator: <UpArrow>", "Acceleration forward."); … … 430 430 _directionRotationRate = 0.0; 431 431 } 432 432 433 433 } 434 434 break; … … 465 465 osg::Vec3d _sideVec = _direction * osg::Matrix::rotate( -M_PI*0.5, upVec); 466 466 467 _position += ((_direction * _forwardSpeed) + 467 _position += ((_direction * _forwardSpeed) + 468 468 (_sideVec * _sideSpeed) + 469 469 (upVec * _upSpeed)) … … 477 477 478 478 _yawOffset += _yawOffsetRate * _dt; 479 if( _yawOffset >= M_PI || _yawOffset < -M_PI ) 479 if( _yawOffset >= M_PI || _yawOffset < -M_PI ) 480 480 _yawOffset *= -1; 481 481 … … 486 486 _adjustPosition(); 487 487 488 _inverseMatrix.makeLookAt( _position, _position + _direction, upVec); 488 _inverseMatrix.makeLookAt( _position, _position + _direction, upVec); 489 489 _matrix.invert(_inverseMatrix); 490 490 … … 541 541 // Check intersects infront. 542 542 osg::Vec3d ip; 543 if (intersect(_position, 543 if (intersect(_position, 544 544 _position + (_direction * (_minDistanceInFront * 3.0)), 545 545 ip )) … … 553 553 } 554 554 } 555 555 556 556 // Check intersects below. 557 557 osg::CoordinateFrame cf( getCoordinateFrame(_position) ); 558 558 osg::Vec3d upVec( getUpVector(cf) ); 559 559 560 if (intersect(_position, 561 _position - upVec*_minHeightAboveGround*3, 560 if (intersect(_position, 561 _position - upVec*_minHeightAboveGround*3, 562 562 ip )) 563 563 {
