Changeset 86 for trunk/VUT/Ogre
- Timestamp:
- 05/06/05 01:39:32 (20 years ago)
- Location:
- trunk/VUT/Ogre
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r85 r86 65 65 /** Issue a occlusion query for this node. 66 66 @param node the current hierarchy node 67 @param wasVisible if the node was visible in the last frame 67 68 @returns occlusion query for this node 68 69 */ 69 GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::HierarchyNode *node); 70 GtpVisibility::OcclusionQuery *IssueOcclusionQuery( 71 GtpVisibility::HierarchyNode *node, const bool wasVisible); 70 72 71 73 protected: -
trunk/VUT/Ogre/include/OgrePlatformOcclusionQuery.h
r59 r86 20 20 virtual ~PlatformOcclusionQuery(); 21 21 22 virtual unsigned int GetQueryResult() const;23 virtual bool ResultAvailable() const;22 virtual bool GetQueryResult(unsigned int &queryResult, 23 const bool waitForResult) const; 24 24 virtual void BeginQuery() const; 25 25 virtual void EndQuery() const; -
trunk/VUT/Ogre/include/OgreSolidHalfBoundingBox.h
r85 r86 16 16 17 17 SolidHalfBoundingBox(); 18 /** Sets up the first or second half of a solid boundingbox.18 /** Sets up the first or second half of a the solid box. 19 19 @param aab the axis aligned bounding box 20 20 @param isFirstHalf if it is the first or the second half … … 22 22 void SetupBoundingBox(const AxisAlignedBox& aabb, const bool isFirstHalf); 23 23 24 protected: 25 /** Builds the wireframe line list. 24 /** Builds the wireframe line list. 26 25 @param aab the axis aligned bounding box for setting up the vertices 27 26 @param first or second half of the box 28 27 */ 29 28 void SetupBoundingBoxVertices(const AxisAlignedBox& aab, const bool isFirstHalf); 29 30 protected: 31 30 32 /** 31 33 Sets the material used for occlusion queries. -
trunk/VUT/Ogre/resources/VisibilityDemo.overlay
r84 r86 10 10 top 5 11 11 width 450 12 height 5512 height 60 13 13 material Core/StatsBlockCenter 14 14 border_size 1 1 1 1 … … 69 69 left 155 70 70 top 20 71 width 90 72 height 30 73 font_name TrebuchetMSBold 74 char_height 16 75 caption : 76 colour_top 0.5 0.7 0.5 77 colour_bottom 0.3 0.5 0.3 78 } 79 element TextArea(Example/Visibility/UseOptimization) 80 { 81 metrics_mode pixels 82 left 5 83 top 35 84 width 90 85 height 30 86 font_name TrebuchetMSBold 87 char_height 16 88 caption [O] Optimization 89 colour_top 0.5 0.7 0.5 90 colour_bottom 0.3 0.5 0.3 91 } 92 element TextArea(Example/Visibility/UseOptimizationInfo) 93 { 94 metrics_mode pixels 95 left 155 96 top 35 71 97 width 90 72 98 height 30 -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r85 r86 57 57 GtpVisibility::HierarchyNode *node2) const 58 58 { 59 // matt: change this (inefficient) 60 AxisAlignedBox box1, box2; 61 62 static_cast<Octree *>(node1)->_getCullBounds(&box1); 63 static_cast<Octree *>(node2)->_getCullBounds(&box2); 64 65 return GetSquaredViewDepth(mCamera, &box1) > GetSquaredViewDepth(mCamera, &box2); 59 return GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node1)->mBox) > 60 GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node2)->mBox); 66 61 } 67 62 //----------------------------------------------------------------------- … … 70 65 { 71 66 Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 72 return (cam->getDerivedPosition() - mid).squaredLength(); 67 // use nearest point rather than midpoint 68 Vector3 camPos = cam->getDerivedPosition(); 69 70 Vector3 minPos(camPos.x < mid.x ? box->getMinimum().x : box->getMaximum().x, 71 camPos.y < mid.y ? box->getMinimum().y : box->getMaximum().y, 72 camPos.z < mid.z ? box->getMinimum().z : box->getMaximum().z); 73 74 return (camPos - minPos).squaredLength(); 73 75 } 74 76 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r85 r86 6 6 #include "OgrePlatformHierarchyInterface.h" 7 7 #include "OgrePlatformOcclusionQuery.h" 8 #include <windows.h> 8 9 9 10 namespace Ogre { … … 33 34 void PlatformHierarchyInterface::RenderBoundingBox(AxisAlignedBox *box) 34 35 { 36 static RenderOperation ro; 37 38 //TODO: this should be the full bounding box 39 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 40 41 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 42 mSceneManager->useRenderableViewProjMode(halfbox); 43 mSceneManager->setPass(halfbox->getTechnique()->getPass(0)); 44 35 45 // Render two halfes of the bounding box (using triangle fans) 36 46 for(int halfIdx = 0; halfIdx < 2; ++halfIdx) 37 47 { 38 //TODO: this should be the full bounding box 39 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 40 halfbox->SetupBoundingBox(*box, halfIdx == 1); 48 halfbox->SetupBoundingBoxVertices(*box, halfIdx == 1); 41 49 42 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);43 44 static RenderOperation ro;45 46 mSceneManager->useRenderableViewProjMode(halfbox);47 mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0));48 50 halfbox->getRenderOperation(ro); 49 51 ro.srcRenderable = halfbox; 50 mRenderSystem->_render(ro); 52 mRenderSystem->_render(ro); 51 53 } 52 54 } … … 70 72 { 71 73 GtpVisibility::HierarchyInterface::InitFrame(root); 74 mPreviousNode = NULL; 72 75 SetCamera(cam); 73 76 } … … 94 97 //----------------------------------------------------------------------- 95 98 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 96 GtpVisibility::HierarchyNode *node )99 GtpVisibility::HierarchyNode *node, const bool wasVisible) 97 100 { 98 101 // get next available test id … … 102 105 query->BeginQuery(); 103 106 104 RenderBoundingBox(GetBoundingBox(node)); 107 // if leaf and was visible => will be rendered anyway, thus we 108 // can also test with the real geometry 109 if(mUseOptimization && wasVisible && IsLeaf(node)) 110 { 111 // OutputDebugString("Using optimization!!\n"); 112 RenderNode(node); 113 } 114 else 115 { 116 // OutputDebugString("Not optimized!!\n"); 117 RenderBoundingBox(GetBoundingBox(node)); 118 } 105 119 106 120 query->EndQuery(); -
trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp
r59 r86 1 1 #include "OgrePlatformOcclusionQuery.h" 2 2 #include <windows.h> 3 3 namespace Ogre { 4 4 … … 24 24 } 25 25 //----------------------------------------------------------------------- 26 unsigned int PlatformOcclusionQuery::GetQueryResult() const 26 bool PlatformOcclusionQuery::GetQueryResult(unsigned int &visiblePixels, 27 const bool waitForResult) const 27 28 { 28 unsigned int visiblePixels = 0; 29 // wait if result not available 30 mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 31 32 return visiblePixels; 33 } 34 //----------------------------------------------------------------------- 35 bool PlatformOcclusionQuery::ResultAvailable() const 36 { 37 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 38 return mHardwareOcclusionQuery->resultAvailable(); 39 #else 40 return true; 41 #endif 29 return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 42 30 } 43 31 -
trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp
r85 r86 26 26 Vector3 vmin = aab.getMinimum(); 27 27 28 Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength());29 mRadius = Math::Sqrt(sqLen);28 //Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 29 //mRadius = Math::Sqrt(sqLen); 30 30 31 31 Real maxx = vmax.x; … … 90 90 91 91 // setup the bounding box of this SimpleRenderable 92 setBoundingBox(aabb);92 //setBoundingBox(aabb); 93 93 } 94 94 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r74 r86 18 18 19 19 //mDisplayNodes = true; 20 mShowBoundingBoxes = true;21 mShowBoxes = true;22 //mMaxDepth = 20;20 //mShowBoundingBoxes = true; 21 //mShowBoxes = true; 22 mMaxDepth = 20; 23 23 } 24 24 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
r75 r86 20 20 { 21 21 mVisibilityManager->SetVisibilityCullingThreshold(*static_cast<const int *>(val)); 22 22 return true; 23 } 24 if (key == "UseOptimization") 25 { 26 mHierarchyInterface->SetUseOptimization(*static_cast<const bool *>(val)); 23 27 return true; 24 28 } … … 53 57 return true; 54 58 } 59 55 60 return false; 56 61 } -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r85 r86 12 12 //namespace GtpVisibility { 13 13 //----------------------------------------------------------------------- 14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( GtpVisibility::VisibilityManager *visManager)15 :mVisibilityManager(visManager)14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 15 GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 16 16 { 17 17 mHierarchyInterface = 18 18 new OctreeHierarchyInterface(this, mDestRenderSystem); 19 19 20 setVisibilityManager(visManager);21 20 //mShowBoxes = true; 22 21 //mDisplayNodes = true;
Note: See TracChangeset
for help on using the changeset viewer.