Changeset 2691 for GTP/trunk/Lib/Vis
- Timestamp:
- 05/21/08 01:18:40 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna
r2689 r2691 25 25 #PREFIX=../work/plots/atlanta2-rss9 26 26 27 DISTRIBUTIONS=mutation+object_direction+spatial 27 #DISTRIBUTIONS=mutation+object_direction+spatial 28 DISTRIBUTIONS=object_direction 28 29 #DISTRIBUTIONS=spatial 29 30 -
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
r2690 r2691 36 36 -gvs_initial_samples=16 \ 37 37 -gvs_max_viewcells=1 \ 38 -gvs_min_contribution= 1500 \38 -gvs_min_contribution=3000 \ 39 39 -gvs_per_viewcell=true \ 40 40 -gvs_stats=$LOG_PREFIX-gvsStats.log \ -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r2686 r2691 2372 2372 } 2373 2373 2374 2375 void AxisAlignedBox3::GetRandomEdgePoint(Vector3 &point, 2376 Vector3 &normal) 2377 { 2378 // get random edge 2379 const int idx = Random(12); 2380 Vector3 a, b; 2381 GetEdge(idx, &a, &b); 2382 2383 const float w = RandomValue(0.0f, 1.0f); 2384 2385 point = a * w + b * (1.0f - w); 2386 2387 // TODO 2388 normal = Vector3(0); 2389 } 2390 2391 2374 2392 Vector3 2375 2393 AxisAlignedBox3::GetUniformRandomSurfacePoint() const -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r2686 r2691 200 200 Vector3 GetRandomSurfacePoint() const; 201 201 Vector3 GetUniformRandomSurfacePoint() const; 202 203 void GetRandomEdgePoint(Vector3 &point, Vector3 &normal); 202 204 203 205 Vector3 GetPoint(const Vector3 &p) const { -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2690 r2691 45 45 GvsPreprocessor::GvsPreprocessor(): 46 46 Preprocessor(), 47 mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION),48 47 mProcessedViewCells(0), 49 48 mCurrentViewCell(NULL), 50 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)) 49 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)), 50 mOnlyRandomSampling(false) 51 //mOnlyRandomSampling(true) 51 52 { 52 53 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); … … 70 71 cout << "number of gvs samples per pass: " << mGvsSamplesPerPass << endl; 71 72 cout << "number of samples per pass: " << mSamplesPerPass << endl; 73 cout << "only random sampling: " << mOnlyRandomSampling << endl; 72 74 73 75 Debug << "Gvs preprocessor options" << endl; … … 81 83 Debug << "min contribution: " << mMinContribution << endl; 82 84 83 if (1) 84 mOnlyRandomSampling = false; 85 else 86 mOnlyRandomSampling = true; 85 mDistribution = new ViewCellBasedDistribution(*this, NULL); 87 86 88 87 mGvsStats.Reset(); … … 90 89 // hack: some generic statistical values that can be read 91 90 // by an application using the preprocessor 92 mGenericStats = 0;93 mGenericStats2= 0;91 for (int i = 0; i < 2; ++ i) 92 mGenericStats[i] = 0; 94 93 } 95 94 … … 97 96 GvsPreprocessor::~GvsPreprocessor() 98 97 { 98 delete mDistribution; 99 99 ClearRayQueue(); 100 100 } … … 177 177 { 178 178 ++ triObj->mCounter; 179 ++ mGenericStats 2;179 ++ mGenericStats[1]; 180 180 } 181 181 } … … 221 221 222 222 // counter < 2 => not accounted for yet 223 // test of triangle was accounted for yet 224 if (result = AddTriangleObject(obj)) 223 // test of triangle was accounted for yet 224 result = AddTriangleObject(obj); 225 226 if (mUseKdPvs && (1 || result)) 225 227 { 226 228 // exchange the triangle with the node in the pvs for kd pvs 227 if (mUseKdPvs) 229 KdNode *node = mKdTree->GetPvsNode(ray.mTermination); 230 231 //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj); 232 //if (!node) cerr << "e: " << obj->GetBox() << " " << ray.mTermination << endl; else 233 if (!node->Mailed()) 228 234 { 229 KdNode *node = mKdTree->GetPvsNode(ray.mTermination); 230 231 if (!node->Mailed()) 232 { 233 // add to pvs 234 node->Mail(); 235 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 236 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 237 238 if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 239 } 235 //cout<<"o"; 236 // add to pvs 237 node->Mail(); 238 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 239 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 240 241 if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 240 242 } 241 242 result = true;243 }244 else245 {246 result = false;247 243 } 248 244 } … … 257 253 return false; 258 254 259 // cout << "t";260 255 if (0 && GVS_DEBUG) 261 256 mVssRays.push_back(new VssRay(*vssRay)); … … 441 436 //const int numRandomRays = 0; 442 437 const int numRandomRays = 16 - (int)simpleRays.size(); 443 ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 444 445 GenerateRays(numRandomRays, vcStrat, simpleRays); 438 439 GenerateRays(numRandomRays, *mDistribution, simpleRays); 446 440 447 441 … … 607 601 608 602 609 int GvsPreprocessor::CastInitialSamples(const int numSamples, 610 const int sampleType) 603 int GvsPreprocessor::CastInitialSamples(int numSamples) 611 604 { 612 605 const long startTime = GetTime(); … … 615 608 SimpleRayContainer simpleRays; 616 609 617 ViewCellB asedDistribution vcStrat(*this, mCurrentViewCell);618 GenerateRays(numSamples, vcStrat, simpleRays);610 ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell); 611 GenerateRays(numSamples, *mDistribution, simpleRays); 619 612 620 613 //cout << "sr: " << simpleRays.size() << endl; … … 880 873 } 881 874 882 #if 1 875 883 876 void GvsPreprocessor::IntersectWithViewCell() 884 877 { 885 mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 886 AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 887 878 AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 879 880 int oldTrianglePvs = (int)mTrianglePvs.size(); 881 int newKdObj = 0; 882 883 // compute pvs kd nodes that intersect view cell 888 884 ObjectContainer kdobjects; 885 886 // find intersecting objects not in pvs (i.e., only unmailed) 889 887 mKdTree->CollectKdObjects(box, kdobjects); 890 888 889 ObjectContainer pvsKdObjects; 890 891 891 ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 892 892 893 893 for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 894 894 { 895 // add to kdnode pvs 896 KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 897 898 mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 899 //if (SHOW_QT_VISUALIZATION) mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 900 895 KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 896 901 897 myobjects.clear(); 902 mKdTree->CollectObjects (kdInt->GetItem(), myobjects);898 mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), myobjects); 903 899 904 900 // account for kd object pvs 901 bool addkdobj = false; 902 905 903 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 906 904 … … 908 906 { 909 907 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 910 911 CountObject(triObj); 912 913 // the triangle itself intersects 908 909 // test if the triangle itself intersects 914 910 if (box.Intersects(triObj->GetItem())) 915 { 916 if ((triObj->mCounter < ACCOUNTED_OBJECT)) 917 { 918 triObj->mCounter += ACCOUNTED_OBJECT; 919 920 mTrianglePvs.push_back(triObj); 921 mGenericStats = (int)mTrianglePvs.size(); 922 } 923 } 924 } 925 } 926 cout << "added " << mTrianglePvs.size() << " triangles (" << mCurrentViewCell->GetPvs().GetSize() << " objects) by intersection" << endl; 927 928 } 929 930 #else 931 932 void GvsPreprocessor::IntersectWithViewCell() 933 { 934 //Intersectable::NewMail(); 935 mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 936 AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 937 938 // compute pvs kd nodes that intersect view cell 939 ObjectContainer kdobjects; 940 mKdTree->CollectKdObjects(box, kdobjects); 941 942 ObjectContainer pvsKdObjects; 943 944 ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 945 946 for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 947 { 948 KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 949 950 myobjects.clear(); 951 mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 952 953 // account for kd object pvs 954 bool addkdobj = false; 955 956 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 957 958 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 959 { 960 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 961 // the triangle itself intersects => add object 962 if (box.Intersects(triObj->GetItem())) 963 { 964 if ((triObj->mCounter < ACCOUNTED_OBJECT)) 965 { 966 triObj->mCounter += ACCOUNTED_OBJECT; 967 968 mTrianglePvs.push_back(triObj); 969 mGenericStats = (int)mTrianglePvs.size(); 970 971 addkdobj = true; 972 } 973 } 911 addkdobj = AddTriangleObject(triObj); 974 912 } 975 913 976 // add node to object pvs 977 if (addkdobj) 978 pvsKdObjects.push_back(kdInt); 979 } 980 981 // new mail because objects were mailed for kd tree search 982 KdNode::NewMail(); 983 984 // now actually ADD new objects to object pvs 985 oit_end = pvsKdObjects.end(); 986 987 for (oit = pvsKdObjects.begin(); oit != oit_end; ++ oit) 988 { 989 KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 990 991 kdInt->Mail(); 992 993 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 994 if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 995 } 996 997 cout << "added " << mTrianglePvs.size() << " triangles (" << (int)pvsKdObjects.size() << " objects) by intersection" << endl; 998 } 999 #endif 914 // add node to kd pvs 915 if (1 && addkdobj) 916 { 917 ++ newKdObj; 918 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 919 //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 920 if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 921 } 922 } 923 924 cout << "added " << (int)mTrianglePvs.size() - oldTrianglePvs << " triangles (" << newKdObj << " objects) by intersection" << endl; 925 } 926 1000 927 1001 928 void GvsPreprocessor::PerViewCellComputation() … … 1009 936 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 1010 937 938 mDistribution->SetViewCell(mCurrentViewCell); 1011 939 ComputeViewCell(); 1012 940 } … … 1114 1042 { 1115 1043 mRayCaster->InitPass(); 1044 1116 1045 // Ray queue empty => 1117 1046 // cast a number of uniform samples to fill ray queue 1118 int newSamples = CastInitialSamples(mInitialSamples , mSamplingType);1047 int newSamples = CastInitialSamples(mInitialSamples); 1119 1048 1120 1049 if (!mOnlyRandomSampling) … … 1286 1215 void GvsPreprocessor::ComputeViewCell() 1287 1216 { 1217 mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 1218 1288 1219 KdNode::NewMail(); 1289 1220 … … 1293 1224 << "computing view cell " << mProcessedViewCells 1294 1225 << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 1295 1296 // compute the pvs of the current view cell 1297 // compute object that directly intersect view cell 1298 //IntersectWithViewCell(); 1226 cout << "bb: " << mCurrentViewCell->GetBox() << endl; 1299 1227 1300 1228 mGvsStats.mPerViewCellSamples = 0; … … 1303 1231 int passSamples = 0; 1304 1232 1305 mGenericStats = 0;1306 mGenericStats2= 0;1233 for (int i = 0; i < 0; ++ i) 1234 mGenericStats[i] = 0; 1307 1235 1308 1236 while (1) 1309 1237 { 1310 int oldPvsSize = 0;//mCurrentViewCell->GetPvs().GetSize();1238 int oldPvsSize = mCurrentViewCell->GetPvs().GetSize(); 1311 1239 1312 1240 mRayCaster->InitPass(); … … 1314 1242 // Ray queue empty => 1315 1243 // cast a number of uniform samples to fill ray queue 1316 int newSamples = CastInitialSamples(mInitialSamples , mSamplingType);1244 int newSamples = CastInitialSamples(mInitialSamples); 1317 1245 1318 1246 if (!mOnlyRandomSampling) … … 1330 1258 if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs); 1331 1259 1260 //const bool convertPerPass = true; 1332 1261 const bool convertPerPass = false; 1333 1262 … … 1364 1293 } 1365 1294 1366 // finally add objects that directly intersect theview cell1367 //IntersectWithViewCell();1295 // at last compute objects that directly intersect view cell 1296 IntersectWithViewCell(); 1368 1297 1369 1298 … … 1407 1336 mGvsStats.mPvsCost = 0; // todo objectPvs.EvalPvsCost(); 1408 1337 } 1409 else 1410 { 1338 else if (0) 1339 { 1340 //KdNode::NewMail(); 1341 1342 // compute pvs kd nodes that intersect view cell 1343 ObjectContainer mykdobjects; 1344 1345 // extract kd pvs 1346 ObjectContainer::const_iterator it, it_end = mTrianglePvs.end(); 1347 1348 for (it = mTrianglePvs.begin(); it != it_end; ++ it) 1349 { 1350 Intersectable *obj = *it; 1351 // find intersecting objects not yet in pvs (i.e., only unmailed) 1352 mKdTree->CollectKdObjects(obj->GetBox(), mykdobjects); 1353 } 1354 1355 // add pvs 1356 it_end = mykdobjects.end(); 1357 1358 for (it = mykdobjects.begin(); it != it_end; ++ it) 1359 { 1360 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 1361 } 1362 1363 cout << "added " << (int)mykdobjects.size() << " new objects " << endl; 1364 1411 1365 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 1412 1366 mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost(); … … 1471 1425 1472 1426 mTrianglePvs.push_back(triObj); 1473 mGenericStats = (int)mTrianglePvs.size();1427 mGenericStats[0] = (int)mTrianglePvs.size(); 1474 1428 return true; 1475 1429 } … … 1478 1432 } 1479 1433 1480 } 1434 1435 1436 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2690 r2691 13 13 class TriangleIntersectable; 14 14 class KdIntersectable; 15 15 class ViewCellBasedDistribution; 16 16 17 17 /** View space partition statistics. … … 128 128 /** Generates the rays starting the adaptive visibility sampling process. 129 129 */ 130 int CastInitialSamples( const int numSamples, const int sampleType);130 int CastInitialSamples(int numSamples); 131 131 132 132 /** Uses the information gained from the ray for doing adaptive border sampling. … … 256 256 257 257 RayQueue mRayQueue; 258 int mSamplingType;258 ViewCellBasedDistribution *mDistribution; 259 259 260 260 //AxisAlignedBox3 mViewSpaceBox; -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2690 r2691 1077 1077 KdInterior *interior = (KdInterior *)node; 1078 1078 1079 if ( box.Max()[interior->mAxis] > interior->mPosition )1079 if ( box.Max()[interior->mAxis] >= interior->mPosition ) 1080 1080 nodeStack.push(interior->mFront); 1081 1081 1082 if (box.Min()[interior->mAxis] < interior->mPosition)1082 if (box.Min()[interior->mAxis] <= interior->mPosition) 1083 1083 nodeStack.push(interior->mBack); 1084 1084 } … … 1155 1155 1156 1156 1157 void KdTree::CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) 1157 void KdTree::CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) const 1158 1158 { 1159 1159 stack<KdNode *> nodeStack; … … 1778 1778 } 1779 1779 1780 1781 KdNode * 1782 KdTree::GetPvsNodeCheck(const Vector3 &point, Intersectable *obj) const 1783 { 1784 KdNode *node = mRoot; 1785 1786 while (node->mPvsTermination == 0 ) { 1787 KdInterior *inter = (KdInterior *)node; 1788 if (point[inter->mAxis] < inter->mPosition) 1789 node = inter->mBack; 1790 else 1791 node = inter->mFront; 1792 } 1793 1794 ObjectContainer objects; 1795 CollectObjectsWithDublicates(node, objects); 1796 1797 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1798 1799 bool found = false; 1800 for (oit = objects.begin(); oit != oit_end; ++ oit) 1801 { 1802 if ((*oit)->GetId() == obj->GetId()) 1803 found = true; 1804 } 1805 1806 if (!found) return NULL; 1807 1808 return node; 1809 } 1810 1780 1811 KdNode * 1781 1812 KdTree::GetNode(const Vector3 &point, -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2690 r2691 386 386 GetPvsNode(const Vector3 &point) const; 387 387 388 KdNode * 389 GetPvsNodeCheck(const Vector3 &point, Intersectable *obj) const; 388 390 389 391 void … … 406 408 /** Collects objects with dublicates (no mailing going on) 407 409 */ 408 void CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) ;410 void CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) const; 409 411 void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 410 412 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r2614 r2691 241 241 242 242 virtual int CastRay(Ray &ray); 243 244 245 243 virtual int CastSimpleRay(const SimpleRay &ray) { return 0;} 244 virtual int CastSimpleRay(const SimpleRay &ray, int IndexRay) 245 { return 0; } 246 246 247 247 virtual bool IsConvex() const { return mMesh->mIsConvex; } -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r2672 r2691 296 296 for (tit = triangles.begin(); tit != tit_end; ++ tit) 297 297 { 298 // test if the triangle is valid (i.e., not degenerated) 299 if (!TriangleValid(*tit)) 300 continue; 301 302 TriangleIntersectable *obj = new TriangleIntersectable(*tit); 303 root->mGeometry.push_back(obj); 298 // test if the triangle is valid (i.e., not degenerated) 299 // matt: removed this option so tris can be mapped to intel 300 if (0 && !TriangleValid(*tit)) 301 continue; 302 303 TriangleIntersectable *obj = new TriangleIntersectable(*tit); 304 root->mGeometry.push_back(obj); 304 305 } 305 306 } … … 311 312 } 312 313 313 //cout << "\n**** " << root->mGeometry.size() << " " << " lines: " << line << endl;314 cout << "\n*********\n***** " << root->mGeometry.size() << " " << " lines: " << line << endl; 314 315 if (loadMeshes) 315 316 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2687 r2691 1016 1016 case SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION: 1017 1017 return new ReverseObjectBasedDistribution(*this); 1018 case SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION: 1019 return new ViewCellBorderBasedDistribution(*this); 1020 case SamplingStrategy::VIEWSPACE_BORDER_BASED_DISTRIBUTION: 1021 return new ViewSpaceBorderBasedDistribution(*this); 1018 //case SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION: 1019 // return new ViewCellBorderBasedDistribution(*this); 1022 1020 case SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION: 1023 1021 return new ReverseViewSpaceBorderBasedDistribution(*this); -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2678 r2691 273 273 RayCaster *mRayCaster; 274 274 275 int mGenericStats; 276 int mGenericStats2; 275 int mGenericStats[2]; 277 276 278 277 void ScheduleUpdateDynamicObjects(); -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2614 r2691 296 296 Vector3 origin, direction; 297 297 298 ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells();298 //ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells(); 299 299 300 300 Vector3 point; 301 301 Vector3 normal, normal2; 302 302 303 const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f);303 //const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f); 304 304 const int objIdx = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 305 305 306 306 Intersectable *object = mPreprocessor.mObjects[objIdx]; 307 ViewCell *viewCell = viewCells[vcIdx];307 ViewCell *viewCell = mViewCell;//viewCells[vcIdx]; 308 308 309 309 object->GetRandomSurfacePoint(point, normal); … … 843 843 Vector3 origin, direction; 844 844 845 ViewCellContainer &viewCells =846 mPreprocessor.mViewCellsManager->GetViewCells();847 848 845 Vector3 point; 849 846 Vector3 normal; 850 847 851 //Vector normalObj;852 // float r[1];853 // sHalton.GetNext(1, r);854 // const int objIdx = (int)(r[0] * (float)mPreprocessor.mObjects.size() - 1.0f);855 // Intersectable *object = mPreprocessor.mObjects[objIdx];856 // object->GetRandomSurfacePoint(point, normal);857 // cout << "obj: " << objIdx << endl;858 859 848 float r[2]; 849 //for (int i=0; i < 2; i++) 850 // r[i] = RandomValue(0, 1); 851 860 852 sHalton.GetNext(2, r); 861 853 … … 869 861 870 862 // get point on view cell surface 871 mViewCell->GetRandomSurfacePoint(origin, normal); 863 if (0) 864 { 865 //mViewCell->GetRandomEdgePoint(origin, normal); 866 mViewCell->GetRandomSurfacePoint(origin, normal); 867 868 // move a little bit back to avoid piercing through walls 869 // that bound the view cell 870 if (0) origin -= 0.01f * normal; 871 } 872 else 873 origin = mViewCell->GetBox().GetUniformRandomSurfacePoint(); 872 874 873 875 //direction = point - origin; 874 875 // move a little bit back to avoid piercing through walls876 // that bound the view cell877 origin -= 0.01f * normal;878 876 879 877 // $$ jb the pdf is yet not correct for all sampling methods! -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r2575 r2691 194 194 public: 195 195 ViewSpaceBorderBasedDistribution(Preprocessor &preprocessor): 196 SamplingStrategy(preprocessor){ 196 SamplingStrategy(preprocessor) 197 { 197 198 mType = VIEWSPACE_BORDER_BASED_DISTRIBUTION; 198 199 } … … 220 221 { 221 222 public: 222 ViewCellBorderBasedDistribution(Preprocessor &preprocessor): 223 SamplingStrategy(preprocessor) {224 mType = VIEWCELL_BORDER_BASED_DISTRIBUTION;225 226 223 ViewCellBorderBasedDistribution(Preprocessor &preprocessor, ViewCell *viewCell) 224 : SamplingStrategy(preprocessor), mViewCell(viewCell) 225 { 226 mType = VIEWCELL_BORDER_BASED_DISTRIBUTION; 227 } 227 228 228 229 private: 229 230 virtual bool GenerateSample(SimpleRay &ray); 231 232 ViewCell *mViewCell; 230 233 }; 231 234 … … 268 271 } 269 272 270 private: 271 272 virtual bool GenerateSample(SimpleRay &ray); 273 void SetViewCell(ViewCell *vc) { mViewCell = vc; } 274 275 private: 276 277 virtual bool GenerateSample(SimpleRay &ray); 273 278 274 279 ViewCell *mViewCell;
Note: See TracChangeset
for help on using the changeset viewer.