- Timestamp:
- 06/14/05 02:50:05 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h
r74 r130 8 8 namespace GtpVisibility 9 9 { 10 11 typedef std::pair<HierarchyNode *, OcclusionQuery *> QueryPair;12 typedef std::queue<QueryPair> QueryQueue;13 10 14 11 /** Renders the scene with the coherent hierarchical culling algorithm. -
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r112 r130 3 3 4 4 #include "DistanceQueue.h" 5 #include "VisibilityMesh.h" 5 6 6 7 namespace GtpVisibility { 7 8 8 9 enum CullingType {QUERY_CULLED, FRUSTUM_CULLED}; 10 11 typedef std::vector<HierarchyNode *> HierarchyNodeList; 12 typedef std::vector<GtpVisibility::Mesh *> GeometryList; 13 typedef std::pair<HierarchyNode *, OcclusionQuery *> QueryPair; 14 typedef std::queue<QueryPair> QueryQueue; 9 15 10 16 /** Class which implements a hierarchy interface for a scene hierarchy. … … 26 32 */ 27 33 virtual void TraverseNode(HierarchyNode *node) = 0; 28 /** Renders current scene node.29 @param node current scenenode to be rendered34 /** Renders current hierarchy node. 35 @param node current hierarchy node to be rendered 30 36 */ 31 37 virtual void RenderNode(HierarchyNode *node) = 0; … … 119 125 CullingType type) = NULL; 120 126 127 /** Returns vector of previously rendered hierarchy nodes. 128 */ 129 std::vector<HierarchyNode *> *GetRenderedNodes(); 130 /** Returns vector of previoulsy rendered geometry. 131 */ 132 133 /** Issue a occlusion query for this mesh. 134 @param node the current mesh 135 @returns occlusion query for this node 136 */ 137 virtual GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh) = 0; 138 139 /** Returns geometry of hierarchy node. 140 */ 141 virtual void GetGeometry(GtpVisibility::HierarchyNode *node, 142 GeometryList *geometryList, 143 bool includeChildren) = 0; 144 145 146 /** Renders geometry. 147 */ 148 virtual void RenderGeometry(GtpVisibility::Mesh *geom) = 0; 149 121 150 protected: 122 151 … … 128 157 //--- statistics 129 158 unsigned int mNumTraversedNodes; 130 unsigned int mNumRenderedNodes;131 159 132 160 DistanceQueue *mDistanceQueue; … … 134 162 HierarchyNode *mPreviousNode; 135 163 136 164 std::vector<HierarchyNode *> mRenderedNodes; 137 165 }; 138 166 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/include/QueryManager.h
r113 r130 11 11 namespace GtpVisibility { 12 12 13 typedef std::vector<OcclusionQuery *> QueryList; 14 13 15 /** This abstract class defines interface for a specific visibility query 14 16 algorithm. The interface supports two from point visibility queries and … … 23 25 public: 24 26 /** Constructor taking a hierarchy interface as an argument. This allows to operate 25 on mdifferent hierarchy types, while reusing the implementation of the query methods.27 on different hierarchy types, while reusing the implementation of the query methods. 26 28 */ 27 29 QueryManager(HierarchyInterface *hierarchyInterface); … … 81 83 ); 82 84 83 /** Sets the scene traverser.84 @remark the scene traverserdepends on the type of hierarchyInterface the scene consists of.85 /** Sets the hierarchy interface. 86 @remark the traversal depends on the type of hierarchyInterface the scene consists of. 85 87 */ 86 void Set SceneTraverser(HierarchyInterface *hierarchyInterface);88 void SetHierarchyInterface(HierarchyInterface *hierarchyInterface); 87 89 88 90 protected: -
trunk/VUT/GtpVisibility/include/VisibilityInfo.h
r71 r130 16 16 NodeInfo(HierarchyNode *node,const float v): mNode(node), mVisibility(v) {} 17 17 18 float GetVisibiliy() const {return mVisibility;} 19 18 20 protected: 19 21 /** pointer to the scene node */ … … 31 33 public: 32 34 MeshInfo(Mesh *mesh, const float v): mMesh(mesh), mVisibility(v) {} 35 36 float GetVisibiliy() const {return mVisibility;} 33 37 34 38 protected: -
trunk/VUT/GtpVisibility/include/VisibilityManager.h
r114 r130 55 55 */ 56 56 void SetUseChcOptimization(bool useOptimization); 57 /** Sets pointer to a query manager. 58 */ 59 void SetQueryManager(QueryManager *queryManager); 60 /** see set 61 */ 62 QueryManager *GetQueryManager(); 57 63 58 64 protected: -
trunk/VUT/GtpVisibility/include/VisibilityMesh.h
r71 r130 2 2 #define _VisibilityMesh_H__ 3 3 4 #include "OgreMesh.h" 4 //#include <OgreMesh.h> 5 #include <OgreEntity.h> 5 6 6 7 namespace GtpVisibility { 7 typedef Ogre:: MeshMesh;8 typedef Ogre::Entity Mesh; 8 9 } 9 10 -
trunk/VUT/GtpVisibility/scripts/GtpVisibility.vcproj
r120 r130 64 64 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 65 65 RuntimeLibrary="2" 66 RuntimeTypeInfo="TRUE" 66 67 UsePrecompiledHeader="0" 67 68 WarningLevel="3" … … 107 108 </File> 108 109 <File 109 RelativePath="..\include\DistanceQueue.h">110 </File>111 <File112 110 RelativePath="..\src\DummyPreprocessingManager.cpp"> 113 111 </File> … … 148 146 </File> 149 147 <File 148 RelativePath="..\include\DistanceQueue.h"> 149 </File> 150 <File 151 RelativePath="..\include\DummyQueryManager.h"> 152 </File> 153 <File 150 154 RelativePath="..\include\FrustumCullingManager.h"> 151 155 </File> -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r119 r130 48 48 49 49 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 50 { //if (mHierarchyInterface->mIsShadowPass)50 { 51 51 mNumFrustumCulledNodes ++; 52 52 -
trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
r120 r130 7 7 //----------------------------------------------------------------------- 8 8 HierarchyInterface::HierarchyInterface(): 9 mFrameId(0), mNumTraversedNodes(0), m NumRenderedNodes(0),10 m SceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(false)9 mFrameId(0), mNumTraversedNodes(0), mSceneRoot(0), 10 mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(false) 11 11 //, mIsShadowPass(false) 12 12 { … … 26 26 void HierarchyInterface::InitFrame(HierarchyNode *root) 27 27 { 28 mFrameId ++;28 ++ mFrameId; 29 29 mCurrentTestIdx = 0; 30 30 mNumTraversedNodes = 0; 31 m NumRenderedNodes = 0;31 mRenderedNodes.clear(); 32 32 33 33 SetSceneRoot(root); … … 63 63 unsigned int HierarchyInterface::GetNumRenderedNodes() 64 64 { 65 return mNumRenderedNodes;65 return (unsigned int)mRenderedNodes.size(); 66 66 } 67 67 //----------------------------------------------------------------------- 68 68 void HierarchyInterface::SetUseOptimization(bool useOptimization) 69 69 { 70 70 mUseOptimization = useOptimization; 71 71 } 72 //----------------------------------------------------------------------- 73 std::vector<HierarchyNode *> *HierarchyInterface::GetRenderedNodes() 74 { 75 return &mRenderedNodes; 76 } 72 77 73 78 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/QueryManager.cpp
r71 r130 5 5 6 6 QueryManager::QueryManager(HierarchyInterface *hierarchyInterface) 7 :mHierarchyInterface(hierarchyInterface) 7 8 { 8 9 } -
trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
r114 r130 83 83 return mCullingManagerType; 84 84 } 85 85 //----------------------------------------------------------------------- 86 void VisibilityManager::SetQueryManager(QueryManager *queryManager) 87 { 88 mQueryManager = queryManager; 89 } 90 //----------------------------------------------------------------------- 91 QueryManager *VisibilityManager::GetQueryManager() 92 { 93 return mQueryManager; 94 } 86 95 } // namespace GtpVisibility -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r112 r130 3 3 4 4 #include <OgreOctree.h> 5 #include "OgrePlatformHierarchyInterface.h" 5 #include <OgreOctreeSceneManager.h> 6 #include "OgreSceneNodeHierarchyInterface.h" 6 7 7 8 namespace Ogre { … … 9 10 This class implements the hierarchy interface for the Ogre octree hierarchy. 10 11 */ 11 class OctreeHierarchyInterface : public PlatformHierarchyInterface12 class OctreeHierarchyInterface : public SceneNodeHierarchyInterface 12 13 { 13 14 public: 14 OctreeHierarchyInterface( SceneManager *sm, RenderSystem *rsys);15 OctreeHierarchyInterface(OctreeSceneManager *sm, RenderSystem *rsys); 15 16 16 17 /** Sets the number of nodes in this octree … … 46 47 GtpVisibility::CullingType type); 47 48 49 /*bool FindVisibleObjects(GtpVisibility::HierarchyNode *node, 50 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 51 bool includeChildren = false);*/ 52 void GetGeometry(GtpVisibility::HierarchyNode *node, 53 GtpVisibility::GeometryList *geometryList, 54 bool includeChildren); 55 48 56 protected: 49 57 /** Returns pointer to the bounding box of the node. … … 57 65 */ 58 66 Real GetSquaredViewDepth(const Camera* cam, const AxisAlignedBox* box) const; 67 /** number of octree hierarchy nodes */ 59 68 unsigned int mNumOctreeNodes; 60 69 }; -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r121 r130 10 10 #include "OgreSolidBoundingBox.h" 11 11 #include "HierarchyInterface.h" 12 #include "VisibilityInfo.h" 12 13 #include "OgrePlatformOcclusionQuery.h" 13 14 … … 51 52 @remark If null, the actual camera is used for both viewing and culling 52 53 */ 53 void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, bool leaveTransparentsInQueue = false); 54 void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, 55 bool leaveTransparentsInQueue = false); 54 56 /** Checks if the node is visible from the current view frustum. 55 57 @param node the current node … … 78 80 GtpVisibility::HierarchyNode *node, const bool wasVisible); 79 81 82 /** Issue a occlusion query for this mesh. 83 @param node the current mesh 84 @returns occlusion query for this node 85 */ 86 GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Mesh *mesh); 87 80 88 /** If true, the interface finds and renders only objects which are marked as shadow casters. 81 89 @remark This is important for the shadow texture pass 82 90 */ 83 91 void SetOnlyShadowCasters(bool onlyShadowCasters); 84 /** see set */ 92 /** see set 93 */ 85 94 bool GetOnlyShadowCasters(); 86 /** see set */ 95 /** see set 96 */ 87 97 bool GetUseOptimization(); 98 /** see set 99 */ 100 SceneManager *GetSceneManager(); 88 101 89 /** true if bounding box query is currently active. */ 102 /** see set 103 */ 104 RenderSystem *GetRenderSystem(); 105 106 /** true if bounding box query is currently active. 107 */ 90 108 bool IsBoundingBoxQuery(); 91 109 110 /** Finds visible objects of hierarchy node using occlusion queries 111 @param node the current scene node 112 @param objs the visible objects 113 @param includeChildren if the children of current scene nodes should also be traversed 114 */ 115 /*virtual bool FindVisibleObjects(GtpVisibility::HierarchyNode *node, 116 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 117 bool includeChildren = false) = 0;*/ 92 118 protected: 93 /** materials for visualizing frustum and query culled nodes */ 119 /** Renders geometry 120 */ 121 void RenderGeometry(GtpVisibility::Mesh *geom); 122 123 /** Materials for visualizing frustum and query culled nodes. 124 */ 94 125 void CreateNodeVizMaterials(); 126 127 /** Deletes all occlusion queries. 128 */ 129 void DeleteQueries(); 130 131 /** Renders bounding box of specified node. 132 @param box the bounding box of the scene node to be rendered 133 */ 134 void RenderBoundingBox(AxisAlignedBox *box); 135 136 /** Returns pointer to current renderable bounding box geometry. 137 */ 138 SolidBoundingBox *GetSolidBoundingBox(); 95 139 96 140 /** A pass that prepares an occlusion query. … … 98 142 vertex and fragment program. 99 143 */ 100 void SetOcclusionPass();144 //void SetOcclusionPass(); 101 145 102 /** Deletes all occlusion queries. 103 */ 104 void DeleteQueries(); 105 /** Renders bounding box of specified node. 106 @param box the bounding box of the scene node to be rendered 107 */ 108 void RenderBoundingBox(AxisAlignedBox *box); 109 110 /** Returns pointer to current renderable bounding box geometry 111 */ 112 SolidBoundingBox *GetSolidBoundingBox(); 113 114 /** Returns pointer to current renderable half bounding box geometry 115 */ 146 /** Returns pointer to current renderable half bounding box geometry.*/ 116 147 //SolidHalfBoundingBox *GetSolidHalfBoundingBox(); 117 148 118 /** Renderable of an aabb 149 /** Renderable of an aabb. 119 150 */ 120 151 SolidBoundingBox *mSolidBoundingBox; -
trunk/VUT/Ogre/include/OgreSceneContentGenerator.h
r107 r130 37 37 void SetScale(Vector3 scale); 38 38 39 /** the number of created objects */39 /** The number of created objects */ 40 40 int GetObjectCount(); 41 41 42 /** writes scene nodes to file */42 /** Writes scene nodes to file */ 43 43 bool WriteObjects(const std::string &filename); 44 44 45 /** loads scene nodes from file */45 /** Loads scene nodes from file */ 46 46 bool LoadObjects(const std::string &filename); 47 47 /** Generates a scene object with the specified parameters 48 @param position the position of the scene object 49 @param orientation the orientation of the scene object 50 @param objName the mesh name of the scene object 51 @returns the created scene object 52 */ 48 53 SceneNode *GenerateSceneObject(const Vector3 &position, 49 54 const Quaternion &orientation, const String &objName); -
trunk/VUT/Ogre/include/OgreSceneNodeHierarchyInterface.h
r112 r130 3 3 4 4 #include "OgrePlatformHierarchyInterface.h" 5 #include "VisibilityInfo.h" 6 #include "QueryManager.h" 7 5 8 6 9 namespace Ogre { … … 38 41 void VisualizeCulledNode(GtpVisibility::HierarchyNode *node, 39 42 GtpVisibility::CullingType type); 43 44 /*bool FindVisibleObjects(GtpVisibility::HierarchyNode *node, 45 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 46 bool includeChildren = false);*/ 47 48 void GetGeometry(GtpVisibility::HierarchyNode *node, 49 GtpVisibility::GeometryList *geometryList, 50 bool includeChildren); 40 51 }; 41 52 -
trunk/VUT/Ogre/include/OgreTerrainContentGenerator.h
r110 r130 35 35 */ 36 36 SceneNode *GenerateSceneObject(const Vector3 &position, 37 const Vector3 &rotation, const String &objName );37 const Vector3 &rotation, const String &objName, const bool clampToTerrain = true); 38 38 39 39 /** offset which is added to objects when put into the terrain */ -
trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
r122 r130 65 65 /** Creates material for depth pass, e.g., a pass that only fills the depth buffer */ 66 66 void InitDepthPass(); 67 68 /** Prepares visualization of hierarchical culling. */ 67 69 void ShowVisualization(Camera *cam); 68 70 OctreeHierarchyInterface *mHierarchyInterface; -
trunk/VUT/Ogre/include/OgreVisibilityOptionsManager.h
r114 r130 2 2 #define _VisibilityOptionsManager_H__ 3 3 4 5 #include <OgreString.h> 6 #include <OgreStringVector.h> 4 7 #include "VisibilityManager.h" 5 8 #include "HierarchyInterface.h" 6 #include <OgreString.h> 7 #include <OgreStringVector.h> 9 8 10 9 11 namespace Ogre { … … 30 32 "Algorithm", "Threshold"; 31 33 */ 32 bool setOption( const String &, const void *);34 bool setOption(const String &, const void *); 33 35 /** Gets the given option for the scene traverser. 34 36 @remarks 35 37 See setOption 36 38 */ 37 bool getOption( const String &, void *);39 bool getOption(const String &, void *); 38 40 bool getOptionKeys( StringVector &refKeys ); 39 41 -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r129 r130 9 9 10 10 #include "OgreOctreeHierarchyInterface.h" 11 #include "OgrePlatformQueryManager.h" 11 12 #include "VisibilityManager.h" 12 13 … … 17 18 using occlusion queries for visibility culling. 18 19 */ 19 class VisibilityTerrainSceneManager: public TerrainSceneManager20 class __declspec(dllexport) VisibilityTerrainSceneManager: public TerrainSceneManager 20 21 { 21 22 public: … … 74 75 Entity* createEntity(const String& entityName, const String& meshName); 75 76 77 /** Returns pointer to visibility manager */ 78 GtpVisibility::VisibilityManager *GetVisibilityManager(); 79 76 80 protected: 77 81 … … 101 105 102 106 int mCurrentEntityId; 107 108 PlatformQueryManager *mQueryManager; 103 109 }; 104 110 -
trunk/VUT/Ogre/scripts/Plugin_VisibilitySceneManager.vcproj
r115 r130 93 93 BufferSecurityCheck="FALSE" 94 94 EnableFunctionLevelLinking="TRUE" 95 RuntimeTypeInfo="TRUE" 95 96 UsePrecompiledHeader="0" 96 97 WarningLevel="3" … … 196 197 </File> 197 198 <File 199 RelativePath="..\include\OgrePlatformQueryManager.h"> 200 </File> 201 <File 198 202 RelativePath="..\include\OgreSceneContentGenerator.h"> 199 203 </File> … … 222 226 <File 223 227 RelativePath="..\src\OgrePlatformOcclusionQuery.cpp"> 228 </File> 229 <File 230 RelativePath="..\src\OgrePlatformQueryManager.cpp"> 224 231 </File> 225 232 <File -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r115 r130 9 9 10 10 //----------------------------------------------------------------------- 11 OctreeHierarchyInterface::OctreeHierarchyInterface( SceneManager *sm, RenderSystem *rsys):12 PlatformHierarchyInterface(sm, rsys)11 OctreeHierarchyInterface::OctreeHierarchyInterface(OctreeSceneManager *sm, RenderSystem *rsys): 12 SceneNodeHierarchyInterface(sm, rsys) 13 13 { 14 14 } … … 106 106 octant->setLastRendered(mFrameId); 107 107 108 static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera,108 dynamic_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, 109 109 octant, mOnlyShadowCasters, mLeaveTransparentsInQueue); 110 110 111 m NumRenderedNodes ++;111 mRenderedNodes.push_back(node); 112 112 } 113 113 #endif … … 157 157 } 158 158 159 static_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 160 } 159 dynamic_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 160 } 161 //----------------------------------------------------------------------- 162 void OctreeHierarchyInterface::GetGeometry(GtpVisibility::HierarchyNode *node, 163 GtpVisibility::GeometryList *geometryList, 164 bool includeChildren) 165 { 166 NodeList::const_iterator nodeIt, nodeIt_end; 167 nodeIt_end = static_cast<Octree *>(node)->mNodes.end(); 168 169 for (nodeIt = static_cast<Octree *>(node)->mNodes.begin(); nodeIt != nodeIt_end; ++nodeIt) 170 { 171 SceneNodeHierarchyInterface::GetGeometry(*nodeIt, geometryList, includeChildren); 172 } 173 } 174 //----------------------------------------------------------------------- 175 /*bool OctreeHierarchyInterface::FindVisibleObjects(GtpVisibility::HierarchyNode *node, 176 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 177 bool includeChildren) 178 { 179 bool foundVisible = false; 180 181 PlatformOcclusionQuery query(mRenderSystem); 182 183 NodeList *nodes = &static_cast<Octree *>(node)->mNodes; 184 185 NodeList::const_iterator nodeIt = nodes->begin(), nodeIt_end; 186 187 nodeIt_end = nodes->end(); 188 189 while (nodeIt != nodeIt_end) 190 { 191 OctreeNode *octreeNode = (*nodeIt); 192 if (SceneNodeHierarchyInterface::FindVisibleObjects(octreeNode, visibleGeometry, includeChildren)) 193 { 194 foundVisible = true; 195 } 196 ++nodeIt; 197 } 198 199 return foundVisible; 200 }*/ 201 161 202 } // namespace Ogre -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r122 r130 1 1 #include <OgreCamera.h> 2 2 #include <OgreLogManager.h> 3 #include <OgreSubEntity.h> 4 #include <OgreEntity.h> 5 #include <OgreMovableObject.h> 3 6 #include "OgreSolidBoundingBox.h" 4 7 #include "OgrePlatformHierarchyInterface.h" … … 138 141 mCullCamera = cullCam ? cullCam : cam; 139 142 140 if (mCullCamera != mCamera)141 LogManager::getSingleton().logMessage("cullcamera is not camera!");143 //if (mCullCamera != mCamera) 144 // LogManager::getSingleton().logMessage("cullcamera is not camera"); 142 145 143 146 // create materials for node visualization … … 186 189 { 187 190 mIsBoundingBoxQuery = true; 191 188 192 //LogManager::getSingleton().logMessage("render box\n"); 189 193 RenderBoundingBox(GetBoundingBox(node)); … … 197 201 } 198 202 //----------------------------------------------------------------------- 199 void PlatformHierarchyInterface::SetOcclusionPass() 203 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery(GtpVisibility::Mesh *mesh) 204 { 205 // get next available test id 206 GtpVisibility::OcclusionQuery *query = GetNextOcclusionQuery(); 207 208 //-- the actual query test 209 query->BeginQuery(); 210 211 RenderGeometry(mesh); 212 213 query->EndQuery(); 214 215 return query; 216 } 217 //----------------------------------------------------------------------- 218 /*void PlatformHierarchyInterface::SetOcclusionPass() 200 219 { 201 220 // disable vertex and fragment program … … 215 234 // Set colour write mode off 216 235 mRenderSystem->_setColourBufferWriteEnabled(false, false, false, false); 217 } 236 }*/ 218 237 //----------------------------------------------------------------------- 219 238 SolidBoundingBox *PlatformHierarchyInterface::GetSolidBoundingBox() … … 228 247 { 229 248 mOnlyShadowCasters = onlyShadowCasters; 230 //mIsShadowPass = mOnlyShadowCasters ;231 249 } 232 250 //----------------------------------------------------------------------- … … 245 263 return mIsBoundingBoxQuery; 246 264 } 265 //----------------------------------------------------------------------- 266 void PlatformHierarchyInterface::RenderGeometry(GtpVisibility::Mesh *geom) 267 { 268 mSceneManager->_renderMovableObject(geom, mLeaveTransparentsInQueue); 269 } 270 //----------------------------------------------------------------------- 271 SceneManager *PlatformHierarchyInterface::GetSceneManager() 272 { 273 return mSceneManager; 274 } 275 //----------------------------------------------------------------------- 276 RenderSystem *PlatformHierarchyInterface::GetRenderSystem() 277 { 278 return mRenderSystem; 279 } 247 280 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp
r121 r130 186 186 return true; 187 187 } 188 188 189 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r115 r130 1 #include "OgreSceneNodeHierarchyInterface.h"2 1 #include <OgreIteratorWrappers.h> 3 2 #include <OgreCamera.h> 4 3 #include <OgreSceneNode.h> 4 #include <OgreEntity.h> 5 #include <OgreSubEntity.h> 6 #include <OgreLogManager.h> 7 #include "OgreSceneNodeHierarchyInterface.h" 8 #include "OgrePlatformOcclusionQuery.h" 9 5 10 6 11 namespace Ogre { … … 40 45 { 41 46 sceneNode->setLastRendered(sceneNode->lastVisited()); 42 m NumRenderedNodes ++;47 mRenderedNodes.push_back(node); 43 48 44 49 mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeaveTransparentsInQueue); … … 130 135 // TODO 131 136 } 137 //----------------------------------------------------------------------- 138 void SceneNodeHierarchyInterface::GetGeometry(GtpVisibility::HierarchyNode *node, 139 GtpVisibility::GeometryList *geometryList, 140 bool includeChildren) 141 { 142 SceneNode::ObjectIterator objIt = 143 static_cast<SceneNode *>(node)->getAttachedObjectIterator(); 144 145 while (objIt.hasMoreElements()) 146 { 147 MovableObject *movable = objIt.getNext(); 148 149 // we are interested only in the entities, i.e., intances of geometry 150 if (movable->getMovableType() == "Entity") 151 { 152 Entity *ent = static_cast<Entity *>(movable); 153 //std::stringstream d; d << "ent " << ent->getName(); 154 //LogManager::getSingleton().logMessage(d.str()); 155 geometryList->push_back(ent); 156 } 157 } 158 } 132 159 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreTerrainContentGenerator.cpp
r111 r130 68 68 //----------------------------------------------------------------------- 69 69 SceneNode *TerrainContentGenerator::GenerateSceneObject(const Vector3 &position, 70 const Vector3 &rotation, const String& objName )70 const Vector3 &rotation, const String& objName, const bool clampToTerrain) 71 71 { 72 72 Vector3 queryResult; 73 73 // set y to max height so we are sure to be over terrain 74 74 Vector3 pos(position.x, MAX_HEIGHT, position.z); 75 76 if (!clampToTerrain) 77 { 78 return SceneContentGenerator::GenerateSceneObject(queryResult, rotation, objName); 79 } 75 80 76 81 if (mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y)) -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r129 r130 24 24 mDelayRenderTransparents(true), 25 25 mUseDepthPass(false), 26 mRenderItemBuffer( true),26 mRenderItemBuffer(false), 27 27 mCurrentEntityId(0) 28 28 { 29 29 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 30 30 mQueryManager = new PlatformQueryManager(mHierarchyInterface, mCurrentViewport); 31 32 mVisibilityManager->SetQueryManager(mQueryManager); 31 33 //mDisplayNodes = true; 32 34 //mShowBoundingBoxes = true; … … 87 89 mHierarchyInterface = NULL; 88 90 } 91 if (mQueryManager) 92 { 93 delete mQueryManager; 94 mQueryManager = NULL; 95 } 89 96 } 90 97 //----------------------------------------------------------------------- 91 98 void VisibilityTerrainSceneManager::ShowVisualization(Camera *cam) 92 99 { 93 LogManager::getSingleton().logMessage("***********VISUALIZATION************");94 100 // add player camera for visualization purpose 95 101 try … … 189 195 setAmbientLight(ColourValue(1,1,1,1)); 190 196 } 191 192 LogManager::getSingleton().logMessage("***********FIND OBJECTS************"); 193 getRenderQueue()->clear(); 197 //getRenderQueue()->clear(); 194 198 195 199 //-- show visible scene nodes and octree bounding boxes from last frame … … 221 225 void VisibilityTerrainSceneManager::_renderVisibleObjects() 222 226 { 223 /*224 std::stringstream d;225 d << "Terrain render level: " << TerrainRenderable::getCurrentRenderLevelIndex();226 LogManager::getSingleton().logMessage(d.str());227 228 227 // increase terrain renderlevel 229 228 int renderLevel = TerrainRenderable::getCurrentRenderLevelIndex() + 1; … … 233 232 renderLevel = 0; 234 233 } 235 */ 234 236 235 // visualization: apply standard rendering 237 236 if (mShowVisualization) 238 237 { 239 238 TerrainSceneManager::_renderVisibleObjects(); 240 //TerrainRenderable::setCurrentRenderLevelIndex(renderLevel);239 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 241 240 return; 242 241 } 243 244 LogManager::getSingleton().logMessage("***********RENDER OBJECTS************");245 242 246 243 InitDepthPass(); // create material for depth pass … … 309 306 TerrainSceneManager::_renderVisibleObjects(); 310 307 311 //TerrainRenderable::setCurrentRenderLevelIndex(renderLevel);308 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 312 309 //WriteLog(); // write out stats 313 310 } … … 374 371 // notifiy that frame has ended so terrain render level can be reset for correct 375 372 // terrain rendering 376 /*if (key == "TerrainLevelIdx")373 if (key == "TerrainLevelIdx") 377 374 { 378 375 TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val))); 379 376 return true; 380 } */377 } 381 378 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 382 379 setOption(key, val) || TerrainSceneManager::setOption(key, val); … … 507 504 //<< ", renderable name: " << irend-> 508 505 RenderSingleObjectForItemBuffer(*irend, ipass->first); 509 RenderSingleObjectForOcclusionQuery(506 //RenderSingleObjectForOcclusionQuery( 510 507 } 511 508 } … … 562 559 //LogManager::getSingleton().logMessage("has vertex program"); 563 560 Pass *usedPass = setPass(mItemBufferPass); 564 //Pass *usedPass = setPass(pass);561 //Pass *usedPass = setPass(pass); 565 562 std::stringstream d; 566 563 d << "item buffer id: " << rend->getId() << ", col: " << col; … … 571 568 } 572 569 //----------------------------------------------------------------------- 573 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, const String& meshName) 570 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager() 571 { 572 return mVisibilityManager; 573 } 574 //----------------------------------------------------------------------- 575 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName, 576 const String& meshName) 574 577 { 575 578 Entity *ent = SceneManager::createEntity(entityName, meshName); 576 579 577 for (int i = 0; i < ent->getNumSubEntities(); ++i)580 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 578 581 { 579 582 ent->getSubEntity(i)->setId(mCurrentEntityId ++); -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r115 r130 161 161 } 162 162 //----------------------------------------------------------------------- 163 TerrainMouseQueryListener::~TerrainMouseQueryListener( 164 { 165 } 166 //----------------------------------------------------------------------- 167 void TerrainMouseQueryListener::mouseMoved 163 TerrainMouseQueryListener::~TerrainMouseQueryListener() 164 { 165 } 166 //----------------------------------------------------------------------- 167 void TerrainMouseQueryListener::mouseMoved(MouseEvent *e) 168 168 { 169 169 // Update CEGUI with the mouse motion 170 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 170 CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * 171 mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight()); 171 172 } 172 173 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.cpp
r122 r130 6 6 #include <OgreMemoryMacros.h> 7 7 #include "TerrainMouseQueryListener.h" 8 #include "OgrePlatformQueryManager.h" 9 #include "OgreVisibilityTerrainSceneManager.h" 10 #include "VisibilityInfo.h" 8 11 9 12 // output file for frame info … … 54 57 mTerrainContentGenerator(sceneGenerator), 55 58 mVisibilityThreshold(0), 56 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),57 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING),59 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 60 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 58 61 mNodeVizMode(NODEVIZ_NONE), 59 62 mVizCameraHeight(Real(2500.0)), … … 81 84 mSunLight(sunLight) 82 85 { 83 mInputDevice = PlatformManager::getSingleton().createInputReader(); 84 mInputDevice->initialise(win, true, true); 85 86 /* 86 //mInputDevice = PlatformManager::getSingleton().createInputReader(); 87 88 //mInputDevice->initialise(win, true, true); 89 mEventProcessor = new EventProcessor(); 90 91 mEventProcessor->initialise(win); 92 mEventProcessor->startProcessingEvents(); 87 93 mEventProcessor->addMouseListener(this); 88 94 mEventProcessor->addMouseMotionListener(this); 89 mEventProcessor->addKeyListener(this); 90 */ 95 96 //mEventProcessor->addKeyListener(this); 97 mInputDevice = mEventProcessor->getInputReader(); 98 91 99 92 100 // create ray query executor, used to place objects in terrain … … 145 153 mSceneMgr->setOption("CullCamera", &mCullCamera); 146 154 mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 155 156 mVisibilityManager = 157 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)->GetVisibilityManager(); 158 159 dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())-> 160 SetViewport(mWindow->getViewport(0)); 147 161 } 148 162 //----------------------------------------------------------------------- 149 163 TerrainMouseQueryListener::~TerrainMouseQueryListener() 150 164 { 151 PlatformManager::getSingleton().destroyInputReader(mInputDevice);165 //PlatformManager::getSingleton().destroyInputReader(mInputDevice); 152 166 153 167 delete mRayQueryExecutor; 168 delete mEventProcessor; 154 169 } 155 170 //----------------------------------------------------------------------- … … 170 185 // Setup the ray scene query 171 186 Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY()); 172 173 Vector3 queryResult;187 188 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay); 174 189 175 190 // Get results, create a node/entity on the position 176 191 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject( 177 mouseRay.getOrigin(), Vector3 (0,0,0), "robot");192 mouseRay.getOrigin(), Vector3::ZERO, "robot", false); 178 193 179 194 mLMouseDown = true; … … 231 246 bool TerrainMouseQueryListener::frameStarted(const FrameEvent &evt) 232 247 { 233 LogManager::getSingleton().logMessage("frame started");234 248 if (mWindow->isClosed()) 249 { 235 250 return false; 236 237 mInputDevice->capture(); 238 239 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 240 int terrainLevelIdx = 0; 241 mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 242 243 //-- setup what is needed for immediate mouse/key movement 244 if (mTimeDelay >= 0) 245 mTimeDelay -= evt.timeSinceLastFrame; 246 247 // If this is the first frame, pick a speed 248 if (evt.timeSinceLastFrame == 0) 249 { 250 mMoveScale = 1; 251 mRotScale = 0.1; 252 } 253 // Otherwise scale movement units by time passed since last frame 254 else 255 { 256 // Move about 100 units per second, 257 mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; 258 // Take about 10 seconds for full rotation 259 mRotScale = mRotateSpeed * evt.timeSinceLastFrame; 260 } 261 262 mRotX = 0; 263 mRotY = 0; 264 mTranslateVector = Vector3::ZERO; 265 266 if (!processUnbufferedKeyInput(evt)) 267 { 268 return false; 269 } 270 if (!processUnbufferedMouseInput(evt)) 271 { 272 return false; 273 } 274 275 if (mShowVisualization) 276 { 251 } 252 253 // mInputDevice->capture(); 254 255 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 256 int terrainLevelIdx = 0; 257 mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 258 259 //-- setup what is needed for immediate mouse/key movement 260 if (mTimeDelay >= 0) 261 { 262 mTimeDelay -= evt.timeSinceLastFrame; 263 } 264 265 // If this is the first frame, pick a speed 266 if (evt.timeSinceLastFrame == 0) 267 { 268 mMoveScale = 1; 269 mRotScale = 0.1; 270 } 271 // Otherwise scale movement units by time passed since last frame 272 else 273 { 274 // Move about 100 units per second, 275 mMoveScale = mMoveSpeed * evt.timeSinceLastFrame; 276 // Take about 10 seconds for full rotation 277 mRotScale = mRotateSpeed * evt.timeSinceLastFrame; 278 } 279 280 mRotX = 0; 281 mRotY = 0; 282 mTranslateVector = Vector3::ZERO; 283 284 if (!processUnbufferedKeyInput(evt)) 285 { 286 return false; 287 } 288 /* if (!processUnbufferedMouseInput(evt)) 289 { 290 return false; 291 }*/ 292 // --- set parameters for visualization 293 if (mShowVisualization) 294 { 277 295 // important for visualization => draw octree bounding boxes 278 296 mSceneMgr->setOption("ShowOctree", &mShowVisualization); 279 // also render nodew content? 280 //mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 281 282 // -- setup visualization camera 297 298 // ---- setup visualization camera 299 283 300 mVizCamera->setPosition(0, 0, 0); 284 301 mVizCamera->setOrientation(Quaternion::IDENTITY); … … 289 306 // point down -Z axis 290 307 mVizCamera->pitch(Radian(Degree(270.0))); 291 308 292 309 // rotation arounnd X axis 293 310 mVizCamera->yaw(Math::ATan2(-mCamera->getDerivedDirection().x, … … 298 315 } 299 316 317 //-- set application state 300 318 switch (mAppState) 301 319 { … … 312 330 StringConverter::toString(mFrameInfo.size() - 1)); 313 331 } 314 315 316 317 318 332 333 moveCamera(); 334 Clamp2Terrain(); 335 336 break; 319 337 default: 320 338 break; 321 339 }; 322 340 323 341 return true; 342 } 343 //----------------------------------------------------------------------- 344 void TerrainMouseQueryListener::ApplyVisibilityQuery() 345 { 346 InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 347 InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; 348 349 mVisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera, 350 &visibleNodes, &visibleGeometry, false); 351 352 for (int i=0; i < visibleGeometry.size(); ++i) 353 { 354 std::stringstream d; d << "Geometry visibility: " << visibleGeometry[i].GetVisibiliy(); 355 LogManager::getSingleton().logMessage(d.str()); 356 } 357 for (int i=0; i < visibleNodes.size(); ++i) 358 { 359 std::stringstream d; d << "Node visibility: " << visibleNodes[i].GetVisibiliy(); 360 LogManager::getSingleton().logMessage(d.str()); 361 } 362 324 363 } 325 364 //----------------------------------------------------------------------- … … 365 404 { 366 405 ofstr << StringConverter::toString((*it).position) << " " 367 << StringConverter::toString((*it).orientation) << " "368 << StringConverter::toString((*it).timeElapsed) << "\n";406 << StringConverter::toString((*it).orientation) << " " 407 << StringConverter::toString((*it).timeElapsed) << "\n"; 369 408 } 370 409 ofstr.close(); … … 390 429 mFrameInfo.push_back(info); 391 430 392 /* 393 std::stringstream d; 431 /* std::stringstream d; 394 432 d << StringConverter::toString(info.position) << " " << StringConverter::toString(info.orientation); 395 LogManager::getSingleton().logMessage(d.str()); 396 */ 433 LogManager::getSingleton().logMessage(d.str()); */ 397 434 } 398 435 ifstr.close(); … … 791 828 KEY_PRESSED(KC_F3, 0.3, nextAppState()); 792 829 KEY_PRESSED(KC_F4, 0.3, toggleRecord()); 830 KEY_PRESSED(KC_F5, 0.3, ApplyVisibilityQuery()); 793 831 794 832 KEY_PRESSED(KC_F11, 0.3, takeScreenShot()); -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.h
r121 r130 9 9 #include <OgreException.h> 10 10 #include "VisibilityEnvironment.h" 11 #include "VisibilityManager.h" 11 12 #include "OgreTerrainContentGenerator.h" 12 13 … … 113 114 void toggleRecord(); 114 115 116 void ApplyVisibilityQuery(); 117 118 void switchMouseMode() 119 { 120 mUseBufferedInputMouse = !mUseBufferedInputMouse; 121 mInputDevice->setBufferedInput(mUseBufferedInputKeys, mUseBufferedInputMouse); 122 } 115 123 protected: 116 124 … … 201 209 202 210 Light *mSunLight; 211 GtpVisibility::VisibilityManager *mVisibilityManager; 212 EventProcessor* mEventProcessor; 213 214 bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 215 203 216 }; 204 217 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj
r115 r130 75 75 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE" 76 76 RuntimeLibrary="2" 77 RuntimeTypeInfo="TRUE" 77 78 UsePrecompiledHeader="0" 78 79 WarningLevel="3" -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r115 r130 57 57 58 58 TerrainMouseQueryListener *mTerrainFrameListener; 59 59 60 60 private: 61 61 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.