Changeset 8999
- Timestamp:
- 10/07/08 16:19:28 (5 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 4 modified
-
include/osgGA/UFOManipulator (modified) (2 diffs)
-
src/osgGA/NodeTrackerManipulator.cpp (modified) (1 diff)
-
src/osgGA/TerrainManipulator.cpp (modified) (1 diff)
-
src/osgGA/UFOManipulator.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgGA/UFOManipulator
r7730 r8999 21 21 #include <osg/Matrix> 22 22 23 /**24 \class osgGA::UFOManipulator25 \brief A UFO manipulator driven with keybindings.23 /** 24 \class osgGA::UFOManipulator 25 \brief A UFO manipulator driven with keybindings. 26 26 27 The UFOManipulator is better suited for applications that employ28 architectural walk-throughs, or situations where the eyepoint motion29 model must move slowly, deliberately and well controlled.27 The UFOManipulator is better suited for applications that employ 28 architectural walk-throughs, or situations where the eyepoint motion 29 model must move slowly, deliberately and well controlled. 30 30 31 The UFO Manipulator allows the following movements with the listed32 Key combinations:33 \param UpArrow Acceleration forward.34 \param DownArrow Acceleration backward (or deceleration forward).35 \param LeftArrow Rotate view and direction of travel to the left.36 \param RightArrow Rotate view and direction of travel to the right.37 \param SpaceBar Brake. Gradually decelerates linear and rotational movement.38 \param Shift/UpArrow Accelerate up.39 \param Shift/DownArrow Accelerate down.40 \param Shift/LeftArrow Accelerate (linearly) left.41 \param Shift/RightArrow Accelerate (linearly) right.42 \param Shift/SpaceBar Instant brake. Immediately stop all linear and rotational movement.31 The UFO Manipulator allows the following movements with the listed 32 Key combinations: 33 \param UpArrow Acceleration forward. 34 \param DownArrow Acceleration backward (or deceleration forward). 35 \param LeftArrow Rotate view and direction of travel to the left. 36 \param RightArrow Rotate view and direction of travel to the right. 37 \param SpaceBar Brake. Gradually decelerates linear and rotational movement. 38 \param Shift/UpArrow Accelerate up. 39 \param Shift/DownArrow Accelerate down. 40 \param Shift/LeftArrow Accelerate (linearly) left. 41 \param Shift/RightArrow Accelerate (linearly) right. 42 \param Shift/SpaceBar Instant brake. Immediately stop all linear and rotational movement. 43 43 44 When the Shift key is released, up, down, linear left and/or linear right movement is decelerated.44 When the Shift key is released, up, down, linear left and/or linear right movement is decelerated. 45 45 46 \param Ctrl/UpArrow Rotate view (but not direction of travel) up.47 \param Ctrl/DownArrow Rotate view (but not direction of travel) down.48 \param Ctrl/LeftArrow Rotate view (but not direction of travel) left.49 \param Ctrl/RightArrow Rotate view (but not direction of travel) right.50 \param Ctrl/Return Straightens out the view offset.46 \param Ctrl/UpArrow Rotate view (but not direction of travel) up. 47 \param Ctrl/DownArrow Rotate view (but not direction of travel) down. 48 \param Ctrl/LeftArrow Rotate view (but not direction of travel) left. 49 \param Ctrl/RightArrow Rotate view (but not direction of travel) right. 50 \param Ctrl/Return Straightens out the view offset. 51 51 52 */52 */ 53 53 54 54 namespace osgGA { … … 130 130 131 131 protected: 132 133 virtual ~UFOManipulator(); 134 135 bool intersect(const osg::Vec3d& start, const osg::Vec3d& end, osg::Vec3d& intersection) const; 136 132 137 osg::ref_ptr<osg::Node> _node; 133 138 float _viewAngle; -
OpenSceneGraph/trunk/src/osgGA/NodeTrackerManipulator.cpp
r8038 r8999 16 16 #include <osg/Notify> 17 17 #include <osg/Transform> 18 #include <osgUtil/IntersectVisitor>19 18 20 19 using namespace osg; -
OpenSceneGraph/trunk/src/osgGA/TerrainManipulator.cpp
r8710 r8999 16 16 #include <osg/Notify> 17 17 #include <osg/io_utils> 18 #include <osgUtil/IntersectVisitor>19 18 #include <osgUtil/LineSegmentIntersector> 20 19 -
OpenSceneGraph/trunk/src/osgGA/UFOManipulator.cpp
r7730 r8999 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 * (at your option) any later version. The full license is in LICENSE file 6 * included with this distribution, and on the openscenegraph.org website. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * OpenSceneGraph Public License for more details. 12 */ 13 14 /* Written by Don Burns */ 15 1 16 #include <osgGA/UFOManipulator> 2 #include <osgUtil/ IntersectVisitor>17 #include <osgUtil/LineSegmentIntersector> 3 18 4 19 #include <osg/io_utils> … … 43 58 } 44 59 60 UFOManipulator::~UFOManipulator() 61 { 62 } 63 64 bool UFOManipulator::intersect(const osg::Vec3d& start, const osg::Vec3d& end, osg::Vec3d& intersection) const 65 { 66 osg::ref_ptr<osgUtil::LineSegmentIntersector> lsi = new osgUtil::LineSegmentIntersector(start,end); 67 68 osgUtil::IntersectionVisitor iv(lsi.get()); 69 iv.setTraversalMask(_intersectTraversalMask); 70 71 _node->accept(iv); 72 73 if (lsi->containsIntersections()) 74 { 75 intersection = lsi->getIntersections().begin()->getWorldIntersectPoint(); 76 return true; 77 } 78 return false; 79 } 80 45 81 void UFOManipulator::setNode( osg::Node *node ) 46 82 { … … 116 152 * from a line segment extending from above to below the database at its 117 153 * horizontal center, that intersects the database closest to zero. */ 118 osgUtil::IntersectVisitor iv;119 iv.setTraversalMask(_intersectTraversalMask);120 154 121 155 osg::CoordinateFrame cf( getCoordinateFrame(bs.center()) ); // not sure what position to use here 122 156 osg::Vec3d upVec( getUpVector(cf) ); 123 osg::ref_ptr<osg::LineSegment> seg = new osg::LineSegment; 157 124 158 osg::Vec3 A = bs.center() + (upVec*(bs.radius()*2)); 125 159 osg::Vec3 B = bs.center() + (-upVec*(bs.radius()*2)); … … 130 164 } 131 165 132 /*133 seg->set( bs.center() + (upVec*(bs.radius()*2)),134 bs.center() + (-upVec*(bs.radius()*2)) );135 */136 seg->set( A, B );137 138 iv.addLineSegment( seg.get() );139 _node->accept(iv);140 141 166 // start with it high 142 167 double ground = bs.radius() * 3; 143 168 144 if (iv.hits()) 145 { 146 osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(seg.get()); 147 osg::Vec3d ip = hitList.front().getWorldIntersectPoint(); 169 osg::Vec3d ip; 170 if (intersect(A, B, ip)) 171 { 148 172 double d = ip.length(); 149 173 if( d < ground ) … … 511 535 return; 512 536 513 osgUtil::IntersectVisitor iv;514 iv.setTraversalMask(_intersectTraversalMask);515 516 537 // Forward line segment at 3 times our intersect distance 517 osg::ref_ptr<osg::LineSegment> segForward = new osg::LineSegment; 518 segForward->set(_position, _position + (_direction * (_minDistanceInFront * 3.0)) ); 519 iv.addLineSegment( segForward.get() ); 520 521 522 // Down line segment at 3 times our intersect distance 538 539 540 typedef std::vector<osg::Vec3d> Intersections; 541 Intersections intersections; 542 543 // Check intersects infront. 544 osg::Vec3d ip; 545 if (intersect(_position, 546 _position + (_direction * (_minDistanceInFront * 3.0)), 547 ip )) 548 { 549 double d = (ip - _position).length(); 550 551 if( d < _minDistanceInFront ) 552 { 553 _position = ip + (_direction * -_minDistanceInFront); 554 _stop(); 555 } 556 } 557 558 // Check intersects below. 523 559 osg::CoordinateFrame cf( getCoordinateFrame(_position) ); 524 560 osg::Vec3d upVec( getUpVector(cf) ); 525 osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment; 526 segDown->set( _position, 527 _position - upVec*_minHeightAboveGround*3); 528 iv.addLineSegment( segDown.get() ); 529 530 _node->accept(iv); 531 532 if (iv.hits()) 533 { 534 // Check intersects infront. 535 { 536 osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segForward.get()); 537 if (!hitList.empty()) 538 { 539 osg::Vec3d ip = hitList.front().getWorldIntersectPoint(); 540 541 double d = (ip - _position).length(); 542 543 if( d < _minDistanceInFront ) 544 { 545 _position = ip + (_direction * -_minDistanceInFront); 546 _stop(); 547 } 548 } 549 } 550 551 // Check intersects below. 552 { 553 osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segDown.get()); 554 if (!hitList.empty()) 555 { 556 osg::Vec3d ip = hitList.front().getWorldIntersectPoint(); 557 double d = (ip - _position).length(); 558 559 if( d < _minHeightAboveGround ) 560 _position = ip + (upVec * _minHeightAboveGround); 561 } 562 } 563 561 562 if (intersect(_position, 563 _position - upVec*_minHeightAboveGround*3, 564 ip )) 565 { 566 double d = (ip - _position).length(); 567 568 if( d < _minHeightAboveGround ) 569 _position = ip + (upVec * _minHeightAboveGround); 564 570 } 565 571 }
