Changeset 2066 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include
- Timestamp:
- 01/31/07 01:51:57 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h
r1676 r2066 21 21 typedef vector<Entity *> EntityContainer; 22 22 23 class ObjectsIntersectable: public GtpVisibilityPreprocessor::IntersectableWrapper<EntityContainer *>23 class EngineIntersectable: public GtpVisibilityPreprocessor::IntersectableWrapper<EntityContainer *> 24 24 { 25 25 public: 26 ObjectsIntersectable(EntityContainer *item):26 EngineIntersectable(EntityContainer *item): 27 27 GtpVisibilityPreprocessor::IntersectableWrapper<EntityContainer *>(item) {} 28 28 29 29 // hack 30 ObjectsIntersectable::~ObjectsIntersectable() 31 { 32 //CLEAR_CONTAINER(*mItem); 30 EngineIntersectable::~EngineIntersectable() 31 { 33 32 delete mItem; 34 33 } … … 36 35 int Type() const 37 36 { 38 return Intersectable:: OBJECTS_INTERSECTABLE;37 return Intersectable::ENGINE_INTERSECTABLE; 39 38 } 40 39 }; … … 90 89 vector<Entity *> &objects) const; 91 90 91 /// this can be any scene manager 92 92 T *mSceneMgr; 93 93 }; … … 108 108 109 109 // get intersecting scene nodes 110 // note: this function must be provided by scene manager 110 111 mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 111 112 … … 169 170 return bestFittingObj; 170 171 } 171 //----------------------------------------------------------------------- 172 /*template<typename T> 172 173 174 #define ENLARGE_OBJECT_BBOX 0 175 #define ENLRAGE_NODE_BBOX 0 176 template<typename T> 173 177 void PlatFormBoundingBoxConverter<T>::FindIntersectingObjects(const AxisAlignedBox &box, 174 178 EntityContainer &objects) const 175 { //return;179 { 176 180 list<SceneNode *> sceneNodeList; 177 181 178 // get intersecting scene nodes (= candidates) 182 // find intersecting scene nodes to get candidates for intersection 183 // note: this function has to be provided by scene manager 184 #if ENLARGE_NODE_BBOX 185 // make search radius larger 179 186 AxisAlignedBox mybox = EnlargeBox(box); 180 187 mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 181 //mSceneMgr->findNodesIn(box, sceneNodeList, NULL);182 188 183 189 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 184 190 185 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(mybox); 186 //GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box); 187 188 // find really intersecting objects 191 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = 192 OgreTypeConverter::ConvertFromOgre(mybox); 193 #else 194 195 mSceneMgr->findNodesIn(box, sceneNodeList, NULL); 196 197 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = 198 OgreTypeConverter::ConvertFromOgre(box); 199 #endif 200 201 // loop through the intersected scene nodes 189 202 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) 190 203 { … … 192 205 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator(); 193 206 207 // find the objects that intersect the box 194 208 while (oit.hasMoreElements()) 195 209 { … … 198 212 // we are only interested in scene entities 199 213 if (mo->getMovableType() != "Entity") 214 continue; 215 216 // get the bounding box of the objects 217 #if ENLARGE_OBJECT_BBOX) 218 // compare with enlarged entitiy box 219 const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox()); 220 #else 221 const AxisAlignedBox bbox = mo->getWorldBoundingBox(); 222 #endif 223 224 // test for intersection (note: function provided of preprocessor) 225 if (Overlap(nodeBox, OgreTypeConverter::ConvertFromOgre(bbox))) 200 226 { 201 continue;227 objects.push_back(static_cast<Entity *>(mo)); 202 228 } 203 204 //const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());205 const AxisAlignedBox bbox = mo->getWorldBoundingBox();206 207 const bool overlaps = Overlap(nodeBox,208 OgreTypeConverter::ConvertFromOgre(bbox)209 );210 //,0.00001);211 212 if (overlaps)213 {214 objects.push_back(static_cast<Entity *>(mo));215 }216 229 } 217 230 } 218 231 } 219 */220 template<typename T>221 void PlatFormBoundingBoxConverter<T>::FindIntersectingObjects(const AxisAlignedBox &box,222 EntityContainer &objects) const223 {//return;224 list<SceneNode *> sceneNodeList;225 226 // get intersecting scene nodes (= candidates)227 //AxisAlignedBox mybox = EnlargeBox(box);228 //mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);229 mSceneMgr->findNodesIn(box, sceneNodeList, NULL);230 231 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end();232 233 //GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(mybox);234 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box);235 236 // find really intersecting objects237 for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit)238 {239 SceneNode *sn = *sit;240 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator();241 242 while (oit.hasMoreElements())243 {244 MovableObject *mo = oit.getNext();245 246 // we are only interested in scene entities247 if (mo->getMovableType() != "Entity")248 {249 continue;250 }251 252 //const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox());253 const AxisAlignedBox bbox = mo->getWorldBoundingBox();254 255 const bool overlaps =256 Overlap(nodeBox, OgreTypeConverter::ConvertFromOgre(bbox));257 258 259 if (overlaps)260 {261 objects.push_back(static_cast<Entity *>(mo));262 }263 }264 }265 }266 232 #if USE_KD_PVS 267 //-------------------------------------------------------------------------268 template<typename T>269 bool PlatFormBoundingBoxConverter<T>::IdentifyObjects(270 const GtpVisibilityPreprocessor::IndexedBoundingBoxContainer &iboxes,271 GtpVisibilityPreprocessor::ObjectContainer &objects) const272 {273 //Ogre::LogManager().logMessage("pvs: intersecting objects");274 const long startTime = GtpVisibilityPreprocessor::GetTime();275 276 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer::277 const_iterator iit, iit_end = iboxes.end();278 279 int i = 0;280 281 for (iit = iboxes.begin(); iit != iit_end; ++ iit, ++ i)282 {283 if (0 && ((i % 1000) == 0))284 {285 std::stringstream d; d << "found " << i << " objects";286 Ogre::LogManager().getSingleton().logMessage(d.str());287 }288 289 const AxisAlignedBox box = OgreTypeConverter::ConvertToOgre((*iit).second);290 291 //GtpVisibilityPreprocessor::ObjectContainer *entryObjects = new EntityContainer();292 EntityContainer *entryObjects = new EntityContainer();293 294 // find all objects that intersect the bounding box295 FindIntersectingObjects(box, *entryObjects);296 297 /*vector<Entity *>::const_iterator mit, mit_end = sceneObjects.end();298 299 for (mit = sceneObjects.begin(); mit != mit_end; ++ mit)300 {301 Entity *ent = *mit;302 // create new mesh instance303 OgreMeshInstance *omi = new OgreGetOrCreateOgreMeshInstance(ent);304 //omi->SetId((*iit).first);305 entryObjects->push_back(omi);306 }*/307 308 ObjectsIntersectable *entry =309 new ObjectsIntersectable(entryObjects);310 entry->SetId((*iit).first);311 //kdObj->mBbox = (*iit).second;312 objects.push_back(entry);313 }314 315 //std::stringstream d; d << "finished object intersection in " << GtpVisibilityPreprocessor::TimeDiff(startTime, GtpVisibilityPreprocessor::GetTime()) * 1e-3 << "secs";316 //Ogre::LogManager().logMessage(d.str());317 318 return true;319 }320 #else321 233 //------------------------------------------------------------------------- 322 234 template<typename T> … … 330 242 for (iit = iboxes.begin(); iit != iit_end; ++ iit) 331 243 { 244 const AxisAlignedBox box = 245 OgreTypeConverter::ConvertToOgre((*iit).second); 246 247 EntityContainer *entryObjects = new EntityContainer(); 248 249 // find all objects that intersect the bounding box 250 FindIntersectingObjects(box, *entryObjects); 251 252 EngineIntersectable *entry = 253 new EngineIntersectable(entryObjects); 254 entry->SetId((*iit).first); 255 256 objects.push_back(entry); 257 } 258 259 return true; 260 } 261 #else 262 //------------------------------------------------------------------------- 263 template<typename T> 264 bool PlatFormBoundingBoxConverter<T>::IdentifyObjects( 265 const GtpVisibilityPreprocessor::IndexedBoundingBoxContainer &iboxes, 266 GtpVisibilityPreprocessor::ObjectContainer &objects) const 267 { 268 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer:: 269 const_iterator iit, iit_end = iboxes.end(); 270 271 for (iit = iboxes.begin(); iit != iit_end; ++ iit) 272 { 332 273 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 333 274 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 334 275 335 276 Entity *ent = FindBestFittingObject(currentBox); 336 337 if (ent) 338 { 339 // create new mesh instance 340 OgreMeshInstance *omi = new OgreMeshInstance(ent); 341 omi->SetId((*iit).first); 342 objects.push_back(omi); 343 } 277 if (!ent) continue; 278 279 // create new mesh instance 280 OgreMeshInstance *omi = new OgreMeshInstance(ent); 281 omi->SetId((*iit).first); 282 objects.push_back(omi); 344 283 } 345 284 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h
r1593 r2066 10 10 Wrapper for Ogre object intances for use with the preprocessed view cells. 11 11 */ 12 #if 0 12 13 class __declspec(dllexport) OgreMeshInstance: public GtpVisibilityPreprocessor::Intersectable 13 14 { … … 56 57 }; 57 58 59 58 60 } // namespace Ogre 59 61 #endif 60 62 #endif // OgreMeshIntance
Note: See TracChangeset
for help on using the changeset viewer.