Changeset 694


Ignore:
Timestamp:
03/15/06 08:59:33 (18 years ago)
Author:
mattausch
Message:

added means for rotating scene

Location:
GTP/trunk/Lib/Vis
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r685 r694  
    3131  environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 
    3232  environment->GetBoolValue("Preprocessor.computeVisibility", mComputeVisibility); 
     33  environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
     34   
     35  Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 
    3336  Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 
    3437 
     
    226229        environment->GetFloatValue("Simulation.vcOverhead", vcOverhead); 
    227230        environment->GetFloatValue("Simulation.moveSpeed", moveSpeed); 
    228  
     231         
    229232        mRenderSimulator =  
    230233                new RenderSimulator(mViewCellsManager, objRenderCost, vcOverhead, moveSpeed); 
     
    240243                //              renderer->makeCurrent(); 
    241244        } 
    242  
    243  
    244         environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
    245245         
    246246        return true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayInfo.cpp

    r639 r694  
    141141        // non-intersecting, otherwise polygon-plane intersections of bsp tree 
    142142        // approaches are not eliminating any rays intersecting the polygon! 
    143         const float thresh = 1 ? 1e-6f : 0.0f; 
     143        const float thresh = 1e-6f; 
    144144 
    145145        // segment is not intersecting plane: fond out if on front or back side 
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r658 r694  
    1515 
    1616 
     17// HACK 
     18static void RotateMesh(Mesh *mesh) 
     19{ 
     20        VertexContainer::iterator it, it_end = mesh->mVertices.end(); 
     21 
     22        const float angle = 30.0f * PI / 180.0f; 
     23        const Matrix4x4 rot = RotationYMatrix(angle); 
     24 
     25        for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
     26        { 
     27                (*it) = rot * (*it);         
     28        } 
     29} 
     30 
     31 
    1732struct ltstr 
    1833{ 
     
    2237  } 
    2338}; 
    24  
    2539 
    2640bool 
     
    4054  float x,y,z; 
    4155  int i; 
    42    
    4356   
    4457  if ((file = fopen(filename.c_str(),"rt")) == NULL) 
     
    145158      if (meshGrouping != 0 && 
    146159                                        currentMesh->mFaces.size() >=  meshGrouping) { 
     160                if (1) 
     161                        RotateMesh(currentMesh); 
    147162                                currentMesh->Preprocess(); 
    148163                                // make an instance of this mesh 
     
    160175   
    161176  if (currentMesh->mVertices.size()) { 
     177          if (1) 
     178                RotateMesh(currentMesh); 
     179  cout << "here9999" << endl;      
    162180    currentMesh->Preprocess(); 
    163181    MeshInstance *mi = new MeshInstance(currentMesh); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r693 r694  
    345345        Debug << "max memory: " << mMaxMemory << endl; 
    346346        Debug << "refining view cells: " << mRefineViewCells << endl; 
     347        Debug << "********* view cell tree options ***************\n"; 
    347348 
    348349        MergeCandidate::sRenderCostWeight = mRenderCostWeight; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r684 r694  
    21272127                                if (extSide < 0) 
    21282128                                        node = in->GetBack(); 
    2129                                 else  
     2129                                else //if (extSide > 0) 
    21302130                                        node = in->GetFront(); 
    2131                                                                  
     2131                                //else break; 
     2132 
    21322133                                continue; // no far child 
    21332134                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r693 r694  
    1717 
    1818#define SAMPLE_AFTER_SUBDIVISION 1 
    19  
     19#define TEST_EMPTY_VIEW_CELLS 0 
    2020 
    2121ViewCellsManager::ViewCellsManager(): 
     
    145145 
    146146        cout << "collecting empty view cells" << endl; 
    147         int i = 0; 
     147         
    148148        for (it = leaves.begin(); it != it_end; ++ it) 
    149149        { 
    150150                if ((*it)->GetPvs().Empty()) 
    151151                { 
    152                         ++ i; 
    153152                        mEmptyViewCells.push_back(*it); 
    154153                } 
    155154        } 
    156         cout << "view cells found: " << i << endl; 
    157 } 
    158  
    159  
    160 void ViewCellsManager::TestEmptyViewCells() 
    161 { 
    162         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), mEmptyViewCells); 
    163  
     155        Debug << "empty view cells found: " << (int)mEmptyViewCells.size() << endl; 
     156} 
     157 
     158 
     159void ViewCellsManager::TestEmptyViewCells(const ObjectContainer &obj) 
     160{ 
    164161        ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end(); 
    165162 
     
    170167                if (!(*it)->GetPvs().Empty()) 
    171168                { 
    172                         sprintf(buf, "empty-viewcells-%09d.x3d", (*it)->GetId()); 
     169                        sprintf(buf, "empty-viewcells-%09d.x3d", i/*(*it)->GetId()*/); 
    173170                        Exporter *exporter = Exporter::GetExporter(buf); 
    174171                         
    175172                        if (exporter && i < 20) 
    176173                        { 
    177                                 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << endl; 
     174                                Ray *pray = (*it)->mPiercingRays[0]; 
     175                                Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << " " << pray->intersections.size() << endl; 
     176 
     177                                exporter->ExportRays((*it)->mPiercingRays); 
     178                                                         
     179                                exporter->SetFilled(); 
     180                                exporter->SetForcedMaterial(RgbColor(0,0,1)); 
     181 
     182                                for (int j = 0; j < (int)pray->intersections.size(); ++ j) 
     183                                { 
     184                                        if (pray->intersections[j].mObject) 
     185                                                exporter->ExportIntersectable(pray->intersections[j].mObject); 
     186                                } 
     187 
     188                                //exporter->SetWireframe(); 
     189                                exporter->SetForcedMaterial(RgbColor(0,1,0)); 
     190                                exporter->ExportGeometry(obj); 
     191 
     192                                exporter->SetFilled(); 
     193 
     194                                exporter->SetForcedMaterial(RgbColor(1,0,0)); 
    178195                                ExportViewCellGeometry(exporter, *it); 
     196 
     197                                delete exporter;                 
    179198                        } 
    180199 
     200                 
    181201                        ++ i; 
    182202                } 
    183203        } 
    184         Debug << "\nfound " << i << " new view cells (" << " of " << mEmptyViewCells.size() << ")" << endl << endl; 
     204        Debug << "\nSampled " << i << " new view cells (" << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 
    185205} 
    186206 
     
    289309 
    290310        // should we use directional samples? 
    291         bool dirSamples = mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION; 
     311        bool dirSamples = (mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
    292312 
    293313        while (numSamples < n) 
     
    296316                VssRayContainer constructionSamples; 
    297317 
    298                 const int samplingType = 
    299                         dirSamples ?  
     318                const int samplingType = mSamplingType; 
     319                        /*dirSamples ?  
    300320                                                Preprocessor::DIRECTION_BASED_DISTRIBUTION : 
    301                                                 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 
     321                                                Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;*/ 
    302322 
    303323                if (0) 
     
    327347        VssRayContainer postProcessSamples; 
    328348 
    329         //-- construction rays => we use uniform samples for this 
     349        //-- construction rays  
    330350        CastPassSamples(mPostProcessSamples, 
    331                                     Preprocessor::DIRECTION_BASED_DISTRIBUTION,  
     351                                        mSamplingType,  
    332352                                        postProcessSamples); 
    333353 
     
    359379 
    360380        // only for testing 
    361         CollectEmptyViewCells(); 
     381        if (TEST_EMPTY_VIEW_CELLS) 
     382                CollectEmptyViewCells(); 
    362383 
    363384 
     
    495516 
    496517        // find empty view cells bug 
    497         TestEmptyViewCells(); 
     518        if (TEST_EMPTY_VIEW_CELLS) 
     519                TestEmptyViewCells(preprocessor->mObjects); 
    498520} 
    499521 
     
    10831105        { 
    10841106                ViewCell *viewcell = *it; 
     1107 
    10851108                if (viewcell->GetValid())  
    10861109                { 
     1110                        // HACK 
     1111                        if (TEST_EMPTY_VIEW_CELLS) 
     1112                                for (int i = 0; i < mEmptyViewCells.size(); ++i) 
     1113                                { 
     1114                                        if (viewcell == mEmptyViewCells[i]) 
     1115                                        { 
     1116                                                viewcell->mPiercingRays.push_back(new Ray(ray)); 
     1117                                                Debug << "empty view cell ray found: " << ray.mOriginObject << ", " << ray.mTerminationObject << endl; 
     1118                                        } 
     1119                                } 
     1120 
    10871121                        // if ray not outside of view space 
    10881122                        float contribution; 
     
    17731807                newVol += lVol; 
    17741808                subdivVol += (*it)->GetVolume(); 
     1809 
     1810                float thres = 0.9; 
     1811                if ((lVol < ((*it)->GetVolume() * thres)) || 
     1812                        (lVol * thres > ((*it)->GetVolume()))) 
     1813                        Debug << "warning: " << lVol << " " << (*it)->GetVolume() << endl; 
    17751814        } 
    17761815         
     
    30323071        MergeViewCells(postProcessRays, objects); 
    30333072         
    3034  
    3035         Debug << "here4" << endl; 
    30363073        // only for testing 
    30373074        TestSubdivision(); 
     
    33413378        Debug << "\nOutput view cells: " << endl; 
    33423379 
     3380        const bool sortViewCells = true; 
     3381 
    33433382        // sort view cells to visualize the largest view cells 
    3344         if (0) 
     3383        if (sortViewCells) 
    33453384                stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    33463385         
     
    33543393                cout << "creating output for view cell " << i << " ... "; 
    33553394 
    3356          
    33573395                ViewCell *vc; 
    33583396         
    3359                 if (0) // largest view cell pvs first 
     3397                if (sortViewCells) // largest view cell pvs first 
    33603398                        vc = mViewCells[i]; 
    33613399                else 
     
    33703408                if (1 || mExportRays) 
    33713409                { 
     3410                        // output rays stored with the view cells during subdivision 
    33723411                        if (0) 
    33733412                        { 
     
    34083447                        } 
    34093448                 
    3410  
     3449                        // associate new rays with output view cell 
    34113450                        if (1) 
    34123451                        { 
     
    35983637                                                                   0.00000001f); 
    35993638         
    3600                                 //Debug << "here geo size: " << geom.Size() << endl; 
    3601                                 //Debug << "here size b: " << back.Size() << " f: " << front.Size() << endl; 
     3639                                //Debug << "geo size: " << geom.Size() << endl; 
     3640                                //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 
    36023641                                if (back.Valid()) 
    36033642                                { 
    36043643                                        exporter->ExportPolygons(back.GetPolys()); 
    36053644                                } 
    3606                                 //else Debug << "here2 size: " << back.Size() << endl; 
     3645                         
    36073646                        } 
    36083647                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r693 r694  
    504504        // HACK in order to detect empty view cells 
    505505        void CollectEmptyViewCells(); 
    506         void TestEmptyViewCells(); 
     506        void TestEmptyViewCells(const ObjectContainer &obj); 
    507507 
    508508        ViewCellContainer mEmptyViewCells; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r685 r694  
    10281028 
    10291029                        if (frontData.mProbability < -0.00001) 
    1030                                 Debug << "here2 error f: " << frontData.mProbability << endl; 
     1030                                Debug << "fatal error f: " << frontData.mProbability << endl; 
    10311031                        if (backData.mProbability < -0.00001) 
    1032                                 Debug << "here2 error b: " << backData.mProbability << endl; 
     1032                                Debug << "fatal error b: " << backData.mProbability << endl; 
    10331033 
    10341034                        // clamp because of precision issues 
     
    29032903} 
    29042904 
     2905 
    29052906BspLeaf *VspBspTree::GetRandomLeaf(const bool onlyUnmailed) 
    29062907{ 
     
    29382939} 
    29392940 
     2941 
    29402942int VspBspTree::ComputePvsSize(const RayInfoContainer &rays) const 
    29412943{ 
     
    29702972        return pvsSize; 
    29712973} 
     2974 
    29722975 
    29732976float VspBspTree::GetEpsilon() const 
     
    30393042 
    30403043        float t; 
    3041         //const float thresh = 1 ? 1e-6f : 0.0f; 
    3042         const float thresh = 0.01f; 
    3043  
     3044        const float thresh = 1e-6f; // matt: change this 
     3045         
    30443046        while (1) 
    30453047        { 
     
    30723074                                farChild = in->GetBack(); // plane splits ray 
    30733075                        } 
    3074                         else // one of the ray end points on the plane 
     3076                        else // one of the ray end points is on the plane 
    30753077                        {       // NOTE: what to do if ray is coincident with plane? 
    30763078                                if (extSide < 0) 
    30773079                                        node = in->GetBack(); 
    3078                                 else  
     3080                                else //if (extSide > 0) 
    30793081                                        node = in->GetFront(); 
    3080                                                                  
     3082                                //else break; // coincident => count no intersections 
     3083 
    30813084                                continue; // no far child 
    30823085                        } 
     
    33673370                 
    33683371                vector<BspLeaf *> neighbors; 
    3369                 if (0) 
     3372                if (1) 
    33703373                        FindNeighbors(leaf, neighbors, true); 
    33713374                else 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r678 r694  
    587587        inline bool LocalTerminationCriteriaMet(const VspBspTraversalData &data) const; 
    588588 
     589        /** Returns true if global tree can be terminated. 
     590        */ 
    589591        inline bool GlobalTerminationCriteriaMet(const VspBspTraversalData &data) const; 
    590592 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r693 r694  
    3434  environment->GetBoolValue("VssPreprocessor.testBeamSampling", mTestBeamSampling); 
    3535  environment->GetBoolValue("VssPreprocessor.enlargeViewSpace", mEnlargeViewSpace); 
    36  
     36  environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
     37   
    3738  useViewspacePlane = mUseViewSpaceBox; //hack 
    3839 
     
    4142  Debug << "use view space box=" << mUseViewSpaceBox << endl; 
    4243  Debug << "enlarge view space=" << mEnlargeViewSpace << endl; 
    43   Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 
    44  
    4544  Debug << "*********** end vss preprocessor options **************" << endl; 
    4645 
     
    102101        // cast ray to KD tree to find intersection with other objects 
    103102        Intersectable *objectA, *objectB; 
    104         Vector3 pointA, pointB; 
     103        // change matt 
     104        Vector3 pointA; 
     105        Vector3 pointB; 
     106 
    105107        float bsize = Magnitude(box.Size()); 
    106108 
     
    126128        } 
    127129 
    128          
    129         if (mDetectEmptyViewSpace) { 
     130        // matt: point A could be undefined? 
     131        if (1 && mDetectEmptyViewSpace) { 
    130132                SetupRay(ray, pointA, -direction); 
    131133        } else 
     
    153155        } 
    154156   
     157        //bool thesame = objectA && (objectA == objectB); 
     158         
    155159        //  if (objectA == NULL && objectB != NULL) { 
    156         if (mDetectEmptyViewSpace)  
     160        if (1 && mDetectEmptyViewSpace)  
    157161        { 
    158162                // cast again to ensure that there is no objectA 
     
    171175 
    172176        bool validSample = (objectA != objectB); 
     177         
     178        //if (validSample && thesame) Debug << "warning!!" << endl; 
    173179 
    174180        if (0 && mDetectEmptyViewSpace)  
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r685 r694  
    1414#include "RssTree.h" 
    1515#include "Beam.h" 
     16 
    1617 
    1718 
     
    210211} 
    211212 
     213 
    212214void 
    213215X3dExporter::ExportMeshInstance(MeshInstance *object) 
     
    218220  ExportMesh(object->GetMesh()); 
    219221} 
     222 
    220223 
    221224void  
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r693 r694  
    5454static SAXParser::ValSchemes    valScheme       = SAXParser::Val_Auto; 
    5555 
    56  
     56#define ROTATE_SCENE 1 
    5757 
    5858 
     
    8383  StrX lname(name); 
    8484  string element(lname.LocalForm()); 
     85   
    8586  if (element == "Shape") 
    8687    EndShape(); 
    8788} 
    8889 
    89 // HACK 
    90 void RotateMesh(Mesh *mesh) 
    91 { 
    92         VertexContainer::const_iterator it, it_end = mesh->mVertices.end(); 
     90 
     91static void RotateMesh(Mesh *mesh) 
     92{ 
     93        VertexContainer::iterator it, it_end = mesh->mVertices.end(); 
    9394 
    9495        const float angle = 30.0f * PI / 180.0f; 
    95         const Matrix4x4 rot = RotationYMatrix(30); 
     96        const Matrix4x4 rot = RotationYMatrix(angle); 
    9697 
    9798        for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
    9899        { 
    99                 const Vector3 pt = rot * (*it); 
     100                (*it) = rot * (*it);         
    100101        } 
    101102} 
     
    124125                         
    125126                        mesh->mFaces.push_back(new Face(vc)); 
    126                         if (0) 
     127                        //if (ROTATE_SCENE) 
    127128                                RotateMesh(mesh); 
    128129                        mesh->Preprocess(); 
     
    142143                { 
    143144                        // HACK 
    144                         if (0) 
     145                        //if (ROTATE_SCENE) 
    145146                                RotateMesh(mCurrentMesh); 
    146147                        mCurrentMesh->Preprocess(); 
     
    156157                        delete mCurrentMesh; 
    157158                } 
     159 
    158160                mCurrentMesh = NULL; 
    159161        } 
     
    246248 
    247249 
    248                         while(1)  
     250                        while (1)  
    249251                        { 
    250252                                float x = (float)strtod(ptr, &endptr); 
     
    298300    StartIndexedFaceSet(attributes); 
    299301  } 
    300  
     302  
    301303  if (element == "Shape") { 
    302     cout<<"+"; 
     304    cout << "+"; 
    303305        mCurrentMesh = new Mesh; 
    304306  } 
     
    503505  StrX lname(name); 
    504506  string element(lname.LocalForm()); 
     507  
    505508  if (element == "Shape") 
    506509    EndShape(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h

    r657 r694  
    1414  bool ParseFile(const string filename, SceneGraphNode **root, const bool loadPolygonsAsMeshes = false); 
    1515  bool ParseFile(const string filename, ViewCellsManager &viewCells); 
    16    
     16  
     17 
     18 
    1719  /// height of a loaded view cell 
    1820  float mViewCellHeight; 
Note: See TracChangeset for help on using the changeset viewer.