- Timestamp:
- 11/08/05 19:00:49 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r389 r390 15 15 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 16 16 environment->GetIntValue("ViewCells.PostProcessing.samples", mPostProcessSamples); 17 environment->GetIntValue("BspTree. visualizationSamples", mVisualizationSamples);17 environment->GetIntValue("BspTree.Visualization.samples", mVisualizationSamples); 18 18 19 19 mKdPvsDepth = 100; … … 728 728 } 729 729 // save rays for post processing 730 else if (( int)mSampleRays.size() < mPostProcessSamples) ||731 (((int)mSampleRays.size() < mVisualizationSamples))730 else if (((int)mSampleRays.size() < mPostProcessSamples) || 731 ((int)mSampleRays.size() < mVisualizationSamples)) 732 732 { 733 733 mSampleRays.push_back(new Ray(ray)); … … 747 747 for (int i = 0; i < limit; ++i) 748 748 { 749 Ray *ray = mSample sRays[i];749 Ray *ray = mSampleRays[i]; 750 750 751 751 // traverse leaves stored in the rays and compare and merge consecutive … … 842 842 //-- some rays for output 843 843 const int raysOut = min((int)mSampleRays.size(), mVisualizationSamples); 844 cout << "visualization using " << mVisualizationSamples << " samples" << endl; 844 845 vector<Ray *> vcRays[leafOut]; 845 846 … … 882 883 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 883 884 885 //exporter->SetWireframe(); 886 exporter->SetFilled(); 887 888 Material m;//= RandomMaterial(); 889 m.mDiffuseColor = RgbColor(0, 1, 0); 890 exporter->SetForcedMaterial(m); 891 892 if (vc->GetMesh()) 893 exporter->ExportViewCell(vc); 894 else 895 { 896 PolygonContainer cell; 897 // export view cell geometry 898 mBspTree->ConstructGeometry(vc, cell); 899 exporter->ExportPolygons(cell); 900 CLEAR_CONTAINER(cell); 901 } 902 903 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 904 << ", piercing rays=" << (int)vcRays[i].size() << endl; 905 906 // export rays piercing this view cell 907 exporter->ExportRays(vcRays[i], 1000, RgbColor(0, 1, 0)); 908 909 m.mDiffuseColor = RgbColor(1, 0, 0); 910 exporter->SetForcedMaterial(m); 911 884 912 exporter->SetWireframe(); 913 914 // output PVS of view cell 915 for (; it != vc->GetPvs().mEntries.end(); ++ it) 916 { 917 Intersectable *intersect = (*it).first; 918 if (!intersect->Mailed()) 919 { 920 exporter->ExportIntersectable(intersect); 921 intersect->Mail(); 922 } 923 } 924 925 // output rest of the objects 926 if (0) 927 { 928 Material m;//= RandomMaterial(); 929 m.mDiffuseColor = RgbColor(0, 0, 1); 930 exporter->SetForcedMaterial(m); 931 932 for (int j = 0; j < objects.size(); ++ j) 933 if (!objects[j]->Mailed()) 934 { 935 exporter->SetForcedMaterial(m); 936 exporter->ExportIntersectable(objects[j]); 937 objects[j]->Mail(); 938 } 939 } 940 DEL_PTR(exporter); 941 cout << "finished" << endl; 942 } 943 } 944 else 945 { 946 ViewCellContainer viewCells; 947 948 mBspTree->CollectViewCells(viewCells); 949 stable_sort(viewCells.begin(), viewCells.end(), vc_gt); 950 951 int limit = min(leafOut, (int)viewCells.size()); 952 953 for (int i = 0; i < limit; ++ i) 954 { 955 cout << "creating output for view cell " << i << " ... "; 956 957 Intersectable::NewMail(); 958 BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]); 959 960 cout << "creating output for view cell " << i << " ... "; 961 // check whether we can add the current ray to the output rays 962 for (int k = 0; k < raysOut; ++ k) 963 { 964 Ray *ray = mSampleRays[k]; 965 966 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 967 { 968 BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 969 970 if (vc == leaf->GetViewCell()) 971 { 972 vcRays[i].push_back(ray); 973 } 974 } 975 } 976 977 //bspLeaves[j]->Mail(); 978 char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 979 980 Exporter *exporter = Exporter::GetExporter(s); 981 exporter->SetFilled(); 982 983 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 984 985 exporter->SetFilled();//Wireframe(); 885 986 886 987 Material m;//= RandomMaterial(); … … 899 1000 } 900 1001 901 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 902 << ", piercing rays=" << (int)vcRays[i].size() << endl; 903 1002 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() << endl; 1003 1004 904 1005 // export rays piercing this view cell 905 exporter->ExportRays(vcRays[i], 1000 , RgbColor(0, 1, 0));1006 exporter->ExportRays(vcRays[i], 10000, RgbColor(0, 1, 0)); 906 1007 907 1008 m.mDiffuseColor = RgbColor(1, 0, 0); … … 919 1020 } 920 1021 921 // output rest of the objects922 if (0)923 {924 Material m;//= RandomMaterial();925 m.mDiffuseColor = RgbColor(0, 0, 1);926 exporter->SetForcedMaterial(m);927 928 for (int j = 0; j < objects.size(); ++ j)929 if (!objects[j]->Mailed())930 {931 exporter->SetForcedMaterial(m);932 exporter->ExportIntersectable(objects[j]);933 objects[j]->Mail();934 }935 }936 DEL_PTR(exporter);937 cout << "finished" << endl;938 }939 }940 else941 {942 ViewCellContainer viewCells;943 944 mBspTree->CollectViewCells(viewCells);945 stable_sort(viewCells.begin(), viewCells.end(), vc_gt);946 947 int limit = min(leafOut, (int)viewCells.size());948 949 for (int i = 0; i < limit; ++ i)950 {951 cout << "creating output for view cell " << i << " ... ";952 953 Intersectable::NewMail();954 BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]);955 956 cout << "creating output for view cell " << i << " ... ";957 // check whether we can add the current ray to the output rays958 for (int k = 0; k < raysOut; ++ k)959 {960 Ray *ray = mSampleRays[k];961 962 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j)963 {964 BspLeaf *leaf = ray->bspIntersections[j].mLeaf;965 966 if (vc == leaf->GetViewCell())967 {968 vcRays[i].push_back(ray);969 }970 }971 }972 973 //bspLeaves[j]->Mail();974 char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i);975 976 Exporter *exporter = Exporter::GetExporter(s);977 exporter->SetFilled();978 979 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin();980 981 exporter->SetWireframe();982 983 Material m;//= RandomMaterial();984 m.mDiffuseColor = RgbColor(0, 1, 0);985 exporter->SetForcedMaterial(m);986 987 if (vc->GetMesh())988 exporter->ExportViewCell(vc);989 else990 {991 PolygonContainer cell;992 // export view cell993 mBspTree->ConstructGeometry(vc, cell);994 exporter->ExportPolygons(cell);995 CLEAR_CONTAINER(cell);996 }997 998 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() << endl;999 1000 1001 // export rays piercing this view cell1002 exporter->ExportRays(vcRays[i], 10000, RgbColor(0, 1, 0));1003 1004 m.mDiffuseColor = RgbColor(1, 0, 0);1005 exporter->SetForcedMaterial(m);1006 1007 // output PVS of view cell1008 for (; it != vc->GetPvs().mEntries.end(); ++ it)1009 {1010 Intersectable *intersect = (*it).first;1011 if (!intersect->Mailed())1012 {1013 exporter->ExportIntersectable(intersect);1014 intersect->Mail();1015 }1016 }1017 1018 1022 DEL_PTR(exporter); 1019 1023 cout << "finished" << endl;
Note: See TracChangeset
for help on using the changeset viewer.