#include <OSGSimpleSceneManager.h>
Definition at line 68 of file OSGSimpleSceneManager.h.
|
|
Definition at line 76 of file OSGSimpleSceneManager.h. 00076 { MouseLeft = 0, 00077 MouseMiddle = 1, 00078 MouseRight = 2, 00079 MouseUp = 3, 00080 MouseDown = 4, 00081 NoButton = -1 00082 };
|
|
|
Constructor Definition at line 189 of file OSGSimpleSceneManager.cpp. 00189 : 00190 _win (NullFC), 00191 _root (NullFC), 00192 _foreground (NullFC), 00193 _statforeground (NullFC), 00194 _statstate (false), 00195 00196 _highlight (NullFC), 00197 _highlightNode (NullFC), 00198 _highlightPoints(NullFC), 00199 00200 _internalRoot (NullFC), 00201 _headlight (NullFC), 00202 _action (NULL ), 00203 _ownAction (NULL ), 00204 _cart (NullFC), 00205 _camera (NullFC), 00206 _navigator ( ), 00207 00208 _lastx (TypeTraits<Int16>::getMax()), 00209 _lasty (TypeTraits<Int16>::getMax()), 00210 _mousebuttons (0 ) 00211 { 00212 }
|
|
|
Destructor Definition at line 225 of file OSGSimpleSceneManager.cpp. References _camera, _internalRoot, _ownAction, osg::NullFC, setRoot(), and osg::subRefCP(). 00226 { 00227 delete _ownAction; 00228 00229 setRoot(NullFC); // sub root 00230 if(_internalRoot != NullFC) 00231 subRefCP(_internalRoot); 00232 if(_camera != NullFC) 00233 subRefCP(_camera); 00234 }
|
|
|
|
|
|
pseudo constructor. Standard interface for OpenSG object creation. Definition at line 217 of file OSGSimpleSceneManager.cpp. 00218 { 00219 return new SimpleSceneManager; 00220 }
|
|
|
get the root of the displayed tree Definition at line 246 of file OSGSimpleSceneManager.cpp. References _root. 00247 { 00248 return _root; 00249 }
|
|
|
get the window to be used for display Definition at line 239 of file OSGSimpleSceneManager.cpp. References _win. Referenced by osg::OSGQGLManagedWidget::initializeGL(), and osg::OSGQGLManagedWidget::paintGL(). 00240 { 00241 return _win; 00242 }
|
|
|
get the highlight object Definition at line 283 of file OSGSimpleSceneManager.cpp. References _highlight. Referenced by highlightChanged(). 00284 { 00285 return _highlight; 00286 }
|
|
|
get the action used to render the scene Definition at line 290 of file OSGSimpleSceneManager.cpp. References _action. 00291 { 00292 return _action; 00293 }
|
|
|
get the navigator Definition at line 253 of file OSGSimpleSceneManager.cpp. References _navigator. 00254 { 00255 return &_navigator; 00256 }
|
|
|
get the headlight state Definition at line 260 of file OSGSimpleSceneManager.cpp. References _headlight. 00261 { 00262 return _headlight->getOn(); 00263 }
|
|
|
get the camera Definition at line 267 of file OSGSimpleSceneManager.cpp. References _camera. 00268 { 00269 return _camera; 00270 }
|
|
|
set the action used to render the scene. Use NULL to set to internally created action. Definition at line 298 of file OSGSimpleSceneManager.cpp. References _action, _ownAction, _statstate, and setStatistics(). 00299 { 00300 bool statstate = _statstate; 00301 00302 if(_action != NULL && statstate) 00303 setStatistics(false); 00304 00305 if(action == NULL) 00306 { 00307 _action = _ownAction; 00308 } 00309 else 00310 { 00311 _action = action; 00312 } 00313 00314 if(statstate) 00315 setStatistics(true); 00316 }
|
|
|
set the root of the displayed tree Definition at line 320 of file OSGSimpleSceneManager.cpp. References _internalRoot, _root, osg::beginEditCP(), osg::Node::ChildrenFieldMask, osg::endEditCP(), initialize(), and osg::NullFC. Referenced by ~SimpleSceneManager(). 00321 { 00322 if(_internalRoot == NullFC) 00323 { 00324 initialize(); 00325 } 00326 00327 if(_root != root) 00328 { 00329 if(_root != NullFC) 00330 { 00331 beginEditCP(_internalRoot, Node::ChildrenFieldMask); 00332 _internalRoot->subChild(_root); 00333 endEditCP(_internalRoot, Node::ChildrenFieldMask); 00334 } 00335 00336 _root = root; 00337 if(_root != NullFC) 00338 { 00339 beginEditCP(_internalRoot, Node::ChildrenFieldMask); 00340 _internalRoot->addChild(_root); 00341 endEditCP(_internalRoot, Node::ChildrenFieldMask); 00342 } 00343 } 00344 }
|
|
|
set the window to be used for display Definition at line 274 of file OSGSimpleSceneManager.cpp. References _navigator, _win, osg::NullFC, and osg::Navigator::setViewport(). Referenced by osg::OSGQGLManagedWidget::OSGQGLManagedWidget(). 00275 { 00276 _win = win; 00277 if(_win->getMFPort()->size() > 0 && _win->getPort(0) != NullFC) 00278 _navigator.setViewport(_win->getPort(0)); 00279 }
|
|
|
set the highlight object Definition at line 376 of file OSGSimpleSceneManager.cpp. References _highlight, and highlightChanged(). 00377 { 00378 _highlight = highlight; 00379 highlightChanged(); 00380 }
|
|
|
set the headlight setting Definition at line 348 of file OSGSimpleSceneManager.cpp. References _headlight, _internalRoot, osg::beginEditCP(), osg::endEditCP(), initialize(), osg::NullFC, and osg::LightBase::OnFieldMask. Referenced by turnHeadlightOff(), and turnHeadlightOn(). 00349 { 00350 if(_internalRoot == NullFC) 00351 { 00352 initialize(); 00353 } 00354 00355 beginEditCP(_headlight, LightBase::OnFieldMask); 00356 _headlight->setOn(on); 00357 endEditCP(_headlight, LightBase::OnFieldMask); 00358 }
|
|
|
turn headlight on. Definition at line 362 of file OSGSimpleSceneManager.cpp. References setHeadlight(). 00363 { 00364 setHeadlight(true); 00365 }
|
|
|
turn headlight off. Definition at line 369 of file OSGSimpleSceneManager.cpp. References setHeadlight(). 00370 { 00371 setHeadlight(false); 00372 }
|
|
|
show the whole scene: move out far enough to see everything Definition at line 532 of file OSGSimpleSceneManager.cpp. References _camera, _navigator, _root, osg::beginEditCP(), osg::endEditCP(), osg::Eps, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::NullFC, osg::osgMax(), osg::osgtan(), osg::Navigator::set(), osg::Navigator::setMotionFactor(), and osg::VecStorage3< ValueTypeT >::setValues(). Referenced by redraw(). 00533 { 00534 if(_root == NullFC) 00535 return; 00536 00537 _root->updateVolume(); 00538 00539 Vec3f min,max; 00540 _root->getVolume().getBounds( min, max ); 00541 Vec3f d = max - min; 00542 00543 if(d.length() < Eps) // Nothing loaded? Use a unity box 00544 { 00545 min.setValues(-1.f,-1.f,-1.f); 00546 max.setValues( 1.f, 1.f, 1.f); 00547 d = max - min; 00548 } 00549 00550 Real32 dist = osgMax(d[0],d[1]) / (2 * osgtan(_camera->getFov() / 2.f)); 00551 00552 Vec3f up(0,1,0); 00553 Pnt3f at((min[0] + max[0]) * .5f,(min[1] + max[1]) * .5f,(min[2] + max[2]) * .5f); 00554 Pnt3f from=at; 00555 from[2]+=(dist+fabs(max[2]-min[2])*0.5f); 00556 00557 _navigator.set(from,at,up); 00558 00559 // adjust the translation factors so that motions are sort of scaled 00560 _navigator.setMotionFactor((d[0] + d[1] + d[2]) / 100.f); 00561 00562 // set the camera to go from 1% of the object to twice its size 00563 Real32 diag = osgMax(osgMax(d[0], d[1]), d[2]); 00564 beginEditCP(_camera); 00565 _camera->setNear (diag / 100.f); 00566 _camera->setFar (10 * diag); 00567 endEditCP(_camera); 00568 }
|
|
|
add the "Powered by OpenSG" logo to the lower left corner Definition at line 572 of file OSGSimpleSceneManager.cpp. References _foreground, osg::beginEditCP(), osg::ImageBase::create(), osg::endEditCP(), osg::LogoData, and osg::ImageFileType::restore(). 00573 { 00574 ImagePtr lo = Image::create(); 00575 ImageFileType::restore( lo, (UChar8*)LogoData, -1 ); 00576 00577 beginEditCP(_foreground); 00578 _foreground->addImage( lo, Pnt2f( 0,0 ) ); 00579 endEditCP (_foreground); 00580 }
|
|
|
Sets the navigation mode Definition at line 584 of file OSGSimpleSceneManager.cpp. References _navigator, osg::Navigator::getMatrix(), osg::Navigator::set(), and osg::Navigator::setMode(). 00585 { 00586 Matrix m=_navigator.getMatrix(); 00587 _navigator.setMode(new_mode); 00588 _navigator.set(m); 00589 }
|
|
|
set the click center mode of the navigator Definition at line 46 of file OSGSimpleSceneManager.inl. References _navigator, and osg::Navigator::setClickCenter(). 00047 { 00048 return _navigator.setClickCenter(mode); 00049 }
|
|
|
set the statistics setting. Only works after the window has been created. Definition at line 384 of file OSGSimpleSceneManager.cpp. References _action, _statforeground, _statstate, _win, osg::NullFC, and osg::DrawActionBase::setStatistics(). Referenced by setAction(). 00385 { 00386 if(_statforeground != NullFC && on != _statstate) 00387 { 00388 ViewportPtr vp = _win->getPort()[0]; 00389 00390 if(on) 00391 { 00392 vp->getForegrounds().push_back(_statforeground); 00393 00394 _action->setStatistics(&_statforeground->getCollector()); 00395 } 00396 else 00397 { 00398 MFForegroundPtr::iterator it; 00399 00400 it = vp->getForegrounds().find(_statforeground); 00401 vp->getForegrounds().erase(it); 00402 00403 _action->setStatistics(NULL); 00404 } 00405 00406 _statstate = on; 00407 } 00408 }
|
|
||||||||||||
|
resize Definition at line 760 of file OSGSimpleSceneManager.cpp. References _win. Referenced by osg::OSGQGLManagedWidget::resizeGL(). 00761 { 00762 _win->resize(width, height); 00763 }
|
|
||||||||||||
|
motion Definition at line 767 of file OSGSimpleSceneManager.cpp. References _lastx, _lasty, _mousebuttons, _navigator, and osg::Navigator::moveTo(). Referenced by osg::OSGQGLManagedWidget::mouseMoveEvent(). 00768 { 00769 if ( _mousebuttons) _navigator.moveTo(x,y); 00770 _lastx = x; 00771 _lasty = y; 00772 00773 }
|
|
||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
resize Definition at line 828 of file OSGSimpleSceneManager.cpp. References _navigator, osg::Navigator::BACKWARDS, osg::Navigator::FORWARDS, osg::Navigator::keyPress(), osg::Navigator::LEFT, osg::Navigator::LEFTROT, osg::Navigator::RIGHT, and osg::Navigator::RIGHTROT. 00829 { 00830 switch ( key ) 00831 { 00832 case 'j': _navigator.keyPress(Navigator::LEFT,x,y); break; 00833 case 'g': _navigator.keyPress(Navigator::RIGHT,x,y); break; 00834 case 'u': _navigator.keyPress(Navigator::LEFTROT,x,y); break; 00835 case 't': _navigator.keyPress(Navigator::RIGHTROT,x,y); break; 00836 case 'y': _navigator.keyPress(Navigator::FORWARDS,x,y); break; 00837 case 'h': _navigator.keyPress(Navigator::BACKWARDS,x,y); break; 00838 } 00839 }
|
|
||||||||||||
|
Calculate a ray that starts at the eye and goes through the position on the screen given by x,y. Definition at line 845 of file OSGSimpleSceneManager.cpp. 00846 { 00847 Line l; 00848 00849 _camera->calcViewRay( l, x, y, *_win->getPort()[0] ); 00850 00851 return l; 00852 }
|
|
|
Draw the next frame, update if needed. Definition at line 601 of file OSGSimpleSceneManager.cpp. References _action, _internalRoot, _navigator, _win, initialize(), osg::NullFC, showAll(), osg::Navigator::updateCameraTransformation(), and updateHighlight(). Referenced by osg::OSGQGLManagedWidget::paintGL(). 00602 { 00603 if (_internalRoot == NullFC) 00604 { 00605 initialize(); 00606 showAll(); 00607 } 00608 00609 // _cart->getSFMatrix()->setValue(_navigator.getMatrix()); 00610 _navigator.updateCameraTransformation(); 00611 00612 updateHighlight(); 00613 00614 _win->render(_action); 00615 }
|
|
|
Draw the next frame, update if needed. Definition at line 594 of file OSGSimpleSceneManager.cpp. References _lastx, _lasty, _mousebuttons, _navigator, and osg::Navigator::idle(). 00595 { 00596 _navigator.idle(_mousebuttons,_lastx, _lasty); 00597 }
|
|
|
less Definition at line 867 of file OSGSimpleSceneManager.cpp.
|
|