- Timestamp:
- 05/02/06 10:26:43 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 3 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/IVReader/src/ivmanualmeshloader.cpp
r187 r870 146 146 147 147 AxisAlignedBox bb(data->boundingBox->getMinimum() - translation, data->boundingBox->getMaximum() - translation); 148 //AxisAlignedBox bb(data->boundingBox->getMinimum(), data->boundingBox->getMaximum()); 148 149 pMesh->_setBounds(bb); 149 150 Real radius = data->boundingBox->getMinimum().length(); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h
r868 r870 123 123 /** Finds object corresponding to this bounding box in the scene. 124 124 */ 125 MovableObject*FindCorrespondingObject(const AxisAlignedBox &box);125 Entity *FindCorrespondingObject(const AxisAlignedBox &box); 126 126 127 127 /** Identifies objects in the scene and gives them unique ids that … … 129 129 */ 130 130 void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects); 131 132 /** Loads / unloads pvs of the view cell to set the visibility in the scene. 133 */ 134 void applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, const bool load); 135 136 /** updates pvs in current frame. 137 */ 138 void updatePvs(Camera *cam); 139 140 /** Sets all objects invisible. 141 */ 142 void SetObjectsVisible(const bool visible); 131 143 132 144 /// the interface to the scene hierarchy. … … 183 195 bool mViewCellsLoaded; 184 196 GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 197 198 /** Used to assign Ogre meshes to view cell entries. 199 */ 200 GtpVisibilityPreprocessor::ObjectContainer mObjects; 201 202 GtpVisibilityPreprocessor::ViewCell *mOldViewCell; 203 GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell; 204 205 /** If view cells are used. 206 */ 207 bool mUseViewCells; 185 208 }; 186 209 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
r868 r870 15 15 #include <OgreConfigFile.h> 16 16 #include "OgreTypeConverter.h" 17 #include "OgreMeshInstance.h" 18 #include "common.h" 17 19 18 20 // normal terrain rendering … … 42 44 mExecuteVertexProgramForAllPasses(true), 43 45 mIsHierarchicalCulling(false), 44 mViewCellsLoaded(false) 46 mViewCellsLoaded(false), 47 mCurrentViewCell(NULL), 48 mOldViewCell(NULL), 49 mUseViewCells(false) 45 50 { 46 51 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 85 90 { 86 91 OGRE_DELETE(mHierarchyInterface); 92 CLEAR_CONTAINER(mObjects); 87 93 } 88 94 //----------------------------------------------------------------------- … … 127 133 } 128 134 // add bounding boxes of rendered objects 135 if (0) 129 136 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 130 137 { … … 145 152 { 146 153 // render the leaf nodes 147 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) && 148 (*it)->getAttachedObject(0)->getMovableType() == "Entity") 154 if ((*it)->numAttachedObjects() && 155 !(*it)->numChildren() && 156 ((*it)->getAttachedObject(0)->getMovableType() == "Entity") && 157 (*it)->getAttachedObject(0)->isVisible()) 149 158 { 150 159 getRenderQueue()->addRenderable((*it)); 151 std::stringstream d;152 d << "here 223 " << (*it)->getAttachedObject(0)->getWorldBoundingBox();153 Ogre::LogManager::getSingleton().logMessage(d.str());154 160 } 155 156 // addbounding boxes instead of node itself157 //(*it)->_addBoundingBoxToQueue(getRenderQueue());158 161 } 159 162 // add renderables itself … … 247 250 return; 248 251 } 252 249 253 250 254 //-- show visible scene nodes and octree bounding boxes from last frame … … 265 269 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 266 270 } 271 267 272 // only shadow casters will be rendered in shadow texture pass 268 273 if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 274 275 276 //-- apply view cell pvs 277 updatePvs(cam); 269 278 } 270 279 … … 311 320 else //-- the hierarchical culling algorithm 312 321 { 313 // this is also called in TerrainSceneManager: really 314 // nexessary? 322 // this is also called in TerrainSceneManager: really necessary? 315 323 //mDestRenderSystem -> setLightingEnabled(false); 316 324 … … 498 506 if (!mViewCellsLoaded) 499 507 { 500 LoadViewCells(""); 501 mViewCellsLoaded = true; 502 } 503 504 return true; 505 } 506 508 LoadViewCells(static_cast<const char *>(val)); 509 mViewCellsLoaded = true; 510 } 511 512 return true; 513 } 514 if (key == "UseViewCells") 515 { 516 if (mViewCellsLoaded) 517 { 518 mUseViewCells = *static_cast<const bool *>(val); 519 520 if (mUseViewCells) 521 { 522 SetObjectsVisible(false); 523 mCurrentViewCell = mOldViewCell = NULL; 524 } 525 else 526 { 527 SetObjectsVisible(true); 528 } 529 } 530 531 return true; 532 } 507 533 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 508 534 setOption(key, val) || OctreeSceneManager::setOption(key, val); … … 876 902 } 877 903 } 878 //----------------------------------------------------------------------- 879 MovableObject *VisibilityOctreeSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 904 905 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box) 906 { 907 const float eps = 1e-3f; 908 const Vector3 veps(eps, eps, eps); 909 Vector3 max = box.getMaximum(); 910 Vector3 min = box.getMinimum(); 911 912 return AxisAlignedBox(min - veps, max + veps); 913 } 914 //----------------------------------------------------------------------- 915 Entity *VisibilityOctreeSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 880 916 { 881 917 list<SceneNode *> sceneNodeList; 882 883 findNodesIn(box, sceneNodeList, NULL); 884 std::stringstream d; 885 d << "\n*******************"; 886 Ogre::LogManager::getSingleton().logMessage(d.str()); 918 AxisAlignedBox mybox = EnlargeBox(box); 919 //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000)); 920 921 // get intersecting scene nodes 922 findNodesIn(mybox, sceneNodeList, NULL); 923 924 887 925 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 888 926 889 float overlap = GtpVisibilityPreprocessor::Limits::Small; 890 891 892 d << "here23 " << box; 893 Ogre::LogManager::getSingleton().logMessage(d.str()); 894 895 MovableObject *bestFittingObj = NULL; 927 float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small; 928 929 Entity *bestFittingObj = NULL; 896 930 float bestFit = overlap; 897 931 … … 908 942 while (oit.hasMoreElements()) 909 943 { 910 MovableObject *mo = oit.getNext(); 911 const AxisAlignedBox bbox = mo->getWorldBoundingBox(true); 912 913 overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(box), 914 OgreTypeConverter::ConvertFromOgre(bbox)); 944 MovableObject *mo = oit.getNext(); 945 946 // we are only interested in scene entities 947 if (mo->getMovableType() != "Entity") 948 { 949 continue; 950 } 951 952 const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox()); 953 954 955 // compute measure how much aabbs overlap 956 overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox), 957 OgreTypeConverter::ConvertFromOgre(bbox)); 958 915 959 if (overlap > bestFit) 916 960 { 917 961 bestFit = overlap; 918 bestFittingObj = mo; 919 d << "new bestfit " << bestFit << endl;Ogre::LogManager::getSingleton().logMessage(d.str()); 920 // perfect fit => object found 962 963 bestFittingObj = static_cast<Entity *>(mo); 964 965 // perfect fit => object found, eraly exit 921 966 if (overlap >= thresh) 922 { 923 std::stringstream d2; 924 925 d2 << "!!best fit " << bestFittingObj->getWorldBoundingBox(true); 926 Ogre::LogManager::getSingleton().logMessage(d2.str()); 927 return bestFittingObj; 928 } 967 return bestFittingObj; 929 968 } 930 969 } 931 970 } 932 971 933 std::stringstream d2; 934 if (bestFittingObj) 935 { 936 d2 << "best fit " << bestFittingObj->getWorldBoundingBox(true); 937 } 938 else 939 { 940 d2 << "warning, no best fitting objects"; 941 } 942 943 Ogre::LogManager::getSingleton().logMessage(d2.str()); 972 if (0) 973 { 974 std::stringstream d; 975 if (bestFittingObj) 976 d << "best fit: " << bestFit; 977 else 978 d << "warning, objects do not fit\n" << box; 979 980 Ogre::LogManager::getSingleton().logMessage(d.str()); 981 } 944 982 945 983 return bestFittingObj; … … 948 986 void VisibilityOctreeSceneManager::LoadViewCells(string filename) 949 987 { 950 GtpVisibilityPreprocessor::ObjectContainer objects; 988 // the objects are set to invisible a prioriy 989 SetObjectsVisible(false); 990 951 991 // identify the corresponding Ogre meshes using the bounding boxes 952 IdentifyObjects( objects);992 IdentifyObjects(mObjects); 953 993 954 994 // load the view cells assigning the found objects to the pvss 955 //mViewCellsManager->LoadViewCells(filename, &objects); 995 mViewCellsManager = 996 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects); 997 998 std::stringstream d; 999 d << "view cells loaded" << endl; 1000 Ogre::LogManager::getSingleton().logMessage(d.str()); 956 1001 } 957 1002 //----------------------------------------------------------------------- … … 970 1015 const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 971 1016 const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 972 973 MovableObject *mo = FindCorrespondingObject(currentBox); 974 975 //objects.push_back(mi); 976 } 977 } 978 1017 1018 Entity *ent = FindCorrespondingObject(currentBox); 1019 1020 // create new mesh instance 1021 OgreMeshInstance *omi = new OgreMeshInstance(ent); 1022 omi->SetId((*iit).first); 1023 objects.push_back(omi); 1024 } 1025 } 979 1026 //------------------------------------------------------------------------- 980 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String& filename) 981 { 982 /// Set up the options 1027 void VisibilityOctreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1028 const bool load) 1029 { GtpVisibilityPreprocessor::Debug << "here9 " << endl; 1030 // NOTE: should not happen, rather apply view cell representing unbounded space then 1031 if (!vc) return; 1032 1033 GtpVisibilityPreprocessor::ObjectPvsMap::const_iterator oit, 1034 oit_end = vc->GetPvs().mEntries.end(); 1035 1036 //-- PVS of view cell 1037 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1038 { 1039 if (!(*oit).first) continue; 1040 1041 OgreMeshInstance *omi = dynamic_cast<OgreMeshInstance*>((*oit).first); 1042 omi->GetMesh()->setVisible(load); 1043 GtpVisibilityPreprocessor::Debug << "here45 " << omi->GetId() << endl; 1044 } 1045 } 1046 //------------------------------------------------------------------------- 1047 void VisibilityOctreeSceneManager::SetObjectsVisible(const bool visible) 1048 { 1049 // for OGRE 1.2 1050 #ifdef OGRE12 1051 MovableObjectIterator mit = getMovableObjectIterator("Entity"); 1052 #else 1053 EntityIterator eit = getEntityIterator(); 1054 1055 // set all objects to invisible (initially); 1056 while (eit.hasMoreElements()) 1057 { 1058 Entity *ent = eit.getNext(); 1059 ent->setVisible(visible); 1060 } 1061 1062 #endif 1063 } 1064 //------------------------------------------------------------------------- 1065 void VisibilityOctreeSceneManager::loadVisibilityConfig(const String &filename) 1066 { 1067 // TODO matt 1068 // Set up the options 983 1069 ConfigFile config; 984 1070 String val; … … 1000 1086 } 1001 1087 } 1088 //------------------------------------------------------------------------- 1089 void VisibilityOctreeSceneManager::updatePvs(Camera *cam) 1090 { 1091 Ogre::LogManager::getSingleton().logMessage("here196"); 1092 if (mViewCellsLoaded && mUseViewCells) 1093 { 1094 GtpVisibilityPreprocessor::ViewCell *vc = 1095 mViewCellsManager->GetViewCell(OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition())); 1096 1097 std::stringstream d; d << "pos " << cam->getDerivedPosition() << "vc: " << vc; 1098 Ogre::LogManager::getSingleton().logMessage(d.str()); 1099 1100 // view cell changed => unload old objects and load new objects 1101 if (vc != mCurrentViewCell) 1102 { 1103 //-- unload old pvs 1104 if (mOldViewCell) 1105 { 1106 const bool load = false; 1107 1108 applyViewCellPvs(mOldViewCell, load); 1109 Ogre::LogManager::getSingleton().logMessage("here16"); 1110 } 1111 1112 mOldViewCell = mCurrentViewCell; 1113 1114 //-- load new pvs 1115 mCurrentViewCell = vc; 1116 const bool load = true; 1117 1118 applyViewCellPvs(mCurrentViewCell, load); 1119 Ogre::LogManager::getSingleton().logMessage("here106"); 1120 } 1121 } 1122 } 1123 1002 1124 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp
r657 r870 49 49 { 50 50 visEnv = new GtpVisibility::VisibilityEnvironment(); 51 visEnv->LoadEnvironment("vienna_simple.env"); 51 52 visManager = new GtpVisibility::VisibilityManager(visEnv); 52 53 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityEnvironment.h
r254 r870 1 1 #ifndef _VisibilityEnvironment_H__ 2 2 #define _VisibilityEnvironment_H__ 3 4 #include <string> 3 5 4 6 namespace GtpVisibility { … … 10 12 public: 11 13 VisibilityEnvironment(); 12 14 ~VisibilityEnvironment(); 13 15 /** Different types of occlusion culling algorithms 14 16 */ … … 20 22 /** Loads an environment from disk. 21 23 */ 22 void LoadEnvironment( );24 void LoadEnvironment(std::string filename); 23 25 }; 24 26 } // namespace GtpVisibility -
GTP/trunk/Lib/Vis/OnlineCullingCHC/scripts/GtpVisibility.vcproj
r827 r870 63 63 Name="VCCLCompilerTool" 64 64 OptimizeForWindowsApplication="TRUE" 65 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\OgreMain\include" "65 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\OgreMain\include";..\..\Preprocessing\src" 66 66 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 67 67 RuntimeLibrary="2" -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/VisibilityEnvironment.cpp
r100 r870 1 1 #include "VisibilityEnvironment.h" 2 #include "common.h" 3 #include "Environment.h" 4 2 5 3 6 namespace GtpVisibility { … … 6 9 VisibilityEnvironment::VisibilityEnvironment() 7 10 { 11 // load debug stream 12 GtpVisibilityPreprocessor::Debug.open("debug.log"); 13 14 } 15 VisibilityEnvironment::~VisibilityEnvironment() 16 { 17 // load debug stream 18 DEL_PTR(GtpVisibilityPreprocessor::environment); 19 8 20 } 9 21 //----------------------------------------------------------------------- 10 void VisibilityEnvironment::LoadEnvironment( )22 void VisibilityEnvironment::LoadEnvironment(string filename) 11 23 { 24 // todo matt: 25 GtpVisibilityPreprocessor::environment = new GtpVisibilityPreprocessor::Environment; 26 27 char argc = 2; 28 char *argv[2]; 29 argv[0] = ""; 30 31 char fname[200]; 32 sprintf(fname, "%s", filename.c_str()); 33 argv[1] = fname; 34 35 GtpVisibilityPreprocessor::Debug << "filename: " << argv[1] << endl; 36 37 GtpVisibilityPreprocessor::environment->Parse(argc, argv, false); 38 //MeshKdTree::ParseEnvironment(); 12 39 } 13 40 41 14 42 } // namespace GtpVisibility -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r863 r870 142 142 between 0 (no overlap) and 1 (same box). 143 143 */ 144 friend inline float FactorOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &);144 friend inline float RatioOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 145 145 146 146 /** Includes returns true if a includes b (completely) … … 540 540 } 541 541 542 inline float FactorOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 543 { 544 const AxisAlignedBox3 isect = Intersect(box1, box2); 545 return isect.GetVolume() / box1.GetVolume(); 542 inline float RatioOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 543 { 544 // return ratio of intersection to union 545 const AxisAlignedBox3 bisect = Intersect(box1, box2); 546 const AxisAlignedBox3 bunion = Union(box1, box2); 547 548 return bisect.GetVolume() / bunion.GetVolume(); 546 549 } 547 550 -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r860 r870 49 49 50 50 virtual AxisAlignedBox3 GetBox() = 0; 51 virtual int CastRay( Ray &ray) = 0;51 virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0; 52 52 53 53 virtual bool IsConvex() = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r863 r870 69 69 Mesh::Preprocess() 70 70 { 71 71 Cleanup(); 72 72 73 73 ComputeBoundingBox(); 74 74 75 /** true if it is a watertight convex mesh */ 76 mIsConvex = false; 77 78 if (mFaces.size() > MeshKdTree::mTermMinCost) { 79 mKdTree = new MeshKdTree(this); 80 MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 81 for (int i = 0; i < mFaces.size(); i++) 82 root->mFaces.push_back(i); 83 cout<<"KD"; 84 mKdTree->Construct(); 85 86 if (mKdTree->GetRoot()->IsLeaf()) { 87 cout<<"d"; 88 delete mKdTree; 89 mKdTree = NULL; 90 } 91 } 75 /** true if it is a watertight convex mesh 76 */ 77 mIsConvex = false; 78 79 if (mFaces.size() > MeshKdTree::mTermMinCost) 80 { 81 mKdTree = new MeshKdTree(this); 82 MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 83 84 for (int i = 0; i < mFaces.size(); i++) 85 root->mFaces.push_back(i); 86 87 cout<<"KD"; 88 mKdTree->Construct(); 89 90 if (mKdTree->GetRoot()->IsLeaf()) 91 { 92 cout<<"d"; 93 delete mKdTree; 94 mKdTree = NULL; 95 } 96 } 92 97 } 93 98 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r863 r870 22 22 23 23 /// vertex index container 24 typedef std::vector<short> VertexIndexContainer;25 24 //typedef std::vector<short> VertexIndexContainer; 25 typedef std::vector<int> VertexIndexContainer; 26 26 27 27 /** Patch used as an element of the mesh */ … … 58 58 /// default vertex container for Mesh 59 59 typedef vector<Vector3> VertexContainer; 60 61 /// vertex index container62 typedef vector<short> VertexIndexContainer;63 60 64 61 /// default patch container for Mesh -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r863 r870 374 374 Debug << "view cell type: VspBsp" << endl; 375 375 376 mVspBspTree = new VspBspTree( );376 mVspBspTree = new VspBspTree(environment); 377 377 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 378 378 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r863 r870 2033 2033 stream << "active=\"" << viewCell->IsActive() << "\" "; 2034 2034 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 2035 stream << "pvs=\""; 2036 2037 //-- NOTE: do not export pvss for interior view cells because 2038 // they can be completely reconstructed from the leaf pvss 2039 if (0) 2040 ExportPvs(viewCell, stream); 2035 2041 2036 //-- NOTE: do not export pvss for interior view cells because2037 // they can be compeletely reconstructed from the leaf pvss2038 if (0)2039 {2040 stream << "pvs=\"";2041 ExportPvs(viewCell, stream);2042 }2043 2044 2042 stream << "\" >" << endl; 2045 2043 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r863 r870 4683 4683 ViewCellsManager *vm = NULL; 4684 4684 4685 Debug << "vc filename: " << filename << endl; 4686 4685 4687 if (parser.ParseFile(filename, &vm, objects)) 4686 4688 { … … 4699 4701 else 4700 4702 { 4701 Debug << " failed loading view cells" << endl;4703 Debug << "Error: loading view cells failed!" << endl; 4702 4704 DEL_PTR(vm); 4703 4705 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r860 r870 362 362 virtual void FinalizeViewCells(const bool createMesh); 363 363 364 365 /** Loads view cells from file. The view cells manager is created with366 respect to the loaded view cells.367 368 @returns the view cells manager if loading was successful, false otherwise369 */370 static ViewCellsManager *LoadViewCells(const string filename,371 ObjectContainer *objects);372 373 364 /** Evaluates statistics values on view cells. 374 365 */ … … 432 423 ); 433 424 434 AxisAlignedBox3 435 GetViewCellBox(ViewCell *vc); 425 /** Returns bounding box of a view cell. 426 */ 427 AxisAlignedBox3 GetViewCellBox(ViewCell *vc); 436 428 437 429 /** Exports bounding boxes of objects to file. … … 442 434 */ 443 435 bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 436 437 438 /** Loads view cells from file. The view cells manager is created with 439 respect to the loaded view cells. 440 441 @returns the view cells manager if loading was successful, false otherwise 442 */ 443 static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 444 444 445 445 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r863 r870 117 117 // go one up in the tree 118 118 if (mCurrentBspNode->GetParent()) 119 { cout<< "]";119 { Debug << "]"; 120 120 mCurrentBspNode = mCurrentBspNode->GetParent(); 121 121 } … … 127 127 // go one up in the tree 128 128 if (mCurrentViewCell->GetParent()) 129 { cout<< "]";129 { Debug << "]"; 130 130 mCurrentViewCell = mCurrentViewCell->GetParent(); 131 131 } … … 160 160 const char *ptr = attrValue.LocalForm(); 161 161 162 //-- the view cells manager is created here 162 163 CreateViewCellsManager(ptr); 163 164 } … … 171 172 if (element == "Interior") 172 173 { 173 cout<< "[";174 Debug << "["; 174 175 StartBspInterior(attributes); 175 176 } … … 177 178 if (element == "Leaf") 178 179 { 179 cout<< "l";180 Debug << "l"; 180 181 Debug << "leaf" << endl; 181 182 StartBspLeaf(attributes); … … 189 190 StrX lname(name); 190 191 string element(lname.LocalForm()); 191 192 192 193 // decides the used view cell hierarchy 193 194 if (element == "ViewCells") 194 195 { 195 cout<< "parsing view cells" << endl;196 Debug << "parsing view cells" << endl; 196 197 mParseViewCells = true; 197 198 } … … 199 200 if (element == "Hierarchy") 200 201 { 201 cout<< "parsing spatial hierarchy" << endl;202 Debug << "parsing spatial hierarchy" << endl; 202 203 mParseViewCells = false; 203 204 StartHierarchy(attributes); … … 207 208 if (element == "ViewSpaceBox") 208 209 { 209 cout<< "b";210 Debug << "b"; 210 211 StartViewSpaceBox(attributes); 211 212 } … … 234 235 if (element == "Interior") 235 236 { 236 cout<< "[";237 Debug << "["; 237 238 StartViewCellInterior(attributes); 238 239 } … … 240 241 if (element == "Leaf") 241 242 { 242 cout<< "l";243 Debug << "l"; 243 244 StartViewCellLeaf(attributes); 244 245 } … … 306 307 // to sumof pdfs, i.e. its relative visibility 307 308 // temporarily set to 1.0f 308 viewCell->GetPvs().AddSample(obj, 1.0f); 309 viewCell->GetPvs().AddSample(obj, 1.0f); 309 310 } 310 311 else … … 559 560 mVspBspTree = new VspBspTree(); 560 561 //mCurrentBspNode = mVspBspTree->GetRoot(); 561 562 562 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 563 563 … … 573 573 else 574 574 { 575 cerr <<"Wrong view cells type " << name << "!!!"<< endl;575 cerr << "Wrong view cells type: " << name << endl; 576 576 exit(1); 577 577 } … … 700 700 catch (const XMLException& e) 701 701 { 702 XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n"702 XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 703 703 << StrX(e.getMessage()) 704 704 << "\n" << XERCES_STD_QUALIFIER endl; 705 errorCount = 1;706 return false;705 errorCount = 1; 706 return false; 707 707 } 708 708 … … 710 710 // Print out the stats that we collected and time taken 711 711 if (!errorCount) { 712 XERCES_STD_QUALIFIER cout<< filename << ": " << duration << " ms ("712 XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 713 713 << handler.GetElementCount() << " elems, " 714 714 << handler.GetAttrCount() << " attrs, " -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r863 r870 55 55 56 56 57 VspBspTree::VspBspTree( ):57 VspBspTree::VspBspTree(Environment *env): 58 58 mRoot(NULL), 59 59 mUseAreaForPvs(false), … … 67 67 { 68 68 bool randomize = false; 69 env ironment->GetBoolValue("VspBspTree.Construction.randomize", randomize);69 env->GetBoolValue("VspBspTree.Construction.randomize", randomize); 70 70 if (randomize) 71 71 Randomize(); // initialise random generator for heuristics 72 72 73 73 //-- termination criteria for autopartition 74 env ironment->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth);75 env ironment->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs);76 env ironment->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays);77 env ironment->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability);78 env ironment->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution);79 env ironment->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength);80 env ironment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio);81 env ironment->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance);82 env ironment->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells);74 env->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 75 env->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 76 env->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays); 77 env->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability); 78 env->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution); 79 env->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 80 env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 81 env->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance); 82 env->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 83 83 84 84 //-- max cost ratio for early tree termination 85 env ironment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio);86 87 env ironment->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio);88 env ironment->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance);85 env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 86 87 env->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 88 env->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 89 89 90 90 // HACK//mTermMinPolygons = 25; 91 91 92 92 //-- factors for bsp tree split plane heuristics 93 env ironment->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor);94 env ironment->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi);93 env->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 94 env->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 95 95 96 96 97 97 //-- partition criteria 98 env ironment->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates);99 env ironment->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates);100 env ironment->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy);101 102 env ironment->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon);103 env ironment->GetIntValue("VspBspTree.maxTests", mMaxTests);98 env->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 99 env->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 100 env->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy); 101 102 env->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon); 103 env->GetIntValue("VspBspTree.maxTests", mMaxTests); 104 104 105 105 // if only the driving axis is used for axis aligned split 106 env ironment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis);106 env->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 107 107 108 108 //-- termination criteria for axis aligned split 109 env ironment->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",109 env->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution", 110 110 mTermMaxRayContriForAxisAligned); 111 env ironment->GetIntValue("VspBspTree.Termination.AxisAligned.minRays",111 env->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 112 112 mTermMinRaysForAxisAligned); 113 113 114 //env ironment->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory);115 env ironment->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory);116 117 env ironment->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight);118 env ironment->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable);119 120 env ironment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics);121 env ironment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue);122 env ironment->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis);123 env ironment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis);124 env ironment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType);125 126 env ironment->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed);114 //env->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 115 env->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 116 117 env->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 118 env->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 119 120 env->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 121 env->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 122 env->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 123 env->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 124 env->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 125 126 env->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); 127 127 128 128 char subdivisionStatsLog[100]; 129 env ironment->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog);129 env->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 130 130 mSubdivisionStats.open(subdivisionStatsLog); 131 131 132 env ironment->GetFloatValue("VspBspTree.Construction.minBand", mMinBand);133 env ironment->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand);134 env ironment->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost);132 env->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 133 env->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 134 env->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost); 135 135 136 136 //-- debug output … … 199 199 } 200 200 201 VspBspTree::VspBspTree(): 202 mRoot(NULL), 203 mUseAreaForPvs(false), 204 mCostNormalizer(Limits::Small), 205 mViewCellsManager(NULL), 206 mOutOfBoundsCell(NULL), 207 mStoreRays(false), 208 mRenderCostWeight(0.5), 209 mUseRandomAxis(false), 210 mTimeStamp(1), 211 mEpsilon(1e-6f) 212 { 213 } 201 214 202 215 BspViewCell *VspBspTree::GetOutOfBoundsCell() -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r863 r870 26 26 class Beam; 27 27 class ViewCellsTree; 28 28 class Environment; 29 29 30 30 /** … … 199 199 VspBspTree(); 200 200 201 202 /** Constructor creating an empty tree. Loads parameters 203 from an environment file. 204 */ 205 VspBspTree(Environment *env); 206 201 207 /** Default destructor. 202 208 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r863 r870 219 219 if (mLoadPolygonsAsMeshes) 220 220 { 221 222 /*vector<VertexIndexContainer>::const_iterator it,223 it_end = mCurrentVertexIndices.end();224 225 for (it = mCurrentVertexIndices.begin(); it != it_end; ++ it)226 {227 // only one face per mesh228 Mesh *mesh = new Mesh();229 230 VertexIndexContainer vc;231 232 // add vertices233 for (int i = 0; i < (int)(*it).size(); ++ i)234 {235 mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]);236 vc.push_back(i);237 }238 239 mesh->mFaces.push_back(new Face(vc));240 241 // NOTE: should rather be written into trafo of mesh instance242 ApplyTransformations(mTransformations, mesh);243 244 mesh->Preprocess();245 // make an instance of this mesh246 MeshInstance *mi = new MeshInstance(mesh);247 mCurrentNode->mGeometry.push_back(mi);248 249 }*/250 251 221 //if (mCurrentMesh->mFaces.empty()) cout << "error!" << endl; 252 222
Note: See TracChangeset
for help on using the changeset viewer.