00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <cstdlib>
00044 #include <cstdio>
00045
00046 #include "OSGConfig.h"
00047 #include "OSGBaseFunctions.h"
00048 #include "OSGImageFileType.h"
00049 #include "OSGSolidBackground.h"
00050 #include "OSGViewport.h"
00051 #include "OSGLogoData.h"
00052 #include "OSGSimpleStatisticsForeground.h"
00053
00054
00055 #include "OSGTypedGeoIntegralProperty.h"
00056 #include "OSGTypedGeoVectorProperty.h"
00057 #include "OSGDrawable.h"
00058 #include "OSGPointLight.h"
00059 #include "OSGSpotLight.h"
00060 #include "OSGDirectionalLight.h"
00061 #include "OSGTextureObjChunk.h"
00062 #include "OSGPerspectiveCamera.h"
00063 #include "OSGOrthographicCamera.h"
00064
00065 #include "OSGSimpleSceneManager.h"
00066
00067 #if defined(OSG_WIN32_ICL) && !defined(OSG_CHECK_FIELDSETARG)
00068 #pragma warning (disable : 383)
00069 #endif
00070
00071
00072 OSG_USING_NAMESPACE
00073
00074
00075
00076
00077
00140
00141
00142
00146 SimpleSceneManager::SimpleSceneManager(void) :
00147 NavigationManager(),
00148 _root (NULL ),
00149 _foreground (NULL ),
00150 _statforeground (NULL ),
00151 _statstate (false),
00152
00153 _highlight (NULL ),
00154 _highlightNode (NULL ),
00155 _highlightPoints(NULL ),
00156
00157 _internalRoot (NULL ),
00158 _headlight (NULL ),
00159 #ifdef OSG_OLD_RENDER_ACTION
00160 _renderAction (NULL ),
00161 _ownAction (NULL ),
00162 #endif
00163 _rtaction (NULL ),
00164 _cart (NULL ),
00165 _camera (NULL ),
00166 _traversalAction(true ),
00167 _highlightMaterial(NULL)
00168 {
00169 }
00170
00171
00174 SimpleSceneManager* SimpleSceneManager::create(void)
00175 {
00176 return new SimpleSceneManager;
00177 }
00178
00182 SimpleSceneManager::~SimpleSceneManager(void)
00183 {
00184 #ifdef OSG_OLD_RENDER_ACTION
00185 delete _ownAction;
00186
00187 if(_renderAction && _renderAction != _ownAction)
00188 delete _renderAction;
00189 #endif
00190
00191 if(_rtaction)
00192 delete _rtaction;
00193
00194 setRoot(NULL);
00195
00196 _internalRoot = NULL;
00197
00198 _camera = NULL;
00199 _cart = NULL;
00200 _headlight = NULL;
00201 _statforeground = NULL;
00202 _foreground = NULL;
00203 _highlightMaterial = NULL;
00204 _highlightPoints = NULL;
00205 _highlightNode = NULL;
00206 _highlight = NULL;
00207 _root = NULL;
00208 }
00209
00210
00213 Node *SimpleSceneManager::getRoot(void)
00214 {
00215 return _root;
00216 }
00217
00218
00221 bool SimpleSceneManager::getHeadlightState(void)
00222 {
00223 return _headlight->getOn();
00224 }
00225
00228 DirectionalLight *SimpleSceneManager::getHeadlight(void)
00229 {
00230 return _headlight;
00231 }
00232
00235 Camera *SimpleSceneManager::getCamera(void)
00236 {
00237 return _camera;
00238 }
00239
00242 Node *SimpleSceneManager::getHighlight(void)
00243 {
00244 return _highlight;
00245 }
00246
00247 #ifdef OSG_OLD_RENDER_ACTION
00248
00250 DrawActionBase *SimpleSceneManager::getAction(void)
00251 {
00252 return _renderAction;
00253 }
00254 #endif
00255
00258 RenderAction *SimpleSceneManager::getRenderAction(void)
00259 {
00260 return _rtaction;
00261 }
00262
00263 #ifdef OSG_OLD_RENDER_ACTION
00264
00268 void SimpleSceneManager::setAction(RenderAction *action)
00269 {
00270 bool statstate = _statstate;
00271
00272 if(_renderAction != NULL && statstate)
00273 setStatistics(false);
00274
00275 if(action == NULL)
00276 {
00277 _renderAction = _ownAction;
00278 }
00279 else
00280 {
00281 _renderAction = action;
00282 }
00283
00284 if(statstate)
00285 setStatistics(true);
00286 }
00287 #endif
00288
00289 void SimpleSceneManager::setAction(RenderAction *action)
00290 {
00291 bool statstate = _statstate;
00292
00293 if(_rtaction != NULL)
00294 {
00295 if(statstate)
00296 setStatistics(false);
00297 delete _rtaction;
00298 }
00299
00300 _rtaction = action;
00301
00302 if(statstate)
00303 setStatistics(true);
00304 }
00305
00308 void SimpleSceneManager::setRoot(Node *root)
00309 {
00310 if(_internalRoot == NULL)
00311 {
00312 initialize();
00313 }
00314
00315 if(_root != root)
00316 {
00317 if(_root != NULL)
00318 {
00319 _internalRoot->subChild(_root);
00320 }
00321
00322 _root = root;
00323
00324 if(_root != NULL)
00325 {
00326 _internalRoot->addChild(_root);
00327 }
00328 }
00329 }
00330
00333 void SimpleSceneManager::setHeadlight(bool on)
00334 {
00335 if(_internalRoot == NULL)
00336 {
00337 initialize();
00338 }
00339
00340 _headlight->setOn(on);
00341 }
00342
00345 void SimpleSceneManager::turnHeadlightOn(void)
00346 {
00347 setHeadlight(true);
00348 }
00349
00350
00351 void SimpleSceneManager::setUseTraversalAction(bool s)
00352 {
00353 _traversalAction = s;
00354 }
00355
00356 bool SimpleSceneManager::getUseTraversalAction(void)
00357 {
00358 return _traversalAction;
00359 }
00360
00361
00364 void SimpleSceneManager::turnHeadlightOff(void)
00365 {
00366 setHeadlight(false);
00367 }
00368
00369 void SimpleSceneManager::setCamera(Camera *camera)
00370 {
00371 if(camera == NULL)
00372 return;
00373
00374 if(_camera != NULL)
00375 camera->setBeacon(_camera->getBeacon());
00376
00377 PerspectiveCamera *oldPer =
00378 dynamic_pointer_cast<PerspectiveCamera>(_camera);
00379 PerspectiveCamera *newPer = dynamic_cast<PerspectiveCamera *>(camera);
00380
00381 OrthographicCamera *oldOrt =
00382 dynamic_pointer_cast<OrthographicCamera>(_camera);
00383
00384 OrthographicCamera *newOrt = dynamic_cast<OrthographicCamera *>(camera);
00385
00386
00387 if (oldPer && newPer) {
00388 newPer->setFov(oldPer->getFov());
00389 }
00390 else if (oldOrt && newOrt) {
00391 newOrt->setVerticalSize(oldOrt->getVerticalSize());
00392 }
00393 else {
00394 FWARNING(("SimpleSceneManager::setCamera: some of the old camera's "
00395 " params could not be copied to the new camera, because of "
00396 " different or unsupported camera types!\n"));
00397 }
00398
00399 if(_camera != NULL)
00400 {
00401 camera->setNear(_camera->getNear());
00402 camera->setFar (_camera->getFar());
00403 }
00404
00405
00406 for(UInt32 i=0;i<_win->getMFPort()->size();++i)
00407 {
00408 Viewport *vp = _win->getPort(i);
00409
00410 if(vp != NULL)
00411 {
00412 vp->setCamera(camera);
00413 }
00414 }
00415
00416
00417 _camera = camera;
00418 }
00419
00422 void SimpleSceneManager::setHighlight(Node *highlight)
00423 {
00424 _highlight = highlight;
00425 highlightChanged();
00426 }
00427
00430 void SimpleSceneManager::setStatistics(bool on)
00431 {
00432 if(_statforeground != NULL && on != _statstate)
00433 {
00434 Viewport *vp = _win->getPort(0);
00435
00436 if(on)
00437 {
00438 vp->addForeground(_statforeground);
00439
00440 #ifdef OSG_OLD_RENDER_ACTION
00441 _renderAction->setStatCollector(_statforeground->getCollector());
00442 #endif
00443 _rtaction ->setStatCollector(_statforeground->getCollector());
00444 }
00445 else
00446 {
00447 vp->removeObjFromForegrounds(_statforeground);
00448
00449 #ifdef OSG_OLD_RENDER_ACTION
00450 _renderAction->setStatCollector(NULL);
00451 #endif
00452 _rtaction ->setStatCollector(NULL);
00453 }
00454
00455 _statstate = on;
00456 }
00457 }
00458
00460 bool SimpleSceneManager::getStatistics(void)
00461 {
00462 return _statstate;
00463 }
00464
00466 void SimpleSceneManager::addForeground(Foreground * const fg)
00467 {
00468 if (fg == NULL) {
00469 FWARNING(("SimpleSceneManager::addForeground: "
00470 "foreground not specified, ignoring!\n"));
00471 return;
00472 }
00473
00474 if(_internalRoot == NULL)
00475 {
00476 initialize();
00477 }
00478
00479 Viewport *vp = _win->getPort(0);
00480
00481 if (vp == NULL) {
00482 FWARNING(("SimpleSceneManager::addForeground: viewport not set, "
00483 "ignoring!\n"));
00484 }
00485 else
00486 vp->addForeground(fg);
00487 }
00488
00490 void SimpleSceneManager::removeForeground(Foreground * const fg)
00491 {
00492 if (fg == NULL) {
00493 FWARNING(("SimpleSceneManager::removeForeground: "
00494 "foreground not specified, ignoring!\n"));
00495 return;
00496 }
00497
00498 if(_internalRoot == NULL)
00499 {
00500 initialize();
00501 }
00502
00503 Viewport *vp = _win->getPort(0);
00504
00505 if (vp == NULL) {
00506 FWARNING(("SimpleSceneManager::removeForeground: viewport not set, "
00507 "ignoring!\n"));
00508 }
00509 else
00510 vp->removeObjFromForegrounds(fg);
00511 }
00512
00513
00514
00515
00516
00519 void SimpleSceneManager::initialize(void)
00520 {
00521
00522 if(_win == NULL)
00523 {
00524 FWARNING(("SimpleSceneManager::initialize: window not set, "
00525 "ignoring!\n"));
00526 return;
00527 }
00528
00529
00530 #ifdef OSG_OLD_RENDER_ACTION
00531 _ownAction = RenderAction::create();
00532 _renderAction = _ownAction;
00533 #endif
00534
00535 _rtaction = RenderAction::create();
00536
00537
00538 NodeUnrecPtr cartN = Node::create();
00539 _cart = Transform::create();
00540
00541 cartN->setCore(_cart);
00542
00543
00544 _internalRoot = Node::create();
00545 _headlight = DirectionalLight::create();
00546
00547 _internalRoot->setCore(_headlight);
00548 _internalRoot->addChild(cartN);
00549
00550
00551 _headlight->setAmbient (.3f, .3f, .3f, 1);
00552 _headlight->setDiffuse ( 1, 1, 1, 1);
00553 _headlight->setSpecular ( 1, 1, 1, 1);
00554 _headlight->setDirection( 0, 0, 1);
00555 _headlight->setBeacon (cartN);
00556
00557
00558 _camera = PerspectiveCamera::create();
00559
00560 _camera->setBeacon(cartN);
00561
00562 PerspectiveCamera *pPerspCam =
00563 dynamic_pointer_cast<PerspectiveCamera>(_camera);
00564
00565 if(pPerspCam != NULL)
00566 pPerspCam->setFov(osgDegree2Rad(60.f));
00567
00568 _camera->setNear (0.1f);
00569 _camera->setFar (10000.f);
00570
00571
00572 if(_win->getMFPort()->size() == 0)
00573 {
00574 SolidBackgroundUnrecPtr bg = SolidBackground::create();
00575
00576 bg->setColor(Color3f(0.2f, 0.2f, 0.2f));
00577
00578 _foreground = ImageForeground::create();
00579
00580 SimpleStatisticsForegroundUnrecPtr sf =
00581 SimpleStatisticsForeground::create();
00582
00583 sf->setSize(25);
00584 sf->setColor(Color4f(0,1,0,0.7f));
00585
00586
00587
00588 sf->addElement(RenderAction::statDrawTime,
00589 "Draw FPS: %r.3f");
00590 sf->addElement(RenderAction::statTravTime,
00591 "Trav FPS: %r.3f");
00592 sf->addElement(RenderAction::statNStates,
00593 " State changes: %d");
00594 sf->addElement(RenderAction::statNShaders,
00595 "Shader changes: %d");
00596 sf->addElement(RenderAction::statNShaderParams,
00597 "Shader param changes: %d");
00598 sf->addElement(TextureObjChunk::statNTextures,
00599 "Textures: %d");
00600 sf->addElement(TextureObjChunk::statNTexBytes,
00601 " Tex Mem: %MB MB");
00602
00603 sf->addElement(RenderAction::statNGeometries,
00604 " Geom nodes: %d");
00605 sf->addElement(RenderAction::statNMatrices,
00606 "Matrix changes: %d");
00607 sf->addElement(RenderAction::statNTriangles,
00608 " Triangles: %d");
00609
00610 sf->addElement(PointLight::statNPointLights,
00611 "%d active point lights");
00612 sf->addElement(DirectionalLight::statNDirectionalLights,
00613 "%d active directional lights");
00614 sf->addElement(SpotLight::statNSpotLights,
00615 "%d active spot lights");
00616
00617 sf->addText ("Drawables: (drawn)");
00618
00619 sf->addElement(Drawable::statNTriangles, " tris: %d");
00620 sf->addElement(Drawable::statNLines, " lines: %d");
00621 sf->addElement(Drawable::statNPoints, "points: %d");
00622 sf->addElement(Drawable::statNVertices, " verts: %d");
00623
00624 if(sf->getCollector() != NULL)
00625 {
00626
00627 sf->getCollector()->getElem(Drawable::statNTriangles);
00628 }
00629
00630 sf->addText ("ChangeList: ");
00631 sf->addElement(ChangeList::statNChangedStoreSize,
00632 " %d entries in changedStore");
00633 sf->addElement(ChangeList::statNCreatedStoreSize,
00634 " %d entries in createdStore");
00635 sf->addElement(ChangeList::statNUnCommittedStoreSize,
00636 " %d entries in uncommitedStore");
00637 sf->addElement(ChangeList::statNPoolSize,
00638 " %d entries in pool");
00639
00640 #if 0
00641
00642 sf->addElement(RenderAction::statTravTime,
00643 "FPS: %r.3f");
00644 sf->addElement(DrawActionBase::statCullTestedNodes,
00645 "Nodes culltested %d");
00646 sf->addElement(DrawActionBase::statCulledNodes,
00647 "Nodes culled %d");
00648 sf->addElement(RenderAction::statNOcclusionMode,
00649 "Occlusion culling %s");
00650 sf->addElement(RenderAction::statNOcclusionTests,
00651 "Occlusion tests %d");
00652 sf->addElement(RenderAction::statNOcclusionCulled,
00653 "Occlusion culled %d");
00654 sf->addElement(RenderAction::statNGeometries,
00655 "Nodes drawn %d");
00656 sf->addElement(RenderAction::statNTransGeometries,
00657 "Transp. Nodes drawn %d");
00658 sf->addElement(RenderAction::statNMaterials,
00659 "Material changes %d");
00660 sf->addElement(RenderAction::statNMatrices,
00661 "Matrix changes %d");
00662
00663 #if 0 // not ready for primetime yet
00664 sf->addElement(PointLight::statNPointLights,
00665 "%d active point lights");
00666 sf->addElement(DirectionalLight::statNDirectionalLights,
00667 "%d active directional lights");
00668 sf->addElement(SpotLight::statNSpotLights,
00669 "%d active spot lights");
00670 #endif
00671 sf->addElement(Drawable::statNTriangles,
00672 "Triangles drawn %d");
00673 sf->addElement(Drawable::statNLines,
00674 "Lines drawn %d");
00675 sf->addElement(Drawable::statNPoints,
00676 "Points drawn %d");
00677 sf->addElement(Drawable::statNVertices,
00678 "Vertices transformed %d");
00679 sf->addElement(RenderAction::statNTextures,
00680 "Textures used %d");
00681 sf->addElement(RenderAction::statNTexBytes,
00682 "Textures size (bytes) %d");
00683 #endif
00684
00685 #if 0
00686
00687 sf->addElement(RenderAction::statDrawTime, "Draw FPS: %r.3f");
00688 sf->addElement(RenderAction::statTravTime, "Trav FPS: %r.3f");
00689 sf->addElement(DrawActionBase::statCullTestedNodes,
00690 "%d Nodes culltested");
00691 sf->addElement(DrawActionBase::statCulledNodes,
00692 "%d Nodes culled");
00693 sf->addElement(RenderAction::statNMaterials,
00694 "%d material changes");
00695 sf->addElement(RenderAction::statNMatrices,
00696 "%d matrix changes");
00697 sf->addElement(RenderAction::statNGeometries,
00698 "%d Nodes drawn");
00699 sf->addElement(RenderAction::statNTransGeometries,
00700 "%d transparent Nodes drawn");
00701 #if 0 // not ready for primetime yet
00702 sf->addElement(PointLight::statNPointLights,
00703 "%d active point lights");
00704 sf->addElement(DirectionalLight::statNDirectionalLights,
00705 "%d active directional lights");
00706 sf->addElement(SpotLight::statNSpotLights,
00707 "%d active spot lights");
00708 #endif
00709 sf->addElement(Drawable::statNTriangles, "%d triangles drawn");
00710 sf->addElement(Drawable::statNLines, "%d lines drawn");
00711 sf->addElement(Drawable::statNPoints, "%d points drawn");
00712 sf->addElement(Drawable::statNVertices, "%d vertices transformed");
00713 sf->addElement(RenderAction::statNTextures, "%d textures used");
00714 sf->addElement(RenderAction::statNTexBytes, "%d bytes of texture used");
00715 if(sf->getCollector() != NULL)
00716 {
00717
00718 sf->editCollector()->getElem(Drawable::statNTriangles);
00719 }
00720 #endif
00721
00722 _statforeground = sf;
00723
00724 ViewportUnrecPtr vp = Viewport::create();
00725
00726 vp->setCamera (_camera);
00727 vp->setRoot (_internalRoot);
00728 vp->setSize (0,0, 1,1);
00729 vp->setBackground(bg);
00730 vp->addForeground(_foreground);
00731
00732 _win->addPort(vp);
00733 }
00734
00735 _navigator.setViewport(_win->getPort(0));
00736 setBeacon(cartN);
00737 }
00738
00741 void SimpleSceneManager::showAll(void)
00742 {
00743 if(_root == NULL)
00744 return;
00745
00746 OSG::commitChanges();
00747
00748 _root->updateVolume();
00749
00750 Vec3f min,max;
00751 _root->getVolume().getBounds( min, max );
00752 Vec3f d = max - min;
00753
00754 if(d.length() < Eps)
00755 {
00756 min.setValues(-1.f,-1.f,-1.f);
00757 max.setValues( 1.f, 1.f, 1.f);
00758 d = max - min;
00759 }
00760
00761 PerspectiveCamera *perCam =
00762 dynamic_pointer_cast<PerspectiveCamera>(_camera);
00763
00764 OrthographicCamera *ortCam =
00765 dynamic_pointer_cast<OrthographicCamera>(_camera);
00766
00767 Real32 dist = osgMax(d[0],d[1]);
00768
00769 if (perCam) {
00770 dist /= (2 * osgTan(perCam->getFov()/2.f));
00771 }
00772 else if (ortCam) {
00773 ortCam->setVerticalSize(dist);
00774 }
00775 else {
00776 FWARNING(("SimpleSceneManager::showAll: unsupported camera type, "
00777 "may not work properly!\n"));
00778 }
00779
00780 Vec3f up(0,1,0);
00781 Pnt3f at((min[0]+max[0])*.5f,(min[1]+max[1])*.5f,(min[2]+max[2])*.5f);
00782 Pnt3f from=at;
00783 from[2]+=(dist+fabs(max[2]-min[2])*0.5f);
00784
00785 _navigator.set(from,at,up);
00786
00787
00788 _navigator.setMotionFactor((d[0] + d[1] + d[2]) / 100.f);
00789
00790
00791 Real32 diag = osgMax(osgMax(d[0], d[1]), d[2]);
00792
00793 _camera->setNear (diag / 100.f);
00794 _camera->setFar (10 * diag);
00795 }
00796
00799 void SimpleSceneManager::useOpenSGLogo(void)
00800 {
00801 ImageUnrecPtr lo = Image::create();
00802
00803 ImageFileType::restore( lo, static_cast<UChar8 *>(LogoData), -1 );
00804
00805 _foreground->addImage( lo, Pnt2f( 0,0 ) );
00806 }
00807
00808
00809
00812 void SimpleSceneManager::update(void)
00813 {
00814 if (_internalRoot == NULL)
00815 {
00816 initialize();
00817 showAll();
00818 }
00819
00820
00821 _navigator.updateCameraTransformation();
00822
00823 updateHighlight();
00824
00825 Thread::getCurrentChangeList()->fillStatistic(
00826 _rtaction->getStatCollector());
00827
00828 Thread::getCurrentChangeList()->commitChanges();
00829 }
00830
00833 void SimpleSceneManager::redraw(void)
00834 {
00835 update();
00836
00837 #ifdef OSG_OLD_RENDER_ACTION
00838 if(!_traversalAction)
00839 { _win->render(_renderAction); }
00840 else
00841 #endif
00842 { _win->render(_rtaction); }
00843 }
00844
00848 void SimpleSceneManager::highlightChanged(void)
00849 {
00850
00851
00852 if(_highlightMaterial == NULL)
00853 {
00854 _highlightMaterial = SimpleMaterial::create();
00855 _highlightMaterial->setDiffuse (Color3f(0,1,0));
00856 _highlightMaterial->setLit (false);
00857 }
00858 if(_highlightNode == NULL)
00859 {
00860 GeoUInt8PropertyUnrecPtr type = GeoUInt8Property::create();
00861 GeoUInt8Property::StoredFieldType* t = type->editFieldPtr();
00862 t->push_back(GL_LINE_STRIP);
00863 t->push_back(GL_LINES);
00864
00865 GeoUInt32PropertyUnrecPtr lens = GeoUInt32Property::create();
00866 GeoUInt32Property::StoredFieldType* l = lens->editFieldPtr();
00867 l->push_back(10);
00868 l->push_back(6);
00869
00870 GeoUInt32PropertyUnrecPtr index = OSG::GeoUInt32Property::create();
00871 GeoUInt32Property::StoredFieldType* idx = index->editFieldPtr();
00872 idx->push_back(0);
00873 idx->push_back(1);
00874 idx->push_back(3);
00875 idx->push_back(2);
00876 idx->push_back(0);
00877 idx->push_back(4);
00878 idx->push_back(5);
00879 idx->push_back(7);
00880 idx->push_back(6);
00881 idx->push_back(4);
00882
00883 idx->push_back(1);
00884 idx->push_back(5);
00885 idx->push_back(2);
00886 idx->push_back(6);
00887 idx->push_back(3);
00888 idx->push_back(7);
00889
00890 _highlightPoints = OSG::GeoPnt3fProperty::create();
00891 OSG::GeoPnt3fProperty::StoredFieldType* p = _highlightPoints->editFieldPtr();
00892 p->push_back(Pnt3f(-1, -1, -1));
00893 p->push_back(Pnt3f( 1, -1, -1));
00894 p->push_back(Pnt3f(-1, 1, -1));
00895 p->push_back(Pnt3f( 1, 1, -1));
00896 p->push_back(Pnt3f(-1, -1, 1));
00897 p->push_back(Pnt3f( 1, -1, 1));
00898 p->push_back(Pnt3f(-1, 1, 1));
00899 p->push_back(Pnt3f( 1, 1, 1));
00900
00901 GeometryUnrecPtr geo = Geometry::create();
00902 geo->setTypes (type);
00903 geo->setLengths (lens);
00904 geo->setIndices (index);
00905 geo->setPositions (_highlightPoints);
00906 geo->setMaterial (_highlightMaterial);
00907
00908 _highlightNode = Node::create();
00909 _highlightNode->setCore(geo);
00910 }
00911
00912
00913 if(getHighlight() != NULL)
00914 {
00915 if(_highlightNode->getParent() == NULL)
00916 {
00917 _internalRoot->addChild(_highlightNode);
00918 }
00919 }
00920 else
00921 {
00922 if(_highlightNode->getParent() != NULL)
00923 {
00924 _internalRoot->subChild(_highlightNode);
00925 }
00926
00927 }
00928
00929 updateHighlight();
00930 }
00931
00935 void SimpleSceneManager::updateHighlight(void)
00936 {
00937 if(_highlight == NULL)
00938 return;
00939
00940
00941
00942
00943 BoxVolume vol;
00944 _highlight->getWorldVolume(vol);
00945
00946 Pnt3f min,max;
00947 vol.getBounds(min, max);
00948
00949 _highlightPoints->setValue(Pnt3f(min[0], min[1], min[2]), 0);
00950 _highlightPoints->setValue(Pnt3f(max[0], min[1], min[2]), 1);
00951 _highlightPoints->setValue(Pnt3f(min[0], max[1], min[2]), 2);
00952 _highlightPoints->setValue(Pnt3f(max[0], max[1], min[2]), 3);
00953 _highlightPoints->setValue(Pnt3f(min[0], min[1], max[2]), 4);
00954 _highlightPoints->setValue(Pnt3f(max[0], min[1], max[2]), 5);
00955 _highlightPoints->setValue(Pnt3f(min[0], max[1], max[2]), 6);
00956 _highlightPoints->setValue(Pnt3f(max[0], max[1], max[2]), 7);
00957 }
00958
00959
00960
00961
00966 Line SimpleSceneManager::calcViewRay(Int16 x, Int16 y)
00967 {
00968 Line l;
00969
00970 _camera->calcViewRay(l, x, y, *_win->getPort(0));
00971
00972 return l;
00973 }
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00988 bool SimpleSceneManager::operator < (const SimpleSceneManager &other) const
00989 {
00990 return this < &other;
00991 }
00992