Changeset 2625 for GTP/trunk/Lib/Vis
- Timestamp:
- 01/22/08 18:59:25 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 2 added
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh
r2540 r2625 15 15 SCENE_PATH=../data/vienna 16 16 17 #SCENE=arena-high-lods18 #SCENE_PATH=../data/Arena17 SCENE=arena-high-lods 18 SCENE_PATH=../data/Arena 19 19 20 20 … … 29 29 ####################################################### 30 30 31 METHOD=seq 31 NODES=4000 32 VIEWCELLS=5000 32 33 33 NODES=400034 VIEWCELLS=400035 34 USE_HEUR=false 36 35 OBJ_WEIGHT=20 36 37 37 SAMPLES=1000000 38 39 METHOD=$VIEWCELLS-viewcells.xml.gz 38 40 39 41 echo "$SCENE $METHOD" -
GTP/trunk/Lib/Vis/Preprocessing/scripts/gvs.env
r2596 r2625 126 126 ViewCells { 127 127 128 useKdPvs true 129 128 130 # samples used for view cell construction 129 131 # (after the sampling used for the hierarchy) -
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_arena
r2596 r2625 7 7 SCENE=../data/Arena/arena-high-lods.obj 8 8 VIEWCELLS=../data/Arena/arena-high-lods-57000-viewcells.xml.gz 9 VIEWCELLS=../data/Arena/arena-high-lods-10000-viewcells.xml.gz 10 VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz 11 9 12 10 13 #-rss_distributions=mutation+object_direction+spatial \ -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2620 r2625 208 208 void SetViewDirection(const Vector3 &vd) { mViewDirection = vd; } 209 209 210 Vector3 GetViewPoint() const { return mViewPoint; } 210 211 public: 211 212 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2615 r2625 35 35 mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 36 36 mProcessedViewCells(0), 37 mCurrentViewCell(NULL) 37 mCurrentViewCell(NULL), 38 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)) 38 39 { 39 40 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); … … 96 97 97 98 98 boolGvsPreprocessor::NextViewCell()99 ViewCell *GvsPreprocessor::NextViewCell() 99 100 { 100 101 //if (mViewCellsManager->GetNumViewCells() == mProcessedViewCells) … … 102 103 103 104 if (mProcessedViewCells == (int)mViewCells.size()) 104 return false; // no more view cells105 106 mCurrentViewCell= mViewCells[mProcessedViewCells];107 108 if (! mCurrentViewCell->GetMesh())109 mViewCellsManager->CreateMesh( mCurrentViewCell);110 111 mGvsStats.mViewCellId = mCurrentViewCell->GetId();112 113 Debug << "vc: " << mCurrentViewCell->GetId() << endl;105 return NULL; // no more view cells 106 107 ViewCell *vc = mViewCells[mProcessedViewCells]; 108 109 if (!vc->GetMesh()) 110 mViewCellsManager->CreateMesh(vc); 111 112 mGvsStats.mViewCellId = vc->GetId(); 113 114 Debug << "vc: " << vc->GetId() << endl; 114 115 115 116 ++ mProcessedViewCells; 116 117 117 return true;118 return vc; 118 119 } 119 120 … … 178 179 result = ray.mPvsContribution > 0; 179 180 } 180 else 181 else // original per view cell gvs 181 182 { 182 183 Intersectable *obj = ray.mTerminationObject; … … 187 188 mTrianglePvs.push_back(obj); 188 189 190 // if using kd pvs, exchange the triangle with the node in the pvs 189 191 if (mUseKdPvs) 190 192 { … … 194 196 { 195 197 node->Mail(); 196 mKdPvs.push_back(mKdTree->GetOrCreateKdIntersectable(node)); 198 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 199 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 200 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 197 201 } 198 202 } … … 478 482 // the point is chosen to be on the side closer to the original ray 479 483 if (Distance(pt1, pt3) < Distance(pt2, pt3)) 480 {481 484 newPoint = pt1 + eps * (pt1 - pt2); 482 }483 485 else 484 {485 486 newPoint = pt2 + eps * (pt2 - pt1); 486 }487 487 488 488 //cout << "passing point: " << newPoint << endl << endl; … … 874 874 KdLeaf *leaf = *lit; 875 875 876 // add to kdnode pvs 876 877 if (mUseKdPvs) 877 mKdPvs.push_back(mKdTree->GetOrCreateKdIntersectable(leaf)); 878 { 879 leaf->Mail(); 880 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(leaf); 881 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 882 883 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 884 } 878 885 879 886 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); … … 898 905 void GvsPreprocessor::PerViewCellComputation() 899 906 { 900 // hack: reset counter 901 ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 902 903 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 904 { 905 (*oit)->mCounter = 0; 906 } 907 908 909 while (NextViewCell())// && (dummy < 3)) 910 { 911 //++ dummy; 912 //if (mProcessedViewCells < 53) continue; 913 914 if (mUseKdPvs) 915 { 916 KdNode::NewMail(); 917 mKdPvs.clear(); 918 } 919 920 long startTime = GetTime(); 921 cout << "\n***********************\n" 922 << "processing view cell " << mProcessedViewCells 923 << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 924 925 // compute the pvs of the current view cell 926 ProcessViewCell(); 927 928 //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 929 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 930 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 931 932 if (!mUseKdPvs) 933 { 934 ObjectContainer objectPvs; 935 936 // optain object pvs 937 GetObjectPvs(objectPvs); 938 939 // add pvs 940 ObjectContainer::const_iterator it, it_end = objectPvs.end(); 941 942 for (it = objectPvs.begin(); it != it_end; ++ it) 943 { 944 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 945 } 946 947 cout << "triangle pvs of " << (int)mTrianglePvs.size() 948 << " was converted to object pvs of " << (int)objectPvs.size() << endl; 949 950 mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 951 } 952 else 953 { 954 // add pvs 955 ObjectContainer::const_iterator it, it_end = mKdPvs.end(); 956 957 for (it = mKdPvs.begin(); it != it_end; ++ it) 958 { 959 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 960 } 961 962 mGvsStats.mPerViewCellPvs = mKdPvs.size(); 963 } 964 965 //////// 966 //-- stats 967 968 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 969 970 971 mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 972 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 973 974 // timing 975 const long currentTime = GetTime(); 976 977 mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 978 mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 979 980 //lastTime = currentTime; 981 982 mGvsStats.Stop(); 983 mGvsStats.Print(mGvsStatsStream); 984 985 mTrianglePvs.clear(); 986 #if 0 987 if (GVS_DEBUG) 988 { 989 //VisualizeViewCell(mCurrentViewCell); 990 VisualizeViewCell(objectPvs); 991 CLEAR_CONTAINER(mVssRays); 992 } 993 cout << "finished" << endl; 994 995 if (mEvaluatePixelError || mExportVisibility) 996 { 997 StorePvs(objectPvs); 998 } 999 #endif 1000 } 1001 } 907 ViewCell *vc; 908 909 while (vc = NextViewCell()) 910 { 911 // hack: reset counters 912 ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 913 914 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 915 (*oit)->mCounter = 0; 916 917 ComputeViewCell(vc); 918 } 919 } 920 921 922 void GvsPreprocessor::PerViewCellComputation2() 923 { 924 ViewCell *vc; 925 926 while (1) 927 { 928 if (!mRendererWidget) 929 continue; 930 931 //ViewCell *vc = mViewCellsManager->GetViewCell(mCurrentViewPoint); 932 ViewCell *vc = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 933 934 //cout << "v " << mRendererWidget->GetViewPoint() << " "; 935 936 // no valid view cell or view cell already computed 937 if (!vc || !vc->GetPvs().Empty()) 938 continue; 939 940 //cout << "computing new view cell: " << vc->GetId() << endl; 941 942 // hack: reset counters 943 ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 944 945 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 946 (*oit)->mCounter = 0; 947 948 ComputeViewCell(vc); 949 ++ mProcessedViewCells; 950 } 951 } 952 953 1002 954 1003 955 … … 1155 1107 cout << "finished view cell construction" << endl; 1156 1108 } 1157 else if (0) 1109 #if 0 1110 else 1158 1111 { 1159 1112 //-- test successful view cells loading by exporting them again … … 1162 1115 mViewCellsManager->ExportViewCells("test.xml.gz", mViewCellsManager->GetExportPvs(), mObjects); 1163 1116 } 1117 #endif 1164 1118 1165 1119 mGvsStats.Stop(); … … 1168 1122 if (mPerViewCell) 1169 1123 { 1124 #if 0 1170 1125 // provide list of view cells to compute 1171 1126 CompileViewCellsList(); … … 1178 1133 ComputeRenderError(); 1179 1134 } 1135 #else 1136 PerViewCellComputation2(); 1137 1138 #endif 1180 1139 } 1181 1140 else … … 1272 1231 1273 1232 1274 } 1233 void GvsPreprocessor::ComputeViewCell(ViewCell *vc) 1234 { 1235 mCurrentViewCell = vc; 1236 1237 if (mUseKdPvs) 1238 { 1239 KdNode::NewMail(); 1240 //mKdPvs.clear(); 1241 } 1242 1243 long startTime = GetTime(); 1244 cout << "\n***********************\n" 1245 << "processing view cell " << mProcessedViewCells 1246 << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 1247 1248 // compute the pvs of the current view cell 1249 ProcessViewCell(); 1250 1251 //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 1252 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 1253 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 1254 1255 if (!mUseKdPvs) 1256 { 1257 ObjectContainer objectPvs; 1258 1259 // optain object pvs 1260 GetObjectPvs(objectPvs); 1261 1262 // add pvs 1263 ObjectContainer::const_iterator it, it_end = objectPvs.end(); 1264 1265 for (it = objectPvs.begin(); it != it_end; ++ it) 1266 { 1267 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 1268 } 1269 1270 cout << "triangle pvs of " << (int)mTrianglePvs.size() 1271 << " was converted to object pvs of " << (int)objectPvs.size() << endl; 1272 1273 mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 1274 } 1275 else 1276 { 1277 /*// add pvs 1278 ObjectContainer::const_iterator it, it_end = mKdPvs.end(); 1279 1280 for (it = mKdPvs.begin(); it != it_end; ++ it) 1281 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 1282 */ 1283 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();; 1284 } 1285 1286 1287 //////// 1288 //-- stats 1289 1290 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 1291 1292 1293 mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 1294 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 1295 1296 // timing 1297 const long currentTime = GetTime(); 1298 1299 mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 1300 mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 1301 1302 //lastTime = currentTime; 1303 1304 mGvsStats.Stop(); 1305 mGvsStats.Print(mGvsStatsStream); 1306 1307 mTrianglePvs.clear(); 1308 #if 0 1309 if (GVS_DEBUG) 1310 { 1311 //VisualizeViewCell(mCurrentViewCell); 1312 VisualizeViewCell(objectPvs); 1313 CLEAR_CONTAINER(mVssRays); 1314 } 1315 cout << "finished" << endl; 1316 1317 if (mEvaluatePixelError || mExportVisibility) 1318 { 1319 StorePvs(objectPvs); 1320 } 1321 #endif 1322 } 1323 1324 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2615 r2625 84 84 based on heuristical sampling of view space. 85 85 */ 86 class GvsPreprocessor : public Preprocessor { 86 class GvsPreprocessor : public Preprocessor 87 { 87 88 88 89 public: … … 190 191 Vector3 &newPoint) const; 191 192 192 boolNextViewCell();193 ViewCell *NextViewCell(); 193 194 194 195 void GlobalComputation(); 195 196 197 /** Loops over aall view cellls. 198 */ 196 199 void PerViewCellComputation(); 200 void PerViewCellComputation2(); 197 201 198 202 void VisualizeViewCells(); … … 205 209 void UpdatePvs(ViewCell *currentViewCell); 206 210 211 void ClearRayQueue(); 212 213 void CompileViewCellsList(); 214 215 void GetObjectPvs(ObjectContainer &trianglePvs) const; 216 217 bool HasContribution(VssRay &ray); 218 219 void IntersectWithViewCell(); 220 221 void DeterminePvsObjects(VssRayContainer &rays); 222 223 void StorePvs(const ObjectContainer &objectPvs); 224 225 void ComputeViewCell(ViewCell *vc); 226 /** Runs gvs on the current view cell. 227 */ 207 228 void ProcessViewCell(); 208 void ClearRayQueue(); 209 210 void CompileViewCellsList(); 211 212 void GetObjectPvs(ObjectContainer &trianglePvs) const; 213 214 bool HasContribution(VssRay &ray); 215 216 void IntersectWithViewCell(); 217 218 void DeterminePvsObjects(VssRayContainer &rays); 219 220 //virtual void ComputeRenderError(); 221 222 void StorePvs(const ObjectContainer &objectPvs); 229 223 230 224 231 … … 266 273 267 274 bool mEvaluatePixelError; 275 276 Vector3 mCurrentViewPoint; 268 277 }; 269 278 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2621 r2625 32 32 class GlobalLinesRenderer; 33 33 class SceneGraphLeaf; 34 class GlRendererWidget; 34 35 35 36 … … 258 259 259 260 GlRendererBuffer *renderer; 261 GlRendererWidget *mRendererWidget; 260 262 261 263 int mTotalSamples; -
GTP/trunk/Lib/Vis/Preprocessing/src/PvsDefinitions.h
r2617 r2625 8 8 //-- typedefs 9 9 //$$ 19.1. 2008 test for speed 10 #define USE_BIT_PVS10 //#define USE_BIT_PVS 11 11 12 12 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2622 r2625 800 800 { 801 801 float dist = Magnitude(mSceneGraph->GetBox().Diagonal()) * mTopDistance; 802 Vector3 pos = mViewPoint + dist*Vector3(0, 803 1, 804 0); 802 Vector3 pos = mViewPoint + dist * Vector3(0, 1, 0); 805 803 806 804 Vector3 target = mViewPoint; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2619 r2625 474 474 inline void disposeRays(VssRayContainer &rays, VssRayContainer *outRays) 475 475 { 476 // hack matt 477 return; 478 476 479 cout << "disposing samples ... "; 477 480 long startTime = GetTime(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2614 r2625 584 584 585 585 586 void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj); 587 586 588 587 589 ////////////////////////////////////////////////////////////////// … … 689 691 void EvaluateViewCellsStats(); 690 692 691 692 void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj);693 693 694 694 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r2609 r2625 117 117 Environment::GetSingleton()->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 118 118 119 119 120 ////////////////////// 120 121 //-- termination criteria for axis aligned split 122 121 123 Environment::GetSingleton()->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution", 122 124 mTermMaxRayContriForAxisAligned); -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r2615 r2625 305 305 306 306 if (evalPixelError && (importRandomViewCells || frames)) 307 307 { 308 308 QGLFormat f; 309 309 f.setStencil(true); 310 310 QGLFormat::setDefaultFormat(f); 311 311 312 // NOTE: render texture should be power of 2 and square 312 313 // renderer must be initialised 313 314 // $$matt 314 315 preprocessor->renderer = 315 316 317 318 319 320 316 new QtGlRendererBuffer(512, 512, 317 preprocessor->mSceneGraph, 318 preprocessor->mViewCellsManager, 319 preprocessor->mKdTree); 320 321 } 321 322 322 323 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) … … 343 344 rendererWidget = 344 345 new QtGlRendererWidget(preprocessor->mSceneGraph, 345 preprocessor->mViewCellsManager,346 preprocessor->mKdTree);346 preprocessor->mViewCellsManager, 347 preprocessor->mKdTree); 347 348 348 349 rendererWidget->Show(); 349 350 351 // hack matt 352 preprocessor->mRendererWidget = rendererWidget; 350 353 //rendererWidget->SetWindowTitle("Global Visualization"); 351 354
Note: See TracChangeset
for help on using the changeset viewer.