Changeset 449 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 12/05/05 05:21:22 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp
r448 r449 4 4 #include "ViewCell.h" 5 5 #include "VspBspTree.h" 6 6 #include "VspKdTree.h" 7 7 8 8 void SimulationStatistics::Print(ostream &app) const … … 148 148 } 149 149 150 /******************************************************* *151 * class KdLeafRenderSimulator implementation * 152 150 /*******************************************************/ 151 /* class KdenderSimulator implementation */ 152 /*******************************************************/ 153 153 154 154 KdRenderSimulator::KdRenderSimulator(float objRenderCost, … … 242 242 /* class BspRenderSimulator implementation */ 243 243 /********************************************************/ 244 244 245 VspBspRenderSimulator::VspBspRenderSimulator(VspBspTree *vspBspTree): 245 246 mVspBspTree(vspBspTree) … … 334 335 return viewCell.GetPvs().GetSize() * objRenderTime; 335 336 } 337 338 339 340 /********************************************************/ 341 /* class BspRenderSimulator implementation */ 342 /********************************************************/ 343 344 345 VspKdRenderSimulator::VspKdRenderSimulator(VspKdTree *vspKdTree): 346 mVspKdTree(vspKdTree) 347 { 348 } 349 350 VspKdRenderSimulator::VspKdRenderSimulator(float objRenderCost, 351 float vcOverhead, 352 float moveSpeed, 353 VspKdTree *vspKdTree): 354 RenderSimulator(objRenderCost, vcOverhead, moveSpeed), 355 mVspKdTree(vspKdTree) 356 { 357 } 358 359 SimulationStatistics VspKdRenderSimulator::SimulateRendering() 360 { 361 SimulationStatistics simStat; 362 363 simStat.Reset(); 364 simStat.Start(); 365 366 // TODO 367 simStat.Stop(); 368 369 return simStat; 370 } 371 372 Real VspKdRenderSimulator::RenderPvs(ViewCell &viewCell, 373 float objRenderTime) const 374 { 375 return 0; // TODO 376 } -
trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.h
r448 r449 9 9 class ViewCell; 10 10 class KdLeaf; 11 class VspKdTree; 11 12 class VspBspTree; 12 13 … … 151 152 }; 152 153 154 class VspKdRenderSimulator: public RenderSimulator 155 { 156 public: 157 VspKdRenderSimulator(VspKdTree *vspKdTree); 158 159 VspKdRenderSimulator(float objRenderCost, 160 float vcOverhead, 161 float moveSpeed, 162 VspKdTree *vspKdTree); 163 164 SimulationStatistics SimulateRendering(); 165 166 protected: 167 /** Simulates rendering of the pvs of one view cell, with given rendering time for an object. 168 @param viewCell the view cell holding the Pvs 169 @param objRenderTime estimated render time for one object of the Pvs 170 */ 171 Real RenderPvs(ViewCell &viewCell, const float objRenderTime) const; 172 173 private: 174 VspKdTree *mVspKdTree; 175 }; 176 153 177 #endif // RenderSimulator -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r448 r449 972 972 mVspKdTree(vspKdTree) 973 973 { 974 mRenderSimulator = NULL;//new VspKdRenderSimulator(vspKdTree);974 mRenderSimulator = new VspKdRenderSimulator(vspKdTree); 975 975 InitRenderSimulator(); 976 976 } … … 1097 1097 1098 1098 //-- export stored PVS 1099 1100 1099 ObjectContainer pvsObj; 1101 1100 leaf->ExtractPvs(pvsObj); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r448 r449 337 337 { 338 338 DEL_PTR(mRoot); 339 DEL_PTR(mSplitCandidates); 339 340 } 340 341 … … 446 447 VspKdTree::Construct(const VssRayContainer &rays, 447 448 AxisAlignedBox3 *forcedBoundingBox) 448 { 449 {Debug << "here888" << endl; 449 450 mStat.Start(); 450 451 Debug << "here1000" << endl; 451 452 mMaxMemory = mMaxStaticMemory; 452 453 Debug << "here1" << endl; 453 454 DEL_PTR(mRoot); 454 455 … … 460 461 mStat.nodes = 1; 461 462 mBox.Initialize(); 462 463 Debug << "here2" << endl; 463 464 //-- compute bounding box 464 465 if (forcedBoundingBox) … … 899 900 requestedSize < (int)(mSplitCandidates->capacity()/10) ) 900 901 { 901 delete mSplitCandidates;902 DEL_PTR(mSplitCandidates); 902 903 mSplitCandidates = new vector<SortableEntry>; 903 904 } -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r446 r449 11 11 #include "VspKdTree.h" 12 12 #include "VssTree.h" 13 #include "RssTree.h" 13 #include "VspBspTree.h" 14 14 15 15 16 X3dExporter::X3dExporter(const string filename):Exporter(filename) … … 285 286 BspNodeGeometry *back = new BspNodeGeometry(); 286 287 287 cell->SplitGeometry(*front, *back, tree, *interior->GetPlane()); 288 cell->SplitGeometry(*front, 289 *back, 290 interior->GetPlane(), 291 tree.GetBoundingBox(), 292 tree.GetEpsilon()); 288 293 289 294 tStack.push(pair<BspNode *, BspNodeGeometry *>(interior->GetFront(), front)); … … 872 877 } 873 878 874 875 bool876 X3dExporter::ExportRssTree2(const RssTree &tree,877 const Vector3 direction878 )879 {880 stack<RssTreeNode *> tStack;881 882 883 mUseForcedMaterial = true;884 885 Vector3 dirParam;886 887 dirParam.x = VssRay::GetDirParam(0, Normalize(direction));888 dirParam.y = VssRay::GetDirParam(1, Normalize(direction));889 890 float maxImportance = 0.0f;891 tStack.push(tree.GetRoot());892 while (!tStack.empty()) {893 894 RssTreeNode *node = tStack.top();895 tStack.pop();896 897 if (!node->IsLeaf()) {898 RssTreeInterior *interior = (RssTreeInterior *)node;899 if (interior->axis < 3) {900 tStack.push(interior->front);901 tStack.push(interior->back);902 } else {903 if (dirParam[interior->axis-3] < interior->position)904 tStack.push(interior->back);905 else906 tStack.push(interior->front);907 }908 } else {909 RssTreeLeaf *leaf = (RssTreeLeaf *)node;910 if (tree.ValidLeaf(leaf)) {911 float i = leaf->GetImportance();912 if (i > maxImportance)913 maxImportance = i;914 }915 }916 }917 918 tStack.push(tree.GetRoot());919 while (!tStack.empty()) {920 921 RssTreeNode *node = tStack.top();922 tStack.pop();923 924 925 if (!node->IsLeaf()) {926 RssTreeInterior *interior = (RssTreeInterior *)node;927 if (interior->axis < 3) {928 tStack.push(interior->front);929 tStack.push(interior->back);930 } else {931 if (dirParam[interior->axis-3] < interior->position)932 tStack.push(interior->back);933 else934 tStack.push(interior->front);935 }936 } else {937 RssTreeLeaf *leaf = (RssTreeLeaf *)node;938 if (tree.ValidLeaf(leaf)) {939 AxisAlignedBox3 box;940 box = tree.GetShrankedBBox(leaf);941 Mesh *mesh = new Mesh;942 AddBoxToMesh(box, mesh);943 944 // get 4 corners of the ray directions945 946 mForcedMaterial.mDiffuseColor.b = 1.0f;947 mForcedMaterial.mDiffuseColor.r = leaf->GetImportance()/maxImportance;948 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r;949 950 ExportMesh(mesh);951 delete mesh;952 }953 }954 }955 956 mUseForcedMaterial = false;957 958 return true;959 }960 961 879 bool 962 880 X3dExporter::ExportBspTreeRayDensity(const BspTree &tree) … … 1070 988 BspNode *mNode; 1071 989 1072 vector<Plane3 *> mPlanes;990 vector<Plane3> mPlanes; 1073 991 vector<bool> mSides; 1074 992 bool mIsFront; … … 1080 998 1081 999 BspSplitData(BspNode *node, 1082 vector<Plane3 *> planes,1000 vector<Plane3> planes, 1083 1001 vector<bool> sides, 1084 1002 const bool isFront, … … 1105 1023 } 1106 1024 1107 void X3dExporter::ExportBspSplits(const BspTree &tree, 1108 const bool exportDepth) 1025 void X3dExporter::ExportBspNodeSplits(BspNode *root, 1026 const AxisAlignedBox3 &box, 1027 const bool exportDepth, 1028 const bool epsilon) 1109 1029 { 1110 1030 std::stack<BspSplitData> tStack; 1111 1031 1112 BspSplitData tData( tree.GetRoot());1032 BspSplitData tData(root); 1113 1033 tStack.push(tData); 1114 1034 … … 1134 1054 1135 1055 // add current side of split plane 1136 if (tData.mNode != tree.GetRoot())1056 if (tData.mNode != root) 1137 1057 tData.mSides.push_back(tData.mIsFront); 1138 1058 1139 1059 // bounded plane is added to the polygons 1140 1060 Polygon3 *planePoly = 1141 tree.GetBoundingBox().CrossSection(*interior->GetPlane());1061 box.CrossSection(interior->GetPlane()); 1142 1062 1143 1063 // do all the splits with the previous planes 1144 1064 for (int i = 0; i < (int)tData.mPlanes.size(); ++ i) 1145 1065 { 1146 if (planePoly->ClassifyPlane(*tData.mPlanes[i]) == Polygon3::SPLIT) 1066 if (planePoly->ClassifyPlane(tData.mPlanes[i], epsilon) 1067 == Polygon3::SPLIT) 1147 1068 { 1148 1069 Polygon3 *frontPoly = new Polygon3(); 1149 1070 Polygon3 *backPoly = new Polygon3(); 1150 1071 1151 planePoly->Split(*tData.mPlanes[i], *frontPoly, *backPoly); 1072 planePoly->Split(tData.mPlanes[i], 1073 *frontPoly, 1074 *backPoly, 1075 epsilon); 1076 1152 1077 DEL_PTR(planePoly); 1153 1078 … … 1167 1092 tData.mPlanes.push_back(interior->GetPlane()); // add plane to split planes 1168 1093 1169 if (planePoly->Valid( ))1094 if (planePoly->Valid(epsilon)) 1170 1095 { 1171 1096 polys.push_back(planePoly); … … 1206 1131 } 1207 1132 1133 void X3dExporter::ExportBspSplits(const BspTree &tree, 1134 const bool exportDepth) 1135 { 1136 ExportBspNodeSplits(tree.GetRoot(), 1137 tree.GetBoundingBox(), 1138 exportDepth, 1139 tree.GetEpsilon()); 1140 } 1141 1142 void X3dExporter::ExportBspSplits(const VspBspTree &tree, 1143 const bool exportDepth) 1144 { 1145 ExportBspNodeSplits(tree.GetRoot(), 1146 tree.GetBoundingBox(), 1147 exportDepth, 1148 tree.GetEpsilon()); 1149 } 1150 1208 1151 void X3dExporter::ExportBspSplitPlanes(const BspTree &tree) 1209 1152 { … … 1225 1168 1226 1169 // bounded plane is added to the polygons 1227 polys.push_back(tree.GetBoundingBox().CrossSection( *interior->GetPlane()));1170 polys.push_back(tree.GetBoundingBox().CrossSection(interior->GetPlane())); 1228 1171 1229 1172 // push the children on the stack … … 1238 1181 1239 1182 1240 void 1241 X3dExporter::ExportGeometry(const ObjectContainer &objects) 1242 { 1243 1244 ObjectContainer::const_iterator oi = objects.begin(); 1245 for (; oi != objects.end(); oi++) { 1246 // export the transform... 1247 ExportIntersectable(*oi); 1248 } 1249 1250 } 1183 void X3dExporter::ExportGeometry(const ObjectContainer &objects) 1184 { 1185 for (int j = 0; j < objects.size(); ++ j) 1186 ExportIntersectable(objects[j]); 1187 } 1188 1189 void X3dExporter::ExportBspViewCellPartition(const VspBspTree &tree, 1190 const int maxPvs) 1191 { 1192 ViewCellContainer viewCells; 1193 tree.CollectViewCells(viewCells); 1194 1195 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 1196 1197 if (maxPvs > 0) 1198 mUseForcedMaterial = true; 1199 1200 for (it = viewCells.begin(); it != it_end; ++ it) 1201 { 1202 if (maxPvs > 0) 1203 { 1204 mForcedMaterial.mDiffuseColor.b = 1.0f; 1205 float importance = (float)(*it)->GetPvs().GetSize() / (float)maxPvs; 1206 1207 mForcedMaterial.mDiffuseColor.r = importance; 1208 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 1209 } 1210 1211 if ((*it)->GetMesh()) 1212 ExportViewCell(*it); 1213 else 1214 { 1215 PolygonContainer cell; 1216 tree.ConstructGeometry(dynamic_cast<BspViewCell *>(*it), cell); 1217 1218 ExportPolygons(cell); 1219 } 1220 } 1221 }
Note: See TracChangeset
for help on using the changeset viewer.