Changeset 449 for trunk


Ignore:
Timestamp:
12/05/05 05:21:22 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp

    r448 r449  
    44#include "ViewCell.h" 
    55#include "VspBspTree.h" 
    6  
     6#include "VspKdTree.h" 
    77 
    88void SimulationStatistics::Print(ostream &app) const 
     
    148148} 
    149149 
    150 /******************************************************** 
    151  *     class KdLeafRenderSimulator implementation       * 
    152  *******************************************************/ 
     150/*******************************************************/ 
     151/*     class KdenderSimulator implementation           */ 
     152/*******************************************************/ 
    153153 
    154154KdRenderSimulator::KdRenderSimulator(float objRenderCost,  
     
    242242/*     class BspRenderSimulator implementation          */ 
    243243/********************************************************/ 
     244 
    244245VspBspRenderSimulator::VspBspRenderSimulator(VspBspTree *vspBspTree): 
    245246mVspBspTree(vspBspTree) 
     
    334335        return viewCell.GetPvs().GetSize() * objRenderTime; 
    335336} 
     337 
     338 
     339 
     340/********************************************************/ 
     341/*     class BspRenderSimulator implementation          */ 
     342/********************************************************/ 
     343 
     344 
     345VspKdRenderSimulator::VspKdRenderSimulator(VspKdTree *vspKdTree): 
     346mVspKdTree(vspKdTree) 
     347{ 
     348} 
     349 
     350VspKdRenderSimulator::VspKdRenderSimulator(float objRenderCost,  
     351                                                                                   float vcOverhead,  
     352                                                                                   float moveSpeed, 
     353                                                                                   VspKdTree *vspKdTree): 
     354RenderSimulator(objRenderCost, vcOverhead, moveSpeed),  
     355mVspKdTree(vspKdTree) 
     356{ 
     357} 
     358 
     359SimulationStatistics 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 
     372Real VspKdRenderSimulator::RenderPvs(ViewCell &viewCell,  
     373                                                                          float objRenderTime) const 
     374{ 
     375        return 0; // TODO 
     376} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.h

    r448 r449  
    99class ViewCell; 
    1010class KdLeaf; 
     11class VspKdTree; 
    1112class VspBspTree; 
    1213 
     
    151152}; 
    152153 
     154class VspKdRenderSimulator: public RenderSimulator 
     155{ 
     156public: 
     157        VspKdRenderSimulator(VspKdTree *vspKdTree); 
     158 
     159        VspKdRenderSimulator(float objRenderCost,  
     160                                                 float vcOverhead,  
     161                                                 float moveSpeed,  
     162                                                 VspKdTree *vspKdTree); 
     163 
     164        SimulationStatistics SimulateRendering(); 
     165 
     166protected: 
     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 
     173private: 
     174        VspKdTree *mVspKdTree; 
     175}; 
     176 
    153177#endif // RenderSimulator 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r448 r449  
    972972mVspKdTree(vspKdTree) 
    973973{ 
    974    mRenderSimulator = NULL;//new VspKdRenderSimulator(vspKdTree); 
     974   mRenderSimulator = new VspKdRenderSimulator(vspKdTree); 
    975975   InitRenderSimulator(); 
    976976} 
     
    10971097 
    10981098                        //-- export stored PVS 
    1099                          
    11001099                        ObjectContainer pvsObj; 
    11011100                        leaf->ExtractPvs(pvsObj); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r448 r449  
    337337{ 
    338338        DEL_PTR(mRoot); 
     339        DEL_PTR(mSplitCandidates); 
    339340} 
    340341 
     
    446447VspKdTree::Construct(const VssRayContainer &rays, 
    447448                                         AxisAlignedBox3 *forcedBoundingBox) 
    448 { 
     449{Debug << "here888" << endl; 
    449450        mStat.Start(); 
    450    
     451  Debug << "here1000" << endl; 
    451452        mMaxMemory = mMaxStaticMemory; 
    452  
     453        Debug << "here1" << endl; 
    453454        DEL_PTR(mRoot); 
    454455 
     
    460461        mStat.nodes = 1; 
    461462        mBox.Initialize(); 
    462  
     463Debug << "here2" << endl; 
    463464        //-- compute bounding box 
    464465        if (forcedBoundingBox) 
     
    899900                requestedSize < (int)(mSplitCandidates->capacity()/10) )  
    900901        { 
    901         delete mSplitCandidates; 
     902        DEL_PTR(mSplitCandidates); 
    902903                mSplitCandidates = new vector<SortableEntry>; 
    903904        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r446 r449  
    1111#include "VspKdTree.h" 
    1212#include "VssTree.h" 
    13 #include "RssTree.h" 
     13#include "VspBspTree.h" 
     14 
    1415 
    1516X3dExporter::X3dExporter(const string filename):Exporter(filename) 
     
    285286                        BspNodeGeometry *back = new BspNodeGeometry(); 
    286287 
    287                         cell->SplitGeometry(*front, *back, tree, *interior->GetPlane()); 
     288                        cell->SplitGeometry(*front,  
     289                                                                *back,  
     290                                                                interior->GetPlane(),  
     291                                                                tree.GetBoundingBox(),  
     292                                                                tree.GetEpsilon()); 
    288293 
    289294                        tStack.push(pair<BspNode *, BspNodeGeometry *>(interior->GetFront(), front)); 
     
    872877} 
    873878 
    874  
    875 bool 
    876 X3dExporter::ExportRssTree2(const RssTree &tree, 
    877                                                         const Vector3 direction 
    878                                                         ) 
    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                 else 
    906                   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                 else 
    934                   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 directions 
    945                  
    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  
    961879bool 
    962880X3dExporter::ExportBspTreeRayDensity(const BspTree &tree) 
     
    1070988        BspNode *mNode; 
    1071989 
    1072         vector<Plane3 *> mPlanes; 
     990        vector<Plane3> mPlanes; 
    1073991        vector<bool> mSides; 
    1074992        bool mIsFront; 
     
    1080998 
    1081999        BspSplitData(BspNode *node,  
    1082                                 vector<Plane3 *> planes,  
     1000                                vector<Plane3> planes,  
    10831001                                vector<bool> sides,  
    10841002                                const bool isFront, 
     
    11051023} 
    11061024 
    1107 void X3dExporter::ExportBspSplits(const BspTree &tree, 
    1108                                                                   const bool exportDepth) 
     1025void X3dExporter::ExportBspNodeSplits(BspNode *root, 
     1026                                                                          const AxisAlignedBox3 &box,  
     1027                                                                          const bool exportDepth, 
     1028                                                                          const bool epsilon) 
    11091029{ 
    11101030        std::stack<BspSplitData> tStack; 
    11111031 
    1112         BspSplitData tData(tree.GetRoot()); 
     1032        BspSplitData tData(root); 
    11131033        tStack.push(tData); 
    11141034   
     
    11341054 
    11351055                        // add current side of split plane 
    1136                         if (tData.mNode != tree.GetRoot()) 
     1056                        if (tData.mNode != root) 
    11371057                                tData.mSides.push_back(tData.mIsFront); 
    11381058 
    11391059                        // bounded plane is added to the polygons 
    11401060                        Polygon3 *planePoly =  
    1141                                 tree.GetBoundingBox().CrossSection(*interior->GetPlane()); 
     1061                                box.CrossSection(interior->GetPlane()); 
    11421062                 
    11431063                        // do all the splits with the previous planes 
    11441064                        for (int i = 0; i < (int)tData.mPlanes.size(); ++ i) 
    11451065                        {                                
    1146                                 if (planePoly->ClassifyPlane(*tData.mPlanes[i]) == Polygon3::SPLIT) 
     1066                                if (planePoly->ClassifyPlane(tData.mPlanes[i], epsilon)  
     1067                                        == Polygon3::SPLIT) 
    11471068                                { 
    11481069                                        Polygon3 *frontPoly = new Polygon3(); 
    11491070                                        Polygon3 *backPoly = new Polygon3(); 
    11501071 
    1151                                         planePoly->Split(*tData.mPlanes[i], *frontPoly, *backPoly); 
     1072                                        planePoly->Split(tData.mPlanes[i],  
     1073                                                                         *frontPoly,  
     1074                                                                         *backPoly, 
     1075                                                                         epsilon); 
     1076 
    11521077                                        DEL_PTR(planePoly); 
    11531078 
     
    11671092                        tData.mPlanes.push_back(interior->GetPlane()); // add plane to split planes 
    11681093 
    1169                         if (planePoly->Valid()) 
     1094                        if (planePoly->Valid(epsilon)) 
    11701095                        { 
    11711096                                polys.push_back(planePoly); 
     
    12061131} 
    12071132 
     1133void X3dExporter::ExportBspSplits(const BspTree &tree, 
     1134                                                                  const bool exportDepth) 
     1135{ 
     1136        ExportBspNodeSplits(tree.GetRoot(),  
     1137                                                tree.GetBoundingBox(),  
     1138                                                exportDepth,  
     1139                                                tree.GetEpsilon()); 
     1140} 
     1141 
     1142void X3dExporter::ExportBspSplits(const VspBspTree &tree, 
     1143                                                                  const bool exportDepth) 
     1144{ 
     1145        ExportBspNodeSplits(tree.GetRoot(),  
     1146                                                tree.GetBoundingBox(),  
     1147                                                exportDepth,  
     1148                                                tree.GetEpsilon()); 
     1149} 
     1150 
    12081151void X3dExporter::ExportBspSplitPlanes(const BspTree &tree) 
    12091152{ 
     
    12251168 
    12261169                        // 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())); 
    12281171                 
    12291172                        // push the children on the stack 
     
    12381181 
    12391182 
    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 } 
     1183void X3dExporter::ExportGeometry(const ObjectContainer &objects) 
     1184{ 
     1185        for (int j = 0; j < objects.size(); ++ j) 
     1186                ExportIntersectable(objects[j]); 
     1187} 
     1188 
     1189void 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.