Changeset 2694


Ignore:
Timestamp:
05/21/08 18:44:16 (16 years ago)
Author:
mattausch
Message:

worked on moving objects

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna

    r2692 r2694  
    88 
    99 
    10 #SCENE=../data/vienna/vienna_cropped.obj 
    11 SCENE=../data/vienna/city_full.obj 
     10SCENE=../data/vienna/vienna_cropped.obj 
     11#SCENE=../data/vienna/city_full.obj 
    1212 
    1313VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
    1414#VIEWCELLS=../data/vienna/vienna_cropped-seq-3000-false-20-viewcells.xml.gz 
    1515#VIEWCELLS=../data/vienna/vienna_cropped-57000-viewcells.xml.gz 
    16 VIEWPOINTS=../data/vienna/change.vp 
     16VIEWPOINTS=../data/vienna/testwalk.vp 
    1717 
    1818 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2691 r2694  
    1111echo "starting $TARGET version" 
    1212 
    13 #SCENE=../data/vienna/vienna_cropped.obj 
    14 SCENE=../data/vienna/city_full.obj 
     13SCENE=../data/vienna/vienna_cropped.obj 
     14#SCENE=../data/vienna/city_full.obj 
    1515 
    1616VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz  
    1717VIEWPOINTS=../data/vienna/testwalk.vp 
    1818 
    19 LOG_PREFIX=../src/SG08/try 
     19LOG_PREFIX=../src/SG08/try_100_real 
    2020#LOG_PREFIX=../src/SG08/city_full_100 
    2121 
     
    3535-gvs_samples_per_pass=1000000 \ 
    3636-gvs_initial_samples=16 \ 
    37 -gvs_max_viewcells=1 \ 
    38 -gvs_min_contribution=3000 \ 
     37-gvs_max_viewcells=20 \ 
     38-gvs_min_contribution=100 \ 
    3939-gvs_per_viewcell=true \ 
    4040-gvs_stats=$LOG_PREFIX-gvsStats.log \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2692 r2694  
    229229 
    230230                        //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj); 
    231                         //if (!node) cerr << "e: " << obj->GetBox() << " " << ray.mTermination << endl; else  
     231                        //if (!node) cerr << "e " << obj->GetBox() << " " << ray.mTermination << endl; else  
    232232                        if (!node->Mailed()) 
    233                         { 
     233                        {//cout<<"o "; 
    234234                                // add to pvs 
    235235                                node->Mail(); 
     
    565565        newOrigin = newPoint - newDir * offset; 
    566566         
     567 
    567568        ////////////// 
    568569        //-- for per view cell sampling, we must check for intersection 
     
    738739        m.mDiffuseColor = RgbColor(0, 1, 0); 
    739740        exporter->SetForcedMaterial(m); 
    740  
    741         //mViewCellsManager->ExportViewCellGeometry(exporter, vc, NULL, NULL); 
    742         //mViewCellsManager->ExportViewCellGeometry(exporter, mCurrentViewCell, NULL, NULL); 
    743741 
    744742        AxisAlignedBox3 bbox = mCurrentViewCell->GetMesh()->mBox; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2691 r2694  
    1414class KdIntersectable; 
    1515class ViewCellBasedDistribution; 
     16class ViewCellBorderBasedDistribution; 
     17 
    1618 
    1719/** View space partition statistics. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2615 r2694  
    202202 
    203203        int CastSimpleRay(const SimpleRay &ray); 
    204         int CastSimpleRay(const SimpleRay &ray, int rayIndex); 
     204       int CastSimpleRay(const SimpleRay &ray, int rayIndex); 
    205205         
    206206        AxisAlignedBox3 GetBox() const; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2691 r2694  
    16041604 
    16051605 
    1606 Mesh *Preprocessor::LoadBinaryObjIntoMesh(const string &filename) 
    1607 { 
    1608         igzstream inStream(filename.c_str()); 
    1609          
    1610         if (!inStream.is_open()) 
    1611                 return NULL; 
    1612  
    1613         cout << "binary obj dump available, loading " << filename.c_str() << endl; 
    1614          
    1615         // read in triangle size 
    1616         int numTriangles; 
    1617  
    1618         inStream.read(reinterpret_cast<char *>(&numTriangles), sizeof(int)); 
    1619          
    1620         cout << "loading " << numTriangles << " triangles into mesh" << endl; 
    1621  
    1622         Mesh *mesh = new Mesh(numTriangles * 3, numTriangles); 
    1623  
    1624         const int t = 1000; 
    1625         for (int j = 0, i = 0; j < numTriangles; ++ j, i += 3) 
    1626         { 
    1627                 Triangle3 tri; 
    1628                  
    1629                 inStream.read(reinterpret_cast<char *>(&mesh->mVertices[i]), sizeof(Vector3)); 
    1630                 inStream.read(reinterpret_cast<char *>(&mesh->mVertices[i + 1]), sizeof(Vector3)); 
    1631                 inStream.read(reinterpret_cast<char *>(&mesh->mVertices[i + 2]), sizeof(Vector3)); 
    1632  
    1633                 // hack: objects initially very small 
    1634                 mesh->mVertices[i] *= 100; 
    1635                 mesh->mVertices[i + 1] *= 100; 
    1636                 mesh->mVertices[i + 2] *= 100; 
    1637  
    1638                 mesh->AddFace(new Face(i + 0, i + 1, i + 2)); 
    1639  
    1640                 if ((j % t) == (t - 1)) 
    1641                          cout<<"\r"<<i<<"/"<<numTriangles<<"\r"; 
    1642         } 
    1643  
    1644         cout << "loaded " << numTriangles << " triangles" << endl; 
    1645  
    1646         mesh->Preprocess(); 
    1647  
    1648         cout << "finished preprocessing" << endl; 
    1649  
    1650         return mesh; 
    1651 } 
    1652  
    1653  
    1654 bool Preprocessor::LoadDynamicGeometry(const string &filename) 
     1606SceneGraphLeaf *Preprocessor::RegisterDynamicGeometryWithRayCaster(SceneGraphLeaf *leaf) 
     1607{ 
     1608        if (mRayCaster) 
     1609                mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation()); 
     1610} 
     1611 
     1612 
     1613SceneGraphLeaf *Preprocessor::LoadDynamicGeometry(const string &filename) 
    16551614{ 
    16561615#if DYNAMIC_OBJECTS_HACK 
     
    16651624                cout<<"parsing obj file.."<<endl; 
    16661625                ObjParser *p = new ObjParser; 
    1667                 parsed = p->ParseFile(filename,  
    1668                         leaf, 
    1669                         false); 
    1670                 leaf->UpdateBox(); 
    1671                 cout<<leaf->GetBox(); 
    1672  
    1673                 float s = 10.0f; 
    1674                 leaf->ApplyTransform(ScaleMatrix(s, s, s)); 
    1675                 leaf->ApplyTransform(TranslationMatrix(Vector3(0, 10, 0))); 
    1676  
    1677  
     1626                parsed = p->ParseFile(filename, leaf, false); 
    16781627        }  
    16791628        else  
    16801629        { 
    16811630                cout<<"parsing binary obj file ... " << endl; 
    1682  
    16831631                parsed = LoadBinaryObj(filename, leaf, NULL, 100); 
    16841632        } 
     
    16861634        if (parsed) 
    16871635        { 
    1688                 cout<<"success."<<endl; 
     1636                const float scale = 0.01f; 
     1637 
     1638                ObjectContainer::const_iterator it, it_end = leaf->mGeometry.end(); 
     1639 
     1640                for (it = leaf->mGeometry.begin(); it != it_end; ++ it) 
     1641                { 
     1642                        TriangleIntersectable *tri = static_cast<TriangleIntersectable *>(*it); 
     1643 
     1644                        Triangle3 t = tri->GetItem(); 
     1645 
     1646                        // scale object appropriately 
     1647                        t.mVertices[0] *= scale; 
     1648                        t.mVertices[1] *= scale; 
     1649                        t.mVertices[2] *= scale; 
     1650 
     1651                        tri->SetItem(t); 
     1652                } 
     1653 
     1654                //leaf->ApplyTransform(ScaleMatrix(s, s, s)); 
     1655                //leaf->ApplyTransform(TranslationMatrix(Vector3(0, 10, 0))); 
     1656 
    16891657                leaf->UpdateBox(); 
    1690                 cout<<leaf->GetBox(); 
    1691                 mDynamicObjects.push_back(leaf); 
    1692                 //leaf->RebuildKtbTree(); 
    16931658                mSceneGraph->GetRoot()->mChildren.push_back(leaf); 
    1694  
    1695                 if (mRayCaster) 
    1696                         mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation()); 
    1697  
    1698  
    1699                 return true; 
     1659                //mDynamicObjects.push_back(leaf); 
     1660 
     1661                cout<<"Dynamic object loaded successfully: " << leaf->GetBox() << endl; 
     1662 
     1663                return leaf; 
    17001664        }  
    1701         else 
    1702         { 
    1703                 cout<<"failed."<<endl; 
    1704  
    1705         } 
    1706  
     1665                 
    17071666 
    17081667#endif 
    1709         return false; 
     1668        cout<<"Dynamic object loading failed."<<endl; 
     1669        return NULL; 
    17101670} 
    17111671 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2691 r2694  
    192192        /** Adds dynamic geometry 
    193193        */ 
    194         bool LoadDynamicGeometry(const string &filename); 
    195  
    196         Mesh *Preprocessor::LoadBinaryObjIntoMesh(const string &filename); 
     194        SceneGraphLeaf *LoadDynamicGeometry(const string &filename); 
     195 
     196        /** Register the dynamic object to be handled by the ray caster for visibility 
     197                computation. 
     198        */ 
     199        SceneGraphLeaf *RegisterDynamicGeometryWithRayCaster(SceneGraphLeaf *leaf); 
     200 
     201         
    197202 
    198203 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp

    r2693 r2694  
    11#include "ObjectPlacer.h" 
     2#include "Matrix4x4.h" 
     3#include "SceneGraph.h" 
    24 
    3 namespace GtpVisibilityPreprocessor { 
     5 
     6 
     7namespace GtpVisibilityPreprocessor  
     8{ 
    49 
    510// --------------------------------------------------------------------------- 
    611//  ObjectPlacer implementation 
    712// --------------------------------------------------------------------------- 
    8 #if 0 
     13 
    914ObjectPlacer::ObjectPlacer() 
    10         :mCurrentLibaryObject(0), mPlacedNodes(new BranchGroup), mLibraryViz(new BranchGroup) 
     15: mCurrentObject(0) 
    1116{ 
    12         mLibraryViz->addChild(new BranchGroup); 
    13  
    14         BranchGroup *bg = new BranchGroup; 
    15         bg->addChild(new Box); 
    16         SetLibrary(bg); 
    1717} 
    1818 
    1919 
    20 void ObjectPlacer::SetLibrary(BranchGroup *library) 
     20void ObjectPlacer::AddObject(SceneGraphLeaf *obj) 
    2121{ 
    22         mLibrary = new BranchGroup; 
    23         if (!library) 
    24         { 
    25                 mLibrary->addChild(new Box); 
    26         } 
    27         else 
    28         { 
    29                 for (int i = 0; i < library->numChildren(); i ++) 
    30                 {        
    31                         Node *n = library->getChild(i); 
    32                         SharedGroup *s = new SharedGroup; 
    33                         s->addChild(n); 
    34                          
    35                         Link *l = new Link; 
    36                         l->setSharedGroup(s); 
    37                         mLibrary->addChild(l); 
    38                 } 
    39         } 
    40          
    41         UpdateLibraryViz(); 
    42 } 
    43  
    44 void ObjectPlacer::UpdateLibraryViz() 
    45 { 
    46         Link *l = new Link; 
    47         l->setSharedGroup(((Link *)mLibrary->getChild(mCurrentLibaryObject))->getSharedGroup()); 
    48  
    49         mLibraryViz->setChild(l, 0); 
     22        mDynamicObjects.push_back(obj); 
    5023} 
    5124 
     
    5326void ObjectPlacer::NextObject() 
    5427{ 
    55         if (mLibrary) 
    56                 mCurrentLibaryObject = (mCurrentLibaryObject + 1) % (mLibrary->numChildren()); 
    57         UpdateLibraryViz(); 
     28        mCurrentObject = (mCurrentObject + 1) % (int)mDynamicObjects.size(); 
    5829} 
     30 
    5931 
    6032void ObjectPlacer::PreviousObject() 
    6133{ 
    62         if (mLibrary) 
    63                 mCurrentLibaryObject = (mCurrentLibaryObject - 1) % (mLibrary->numChildren()); 
    64         UpdateLibraryViz(); 
    65 } 
    66  
    67 void ObjectPlacer::AddObject(const Point3f &p) 
    68 { 
    69         //BranchGroup *o = new BranchGroup; 
    70         TransformGroup *tg = new TransformGroup; 
    71         Transform3D t; 
    72         t.setTranslation(p - Origin3f); 
    73         tg->setTransform(t); 
    74         //o->addChild(tg); 
    75  
    76         Link *l = new Link; 
    77         l->setSharedGroup(((Link *)(mLibrary->getChild(mCurrentLibaryObject)))->getSharedGroup()); 
    78         tg->addChild(l); 
    79  
    80         mPlacedNodes->addChild(tg); 
    81 } 
    82  
    83 void ObjectPlacer::RemoveLastObject() 
    84 { 
    85         if (mPlacedNodes->numChildren() > 0) 
    86                 mPlacedNodes->removeChild(mPlacedNodes->numChildren()-1); 
    87 } 
    88  
    89 void ObjectPlacer::SaveObjects(const String &filename) 
    90 { 
    91         WriteActionIV wa(filename, ""); 
    92  
    93         wa.Apply(mPlacedNodes); 
    94 } 
    95  
    96 BranchGroup *ObjectPlacer::GetLibraryVisualization() 
    97 { 
    98         return mLibraryViz; 
    99 } 
    100  
    101 BranchGroup *ObjectPlacer::GetPlacedNodeVisualization() 
    102 { 
    103         return mPlacedNodes; 
    104 } 
    105  
    106 void ObjectPlacer::Clear() 
    107 { 
    108         mPlacedNodes->removeAllChildren();       
     34        mCurrentObject = (mCurrentObject - 1) % (int)mDynamicObjects.size(); 
    10935} 
    11036 
    11137 
    112 void TestApp::Placer(const String &parm) 
     38SceneGraphLeaf *ObjectPlacer::GetCurrentObject()  
     39{  
     40        if (mCurrentObject >= mDynamicObjects.size()) 
     41                return NULL; 
     42 
     43        return mDynamicObjects[mCurrentObject]; 
     44} 
     45 
     46 
     47void ObjectPlacer::PlaceObject(const Vector3 &pt) 
     48{ 
     49        Vector3 p = pt; 
     50 
     51        SceneGraphLeaf *obj = mDynamicObjects[mCurrentObject]; 
     52 
     53        // set pivot to ground of object 
     54        p.y -= obj->GetOriginalBox().Min().y; 
     55        Matrix4x4 trafo = TranslationMatrix(p); 
     56 
     57        obj->LoadTransform(trafo); 
     58} 
     59 
     60 
     61/*void TestApp::Placer(const String &parm) 
    11362{ 
    11463        if (parm.Empty()) 
     
    191140        } else 
    192141                OUT1("Unknown placer command"); 
     142} 
     143*/ 
    193144 
    194145} 
    195  
    196 #endif 
    197  
    198 } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h

    r2693 r2694  
    11 #ifndef OBJECTPLACER_H 
    22#define OBJECTPLACER_H 
     3 
     4#include "Containers.h" 
    35 
    46namespace GtpVisibilityPreprocessor { 
    57 
    68class Vector3; 
     9class Preprocessor; 
    710 
    811 
     
    1215{ 
    1316public: 
     17        /** Default constructor taking a pointer to the currently used preprocessor. 
     18        */ 
     19//      ObjectPlacer(Preprocessor *prep); 
    1420        ObjectPlacer(); 
    1521 
    16         /// sets library objects 
    17         //void SetLibrary(BranchGroup *library); 
    18         /// selects the next library object 
     22        /** Sets library objects. 
     23        */ 
     24        void AddObject(SceneGraphLeaf *object); 
     25 
     26        /** Selects the next library object. 
     27        */ 
    1928        void NextObject(); 
    20         /// selects the previous library object 
     29        /** Selects the previous library object. 
     30        */ 
    2131        void PreviousObject(); 
    22         /// adds an object at the indicated position 
    23         void AddObject(const Vector3 &p); 
    24         /// remove the last added object 
    25         void RemoveLastObject(); 
     32        /** Adds an object at the indicated position. 
     33        */ 
     34        void PlaceObject(const Vector3 &p); 
    2635 
    27         /// Clear all objects 
    28         void Clear(); 
     36        SceneGraphLeaf *GetCurrentObject(); 
    2937 
    30         /// Save the objects 
    31         /*void SaveObjects(const std::string &filename); 
    32  
    33         /// Get a node to visualize from the library 
    34         BranchGroup *GetLibraryVisualization(); 
    35  
    36         /// Get the nodes that have already been placed 
    37         BranchGroup *GetPlacedNodeVisualization(); 
    38  
    39 */       
    4038        virtual ~ObjectPlacer() {} 
    4139 
     40        DynamicObjectsContainer &GetDynamicObjects() { return mDynamicObjects; } 
     41 
     42 
    4243protected: 
    43         /*SceneBasePtr<BranchGroup> mLibrary; 
    44         SceneBasePtr<BranchGroup> mPlacedNodes; 
    45         SceneBasePtr<BranchGroup> mLibraryViz; 
    46         int mCurrentLibaryObject; 
    4744 
    48         /// Get a link to an object in the library 
    49         void UpdateLibraryViz(); 
    50 */ 
     45        //Preprocessor *mPreprocessor; 
     46 
     47        DynamicObjectsContainer mDynamicObjects; 
     48                 
     49        int mCurrentObject; 
     50 
    5151}; 
    5252 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2693 r2694  
    1818#include "LogWriter.h" 
    1919#include "RayCaster.h" 
     20#include "ObjectPlacer.h" 
    2021 
    2122 
     
    271272        if (pixelCount > pixelThres)  
    272273        { 
    273                 cout << "frame " << mFrame << " vc id: " << viewcell->GetId() << " pvs: " << pvsSize << " pc: " << pixelCount << " vp: " << mViewPoint << endl; 
     274                cout << "f " << mFrame << " id " << viewcell->GetId() << " pvs " << pvsSize << " e " << pixelCount << " vp " << mViewPoint << " vd " << mViewDirection << endl; 
    274275         
    275276                if (mSnapErrorFrames)  
     
    510511                _RenderDynamicObject(*dit); 
    511512        } 
     513 
     514        if (mPendingDynamicObject) 
     515                _RenderDynamicObject(mPendingDynamicObject); 
    512516#endif 
    513517} 
     
    736740        mousePoint.y = y; 
    737741 
    738 } 
     742        if (e->button() == Qt::RightButton) 
     743        { 
     744                if (mPlacer->GetCurrentObject()) 
     745                { 
     746                        Vector3 pt = Unproject(x, y); 
     747                        cout << "unproject: " << pt << endl; 
     748 
     749                        mPlacer->PlaceObject(pt); 
     750                        mPendingDynamicObject = mPlacer->GetCurrentObject(); 
     751                } 
     752        } 
     753} 
     754 
    739755 
    740756void QtGlRendererWidget::mouseReleaseEvent(QMouseEvent *e) 
     
    10471063 
    10481064        mRenderError = 0.0f; 
     1065 
    10491066        mShowRays = false; 
    1050  
    10511067        mReplayMode = false; 
     1068 
     1069        mPlacer = new ObjectPlacer(); 
     1070 
     1071        mPendingDynamicObject = NULL; 
    10521072 
    10531073        SetSceneCut(1000); 
     
    11831203        ++ mCurrentDynamicObjectIdx; 
    11841204 
    1185         if (mViewCellsManager->GetPreprocessor()->LoadDynamicGeometry(filename)) { 
    1186            
    1187           cout << "Loading finished" << endl; 
    1188         } else 
    1189           cerr << "Loading failed" << endl; 
     1205        SceneGraphLeaf *leaf =  
     1206                mViewCellsManager->GetPreprocessor()->LoadDynamicGeometry(filename); 
     1207 
     1208        if (leaf) 
     1209        { 
     1210                mPlacer->AddObject(leaf); 
     1211                cout << "Loading finished" << endl; 
     1212        } 
     1213        else 
     1214                cerr << "Loading failed" << endl; 
    11901215         
    11911216    updateGL(); 
    11921217} 
     1218 
    11931219 
    11941220void 
     
    25242550{ 
    25252551        // swap y coordinate 
    2526         //y = GetHeight() - y; 
     2552        y = GetHeight() - y; 
    25272553 
    25282554        // HACK: should come from camera! 
     
    25342560        const int viewport[4] = {0,0, GetWidth(), GetHeight()}; 
    25352561 
     2562        RenderScene(); 
     2563 
    25362564        float z; 
    25372565        glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); 
    2538  
    2539         RenderScene(); 
    2540  
     2566         
    25412567        GLdouble rx, ry, rz; 
    25422568        gluUnProject(x, y, z, modelview, projection, viewport, &rx, &ry, &rz); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2693 r2694  
    3939class OcclusionQuery; 
    4040class TransformedMeshInstance; 
     41class ObjectPlacer; 
    4142 
    4243 
     
    221222        float mTransferFunction; 
    222223 
    223  
    224224        Vector3 mDummyViewPoint; 
    225225 
     
    242242        int mReplayTimerId; 
    243243 
     244        ObjectPlacer *mPlacer; 
     245 
    244246#if DYNAMIC_OBJECTS_HACK 
     247         
     248        SceneGraphLeaf *mPendingDynamicObject; 
     249 
    245250        DynamicObjectsContainer mDynamicObjects; 
    246251#endif 
     
    254259 
    255260        QtGlRendererWidget() {}; 
     261 
     262        ~QtGlRendererWidget() { delete mPlacer; } 
    256263 
    257264        void SetThread(QtPreprocessorThread *t) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2691 r2694  
    3636 
    3737HaltonSequence ViewCellBasedDistribution::sHalton; 
     38HaltonSequence ViewCellBorderBasedDistribution::sHalton; 
    3839 
    3940SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor):  
     
    289290   
    290291  return true; 
    291 } 
    292  
    293  
    294 bool ViewCellBorderBasedDistribution::GenerateSample(SimpleRay &ray) 
    295 { 
    296         Vector3 origin, direction;  
    297  
    298         //ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells(); 
    299  
    300         Vector3 point; 
    301         Vector3 normal, normal2; 
    302          
    303         //const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f); 
    304         const int objIdx = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 
    305  
    306         Intersectable *object = mPreprocessor.mObjects[objIdx]; 
    307         ViewCell *viewCell = mViewCell;//viewCells[vcIdx]; 
    308  
    309         object->GetRandomSurfacePoint(point, normal); 
    310         viewCell->GetRandomEdgePoint(origin, normal2); 
    311  
    312         direction = point - origin; 
    313  
    314         // $$ jb the pdf is yet not correct for all sampling methods! 
    315         const float c = Magnitude(direction); 
    316  
    317         if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/) 
    318         { 
    319                 return false; 
    320         } 
    321  
    322         // $$ jb the pdf is yet not correct for all sampling methods! 
    323         const float pdf = 1.0f; 
    324         //cout << "p: " << point << " "; 
    325         direction *= 1.0f / c; 
    326         ray = SimpleRay(origin, direction, VIEWCELL_BORDER_BASED_DISTRIBUTION, pdf); 
    327  
    328         //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl; 
    329  
    330         return true; 
    331292} 
    332293 
     
    886847 
    887848 
    888 } 
    889  
    890  
     849bool ViewCellBorderBasedDistribution::GenerateSample(SimpleRay &ray) 
     850{ 
     851        float r[3]; 
     852        sHalton.GetNext(3, r); 
     853   
     854        Vector3 origin, direction;  
     855        Vector3 normal; 
     856 
     857        Vector3 point = mPreprocessor.sceneBox.GetRandomPoint(Vector3(r[0], r[1], r[2])); 
     858 
     859        mViewCell->GetRandomEdgePoint(origin, normal); 
     860 
     861        direction = point - origin; 
     862 
     863        // $$ jb the pdf is yet not correct for all sampling methods! 
     864        const float c = Magnitude(direction); 
     865 
     866        if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/) 
     867        { 
     868                return false; 
     869        } 
     870 
     871        // $$ jb the pdf is yet not correct for all sampling methods! 
     872        const float pdf = 1.0f; 
     873        //cout << "p: " << point << " "; 
     874        direction *= 1.0f / c; 
     875        ray = SimpleRay(origin, direction, VIEWCELL_BORDER_BASED_DISTRIBUTION, pdf); 
     876 
     877        //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl; 
     878 
     879        return true; 
     880} 
     881 
     882 
     883} 
     884 
     885 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h

    r2691 r2694  
    218218 
    219219 
    220 class ViewCellBorderBasedDistribution: public SamplingStrategy 
    221 { 
    222  public: 
    223          ViewCellBorderBasedDistribution(Preprocessor &preprocessor, ViewCell *viewCell) 
    224                  : SamplingStrategy(preprocessor), mViewCell(viewCell) 
    225          { 
    226                  mType = VIEWCELL_BORDER_BASED_DISTRIBUTION; 
    227          } 
    228  
    229 private: 
    230   virtual bool GenerateSample(SimpleRay &ray); 
    231  
    232   ViewCell *mViewCell; 
    233 }; 
    234  
    235  
    236220class GlobalLinesDistribution: public SamplingStrategy 
    237221{ 
     
    334318}; 
    335319 
     320class ViewCellBorderBasedDistribution: public SamplingStrategy 
     321{ 
     322 public: 
     323         ViewCellBorderBasedDistribution(Preprocessor &preprocessor, ViewCell *viewCell) 
     324                 : SamplingStrategy(preprocessor), mViewCell(viewCell) 
     325         { 
     326                 mType = VIEWCELL_BORDER_BASED_DISTRIBUTION; 
     327         } 
     328 
     329        void SetViewCell(ViewCell *vc) { mViewCell = vc; } 
     330 
     331private: 
     332 
     333        // Generate a new sample according to a mixture distribution 
     334        virtual bool GenerateSample(SimpleRay &ray); 
     335 
     336        // halton sequence generator for deciding between distributions 
     337        static HaltonSequence sHalton; 
     338 
     339        ViewCell *mViewCell; 
     340}; 
     341 
     342 
    336343}; 
    337344 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp

    r2662 r2694  
    260260                        SceneGraphLeaf *leaf = static_cast<SceneGraphLeaf *>(node); 
    261261 
    262                         size += leaf->mGeometry.size(); 
     262                        size += (int)leaf->mGeometry.size(); 
    263263                } 
    264264                else 
     
    318318 
    319319 
    320  
    321 } 
     320AxisAlignedBox3 SceneGraphLeaf::GetOriginalBox() const  
     321{ 
     322        return mBox; 
     323} 
     324 
     325} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h

    r2678 r2694  
    6565 
    6666        virtual AxisAlignedBox3 GetBox() const; 
     67        /** Returns the box without the trafo. 
     68        */ 
     69        virtual AxisAlignedBox3 GetOriginalBox() const; 
    6770 
    6871        virtual void ApplyTransform(const Matrix4x4 &trafo); 
Note: See TracChangeset for help on using the changeset viewer.