Changeset 2115 for GTP/trunk/Lib/Vis/OnlineCullingCHC
- Timestamp:
- 02/12/07 19:00:37 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h
r2113 r2115 39 39 }; 40 40 41 41 42 /** Class which converts preprocessor types to OGRE types 42 43 */ … … 121 122 122 123 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 124 123 125 // find the bbox which is closest to the current bbox 124 126 for (sit = sceneNodeList.begin(); sit != sit_end; ++ sit) … … 247 249 for (iit = iboxes.begin(); iit != iit_end; ++ iit) 248 250 { 251 const GtpVisibilityPreprocessor::AxisAlignedBox3 pbox = (*iit).second; 252 const int id = (*iit).first; 253 249 254 const AxisAlignedBox box = 250 OgreTypeConverter::ConvertToOgre( (*iit).second);251 252 EntityContainer *entryObjects = new EntityContainer();255 OgreTypeConverter::ConvertToOgre(pbox); 256 257 EntityContainer entryObjects; 253 258 254 259 // find all objects that intersect the bounding box 255 FindIntersectingObjects(box, *entryObjects); 256 260 FindIntersectingObjects(box, entryObjects); 261 262 // TODO: can actually just put single objects into pvs with same id, 263 // this can be sorted out later!! 264 #if 1 265 EntityContainer::const_iterator eit, eit_end = entryObjects.end(); 266 267 for (eit = entryObjects.begin(); eit != eit_end; ++ eit) 268 { 269 Entity *ent = *eit; 270 271 // warning: multiple ids possible 272 OgreMeshInstance *omi = new OgreMeshInstance(ent); 273 omi->SetId(id); 274 objects.push_back(omi); 275 } 276 #else 257 277 EngineIntersectable *entry = 258 278 new EngineIntersectable(entryObjects); 259 279 260 entry->SetId((*iit).first); 261 280 entry->SetId(id); 262 281 objects.push_back(entry); 282 #endif 263 283 } 264 284 265 285 return true; 266 286 } 287 267 288 #else 289 268 290 //------------------------------------------------------------------------- 269 291 template<typename T> -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreMeshInstance.h
r2069 r2115 49 49 const int maxTries); 50 50 51 int GetRandomEdgePoint(GtpVisibilityPreprocessor::Vector3 &point, 52 GtpVisibilityPreprocessor::Vector3 &normal); 53 51 54 ostream &Describe(ostream &s); 52 55 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
r2114 r2115 1325 1325 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1326 1326 BvhBoundingBoxConverter bconverter(this); 1327 GtpVisibilityPreprocessor::ObjectContainer dummys; 1327 1328 1328 // load the view cells and assigns the objects in the pvs to 1329 1329 // the scene objects using the bounding boxes 1330 1330 mViewCellsManager = 1331 1331 GtpVisibilityPreprocessor::ViewCellsManager:: 1332 LoadViewCells(filename, mObjects, dummys,false, &bconverter);1332 LoadViewCells(filename, mObjects, false, &bconverter); 1333 1333 1334 1334 return (mViewCellsManager != NULL); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r2114 r2115 1325 1325 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1326 1326 KdTreeBoundingBoxConverter bconverter(this); 1327 GtpVisibilityPreprocessor::ObjectContainer dummys; 1327 1328 1328 // load the view cells assigning the found objects to the pvss 1329 1329 mViewCellsManager = 1330 1330 GtpVisibilityPreprocessor::ViewCellsManager:: 1331 LoadViewCells(filename, mObjects, dummys,false, &bconverter);1331 LoadViewCells(filename, mObjects, false, &bconverter); 1332 1332 1333 1333 return (mViewCellsManager != NULL); … … 1344 1344 // representing unbounded space then 1345 1345 SetObjectsVisible(true); 1346 1346 1347 return; 1347 1348 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreMeshInstance.cpp
r2066 r2115 55 55 56 56 int OgreMeshInstance::GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, 57 GtpVisibilityPreprocessor::Vector3 &normal)57 GtpVisibilityPreprocessor::Vector3 &normal) 58 58 { 59 59 return 0; 60 60 } 61 61 62 int OgreMeshInstance::GetRandomEdgePoint(GtpVisibilityPreprocessor::Vector3 &point, 63 GtpVisibilityPreprocessor::Vector3 &normal) 64 { 65 return 0; 66 } 67 62 68 int OgreMeshInstance::GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, 63 69 GtpVisibilityPreprocessor::Vector3 &normal, … … 67 73 return 0; 68 74 } 69 75 70 76 ostream &OgreMeshInstance::Describe(ostream &s) 71 77 { -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2114 r2115 403 403 // show current view cell geometry 404 404 if (mCurrentViewCell && mCurrentViewCell->GetMesh()) 405 { 405 {/* 406 406 //const bool showSingleViewCell = true; 407 407 if (mViewCellsGeometryLoaded) … … 427 427 } 428 428 } 429 430 429 */ 431 430 ////////// 432 431 //-- set PVS of view cell visible 433 432 434 GtpVisibilityPreprocessor::ObjectPvsIterator pit = 435 mCurrentViewCell->GetPvs().GetIterator(); 433 GtpVisibilityPreprocessor::ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 436 434 437 435 while (pit.HasMoreEntries()) … … 440 438 GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject; 441 439 442 if (obj->Type() != 443 GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE) 444 continue; 445 446 EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 447 448 EntityContainer *entries = oi->GetItem(); 449 EntityContainer::const_iterator eit, eit_end = entries->end(); 450 451 for (eit = entries->begin(); eit != eit_end; ++ eit) 452 { 453 (*eit)->setUserAny(Any((int)0)); 454 } 455 } 456 457 pit = mCurrentViewCell->GetPvs().GetIterator(); 458 459 while (pit.HasMoreEntries()) 460 { 461 GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 462 GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject; 463 464 switch (obj->Type()) 465 { 466 case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 467 { 468 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 469 omi->GetEntity()->_updateRenderQueue(getRenderQueue()); 470 } 471 break; 472 473 case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 474 { 475 EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 476 477 EntityContainer *entries = oi->GetItem(); 478 EntityContainer::const_iterator eit, eit_end = entries->end(); 479 480 for (eit = entries->begin(); eit != eit_end; ++ eit) 481 { 482 483 Entity *ent = *eit; 484 Any newAny = ent->getUserAny(); 485 486 int flt = any_cast<int>(newAny); 487 488 if (any_cast<int>(newAny) == 0) 489 { 490 ent->setUserAny(Any((int)1)); 491 ent->_updateRenderQueue(getRenderQueue()); 492 } 493 494 } 495 } 496 break; 497 default: 498 break; 499 } 500 } 440 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 441 omi->GetEntity()->_updateRenderQueue(getRenderQueue()); 442 } 443 501 444 } 502 445 /* … … 1414 1357 GtpVisibilityPreprocessor::Intersectable *entry = *it; 1415 1358 1416 switch (entry->Type()) 1417 { 1418 case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 1419 { 1420 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 1421 omi->GetEntity()->setVisible(visible); 1422 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1423 } 1424 break; 1425 case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 1426 { 1427 EngineIntersectable *oi = static_cast<EngineIntersectable *>(entry); 1428 1429 EntityContainer *entries = oi->GetItem(); 1430 EntityContainer::const_iterator eit, 1431 eit_end = entries->end(); 1432 for (eit = entries->begin(); eit != eit_end; ++ eit) 1433 { 1434 Entity *ent = *eit; 1435 ent->setVisible(visible); 1436 } 1437 } 1438 break; 1439 default: 1440 break; 1441 } 1359 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 1360 omi->GetEntity()->setVisible(visible); 1361 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1442 1362 } 1443 1363 } … … 1459 1379 const bool finalizeViewCells = false; 1460 1380 1461 GtpVisibilityPreprocessor::ObjectContainer dummys;1462 1381 // load the view cells assigning the found objects to the pvss 1463 1382 mViewCellsManager = 1464 1383 GtpVisibilityPreprocessor::ViewCellsManager:: 1465 LoadViewCells(filename, mObjects, dummys,false, &bconverter);1384 LoadViewCells(filename, mObjects, false, &bconverter); 1466 1385 1467 1386 Ogre::LogManager::getSingleton().logMessage("******** view cells loaded *********"); … … 1508 1427 if (!obj) continue; 1509 1428 1510 switch (obj->Type()) 1511 { 1512 case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 1513 { 1514 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 1515 omi->GetEntity()->setVisible(load); 1516 } 1517 break; 1518 case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 1519 { 1520 EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 1521 1522 EntityContainer *entries = oi->GetItem(); 1523 1524 EntityContainer::const_iterator eit, eit_end = entries->end(); 1525 1526 for (eit = entries->begin(); eit != eit_end; ++ eit) 1527 { 1528 Entity *ent = *eit; 1529 ent->setVisible(load); 1530 } 1531 } 1532 break; 1533 default: 1534 LogManager::getSingleton().logMessage("error: should not come here"); 1535 break; 1536 } 1429 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 1430 omi->GetEntity()->setVisible(load); 1537 1431 } 1538 1432 } -
GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h
r2112 r2115 31 31 32 32 const std::vector<Ogre::Entity *> &GetObjects() const; 33 34 Ogre::Entity *CreateEntity(const std::string &name); 33 35 34 36 protected: -
GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp
r2112 r2115 57 57 58 58 59 #if TODO 60 61 Ogre::Entity *IVReader::createEntity(Ogre::SceneManager* sceneMgr, 62 std::string name, 63 ObjMeshData *mData, 64 Ogre::Vector3 *translation) 59 Ogre::Entity *ObjReader::CreateEntity(const std::string &name) 60 // ObjMeshData *mData, 61 // Ogre::Vector3 *translation) 65 62 { 66 63 using namespace Ogre; 64 Entity *entity; 67 65 66 68 67 std::string meshName = name.substr(name.find('/',0), name.length()) + "/Mesh"; 69 68 std::string entityName = name + "/Entity"; 70 69 71 Mesh* pMesh = NULL; 72 if ((pMesh = (Mesh *) MeshManager::getSingleton().getByName(meshName).getPointer()) == NULL) 70 MeshPtr mesh = MeshManager::getSingleton().createManual(meshName, "ObjGroup"); 71 SubMesh* submesh = mesh->createSubMesh(); 72 int nbVertices = 99992; 73 // We must create the vertex data, indicating how many vertices there will be 74 submesh->useSharedVertices = false; 75 submesh->vertexData = new VertexData(); 76 submesh->vertexData->vertexStart = 0; 77 submesh->vertexData->vertexCount = nbVertices; 78 79 static const unsigned short source = 0; 80 size_t offset = 0; 81 82 VertexDeclaration* declaration = HardwareBufferManager::getSingleton().createVertexDeclaration(); 83 84 offset += declaration->addElement(source,offset,VET_FLOAT3,VES_POSITION).getSize(); 85 // offset += declaration->addElement(source,offset,VET_FLOAT3,VES_NORMAL).getSize(); 86 // offset += declaration->addElement(source,offset,VET_FLOAT2,VES_TEXTURE_COORDINATES).getSize(); 87 88 89 int numVertices = 0; 90 91 HardwareVertexBufferSharedPtr vbuffer = 92 HardwareBufferManager::getSingleton().createVertexBuffer(declaration->getVertexSize(source), // size of one whole vertex 93 submesh->vertexData->vertexCount, // number of vertices 94 HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage 95 false); // no shadow buffer 96 97 98 // No we get access to the buffer to fill it. During so we record the bounding box. 99 AxisAlignedBox aabox; 100 101 float* vdata = static_cast<float*>(vbuffer->lock(HardwareBuffer::HBL_DISCARD)); 102 103 for (size_t i = 0; i < nbVertices; ++ i) 73 104 { 105 // Position 106 Vector3 position;// = 20.0f*positions[i]; 107 *vdata++ = position.x; 108 *vdata++ = position.y; 109 *vdata++ = position.z; 110 aabox.merge(position); 111 // Normal 112 Vector3 normal = position.normalisedCopy(); 113 *vdata++ = normal.x; 114 *vdata++ = normal.y; 115 *vdata++ = normal.z; 74 116 75 ObjMeshData *data = mData->expand(); 117 // Texture coordinate 118 Vector2 tcoordinate;// = tcoordinates[i]; 119 *vdata ++ = tcoordinate.x; 76 120 77 ObjManualMeshLoader *loader = new ObjManualMeshLoader(data);121 *vdata ++ = tcoordinate.y; 78 122 79 if (translation != NULL) *translation = data->boundingBox->getCenter();80 81 addMeshToList(meshName, loader);82 83 Mesh* pMesh = MeshManager::getSingleton().createManual(meshName, "IVGroup", loader).getPointer();84 85 pMesh->load();86 pMesh->touch();87 }88 else89 {90 if (translation != NULL)91 {92 *translation = meshList->getManualMeshLoader(meshName)->getBoundingBox()->getCenter();93 }94 123 } 95 124 96 Entity *pEntity = sceneMgr->createEntity(entityName, meshName);125 vbuffer->unlock(); 97 126 127 // We must indicate the bounding box 128 //mesh->_setBounds(aabox); 98 129 99 if (0) pEntity->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN);130 //mesh->_setBoundingSphereRadius((aabox.getMaximum()-aabox.getMinimum()).length()/2.0); 100 131 101 return pEntity; 132 mesh->load(); 133 134 // Create an entity with the mesh 135 //entity = mSceneManager->createEntity(meshName, entityName); 136 137 return entity; 102 138 } 103 104 105 #endif
Note: See TracChangeset
for help on using the changeset viewer.