- Timestamp:
- 06/08/05 17:44:48 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r120 r121 87 87 bool GetUseOptimization(); 88 88 89 /** true if bounding box query is currently active. */ 90 bool IsBoundingBoxQuery(); 91 89 92 protected: 90 93 /** materials for visualizing frustum and query culled nodes */ … … 129 132 bool mOnlyShadowCasters; 130 133 bool mLeaveTransparentsInQueue; 134 bool mIsBoundingBoxQuery; 131 135 }; 132 136 -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r119 r121 59 59 void WriteLog(); 60 60 61 /** Override pass so we can do the z-fail pass */ 61 /** Override pass so we can do the z-fail pass. 62 */ 62 63 Pass* setPass(Pass* pass); 64 65 /** Override from SceneManager so we can skip all but first pass for depth pass. 66 */ 67 bool validatePassForRendering(Pass* pass); 63 68 64 69 protected: -
trunk/VUT/Ogre/resources/VisibilityDemo.overlay
r120 r121 306 306 caption [F2] Show / Hide stats 307 307 } 308 element TextArea(Example/Visibility/Help/AppStateInfo): Example/Visibility/Templates/BasicText 309 { 310 left 5 311 top 85 312 width 180 313 height 30 314 caption [F3] Toggle between interactive / recorded walkthrough 315 } 308 316 element TextArea(Example/Visibility/Help/RecordedInfo): Example/Visibility/Templates/BasicText 309 317 { … … 312 320 width 180 313 321 height 30 314 caption [F3] Start / End frame recording 315 } 316 element TextArea(Example/Visibility/Help/AppStateInfo): Example/Visibility/Templates/BasicText 317 { 318 left 5 319 top 85 320 width 180 321 height 30 322 caption [F4] Toggle between interactive / recorded walkthrough 322 caption [F4] Start / End frame recording 323 323 } 324 324 element TextArea(Example/Visibility/Help/ScreenshotsInfo): Example/Visibility/Templates/BasicText -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r120 r121 9 9 //----------------------------------------------------------------------- 10 10 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 11 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), 12 mCamera(NULL), mCullCamera(NULL), mOnlyShadowCasters(false), mLeaveTransparentsInQueue(false) 11 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), mCamera(NULL), 12 mCullCamera(NULL), mOnlyShadowCasters(false), mLeaveTransparentsInQueue(false), 13 mIsBoundingBoxQuery(false) 13 14 { 14 15 } … … 86 87 87 88 // set no depth write, no color, no lighting material 88 //mSceneManager->setPass(solidBox->getTechnique()->getPass(0));89 SetOcclusionPass();89 mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 90 //SetOcclusionPass(); 90 91 91 92 solidBox->SetupBoundingBoxVertices(*box); … … 130 131 { 131 132 GtpVisibility::HierarchyInterface::InitFrame(root); 133 132 134 mPreviousNode = NULL; 133 135 mLeaveTransparentsInQueue = leaveTransparentsInQueue; 134 SetCamera(cam); 135 136 if (cullCam) 137 { 138 SetCullCamera(cullCam); 139 } 140 else 141 { 142 SetCullCamera(cam); 143 } 144 136 137 mCamera = cam; 138 mCullCamera = cullCam ? cullCam : cam; 139 140 if (mCullCamera != mCamera) 141 LogManager::getSingleton().logMessage("cullcamera is not camera!"); 142 143 // create materials for node visualization 145 144 CreateNodeVizMaterials(); 146 145 } … … 186 185 else 187 186 { 187 mIsBoundingBoxQuery = true; 188 188 //LogManager::getSingleton().logMessage("render box\n"); 189 189 RenderBoundingBox(GetBoundingBox(node)); 190 191 mIsBoundingBoxQuery = false; 190 192 } 191 193 … … 238 240 return mUseOptimization; 239 241 } 242 //----------------------------------------------------------------------- 243 bool PlatformHierarchyInterface::IsBoundingBoxQuery() 244 { 245 return mIsBoundingBoxQuery; 246 } 240 247 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp
r112 r121 160 160 char objName[100]; 161 161 162 if (!ifstr.is_open())162 if (!ifstr.is_open()) 163 163 return false; 164 164 … … 177 177 orientation.getRoll().valueDegrees());*/ 178 178 179 (void)GenerateSceneObject(position, orientation, objName);179 GenerateSceneObject(position, orientation, objName); 180 180 181 std::stringstream d; 182 d << StringConverter::toString(position) << " " << StringConverter::toString(orientation); 183 LogManager::getSingleton().logMessage(d.str()); 181 //std::stringstream d; d << StringConverter::toString(position) << " " << StringConverter::toString(orientation); 182 //LogManager::getSingleton().logMessage(d.str()); 184 183 } 185 184 ifstr.close(); -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r120 r121 249 249 // for delayed rendering: transparents, overlay 250 250 clearSpecialCaseRenderQueues(); 251 SceneManager::_renderVisibleObjects();251 OctreeSceneManager::_renderVisibleObjects(); 252 252 253 253 WriteLog(); // write out stats -
trunk/VUT/Ogre/src/OgreVisibilitySceneManagerDll.cpp
r120 r121 57 57 58 58 heightmapTerrainPageSource = new HeightmapTerrainPageSource(); 59 visibilityTerrainPlugin->registerPageSource("Heightmap", heightmapTerrainPageSource);60 61 59 62 60 // Register … … 64 62 Root::getSingleton().setSceneManager(ST_EXTERIOR_CLOSE, visibilityTerrainPlugin); 65 63 //Root::getSingleton().setSceneManager(ST_GENERIC, occlusionDotPlugin); 64 65 visibilityTerrainPlugin->registerPageSource("Heightmap", heightmapTerrainPageSource); 66 66 } 67 67 //----------------------------------------------------------------------- 68 extern "C" void dllStopPlugin( void)68 extern "C" void dllStopPlugin() 69 69 { 70 70 delete heightmapTerrainPageSource; 71 71 72 72 delete visibilityOctreePlugin; 73 73 delete visibilityTerrainPlugin; 74 74 //delete occlusionDotPlugin; 75 75 76 76 delete visManager; 77 77 delete visEnv; 78 78 } 79 //----------------------------------------------------------------------- 80 extern "C" void dllShutdownPlugin() 81 { 82 visibilityTerrainPlugin->shutdown(); 83 heightmapTerrainPageSource->shutdown(); 84 } 79 85 80 86 } //namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r120 r121 63 63 } 64 64 //----------------------------------------------------------------------- 65 /*Pass *VisibilityTerrainSceneManager::setPass(Pass* pass)66 {67 static bool myLastUsedVertexProgram = false;68 static bool myLastUsedFragmentProgram = false;69 70 // set depth fill pass only if depth write enabled71 Pass *usedPass = pass;72 73 if (mIsDepthPass && pass->getDepthWriteEnabled())74 {75 usedPass = mDepthPass;76 }77 78 if (mIlluminationStage == IRS_RENDER_TO_TEXTURE)79 {80 // Derive a special shadow caster pass from this one81 usedPass = deriveShadowCasterPass(usedPass);82 }83 else if (mIlluminationStage == IRS_RENDER_MODULATIVE_PASS)84 {85 usedPass = deriveShadowReceiverPass(usedPass);86 }87 88 bool passSurfaceAndLightParams = true;89 90 // take original pass here91 if (usedPass->hasVertexProgram())92 {93 mDestRenderSystem->bindGpuProgram(usedPass->getVertexProgram()->_getBindingDelegate());94 // bind parameters later since they can be per-object95 myLastUsedVertexProgram = true;96 // does the vertex program want surface and light params passed to rendersystem?97 passSurfaceAndLightParams = usedPass->getVertexProgram()->getPassSurfaceAndLightStates();98 }99 else100 {101 // Unbind program?102 if (myLastUsedVertexProgram)103 {104 mDestRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM);105 myLastUsedVertexProgram = false;106 }107 // Set fixed-function vertex parameters108 }109 110 if (passSurfaceAndLightParams)111 {112 // Set surface reflectance properties, only valid if lighting is enabled113 if (usedPass->getLightingEnabled())114 {115 mDestRenderSystem->_setSurfaceParams(116 usedPass->getAmbient(),117 usedPass->getDiffuse(),118 usedPass->getSpecular(),119 usedPass->getSelfIllumination(),120 usedPass->getShininess(),121 usedPass->getVertexColourTracking() );122 }123 124 // Dynamic lighting enabled?125 mDestRenderSystem->setLightingEnabled(usedPass->getLightingEnabled());126 }127 128 // Using a fragment program?129 if (usedPass->hasFragmentProgram())130 {131 mDestRenderSystem->bindGpuProgram(132 usedPass->getFragmentProgram()->_getBindingDelegate());133 // bind parameters later since they can be per-object134 myLastUsedFragmentProgram = true;135 }136 else137 {138 // Unbind program?139 if (myLastUsedFragmentProgram)140 {141 mDestRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM);142 myLastUsedFragmentProgram = false;143 }144 145 // Set fixed-function fragment settings146 147 // Fog (assumes we want pixel fog which is the usual)148 // New fog params can either be from scene or from material149 FogMode newFogMode;150 ColourValue newFogColour;151 Real newFogStart, newFogEnd, newFogDensity;152 if (usedPass->getFogOverride())153 {154 // New fog params from material155 newFogMode = usedPass->getFogMode();156 newFogColour = usedPass->getFogColour();157 newFogStart = usedPass->getFogStart();158 newFogEnd = usedPass->getFogEnd();159 newFogDensity = usedPass->getFogDensity();160 }161 else162 {163 // New fog params from scene164 newFogMode = mFogMode;165 newFogColour = mFogColour;166 newFogStart = mFogStart;167 newFogEnd = mFogEnd;168 newFogDensity = mFogDensity;169 }170 mDestRenderSystem->_setFog(newFogMode, newFogColour, newFogDensity, newFogStart, newFogEnd);171 172 }173 174 // The rest of the settings are the same no matter whether we use programs or not175 176 // Set scene blending177 mDestRenderSystem->_setSceneBlending(178 usedPass->getSourceBlendFactor(), usedPass->getDestBlendFactor());179 180 181 // Texture unit settings182 183 Pass::TextureUnitStateIterator texIter = usedPass->getTextureUnitStateIterator();184 size_t unit = 0;185 while(texIter.hasMoreElements())186 {187 TextureUnitState* pTex = texIter.getNext();188 mDestRenderSystem->_setTextureUnitSettings(unit, *pTex);189 ++unit;190 }191 // Disable remaining texture units192 mDestRenderSystem->_disableTextureUnitsFrom(usedPass->getNumTextureUnitStates());193 194 // Set up non-texture related material settings195 // Depth buffer settings196 mDestRenderSystem->_setDepthBufferFunction(usedPass->getDepthFunction());197 mDestRenderSystem->_setDepthBufferCheckEnabled(usedPass->getDepthCheckEnabled());198 mDestRenderSystem->_setDepthBufferWriteEnabled(usedPass->getDepthWriteEnabled());199 mDestRenderSystem->_setDepthBias(usedPass->getDepthBias());200 // Alpha-reject settings201 mDestRenderSystem->_setAlphaRejectSettings(202 usedPass->getAlphaRejectFunction(), usedPass->getAlphaRejectValue());203 // Set colour write mode204 // Right now we only use on/off, not per-channel205 bool colWrite = usedPass->getColourWriteEnabled();206 mDestRenderSystem->_setColourBufferWriteEnabled(colWrite, colWrite, colWrite, colWrite);207 // Culling mode208 mDestRenderSystem->_setCullingMode(usedPass->getCullingMode());209 // Shading210 mDestRenderSystem->setShadingType(usedPass->getShadingMode());211 212 return usedPass;213 }*/214 //-----------------------------------------------------------------------215 65 void VisibilityTerrainSceneManager::ShowVisualization(Camera *cam) 216 66 { 217 67 // add player camera for visualization purpose 218 try { 68 try 69 { 219 70 Camera *c; 220 71 if ((c = getCamera("PlayerCam")) != NULL) … … 223 74 } 224 75 } 225 catch (...)76 catch (...) 226 77 { 227 78 // ignore … … 241 92 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 242 93 { 243 244 94 if (mRenderNodesForViz) 245 95 { 246 96 getRenderQueue()->addRenderable(*it); 97 247 98 // addbounding boxes instead of node itself 248 99 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); … … 250 101 if (mRenderNodesContentForViz) 251 102 { 252 (*it)->_ addToRenderQueue(cam, getRenderQueue(), false);103 (*it)->_myAddToRenderQueue(cam, getRenderQueue(), false); 253 104 } 254 105 } 255 } 256 106 } 257 107 } 258 108 //----------------------------------------------------------------------- 259 109 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 260 110 { 261 // setting vertex program is not efficient262 //Pass *usedPass = ((mIsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass);111 //Pass *usedPass = ((mIsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); // setting vertex program is not efficient 112 263 113 // set depth fill pass only if depth write enabled 264 Pass *usedPass = (mIsDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass); 114 Pass *usedPass = (mIsDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ? mDepthPass : pass); 115 116 IlluminationRenderStage savedStage = mIlluminationStage; 117 118 // set illumination stage to NONE so no shadow material is used 119 // for depth pass or for occlusion query 120 if (mIsDepthPass || mHierarchyInterface->IsBoundingBoxQuery()) 121 { 122 mIlluminationStage = IRS_NONE; 123 } 265 124 266 125 if (mIsDepthPass) … … 286 145 } 287 146 } 288 /*else if (mIsItemBufferPass) 289 { 290 usedPass = mItemBufferPass; 291 }*/ 292 SceneManager::setPass(usedPass); 293 294 return usedPass; 147 //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 148 149 Pass *result = SceneManager::setPass(usedPass); 150 151 // reset illumination stage 152 mIlluminationStage = savedStage; 153 154 return result; 295 155 } 296 156 //----------------------------------------------------------------------- … … 302 162 ShowVisualization(cam); 303 163 } 304 else 305 { 306 mVisible.clear(); 307 mBoxes.clear(); 308 309 // if there is no depth pass => 310 // we interleave identification and rendering of objects 311 // in _renderVisibibleObjects 312 313 // only shadow casters will be rendered in shadow texture pass 314 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 315 } 164 165 mVisible.clear(); 166 mBoxes.clear(); 167 168 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 169 170 // if there is no depth pass => 171 // we interleave identification and rendering of objects 172 // in _renderVisibibleObjects 173 174 // only shadow casters will be rendered in shadow texture pass 175 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 176 177 bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 178 179 // possible two cameras (one for culling, one for rendering) 180 mHierarchyInterface->InitFrame(mOctree, cam, //mCameraInProgress, 181 mCullCamera ? getCamera("CullCamera") : NULL, 182 leaveTransparentsInQueue); 316 183 } 317 184 //----------------------------------------------------------------------- 318 185 void VisibilityTerrainSceneManager::_renderVisibleObjects() 319 186 { 320 // create material for depth pass321 InitDepthPass();322 323 187 // visualization: apply standard rendering 324 188 if (mShowVisualization) … … 327 191 return; 328 192 } 329 193 194 // create material for depth pass 195 InitDepthPass(); 330 196 331 197 //-- hierarchical culling … … 333 199 // overlay) must be identified and rendered one after another 334 200 335 bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 336 337 // possible two cameras (one for culling, one for rendering) 338 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress, 339 mCullCamera ? getCamera("CullCamera") : NULL, 340 leaveTransparentsInQueue); 341 342 // call initframe to reset culling manager stats 201 // frame initialisation to reset culling manager stats 343 202 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 344 203 … … 351 210 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 352 211 353 SceneManager::_renderVisibleObjects();212 TerrainSceneManager::_renderVisibleObjects(); 354 213 355 214 … … 396 255 // for delayed rendering: transparents, overlay 397 256 clearSpecialCaseRenderQueues(); 398 SceneManager::_renderVisibleObjects(); 399 257 TerrainSceneManager::_renderVisibleObjects(); 258 259 getRenderQueue()->clear(); 400 260 //WriteLog(); // write out stats 401 261 } … … 517 377 bool doLightIteration, const LightList* manualLightList) 518 378 { 379 // for correct rendering, transparents must be rendered after hierarchical culling 519 380 if (!mSkipTransparents) 520 381 { … … 522 383 } 523 384 } 385 //----------------------------------------------------------------------- 386 bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass) 387 { 388 // skip all but first pass if we are doing the depth pass 389 if (mIsDepthPass && pass->getIndex() > 0) 390 { 391 return false; 392 } 393 return SceneManager::validatePassForRendering(pass); 394 } 524 395 525 396 } // namespace Ogre -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.cpp
r120 r121 37 37 TerrainContentGenerator *sceneGenerator, 38 38 Camera *vizCamera, 39 SceneNode *camNode): 39 SceneNode *camNode, 40 Light *sunLight): 40 41 mCamera(cam), 41 42 mWindow(win), … … 77 78 mShowHelp(false), 78 79 mDisplayCameraDetails(false), 79 mVisualizeCulledNodes(false) 80 mVisualizeCulledNodes(false), 81 mSunLight(sunLight) 80 82 { 81 83 mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 403 405 writeFrames(); 404 406 405 //-- write out stats 407 //-- write out stats for recorded walkthrough 406 408 std::stringstream d; 407 409 d << "Algorithm: " << mCurrentAlgorithmCaptions[mCurrentAlgorithm] << "\n" … … 637 639 mUseShadows = !mUseShadows; 638 640 639 //mSunLight->setCastShadows(mUseShadows);641 mSunLight->setCastShadows(mUseShadows); 640 642 641 643 if (mUseShadows) … … 783 785 KEY_PRESSED(KC_F2, 0.3, toggleShowStats()); 784 786 KEY_PRESSED(KC_F3, 0.3, nextAppState()); 785 786 KEY_PRESSED(KC_F10, 0.3, toggleRecord()); 787 KEY_PRESSED(KC_F4, 0.3, toggleRecord()); 788 787 789 KEY_PRESSED(KC_F11, 0.3, takeScreenShot()); 788 790 KEY_PRESSED(KC_F12, 0.3, mTerrainContentGenerator->WriteObjects(objects_out_filename)); -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.h
r120 r121 25 25 TerrainMouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 26 26 CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera, 27 SceneNode *camNode );27 SceneNode *camNode, Light *sunLight); 28 28 29 29 ~TerrainMouseQueryListener(); … … 84 84 85 85 86 87 86 // Constructor takes a RenderWindow because it uses that to determine input context 88 87 //ExampleFrameListener(RenderWindow* win, Camera* cam, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false) … … 200 199 Overlay* mHelpOverlay; 201 200 Overlay* mCullStatsOverlay; 201 202 Light *mSunLight; 202 203 }; 203 204 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r120 r121 120 120 121 121 // Floor plane 122 /*Plane plane; 122 /* 123 Plane plane; 123 124 plane.normal = Vector3::UNIT_Y; 124 125 plane.d = -60; … … 129 130 pPlaneEnt->setMaterialName("Examples/Rockwall"); 130 131 pPlaneEnt->setCastShadows(true); 131 mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);*/ 132 mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); 133 */ 132 134 133 135 if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_HWRENDER_TO_TEXTURE)) … … 191 193 { 192 194 mTerrainFrameListener = new TerrainMouseQueryListener(mWindow, mCamera, mSceneMgr, 193 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode );195 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight); 194 196 195 197 mRoot->addFrameListener(mTerrainFrameListener);
Note: See TracChangeset
for help on using the changeset viewer.