Changeset 130 for trunk/VUT/Ogre
- Timestamp:
- 06/14/05 02:50:05 (20 years ago)
- Location:
- trunk/VUT/Ogre
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
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 ++);
Note: See TracChangeset
for help on using the changeset viewer.