Changeset 1623 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/13/06 10:49:29 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h
r1621 r1623 66 66 } 67 67 68 //------------------------------------------------------------------------- 69 inline static AxisAlignedBox ScaleBox(const AxisAlignedBox &box) 70 { 71 const float scale = 1.5f; 72 Vector3 max = box.getMaximum(); 73 Vector3 min = box.getMinimum(); 74 Vector3 size = max - min; 75 Vector3 newSize = size*(scale*0.5f); 76 Vector3 center = 0.5f * (min + max); 77 78 Vector3 min = center - newSize; 79 Vector3 max = center + newSize; 80 81 return AxisAlignedBox(min, max); 82 } 68 83 /** find object which fits best to this bounding box 69 84 */ … … 89 104 { 90 105 list<SceneNode *> sceneNodeList; 106 AxisAlignedBox3 enlargedBox = 91 107 AxisAlignedBox mybox = EnlargeBox(box); 92 108 … … 154 170 } 155 171 //----------------------------------------------------------------------- 156 template<typename T>172 /*template<typename T> 157 173 void PlatFormBoundingBoxConverter<T>::FindIntersectingObjects(const AxisAlignedBox &box, 158 174 EntityContainer &objects) const … … 161 177 162 178 // get intersecting scene nodes (= candidates) 163 //AxisAlignedBox mybox = EnlargeBox(box);164 //mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL);165 mSceneMgr->findNodesIn(box, sceneNodeList, NULL);179 AxisAlignedBox mybox = EnlargeBox(box); 180 mSceneMgr->findNodesIn(mybox, sceneNodeList, NULL); 181 //mSceneMgr->findNodesIn(box, sceneNodeList, NULL); 166 182 167 183 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 168 184 169 //GtpVisibilityPreprocessor::AxisAlignedBoxnodeBox = OgreTypeConverter::ConvertFromOgre(mybox);170 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box);185 GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(mybox); 186 //GtpVisibilityPreprocessor::AxisAlignedBox3 nodeBox = OgreTypeConverter::ConvertFromOgre(box); 171 187 172 188 // find really intersecting objects … … 201 217 } 202 218 } 203 219 */ 220 template<typename T> 221 void PlatFormBoundingBoxConverter<T>::FindIntersectingObjects(const AxisAlignedBox &box, 222 EntityContainer &objects) const 223 {//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 objects 237 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 entities 247 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 = Overlap(nodeBox, 256 OgreTypeConverter::ConvertFromOgre(bbox) 257 ); 258 //,0.00001); 259 260 if (overlaps) 261 { 262 objects.push_back(static_cast<Entity *>(mo)); 263 } 264 } 265 } 266 } 204 267 #if USE_KD_PVS 205 268 //------------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r1622 r1623 703 703 SetObjectsVisible(!mUseViewCells); 704 704 705 /*MovableObjectIterator movit = getMovableObjectIterator("Entity");705 MovableObjectIterator movit = getMovableObjectIterator("Entity"); 706 706 while (movit.hasMoreElements()) 707 707 { 708 708 Entity *ent = static_cast<Entity *>(movit.getNext()); 709 709 ent->setVisible(!mUseViewCells); 710 } */710 } 711 711 } 712 712 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1622 r1623 94 94 , mBoundingBoxConverter(bconverter) 95 95 , mHierarchyManager(NULL) 96 , nViewCells(0) 96 97 { 97 98 std::stable_sort(mObjects->begin(), mObjects->end(), ilt); … … 205 206 // go one up in the tree 206 207 if (mCurrentBspNode->GetParent()) 207 { cout<< "]";208 { Debug << "]"; 208 209 mCurrentBspNode = mCurrentBspNode->GetParent(); 209 210 } … … 215 216 // go one up in the tree 216 217 if (mCurrentBvhNode->GetParent()) 217 { cout<< "]";218 { Debug << "]"; 218 219 mCurrentBvhNode = mCurrentBvhNode->GetParent(); 219 220 } … … 225 226 // go one up in the tree 226 227 if (mCurrentOspNode->mParent) 227 { cout<< "]";228 { Debug << "]"; 228 229 mCurrentOspNode = mCurrentOspNode->mParent; 229 230 } … … 235 236 // go one up in the tree 236 237 if (mCurrentVspNode->GetParent()) 237 { cout<< "]";238 { Debug << "]"; 238 239 mCurrentVspNode = mCurrentVspNode->GetParent(); 239 240 } … … 245 246 // go one up in the tree 246 247 if (mCurrentViewCell->GetParent()) 247 { cout<< "]";248 { Debug << "]"; 248 249 mCurrentViewCell = mCurrentViewCell->GetParent(); 249 250 } … … 260 261 { 261 262 // sort view cells to help associating view cells according to their id 262 //stable_sort(mViewCells.begin(), mViewCells.end(), vlt);263 stable_sort(mViewCells.begin(), mViewCells.end(), vlt); 263 264 264 265 // not parsing view cells anymore … … 288 289 if (element == "Interior") 289 290 { 290 cout<< "[";291 Debug << "["; 291 292 StartBspInterior(attributes); 292 293 } … … 294 295 if (element == "Leaf") 295 296 { 296 cout<< "l";297 Debug << "l"; 297 298 StartBspLeaf(attributes); 298 299 } … … 305 306 if (element == "Interior") 306 307 { 307 cout<< "[";308 Debug << "["; 308 309 StartVspInterior(attributes); 309 310 } 310 311 if (element == "Leaf") 311 312 { 312 cout<< "l";313 Debug << "l"; 313 314 StartVspLeaf(attributes); 314 315 } … … 321 322 if (element == "Interior") 322 323 { 323 cout<< "[";324 Debug << "["; 324 325 StartOspInterior(attributes); 325 326 } … … 327 328 if (element == "Leaf") 328 329 { 329 cout<< "l";330 Debug << "l"; 330 331 StartOspLeaf(attributes); 331 332 } … … 338 339 if (element == "Interior") 339 340 { 340 cout<< "[";341 Debug << "["; 341 342 StartBvhInterior(attributes); 342 343 } … … 344 345 if (element == "Leaf") 345 346 { 346 cout<< "l";347 Debug << "l"; 347 348 StartBvhLeaf(attributes); 348 349 } … … 391 392 AttributeList& attributes) 392 393 { 394 if (((nViewCells ++) % 1000) == 0) 395 Debug << "\n " << nViewCells << " view cells parsed" << endl; 393 396 // interiors + leaves interpreted view cells else 394 397 if (element == "Interior") 395 398 { 396 cout<< "[";399 Debug << "["; 397 400 StartViewCell(attributes, false); 398 401 } … … 400 403 if (element == "Leaf") 401 404 { 402 cout<< "l";405 Debug << "l"; 403 406 StartViewCell(attributes, true); 404 407 } … … 414 417 if (element == "ViewCells") 415 418 { 416 cout<< "\nparsing view cells" << endl;419 Debug << "\nparsing view cells" << endl; 417 420 418 421 mCurrentState = PARSE_VIEWCELLS; … … 425 428 if (element == "ViewSpaceHierarchy") 426 429 { 427 cout<< "\nparsing view space hierarchy" << endl;430 Debug << "\nparsing view space hierarchy" << endl; 428 431 mCurrentState = PARSE_VIEWSPACE_HIERARCHY; 429 432 StartViewSpaceHierarchy(attributes); … … 433 436 if (element == "ObjectSpaceHierarchy") 434 437 { 435 cout<< "\nparsing object space hierarchy" << endl;438 Debug << "\nparsing object space hierarchy" << endl; 436 439 mCurrentState = PARSE_OBJECTSPACE_HIERARCHY; 437 440 StartObjectSpaceHierarchy(attributes); … … 441 444 if (element == "BoundingBox") 442 445 { 443 // cout<< "b";446 // Debug << "b"; 444 447 StartBoundingBox(attributes); 445 448 } … … 506 509 else 507 510 { 508 cout<< "error: object with id " << objId << " does not exist" << endl;511 Debug << "error: object with id " << objId << " does not exist" << endl; 509 512 } 510 513 } … … 529 532 if (strcmp(ptr, "bsp") == 0) 530 533 { 531 cout<< "\nview space hierarchy: Bsp" << endl;534 Debug << "\nview space hierarchy: Bsp" << endl; 532 535 mViewSpaceHierarchyType = BSP; 533 536 } 534 537 else if (strcmp(ptr, "vsp") == 0) 535 538 { 536 cout<< "\nview space hierarchy: Vsp" << endl;539 Debug << "\nview space hierarchy: Vsp" << endl; 537 540 mViewSpaceHierarchyType = VSP; 538 541 } … … 573 576 if (strcmp(ptr, "osp") == 0) 574 577 { 575 cout<< "\nobject space hierarchy: Osp" << endl;578 Debug << "\nobject space hierarchy: Osp" << endl; 576 579 577 580 mHierarchyManager = … … 597 600 else if (strcmp(ptr, "bvh") == 0) 598 601 { 599 cout<< "\nobject space hierarchy: Bvh" << endl;602 Debug << "\nobject space hierarchy: Bvh" << endl; 600 603 mObjectSpaceHierarchyType = BVH; 601 604 mHierarchyManager = … … 639 642 AxisAlignedBox3 box(bmin, bmax); 640 643 mIBoundingBoxes.push_back(IndexedBoundingBox(id, box)); 641 // cout<< "bbox: " << box << endl;644 //Debug << "bbox: " << box << endl; 642 645 } 643 646 … … 683 686 { 684 687 // TODO: get view cell with specified id 685 ViewCellsMap::iterator vit = mViewCells.find(viewCellId); 686 BspViewCell *viewCell = dynamic_cast<BspViewCell *>((*vit).second); 687 688 ViewCellInterior dummyVc; 689 dummyVc.SetId(viewCellId); 690 691 ViewCellContainer::iterator vit = 692 lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 693 694 //ViewCellsMap::iterator vit = mViewCells.find(viewCellId); 695 // BspViewCell *viewCell = dynamic_cast<BspViewCell *>((*vit).second); 696 BspViewCell *viewCell = dynamic_cast<BspViewCell *>(*vit); 688 697 if (viewCell->GetId() == viewCellId) 689 698 { … … 694 703 else 695 704 { 696 cout<< "error: view cell does not exist" << endl;705 Debug << "error: view cell does not exist" << endl; 697 706 } 698 707 } … … 744 753 745 754 ViewCell *ViewCellsParseHandlers::GetOrCreateViewCell(const int id, const bool isLeaf) 746 { 755 {/* 747 756 ViewCellsMap::iterator vit = mViewCells.find(id); 748 757 … … 766 775 mViewCells[id] = vc; 767 776 return vc; 768 } 777 }*/ 778 return NULL; 769 779 } 770 780 … … 776 786 const int len = attributes.getLength(); 777 787 float mergeCost; 778 ObjectPvs pvs; 788 //ObjectPvs pvs; 789 790 //viewCell = GetOrCreateViewCell(id, isLeaf); 791 792 if (isLeaf) 793 { 794 viewCell = new ViewCellLeaf(); 795 } 796 else 797 { 798 viewCell = new ViewCellInterior(); 799 } 779 800 780 801 for (int i = 0; i < len; ++ i) … … 790 811 791 812 // create new view cell, otherwise use reference. 792 viewCell = GetOrCreateViewCell(id, isLeaf); 793 813 //viewCell = GetOrCreateViewCell(id, isLeaf); 814 viewCell->SetId(id); 815 794 816 if (mCurrentViewCell) // replace front or (if not NULL) back child 795 817 { … … 815 837 // note: id must come before pvs! 816 838 // otherwise view cell is undefined 817 StartViewCellPvs(pvs, ptr); 839 840 StartViewCellPvs(viewCell->GetPvs(), ptr); // assume that view cell comes before pvs 841 //StartViewCellPvs(pvs, ptr); 818 842 } 819 843 else if (attrName == "active") … … 840 864 841 865 viewCell->SetMergeCost(mergeCost); 842 viewCell->SetPvs(pvs); 866 //viewCell->SetPvs(pvs); 867 mViewCells.push_back(viewCell); 843 868 } 844 869 … … 848 873 if (mViewSpaceHierarchyType == BSP) 849 874 { 850 cout<< "hierarchy type: Bsp" << endl;875 Debug << "hierarchy type: Bsp" << endl; 851 876 mVspBspTree = new VspBspTree(); 852 877 … … 854 879 mVspBspTree->mBoundingBox = mViewSpaceBox; 855 880 856 ViewCellsMap::iterator vit, vit_end = mViewCells.end(); 857 881 //ViewCellsMap::iterator vit, vit_end = mViewCells.end(); 882 ViewCellContainer::iterator vit, vit_end = mViewCells.end(); 883 884 Debug << "exchanging boxes" << endl; 885 int i = 0; 858 886 // remove view cells and exchange them with the 859 887 // view cells specialized for the current hierarchy node type 860 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 861 { 862 ViewCell *vc = (*vit).second; 888 for (vit = mViewCells.begin(); vit != vit_end; ++ vit, ++ i) 889 { 890 if ((i % 1000) == 0) 891 Debug << "\n exchanged " << i << " boxes" << endl; 892 ViewCell *vc = (*vit); 863 893 864 894 if (!vc->IsLeaf()) // exchange only leaves … … 868 898 869 899 bspVc->SetId(vc->GetId()); 900 //bspVc->GetPvs().reserve(vc->GetPvs().size()); 870 901 bspVc->SetPvs(vc->GetPvs()); 871 902 … … 880 911 881 912 DEL_PTR(vc); 882 (*vit).second = bspVc; 883 } 913 // (*vit).second = bspVc; 914 (*vit) = bspVc; 915 } 916 Debug << "finished" << endl; 884 917 } 885 918 else if (mViewSpaceHierarchyType == VSP) 886 919 { 887 cout<< "hierarchy type: Vsp" << endl;920 Debug << "hierarchy type: Vsp" << endl; 888 921 mVspTree = new VspTree(); 889 922 … … 891 924 mVspTree->mBoundingBox = mViewSpaceBox; 892 925 893 ViewCellsMap::iterator vit, vit_end = mViewCells.end();894 926 // ViewCellsMap::iterator vit, vit_end = mViewCells.end(); 927 ViewCellContainer::iterator vit, vit_end = mViewCells.end(); 895 928 // reset view cells using the current node type 896 929 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 897 930 { 898 ViewCell *vc = (*vit).second;899 931 //ViewCell *vc = (*vit).second; 932 ViewCell *vc = (*vit); 900 933 VspViewCell *vspVc = new VspViewCell(); 901 934 vspVc->SetPvs(vc->GetPvs()); … … 914 947 } 915 948 916 DEL_PTR(vc); 917 (*vit).second = vspVc; 949 //DEL_PTR(vc); 950 //(*vit).second = vspVc; 951 (*vit) = vspVc; 918 952 } 919 953 … … 1007 1041 { 1008 1042 // TODO: get view cell with specified id 1009 /*ViewCellInterior dummyVc;1043 ViewCellInterior dummyVc; 1010 1044 dummyVc.SetId(viewCellId); 1011 1045 1012 1046 ViewCellContainer::iterator vit = 1013 1047 lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 1014 */1015 ViewCellsMap::iterator vit = mViewCells.find(viewCellId);1048 1049 //ViewCellsMap::iterator vit = mViewCells.find(viewCellId); 1016 1050 if (vit == mViewCells.end()) 1017 cout<< "error: view cell " << viewCellId << " not found" << endl;1051 Debug << "error: view cell " << viewCellId << " not found" << endl; 1018 1052 1019 VspViewCell *viewCell = dynamic_cast<VspViewCell *>((*vit).second); 1053 //VspViewCell *viewCell = dynamic_cast<VspViewCell *>((*vit).second); 1054 VspViewCell *viewCell = dynamic_cast<VspViewCell *>(*vit); 1020 1055 1021 1056 if (viewCell->GetId() == viewCellId) … … 1026 1061 else 1027 1062 { 1028 cout<< "error: view cell does not exist" << endl;1063 Debug << "error: view cell does not exist" << endl; 1029 1064 } 1030 1065 } … … 1237 1272 else 1238 1273 { 1239 cout<< "error: object with id " << objId << " does not exist" << endl;1274 Debug << "error: object with id " << objId << " does not exist" << endl; 1240 1275 } 1241 1276 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r1551 r1623 95 95 ViewCell *mViewCellRoot; 96 96 97 typedef map<int, ViewCell *> ViewCellsMap; 98 ViewCellsMap mViewCells; 97 // typedef map<int, ViewCell *> ViewCellsMap; 98 //ViewCellsMap mViewCells; 99 ViewCellContainer mViewCells; 99 100 100 101 ViewCellsManager *mViewCellsManager; … … 118 119 int mViewSpaceHierarchyType; 119 120 int mObjectSpaceHierarchyType; 120 121 int nViewCells; 121 122 //////////////////////////////// 122 123
Note: See TracChangeset
for help on using the changeset viewer.