Changeset 159 for trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
- Timestamp:
- 07/06/05 17:52:44 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp
r158 r159 3 3 #include <OgreStringConverter.h> 4 4 #include <vector> 5 5 #include <OgreSubEntity.h> 6 6 7 7 namespace Ogre { 8 8 //----------------------------------------------------------------------- 9 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp): 10 PlatformQueryManager(hierarchyInterface, vp) 9 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp, 10 const bool renderPatches): 11 PlatformQueryManager(hierarchyInterface, vp), mRenderPatchesForItemBuffer(renderPatches) 11 12 { 12 13 } … … 21 22 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 22 23 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 24 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 23 25 bool relativeVisibility) 24 26 { 25 27 // initialise item buffer (if not already initialised) 26 InitItemBuffer(visibleNodes, visibleGeometry );28 InitItemBuffer(visibleNodes, visibleGeometry, visiblePatches); 27 29 28 30 // we need access to the scene manager and the rendersystem … … 32 34 SceneManager *sm = pfHierarchyInterface->GetSceneManager(); 33 35 34 // --- -Render scene with item buffer (i.e., objects with their id as color codes)36 // --- Render scene with item buffer (i.e., objects with their id as color codes) 35 37 36 38 // const_cast allowed because camera is not changed in renderScene … … 61 63 uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 62 64 65 int n = mRenderPatchesForItemBuffer ? (int)visiblePatches->size() : (int)visibleGeometry->size(); 63 66 64 67 // loop through frame buffer & collect visible pixels … … 71 74 72 75 // if valid id <= add visibility (id values start at 1 73 if ((id > 0) && (id < (int)visibleGeometry->size()))76 if ((id > 0) && (id < n)) 74 77 { 75 ((*visibleGeometry)[id]).AddVisibility(1, 1); 78 if (mRenderPatchesForItemBuffer) 79 { 80 ((*visiblePatches)[id]).AddVisibility(1, 1); 81 } 82 else 83 { 84 ((*visibleGeometry)[id]).AddVisibility(1, 1); 85 } 76 86 } 77 87 } … … 93 103 } 94 104 //----------------------------------------------------------------------- 95 void ItemBufferQueryManager::InitItemBuffer(InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 96 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry) 105 void ItemBufferQueryManager::InitItemBuffer( 106 InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 107 InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 108 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches) 97 109 { 98 110 if (mWasInitialised) … … 109 121 visibleGeometry->clear(); 110 122 visibleNodes->clear(); 123 visiblePatches->clear(); 111 124 125 int id = 0; 126 127 /* We can either use patches or meshes. If patches are used, an unique id must 128 be given each patch. Otherwise the same id must be given to all patches belonging 129 to the same mesh. 130 */ 112 131 while (it.hasMoreElements()) 113 132 { 114 visibleGeometry->push_back(GtpVisibility::MeshInfo(it.getNext(), 0, 0)); 133 Entity *ent = it.getNext(); 134 135 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 136 { 137 SubEntity *subEnt = ent->getSubEntity(i); 138 139 if (mRenderPatchesForItemBuffer) 140 { 141 ++ id; 142 visiblePatches->push_back(GtpVisibility::PatchInfo(subEnt, 0, 0)); 143 } 144 145 subEnt->setId(id); 146 } 147 148 if (!mRenderPatchesForItemBuffer) 149 { 150 visibleGeometry->push_back(GtpVisibility::MeshInfo(ent, 0, 0)); 151 ++ id; 152 } 115 153 } 116 154 } 117 155 156 /* 157 //----------------------------------------------------------------------- 158 Entity* VisibilityOctreeSceneManager::createEntity(const String& entityName, 159 const String& meshName) 160 { 161 Entity *ent = SceneManager::createEntity(entityName, meshName); 162 163 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 164 { 165 ent->getSubEntity(i)->setId(mCurrentEntityId); 166 } 167 168 // increase counter of entity id values 169 ++ mCurrentEntityId; 170 171 return ent; 172 } 173 */ 118 174 } // namespace Ogre
Note: See TracChangeset
for help on using the changeset viewer.