#include <OSGNavigator.h>
Definition at line 62 of file OSGNavigator.h.
| enum osg::Navigator::Mode |
The navigation state, mainly needed for correct interpretation of mouse motions, which have to be interpreted differently for different states. Interpretation also depends on the currently active Navigator::Mode.
| IDLE | Inactive state. |
| ROTATING | State for in-place rotation. |
| TRANSLATING_XY | State for x/y translation, used by the Trackball case. |
| TRANSLATING_Z | State for z translation, used by the Trackball case. |
| TRANSLATING_ZPLUS | State for rotation with automatic forward motion. The standard fly forward state. |
| TRANSLATING_ZMINUS | State for rotation with automatic backwards motion. The standard fly backwards state. |
Definition at line 75 of file OSGNavigator.h.
00076 { 00077 IDLE=0, 00078 ROTATING, 00079 TRANSLATING_XY, 00080 TRANSLATING_Z, 00081 00082 TRANSLATING_ZPLUS=10, 00083 TRANSLATING_ZMINUS 00084 };
Abstraction enumeration for mouse buttons, to keep the Navigator independent of the actual Window System.
| LEFT_MOUSE | |
| MIDDLE_MOUSE | |
| RIGHT_MOUSE | |
| UP_MOUSE | Mouse wheel up button. |
| DOWN_MOUSE | Mouse wheel down button. |
Definition at line 86 of file OSGNavigator.h.
00087 { 00088 LEFT_MOUSE=0, 00089 MIDDLE_MOUSE, 00090 RIGHT_MOUSE, 00091 UP_MOUSE, 00092 DOWN_MOUSE 00093 };
| enum osg::Navigator::Key |
| Navigator::Navigator | ( | ) |
Definition at line 154 of file OSGNavigator.cpp.
00154 : 00155 _rRotationAngle(0.04908739f), 00156 _rMotionFactor(1.f), 00157 _currentState(IDLE), 00158 _currentMode(TRACKBALL), 00159 _absolute(true), 00160 _vp(NullFC), 00161 _cartN(NullFC), 00162 _moved(false), 00163 _clickCenter(true), 00164 _clickNoIntersect(false), 00165 _lastX(0), 00166 _lastY(0), 00167 _ip(0,0,0) 00168 { 00169 }
| Navigator::~Navigator | ( | ) | [virtual] |
Mouse button press handler.
Definition at line 181 of file OSGNavigator.cpp.
References _currentMode, _currentState, _flyer, _lastX, _lastY, _moved, _rMotionFactor, _trackball, _walker, DOWN_MOUSE, FLY, FNOTICE, osg::WalkNavigator::forward(), osg::FlyNavigator::forward(), getIntersectionPoint(), IDLE, LEFT_MOUSE, MIDDLE_MOUSE, NONE, RIGHT_MOUSE, ROTATING, TRACKBALL, osg::TrackballNavigator::translateZ(), TRANSLATING_XY, TRANSLATING_Z, TRANSLATING_ZMINUS, TRANSLATING_ZPLUS, UP_MOUSE, and WALK.
Referenced by osg::SimpleSceneManager::mouseButtonPress().
00182 { 00183 _lastX = x; _lastY = y; 00184 _moved = false; 00185 00186 switch (_currentMode) 00187 { 00188 case NONE: 00189 _currentState = IDLE; 00190 break; 00191 00192 case TRACKBALL: 00193 00194 switch (button) 00195 { 00196 case LEFT_MOUSE : _currentState = ROTATING; 00197 break; 00198 00199 case RIGHT_MOUSE : _currentState = TRANSLATING_Z; 00200 break; 00201 00202 case MIDDLE_MOUSE: _currentState = TRANSLATING_XY; 00203 getIntersectionPoint(x,y); 00204 break; 00205 00206 case UP_MOUSE : _currentState = IDLE; 00207 _trackball.translateZ(-_rMotionFactor); 00208 break; 00209 00210 case DOWN_MOUSE : _currentState = IDLE; 00211 _trackball.translateZ(_rMotionFactor); 00212 break; 00213 00214 default: FNOTICE(("Navigator: buttonPress, unknown button\n")); 00215 break; 00216 } 00217 break; 00218 00219 case FLY: 00220 00221 switch (button) 00222 { 00223 case LEFT_MOUSE : _currentState = TRANSLATING_ZPLUS; 00224 break; 00225 00226 case MIDDLE_MOUSE: _currentState = ROTATING; 00227 break; 00228 00229 case RIGHT_MOUSE : _currentState = TRANSLATING_ZMINUS; 00230 break; 00231 00232 case UP_MOUSE : _currentState = IDLE; 00233 _flyer.forward(-_rMotionFactor); 00234 break; 00235 00236 case DOWN_MOUSE : _currentState = IDLE; 00237 _flyer.forward(_rMotionFactor); 00238 break; 00239 00240 default: FNOTICE(("Navigator: buttonPress, unknown button\n")); 00241 break; 00242 } 00243 break; 00244 00245 case WALK: 00246 00247 switch (button) 00248 { 00249 case LEFT_MOUSE : _currentState = TRANSLATING_ZPLUS; 00250 break; 00251 00252 case MIDDLE_MOUSE: _currentState = ROTATING; 00253 break; 00254 00255 case RIGHT_MOUSE : _currentState = TRANSLATING_ZMINUS; 00256 break; 00257 00258 case UP_MOUSE : _currentState = IDLE; 00259 _walker.forward(-_rMotionFactor); 00260 break; 00261 00262 case DOWN_MOUSE : _currentState = IDLE; 00263 _walker.forward(_rMotionFactor); 00264 break; 00265 00266 default: FNOTICE(("Navigator: buttonPress, unknown button\n")); 00267 break; 00268 } 00269 break; 00270 00271 default: 00272 00273 FNOTICE(("Navigator: buttonPress, unknown mode\n")); 00274 break; 00275 } 00276 }
Mouse button release handler.
Definition at line 280 of file OSGNavigator.cpp.
References _clickCenter, _currentMode, _currentState, _moved, _trackball, _vp, osg::Action::apply(), osg::IntersectAction::create(), osg::IntersectAction::didHit(), FLY, FNOTICE, osg::Line::getDirection(), osg::IntersectAction::getHitPoint(), osg::Line::getPosition(), IDLE, NONE, osg::TrackballNavigator::setAt(), osg::IntersectAction::setLine(), TRACKBALL, and WALK.
Referenced by osg::SimpleSceneManager::mouseButtonRelease().
00281 { 00282 switch (_currentMode) 00283 { 00284 case NONE: break; 00285 00286 case TRACKBALL: if (!_moved && _clickCenter) 00287 { 00288 IntersectAction * act = IntersectAction::create(); 00289 Line line; 00290 _vp->getCamera()->calcViewRay(line, x, y, *_vp); 00291 00292 Pnt3f lp1 = line.getPosition(); 00293 Vec3f ld1 = line.getDirection(); 00294 00295 act->setLine(line); 00296 act->apply(_vp->getRoot()); 00297 if (act->didHit()) 00298 { 00299 Pnt3f p1 = act->getHitPoint(); 00300 _trackball.setAt(p1); 00301 } 00302 00303 delete act; 00304 } 00305 break; 00306 00307 case FLY: break; 00308 case WALK: break; 00309 00310 default: FNOTICE(("Navigator: buttonRelease, unknown mode\n")); 00311 break; 00312 } 00313 _currentState=IDLE; 00314 }
Key press handler.
Definition at line 318 of file OSGNavigator.cpp.
References _currentMode, _flyer, _rMotionFactor, _rRotationAngle, _trackball, _walker, BACKWARDS, FLY, FNOTICE, osg::WalkNavigator::forward(), osg::FlyNavigator::forward(), FORWARDS, LEFT, LEFTROT, NONE, osg::WalkNavigator::right(), osg::FlyNavigator::right(), RIGHT, RIGHTROT, osg::WalkNavigator::rotate(), osg::FlyNavigator::rotate(), TRACKBALL, osg::TrackballNavigator::translateZ(), and WALK.
Referenced by osg::SimpleSceneManager::key().
00319 { 00320 switch (_currentMode) 00321 { 00322 case NONE: 00323 break; 00324 00325 case TRACKBALL: 00326 00327 switch (key) 00328 { 00329 case LEFT : /*undefined*/ break; 00330 case RIGHT : /*undefined*/ break; 00331 case FORWARDS : _trackball.translateZ(-_rMotionFactor); break; 00332 case BACKWARDS : _trackball.translateZ(_rMotionFactor); break; 00333 default : FNOTICE(("Navigator: keyPress, unknown key\n")); 00334 } 00335 break; 00336 00337 case FLY: 00338 00339 switch (key) 00340 { 00341 case LEFTROT : _flyer.rotate(-_rRotationAngle, 0); break; 00342 case RIGHTROT : _flyer.rotate( _rRotationAngle, 0); break; 00343 case LEFT : _flyer.right( _rMotionFactor); break; 00344 case RIGHT : _flyer.right(-_rMotionFactor); break; 00345 case FORWARDS : _flyer.forward(-_rMotionFactor); break; 00346 case BACKWARDS : _flyer.forward( _rMotionFactor); break; 00347 default : FNOTICE(("Navigator: keyPress, unknown key\n")); 00348 } 00349 break; 00350 00351 case WALK: 00352 00353 switch (key) 00354 { 00355 case LEFTROT : _walker.rotate(-_rRotationAngle, 0); break; 00356 case RIGHTROT : _walker.rotate( _rRotationAngle, 0); break; 00357 case LEFT : _walker.right( _rMotionFactor); break; 00358 case RIGHT : _walker.right(-_rMotionFactor); break; 00359 case FORWARDS : _walker.forward(-_rMotionFactor); break; 00360 case BACKWARDS : _walker.forward( _rMotionFactor); break; 00361 default : FNOTICE(("Navigator: keyPress, unknown key\n")); 00362 } 00363 break; 00364 00365 default: 00366 00367 FNOTICE(("Navigator: keyPress, unknown mode\n")); 00368 break; 00369 } 00370 }
Mouse motion handler.
Definition at line 374 of file OSGNavigator.cpp.
References _currentMode, _currentState, _flyer, _lastX, _lastY, _moved, _rMotionFactor, _trackball, _vp, _walker, calcDeltas(), FLY, FNOTICE, osg::WalkNavigator::forward(), osg::FlyNavigator::forward(), NONE, osg::NullFC, osg::osgabs(), osg::osgpow(), osg::osgSgn(), osg::WalkNavigator::rotate(), osg::FlyNavigator::rotate(), osg::TrackballNavigator::rotate(), ROTATING, TRACKBALL, osg::TrackballNavigator::translateXY(), osg::TrackballNavigator::translateZ(), TRANSLATING_XY, TRANSLATING_Z, TRANSLATING_ZMINUS, TRANSLATING_ZPLUS, and WALK.
Referenced by idle(), and osg::SimpleSceneManager::mouseMove().
00375 { 00376 _moved = true; 00377 00378 Real32 width = Real32(_vp->getPixelWidth()); 00379 Real32 height = Real32(_vp->getPixelHeight()); 00380 00381 if(width <= 0 || height <= 0) 00382 return; 00383 00384 WindowPtr par = _vp->getParent(); 00385 Real32 winHeight; 00386 00387 if(par != NullFC) 00388 winHeight = (Real32)par->getHeight(); 00389 else 00390 winHeight = height; 00391 00392 Real32 fromX = (2.0f * (_lastX - _vp->getPixelLeft())- width)/ width; 00393 Real32 fromY = (2.0f * (winHeight - _lastY - _vp->getPixelBottom()) 00394 - height) / height; 00395 Real32 toX = (2.0f * (x - _vp->getPixelLeft()) - width) / width; 00396 Real32 toY = (2.0f * (winHeight - y - _vp->getPixelBottom()) 00397 - height)/height; 00398 00399 switch (_currentMode) 00400 { 00401 case NONE: 00402 FNOTICE(("Navigator: moveTo NONE mode\n")); 00403 break; 00404 00405 case TRACKBALL: 00406 00407 switch (_currentState) 00408 { 00409 case ROTATING :_trackball.rotate(fromX, fromY, toX, toY); 00410 break; 00411 00412 case TRANSLATING_XY:{ 00413 Real32 distanceX = 0,distanceY = 0; 00414 calcDeltas(Int16(_lastX), Int16(_lastY), x, y, 00415 distanceX, distanceY); 00416 _trackball.translateXY(distanceX, distanceY); 00417 } 00418 break; 00419 00420 case TRANSLATING_Z: { 00421 Real32 distance = osgSgn(toY-fromY)* 00422 100.f * 00423 osgpow(osgabs(toY-fromY),2.f); 00424 _trackball.translateZ(distance * _rMotionFactor); 00425 } 00426 break; 00427 00428 default :;//IDLE 00429 } 00430 00431 break; 00432 00433 case FLY: 00434 00435 { 00436 Real32 distanceX = -(fromX-toX); 00437 Real32 distanceY = (fromY-toY); 00438 _flyer.rotate(distanceX, distanceY); 00439 00440 switch (_currentState) 00441 { 00442 case TRANSLATING_ZPLUS: _flyer.forward(-_rMotionFactor); 00443 break; 00444 00445 case TRANSLATING_ZMINUS: _flyer.forward(_rMotionFactor); 00446 break; 00447 00448 case ROTATING: break; 00449 00450 default: ;//IDLE 00451 } 00452 } 00453 break; 00454 00455 case WALK: 00456 00457 { 00458 Real32 distanceX = -(fromX-toX); 00459 Real32 distanceY = (fromY-toY); 00460 _walker.rotate(distanceX, distanceY); 00461 00462 switch (_currentState) 00463 { 00464 case TRANSLATING_ZPLUS: _walker.forward(-_rMotionFactor); 00465 break; 00466 00467 case TRANSLATING_ZMINUS: _walker.forward(_rMotionFactor); 00468 break; 00469 00470 case ROTATING: break; 00471 00472 default: ;//IDLE 00473 } 00474 } 00475 break; 00476 00477 default: 00478 00479 FNOTICE(("Navigator: moveTo, unknown mode\n")); 00480 break; 00481 } 00482 _lastX = x; 00483 _lastY = y; 00484 }
Performs some idle operations, depending on the current navigation mode
Definition at line 488 of file OSGNavigator.cpp.
References _currentMode, FLY, moveTo(), NONE, TRACKBALL, and WALK.
Referenced by osg::SimpleSceneManager::idle().
00489 { 00490 switch (_currentMode) 00491 { 00492 case NONE: 00493 case TRACKBALL: 00494 break; 00495 case FLY: 00496 case WALK: 00497 if (buttons) 00498 moveTo(x,y); 00499 break; 00500 } 00501 }
| void Navigator::updateCameraTransformation | ( | ) |
Updates the camera transformation matrix directly in the node specified as the cart.
Definition at line 506 of file OSGNavigator.cpp.
References _absolute, _cartN, _currentMode, _flyer, _NoneMatrix, _trackball, _walker, osg::beginEditCP(), osg::AttachmentContainerPtr::dcast(), osg::endEditCP(), FFATAL, FLY, FNOTICE, FWARNING, osg::NodePtr::getCore(), getMatrix(), osg::TrackballNavigator::getMatrix(), osg::TransformationMatrix< ValueTypeT >::inverse(), osg::TransformationMatrix< ValueTypeT >::mult(), NONE, osg::NullFC, osg::TransformationMatrix< ValueTypeT >::setIdentity(), theMatrix, TRACKBALL, and WALK.
Referenced by osg::SimpleSceneManager::redraw().
00507 { 00508 theMatrix.setIdentity(); 00509 if(_absolute && _cartN != NullFC && _cartN->getParent() != NullFC) 00510 { 00511 _cartN->getParent()->getToWorld(theMatrix); 00512 theMatrix.inverse(theMatrix); 00513 } 00514 00515 switch(_currentMode) 00516 { 00517 case NONE: theMatrix.mult(_NoneMatrix); break; 00518 case TRACKBALL: theMatrix.mult(_trackball.getMatrix()); break; 00519 case FLY: theMatrix.mult(_flyer .getMatrix()); break; 00520 case WALK: theMatrix.mult(_walker .getMatrix()); break; 00521 default: FNOTICE(("Navigator: updateCamTrans, unknown mode\n")); 00522 break; 00523 } 00524 00525 if(_cartN != NullFC) 00526 { 00527 TransformPtr t = TransformPtr::dcast(_cartN->getCore()); 00528 if(t == NullFC) 00529 { 00530 FWARNING (("Navigator: updateCamTrans, core is not TransformPtr\n")); 00531 } 00532 else 00533 { 00534 // don't pollute the changelist with a unchanged matrix. 00535 if(t->getMatrix() != theMatrix) 00536 { 00537 beginEditCP(t); 00538 t->setMatrix(theMatrix); 00539 endEditCP(t); 00540 } 00541 } 00542 } 00543 else 00544 { 00545 FFATAL (("!_cartN in Navigator::updateCameraTrans\n")); 00546 } 00547 }
| void Navigator::setMode | ( | Navigator::Mode | new_mode | ) |
Set the navigator mode (Trackball/Flyer/Walker).
Definition at line 553 of file OSGNavigator.cpp.
References _currentMode.
Referenced by osg::SimpleSceneManager::initialize(), and osg::SimpleSceneManager::setNavigationMode().
00554 { 00555 if (_currentMode == new_mode) return; 00556 00557 _currentMode = new_mode; 00558 }
| void Navigator::setViewport | ( | ViewportPtr | new_viewport | ) |
Set the viewport.
Definition at line 576 of file OSGNavigator.cpp.
References _vp, _walker, osg::WalkNavigator::setGround(), and osg::WalkNavigator::setWorld().
Referenced by osg::SimpleSceneManager::initialize(), and osg::SimpleSceneManager::setWindow().
00577 { 00578 _vp=new_viewport; 00579 _walker.setGround(_vp->getRoot()); 00580 _walker.setWorld (_vp->getRoot()); 00581 }
| void Navigator::setRotationAngle | ( | Real32 | new_angle | ) |
Set the rotation angle.
Definition at line 562 of file OSGNavigator.cpp.
References _rRotationAngle.
00563 { 00564 _rRotationAngle = new_angle; 00565 }
| void Navigator::setMotionFactor | ( | Real32 | new_factor | ) |
Set the motion factor.
Definition at line 569 of file OSGNavigator.cpp.
References _rMotionFactor.
Referenced by osg::SimpleSceneManager::showAll().
00570 { 00571 _rMotionFactor = new_factor; 00572 }
| void Navigator::setFrom | ( | Pnt3f | new_from | ) |
Set the from point, i.e. the viewer position.
Definition at line 594 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, NONE, osg::FlyNavigator::setFrom(), osg::TrackballNavigator::setFrom(), setNoneMatrix(), TRACKBALL, and WALK.
00595 { 00596 switch (_currentMode) 00597 { 00598 case NONE: 00599 setNoneMatrix( new_from, 00600 (Pnt3f)(_NoneMatrix[3]-_NoneMatrix[2]), 00601 (Vec3f) _NoneMatrix[1] ); 00602 break; 00603 case TRACKBALL: _trackball.setFrom(new_from); break; 00604 case FLY: _flyer .setFrom(new_from); break; 00605 case WALK: _walker .setFrom(new_from); break; 00606 default: FNOTICE(("Navigator: setFrom, unknown mode")); 00607 break; 00608 } 00609 }
| void Navigator::setAt | ( | Pnt3f | new_at | ) |
Set the at point, i.e. the target position for the viewer.
Definition at line 613 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, NONE, osg::FlyNavigator::setAt(), osg::TrackballNavigator::setAt(), setNoneMatrix(), TRACKBALL, and WALK.
00614 { 00615 switch (_currentMode) 00616 { 00617 case NONE: 00618 setNoneMatrix((Pnt3f)_NoneMatrix[3], new_at, (Vec3f)_NoneMatrix[1]); 00619 break; 00620 case TRACKBALL: _trackball.setAt(new_at); break; 00621 case FLY: _flyer .setAt(new_at); break; 00622 case WALK: _walker .setAt(new_at); break; 00623 default: FNOTICE(("Navigator: setAt, unknown mode")); 00624 break; 00625 } 00626 }
| void Navigator::setDistance | ( | Real32 | new_distance | ) |
Set the distance from the target position.
Definition at line 630 of file OSGNavigator.cpp.
References _currentMode, _flyer, _trackball, _walker, FLY, FNOTICE, osg::WalkNavigator::forward(), osg::FlyNavigator::forward(), NONE, osg::TrackballNavigator::setDistance(), TRACKBALL, and WALK.
00631 { 00632 switch (_currentMode) 00633 { 00634 case NONE: break; 00635 00636 case TRACKBALL: _trackball.setDistance(new_distance); 00637 break; 00638 00639 case FLY: _flyer.forward(new_distance); 00640 break; 00641 00642 case WALK: _walker.forward(new_distance); 00643 break; 00644 00645 default: FNOTICE(("Navigator: setDistance, unknown mode")); 00646 break; 00647 } 00648 }
| void Navigator::setUp | ( | Vec3f | new_up | ) |
Set the up vector, i.e. the vertical direction on screen.
Definition at line 653 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, NONE, setNoneMatrix(), osg::FlyNavigator::setUp(), osg::TrackballNavigator::setUp(), TRACKBALL, and WALK.
00654 { 00655 switch (_currentMode) 00656 { 00657 case NONE: 00658 setNoneMatrix((Pnt3f) _NoneMatrix[3], 00659 (Pnt3f)(_NoneMatrix[3]-_NoneMatrix[2]), 00660 new_up ); 00661 break; 00662 00663 case TRACKBALL: _trackball.setUp(new_up); 00664 break; 00665 00666 case FLY: _flyer.setUp(new_up); 00667 break; 00668 00669 case WALK: _walker.setUp(new_up); 00670 break; 00671 00672 default: FNOTICE(("Navigator: setUp, unknown mode")); 00673 break; 00674 } 00675 }
Set the full navigator parameters.
Definition at line 679 of file OSGNavigator.cpp.
References _currentMode, _flyer, _trackball, _walker, FLY, FNOTICE, NONE, osg::FlyNavigator::set(), osg::TrackballNavigator::set(), setNoneMatrix(), TRACKBALL, and WALK.
Referenced by osg::SimpleSceneManager::setNavigationMode(), and osg::SimpleSceneManager::showAll().
00680 { 00681 switch (_currentMode) 00682 { 00683 case NONE: setNoneMatrix(new_from, new_at, new_up); 00684 break; 00685 00686 case TRACKBALL: _trackball.set(new_from, new_at, new_up); 00687 break; 00688 00689 case FLY: _flyer.set(new_from, new_at, new_up); 00690 break; 00691 00692 case WALK: _walker.set(new_from, new_at, new_up); 00693 break; 00694 00695 default: FNOTICE(("Navigator: set, unknown mode")); 00696 break; 00697 } 00698 }
| void Navigator::set | ( | const Matrix & | new_matrix | ) |
Set the full navigator parameters from a matrix.
Definition at line 702 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, NONE, osg::FlyNavigator::set(), osg::TrackballNavigator::set(), TRACKBALL, and WALK.
00703 { 00704 switch (_currentMode) 00705 { 00706 case NONE: //setNoneMatrix((Pnt3f) new_matrix[3], 00707 // (Pnt3f)(new_matrix[3]-new_matrix[2]), 00708 // (Vec3f) new_matrix[1]); 00709 _NoneMatrix = new_matrix; 00710 break; 00711 00712 case TRACKBALL: _trackball.set(new_matrix); 00713 break; 00714 00715 case FLY: _flyer.set(new_matrix); 00716 break; 00717 00718 case WALK: _walker.set(new_matrix); 00719 break; 00720 00721 default: FNOTICE(("Navigator: set(Matrix), unknown mode")); 00722 break; 00723 } 00724 }
| bool Navigator::setAbsolute | ( | bool | state | ) |
| bool Navigator::setClickCenter | ( | bool | state | ) |
Set the clickCenter current state.
Definition at line 892 of file OSGNavigator.cpp.
References _clickCenter.
Referenced by osg::SimpleSceneManager::setClickCenter().
00893 { 00894 bool old = _clickCenter; 00895 00896 _clickCenter = state; 00897 return old; 00898 }
| bool Navigator::setClickNoIntersect | ( | bool | state | ) |
Set the clickCenter current state.
Definition at line 912 of file OSGNavigator.cpp.
References _clickNoIntersect.
00913 { 00914 bool old = _clickNoIntersect; 00915 00916 _clickNoIntersect = state; 00917 return old; 00918 }
| void Navigator::setCameraTransformation | ( | const NodePtr & | new_cartn | ) |
Set the camera transformation node.
Definition at line 729 of file OSGNavigator.cpp.
References _cartN, FWARNING, and osg::NullFC.
Referenced by osg::SimpleSceneManager::initialize().
00730 { 00731 if (new_cartn == NullFC) 00732 { 00733 FWARNING (("Set _cartN in Navigator to NullFC\n")); 00734 } 00735 00736 _cartN = new_cartn; 00737 }
| const Matrix & Navigator::getMatrix | ( | void | ) |
Get the transformation matrix.
Definition at line 743 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, osg::FlyNavigator::getMatrix(), osg::TrackballNavigator::getMatrix(), osg::TransformationMatrix< ValueTypeT >::identity(), NONE, TRACKBALL, and WALK.
Referenced by osg::SimpleSceneManager::setNavigationMode(), and updateCameraTransformation().
00744 { 00745 switch (_currentMode) 00746 { 00747 case NONE: return _NoneMatrix; 00748 case TRACKBALL: return _trackball.getMatrix(); 00749 case FLY: return _flyer .getMatrix(); 00750 case WALK: return _walker .getMatrix(); 00751 default: FNOTICE(("Navigator: getMatrix, unknown mode")); 00752 break; 00753 } 00754 00755 return Matrix::identity(); 00756 }
| const Pnt3f & Navigator::getFrom | ( | void | ) |
Get the from point, i.e. the viewer position.
Definition at line 760 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, osg::FlyNavigator::getFrom(), osg::TrackballNavigator::getFrom(), NONE, TRACKBALL, and WALK.
00761 { 00762 static Pnt3f returnValue(0.f, 0.f, 0.f); 00763 returnValue = (Pnt3f)_NoneMatrix[3]; 00764 00765 switch (_currentMode) 00766 { 00767 case NONE: return returnValue; 00768 case TRACKBALL: return _trackball.getFrom(); 00769 case FLY: return _flyer .getFrom(); 00770 case WALK: return _walker .getFrom(); 00771 default: FNOTICE(("Navigator: getFrom, unknown mode")); 00772 break; 00773 } 00774 00775 return returnValue; 00776 }
| const Pnt3f & Navigator::getAt | ( | void | ) |
Get the at point, i.e. the target position.
Definition at line 780 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, osg::FlyNavigator::getAt(), osg::TrackballNavigator::getAt(), NONE, TRACKBALL, and WALK.
00781 { 00782 static Pnt3f returnValue(0.f, 0.f, 0.f); 00783 returnValue = (Pnt3f)(_NoneMatrix[3] - _NoneMatrix[2]); 00784 00785 switch (_currentMode) 00786 { 00787 case NONE: return returnValue; 00788 case TRACKBALL: return _trackball.getAt(); 00789 case FLY: return _flyer .getAt(); 00790 case WALK: return _walker .getAt(); 00791 default: FNOTICE(("Navigator: getAt, unknown mode")); 00792 break; 00793 } 00794 00795 return returnValue; 00796 }
| const Vec3f & Navigator::getUp | ( | void | ) |
Get the up vector.
Definition at line 800 of file OSGNavigator.cpp.
References _currentMode, _flyer, _NoneMatrix, _trackball, _walker, FLY, FNOTICE, osg::FlyNavigator::getUp(), osg::TrackballNavigator::getUp(), NONE, TRACKBALL, and WALK.
00801 { 00802 static Vec3f returnValue(0.f, 0.f, 0.f); 00803 returnValue = (Vec3f)_NoneMatrix[1]; 00804 00805 switch (_currentMode) 00806 { 00807 case NONE: return returnValue; 00808 case TRACKBALL: return _trackball.getUp(); 00809 case FLY: return _flyer .getUp(); 00810 case WALK: return _walker .getUp(); 00811 default: FNOTICE(("NavigUpor: getUp, unknown mode")); 00812 break; 00813 } 00814 00815 return returnValue; 00816 }
| Real32 Navigator::getDistance | ( | void | ) |
Get the distance from the target position.
Definition at line 820 of file OSGNavigator.cpp.
References _currentMode, _trackball, FLY, FNOTICE, osg::TrackballNavigator::getDistance(), NONE, TRACKBALL, and WALK.
00821 { 00822 Real32 distance = 0.0f; 00823 switch (_currentMode) 00824 { 00825 case NONE: break; 00826 00827 case TRACKBALL: distance = _trackball.getDistance(); 00828 break; 00829 00830 case FLY: break; 00831 00832 case WALK: break; 00833 00834 default: FNOTICE(("Navigator: setDistance, unknown mode")); 00835 break; 00836 } 00837 00838 return distance; 00839 }
| Navigator::State Navigator::getState | ( | void | ) |
Get the navigator's current state.
Definition at line 843 of file OSGNavigator.cpp.
References _currentState.
00844 { 00845 return _currentState; 00846 }
| Navigator::Mode Navigator::getMode | ( | void | ) |
Get the navigator's current mode.
Definition at line 850 of file OSGNavigator.cpp.
References _currentMode.
00851 { 00852 return _currentMode; 00853 }
| Real32 Navigator::getRotationAngle | ( | void | ) |
Get the navigator's rotation angle.
Definition at line 857 of file OSGNavigator.cpp.
References _rRotationAngle.
00858 { 00859 return _rRotationAngle; 00860 }
| Real32 Navigator::getMotionFactor | ( | void | ) |
Get the navigator's motion factor
Definition at line 864 of file OSGNavigator.cpp.
References _rMotionFactor.
00865 { 00866 return _rMotionFactor; 00867 }
| bool Navigator::getAbsolute | ( | void | ) |
Get the absolute current state.
Definition at line 871 of file OSGNavigator.cpp.
References _absolute.
00872 { 00873 return _absolute; 00874 }
| bool Navigator::getClickCenter | ( | void | ) |
Get the clickCenter current state.
Definition at line 878 of file OSGNavigator.cpp.
References _clickCenter.
00879 { 00880 return _clickCenter; 00881 }
| bool Navigator::getClickNoIntersect | ( | void | ) |
Get the clickNoIntersect current state.
Definition at line 885 of file OSGNavigator.cpp.
References _clickNoIntersect.
00886 { 00887 return _clickNoIntersect; 00888 }
| WalkNavigator* osg::Navigator::getWalkNavigator | ( | ) | [inline] |
Get the transformation matrix.
Definition at line 172 of file OSGNavigator.h.
00172 { return &_walker; }
Set the navigation parameters in case of NONE mode
Definition at line 585 of file OSGNavigator.cpp.
References _NoneMatrix, FNOTICE, and osg::MatrixLookAt().
Referenced by set(), setAt(), setFrom(), and setUp().
00586 { 00587 bool b = MatrixLookAt(_NoneMatrix, new_at, new_at+(new_at-new_from), new_up); 00588 00589 if (b) FNOTICE(("Navigator: set(.,.,.) failed\n")); 00590 }
Calculates the intersection point of a ray that starts at from and goes through the position on the screen given by x,y with the world, if no intersection point exists the intersection is set to (0,0,0)
Definition at line 945 of file OSGNavigator.cpp.
References _clickNoIntersect, _dir, _ip, _vp, osg::Action::apply(), calcCCtoWCMatrix(), osg::IntersectAction::create(), osg::IntersectAction::didHit(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::Line::getDirection(), osg::IntersectAction::getHitPoint(), osg::Line::getPosition(), osg::TransformationMatrix< ValueTypeT >::multFullMatrixPnt(), and osg::IntersectAction::setLine().
Referenced by buttonPress().
00946 { 00947 00948 IntersectAction * act = IntersectAction::create(); 00949 Line line; 00950 00951 _vp->getCamera()->calcViewRay(line, x, y, *_vp); 00952 00953 if(_clickNoIntersect) 00954 { 00955 Real32 u = (_dir.dot(Pnt3f(0.0f, 0.0f, 0.0f) - line.getPosition())) / 00956 (_dir.dot(line.getDirection())); 00957 _ip = line.getPosition() + u * line.getDirection(); 00958 return; 00959 } 00960 00961 act->setLine(line); 00962 act->apply(_vp->getRoot()); 00963 00964 Matrix cctowc,view; 00965 Int16 width = _vp->getPixelWidth(); 00966 Int16 height = _vp->getPixelHeight(); 00967 00968 _vp->getCamera()->getViewing(view, width, height); 00969 00970 calcCCtoWCMatrix(cctowc, view, _vp); 00971 00972 Pnt3f at,to; 00973 00974 cctowc.multFullMatrixPnt( Pnt3f( 0, 0, 0.5f ), to ); 00975 cctowc.multFullMatrixPnt( Pnt3f( 0, 0, 1 ), at ); 00976 00977 _dir = to - at; 00978 00979 if (act->didHit()) 00980 { 00981 _ip = act->getHitPoint(); 00982 } 00983 else 00984 { 00985 Real32 u = (_dir.dot(Pnt3f(0.0f, 0.0f, 0.0f) - line.getPosition())) / 00986 (_dir.dot(line.getDirection())); 00987 _ip = line.getPosition() + u * line.getDirection(); 00988 } 00989 00990 delete act; 00991 }
| void Navigator::calcDeltas | ( | Int16 | fromX, | |
| Int16 | fromY, | |||
| Int16 | toX, | |||
| Int16 | toY, | |||
| Real32 & | distanceX, | |||
| Real32 & | distanceY | |||
| ) | [private] |
Calculate the real translation that has to be done, so that the trackball can actually drag the object in the plane parallel to the screen.
Definition at line 997 of file OSGNavigator.cpp.
References _dir, _ip, _trackball, _vp, calcCCtoWCMatrix(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::Line::getDirection(), osg::TrackballNavigator::getMatrix(), osg::Line::getPosition(), osg::TransformationMatrix< ValueTypeT >::invert(), osg::TransformationMatrix< ValueTypeT >::multFullMatrixPnt(), osg::TransformationMatrix< ValueTypeT >::multMatrixVec(), and osg::Line::setValue().
Referenced by moveTo().
00999 { 01000 Matrix view; 01001 01002 view=_trackball.getMatrix(); 01003 01004 Pnt3f from( view[3][0], view[3][1], view[3][2] ); 01005 01006 view.invert(); 01007 Matrix cctowc; 01008 calcCCtoWCMatrix(cctowc, view, _vp); 01009 01010 Real32 rx = ( toX / (Real32) _vp->getPixelWidth() ) * 2.f - 1.f, 01011 ry = 1.f - ( toY / (Real32) _vp->getPixelHeight() ) * 2.f; 01012 01013 Pnt3f at; 01014 cctowc.multFullMatrixPnt( Pnt3f( rx, ry, 1 ), at ); 01015 01016 Line line2; 01017 line2.setValue(from, at-from); 01018 01019 Real32 u = (_dir.dot(_ip-line2.getPosition())) / 01020 (_dir.dot(line2.getDirection())); 01021 01022 Pnt3f p2 = line2.getPosition() + u * line2.getDirection(); 01023 01024 Vec3f transl; 01025 transl[0] = -p2[0] + _ip[0]; 01026 transl[1] = -p2[1] + _ip[1]; 01027 transl[2] = -p2[2] + _ip[2]; 01028 01029 view.multMatrixVec(transl); 01030 01031 distanceX = transl[0]; 01032 distanceY = transl[1]; 01033 }
TrackballNavigator osg::Navigator::_trackball [private] |
Definition at line 182 of file OSGNavigator.h.
Referenced by buttonPress(), buttonRelease(), calcDeltas(), getAt(), getDistance(), getFrom(), getMatrix(), getUp(), keyPress(), moveTo(), set(), setAt(), setDistance(), setFrom(), setUp(), and updateCameraTransformation().
FlyNavigator osg::Navigator::_flyer [private] |
Definition at line 183 of file OSGNavigator.h.
Referenced by buttonPress(), getAt(), getFrom(), getMatrix(), getUp(), keyPress(), moveTo(), set(), setAt(), setDistance(), setFrom(), setUp(), and updateCameraTransformation().
WalkNavigator osg::Navigator::_walker [private] |
Definition at line 184 of file OSGNavigator.h.
Referenced by buttonPress(), getAt(), getFrom(), getMatrix(), getUp(), keyPress(), moveTo(), set(), setAt(), setDistance(), setFrom(), setUp(), setViewport(), and updateCameraTransformation().
Real32 osg::Navigator::_rRotationAngle [private] |
Definition at line 186 of file OSGNavigator.h.
Referenced by getRotationAngle(), keyPress(), and setRotationAngle().
Navigator::_rMotionFactor [private] |
The motion factor, roughly equivalent to speed.
Definition at line 187 of file OSGNavigator.h.
Referenced by buttonPress(), getMotionFactor(), keyPress(), moveTo(), and setMotionFactor().
State osg::Navigator::_currentState [private] |
Definition at line 188 of file OSGNavigator.h.
Referenced by buttonPress(), buttonRelease(), getState(), and moveTo().
Mode osg::Navigator::_currentMode [private] |
Definition at line 189 of file OSGNavigator.h.
Referenced by buttonPress(), buttonRelease(), getAt(), getDistance(), getFrom(), getMatrix(), getMode(), getUp(), idle(), keyPress(), moveTo(), set(), setAt(), setDistance(), setFrom(), setMode(), setUp(), and updateCameraTransformation().
bool osg::Navigator::_absolute [private] |
Definition at line 190 of file OSGNavigator.h.
Referenced by getAbsolute(), setAbsolute(), and updateCameraTransformation().
ViewportPtr osg::Navigator::_vp [private] |
Definition at line 192 of file OSGNavigator.h.
Referenced by buttonRelease(), calcDeltas(), getIntersectionPoint(), moveTo(), and setViewport().
NodePtr osg::Navigator::_cartN [private] |
Definition at line 193 of file OSGNavigator.h.
Referenced by setCameraTransformation(), and updateCameraTransformation().
bool osg::Navigator::_moved [private] |
Definition at line 195 of file OSGNavigator.h.
Referenced by buttonPress(), buttonRelease(), and moveTo().
bool osg::Navigator::_clickCenter [private] |
Definition at line 196 of file OSGNavigator.h.
Referenced by buttonRelease(), getClickCenter(), and setClickCenter().
bool osg::Navigator::_clickNoIntersect [private] |
Definition at line 197 of file OSGNavigator.h.
Referenced by getClickNoIntersect(), getIntersectionPoint(), and setClickNoIntersect().
Real32 osg::Navigator::_lastX [private] |
Real32 osg::Navigator::_lastY [private] |
Navigator::_ip [private] |
Temporary hit point for intersection testing.
Definition at line 199 of file OSGNavigator.h.
Referenced by calcDeltas(), and getIntersectionPoint().
Navigator::_dir [private] |
Temporary ray direction for intersection testing.
Definition at line 200 of file OSGNavigator.h.
Referenced by calcDeltas(), and getIntersectionPoint().
Matrix osg::Navigator::theMatrix [private] |
Matrix osg::Navigator::_NoneMatrix [private] |
Definition at line 203 of file OSGNavigator.h.
Referenced by getAt(), getFrom(), getMatrix(), getUp(), set(), setAt(), setFrom(), setNoneMatrix(), setUp(), and updateCameraTransformation().
1.5.5