From: <sv...@ww...> - 2006-03-16 08:14:09
|
Author: mkrose Date: 2006-03-16 00:13:58 -0800 (Thu, 16 Mar 2006) New Revision: 1867 Modified: trunk/csp/cspsim/SceneConstants.h trunk/csp/cspsim/VirtualScene.cpp trunk/csp/cspsim/VirtualScene.h Log: Add scene mask bits for the near and far sceneviews to allow the canopy model to be switched from pit reflections in the internal view to scene reflections in external views. This is a simple solution, but a better approach would probably use an Animation subclass to switch nodes on or off depending on bus channels. This would allow the visible model to be specialized for different stations. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1867 Modified: trunk/csp/cspsim/SceneConstants.h =================================================================== --- trunk/csp/cspsim/SceneConstants.h 2006-03-09 05:34:49 UTC (rev 1866) +++ trunk/csp/cspsim/SceneConstants.h 2006-03-16 08:13:58 UTC (rev 1867) @@ -29,13 +29,34 @@ CSP_NAMESPACE +/** NodeVisitor traversal mask bits that are set when rendering the scene. + * + * UPDATE_ONLY - set during the update traversal. + * CULL_ONLY - set during the cull traversal. + * LABELS - set only if labels are turned on. + * NEAR - set for traversals of the near scene graph. + * FAR - set for traversals of all far scene graphs. + * + * For example, the NEAR mask bit is used to enable rendering of canopy + * reflections in internal views by setting the node mask of a canopy model + * with a cockpit reflection texture map to NEAR. That node is culled in + * external views, and a second canopy model with node mask FAR and an + * environmental reflection texture map is rendered instead. + * + * Note that the OSG enables a node if there is any overlap between the node + * mask and the traversal mask. So for example, there is no way to set a node + * mask such that a node is only enabled for update traversals (UPDATE_ONLY) + * that occur in the near scene graph (NEAR). + */ class SceneMasks { public: typedef enum { UPDATE_ONLY = 0x0001, CULL_ONLY = 0x0002, NORMAL = 0x0003, - LABELS = 0x0100 + LABELS = 0x0100, + NEAR = 0x200, + FAR = 0x400 } NodeMask; }; Modified: trunk/csp/cspsim/VirtualScene.cpp =================================================================== --- trunk/csp/cspsim/VirtualScene.cpp 2006-03-09 05:34:49 UTC (rev 1866) +++ trunk/csp/cspsim/VirtualScene.cpp 2006-03-16 08:13:58 UTC (rev 1867) @@ -292,7 +292,7 @@ createInfoView(); } -osgUtil::SceneView *VirtualScene::makeSceneView() { +osgUtil::SceneView *VirtualScene::makeSceneView(unsigned mask) { osgUtil::SceneView *sv = new osgUtil::SceneView(m_DisplaySettings.get()); sv->setDefaults(osgUtil::SceneView::COMPILE_GLOBJECTS_AT_INIT); sv->setViewport(0, 0, m_ScreenWidth, m_ScreenHeight); @@ -307,21 +307,21 @@ sv->getCullVisitor()->setImpostorsActive(true); sv->getCullVisitor()->setComputeNearFarMode(osgUtil::CullVisitor::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); sv->getCullVisitor()->setCullingMode(osgUtil::CullVisitor::ENABLE_ALL_CULLING); - sv->setCullMask(SceneMasks::CULL_ONLY | SceneMasks::NORMAL); + sv->setCullMask(SceneMasks::CULL_ONLY | SceneMasks::NORMAL | mask); // default update settings - sv->getUpdateVisitor()->setTraversalMask(SceneMasks::UPDATE_ONLY | SceneMasks::NORMAL); + sv->getUpdateVisitor()->setTraversalMask(SceneMasks::UPDATE_ONLY | SceneMasks::NORMAL | mask); return sv; } void VirtualScene::createVeryFarView() { - m_VeryFarView = makeSceneView(); + m_VeryFarView = makeSceneView(SceneMasks::FAR); m_VeryFarGroup = new osg::Group; m_VeryFarGroup->setName("very_far_group"); m_VeryFarView->setSceneData(m_VeryFarGroup.get()); } void VirtualScene::createFarView() { - m_FarView = makeSceneView(); + m_FarView = makeSceneView(SceneMasks::FAR); // clear the depth buffer (but not the color buffer) m_FarView->getRenderStage()->setClearMask(GL_DEPTH_BUFFER_BIT); m_FarGroup = new osg::Group; @@ -330,7 +330,7 @@ } void VirtualScene::createNearView() { - m_NearView = makeSceneView(); + m_NearView = makeSceneView(SceneMasks::NEAR); // clear the depth buffer (but not the color buffer) m_NearView->getRenderStage()->setClearMask(GL_DEPTH_BUFFER_BIT); m_NearView->getCullVisitor()->setImpostorsActive(false); @@ -340,7 +340,7 @@ } void VirtualScene::createInfoView() { - m_InfoView = makeSceneView(); + m_InfoView = makeSceneView(0); // clear the depth buffer (but not the color buffer) m_InfoView->getRenderStage()->setClearMask(GL_DEPTH_BUFFER_BIT); Modified: trunk/csp/cspsim/VirtualScene.h =================================================================== --- trunk/csp/cspsim/VirtualScene.h 2006-03-09 05:34:49 UTC (rev 1866) +++ trunk/csp/cspsim/VirtualScene.h 2006-03-16 08:13:58 UTC (rev 1867) @@ -167,7 +167,7 @@ int _getFeatureTileIndex(Ref<FeatureGroup> feature) const; void _updateOrigin(Vector3 const &origin); - osgUtil::SceneView *makeSceneView(); + osgUtil::SceneView *makeSceneView(unsigned mask); void init(); void createSceneViews(); |