Changeset 2702


Ignore:
Timestamp:
05/23/08 17:47:22 (16 years ago)
Author:
mattausch
Message:

implemented dynamic object placement / removal

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

Legend:

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

    r2696 r2702  
    88 
    99 
    10 #SCENE=../data/vienna/vienna_cropped.obj 
     10SCENE=../data/vienna/vienna_cropped.obj 
    1111#SCENE=../data/vienna/city_full.obj 
    1212#SCENE=../data/vienna/city_full_hp.obj 
    13 SCENE=../data/vienna/vienna_rep.obj 
     13#SCENE=../data/vienna/vienna_rep.obj 
    1414 
    1515VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2699 r2702  
    1414#VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz 
    1515#SCENE=../data/vienna/vienna_cropped.obj 
    16 #SCENE=../data/roofs2.obj 
     16SCENE=../data/roofs_new.obj 
    1717#SCENE=../data/vienna/city_full_hp.obj 
    18 SCENE=../data/vienna/vienna_rep.obj 
     18#SCENE=../data/vienna/vienna_rep.obj 
    1919 
    2020#SCENE=../data/vienna/vienna_cropped.obj 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h

    r2678 r2702  
    2222class KdLeaf; 
    2323class Vector3; 
     24class IntersectableGroup; 
    2425 
    2526struct IndexedBoundingBox; 
     
    7576 
    7677/// a container for dynamic objects 
    77  
    7878typedef vector<SceneGraphLeaf *> DynamicObjectsContainer; 
    7979 
     80// a container for intersectable groups (e.g., triangle soups) 
     81typedef vector<IntersectableGroup *> GroupContainer; 
    8082 
    8183} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2697 r2702  
    551551        glPopMatrix(); 
    552552 
    553         if (1) 
    554         { 
    555                 // test the box of the object 
     553        if (0) 
     554        { 
     555                // render the box of the object 
    556556                AxisAlignedBox3 box = leaf->GetBox(); 
    557557                RenderBox(box); 
     
    590590        Intersectable::NewMail(); 
    591591 
    592 #if DYNAMIC_OBJECTS_HACK 
    593592        Preprocessor *p = mViewCellsManager->GetPreprocessor(); 
    594593        // handle dynamic objects 
     
    599598                _RenderDynamicObject(*dit); 
    600599        } 
    601 #endif 
     600 
    602601        _RenderSceneTrianglesWithDrawArrays(); 
    603602 
     
    606605 
    607606 
    608 void 
    609 GlRendererBuffer::EvalQueryWithItemBuffer() 
    610 { 
    611         // read back the texture 
    612         glReadPixels(0, 0, 
    613                 GetWidth(), GetHeight(), 
    614                 GL_RGBA, 
    615                 GL_UNSIGNED_BYTE, 
    616                 mPixelBuffer); 
    617  
    618  
    619         unsigned int *p = mPixelBuffer; 
    620  
    621         for (int y = 0; y < GetHeight(); y++) 
    622         { 
    623                 for (int x = 0; x < GetWidth(); x++, p++)  
    624                 { 
    625                         unsigned int id = (*p) & 0xFFFFFF; 
    626  
    627                         if (id != 0xFFFFFF) 
    628                         { 
    629                                 ++ mObjects[id]->mCounter; 
    630                         } 
    631                 } 
    632         } 
    633 } 
    634  
     607 
     608Preprocessor *GlRenderer::GetPreprocessor() 
     609{ 
     610        return mViewCellsManager->GetPreprocessor(); 
     611} 
    635612 
    636613 
     
    648625        mPixelBuffer = NULL;  
    649626        // implement width and height in subclasses 
     627} 
     628 
     629 
     630void 
     631GlRendererBuffer::EvalQueryWithItemBuffer() 
     632{ 
     633        // read back the texture 
     634        glReadPixels(0, 0, 
     635                GetWidth(), GetHeight(), 
     636                GL_RGBA, 
     637                GL_UNSIGNED_BYTE, 
     638                mPixelBuffer); 
     639 
     640 
     641        unsigned int *p = mPixelBuffer; 
     642 
     643        for (int y = 0; y < GetHeight(); y++) 
     644        { 
     645                for (int x = 0; x < GetWidth(); x++, p++)  
     646                { 
     647                        unsigned int id = (*p) & 0xFFFFFF; 
     648 
     649                        if (id != 0xFFFFFF) 
     650                        { 
     651                                ++ mObjects[id]->mCounter; 
     652                        } 
     653                } 
     654        } 
    650655} 
    651656 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2686 r2702  
    2929class SimpleRayContainer; 
    3030class SceneGraphLeaf; 
     31class Preprocessor; 
    3132 
    3233struct VssRayContainer; 
     
    234235        }; 
    235236 
     237        Preprocessor *GetPreprocessor(); 
     238 
     239 
    236240        vector<PvsErrorEntry> mPvsErrorBuffer; 
    237241 
     
    297301 
    298302        GlRendererBuffer(SceneGraph *sceneGraph, 
    299                 ViewCellsManager *viewcells, 
    300                 KdTree *tree); 
     303                                         ViewCellsManager *viewcells, 
     304                                         KdTree *tree); 
    301305 
    302306        virtual ~GlRendererBuffer(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2694 r2702  
    249249/** Intersectable wrapping is a group of objects. 
    250250*/ 
    251 class ContainerIntersectable: public GtpVisibilityPreprocessor::IntersectableWrapper<ObjectContainer *> 
    252 { 
    253 public: 
    254         ContainerIntersectable(ObjectContainer *item): 
     251class IntersectableGroup: public GtpVisibilityPreprocessor::IntersectableWrapper<ObjectContainer *> 
     252{ 
     253public: 
     254        IntersectableGroup(ObjectContainer *item): 
    255255          IntersectableWrapper<ObjectContainer *>(item) {} 
    256256 
    257257        // hack 
    258         ~ContainerIntersectable()  
     258        ~IntersectableGroup()  
    259259        { 
    260260                delete mItem; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp

    r2544 r2702  
    5555                FindIntersectingObjects(box, *entryObjects); 
    5656 
    57                 ContainerIntersectable *entry =  
    58                         new ContainerIntersectable(entryObjects); 
     57                IntersectableGroup *entry =  
     58                        new IntersectableGroup(entryObjects); 
    5959 
    6060                entry->SetId((*iit).first); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2701 r2702  
    15911591 
    15921592 
    1593 SceneGraphLeaf *Preprocessor::RegisterDynamicGeometryWithRayCaster(SceneGraphLeaf *leaf) 
    1594 { 
     1593void Preprocessor::RegisterDynamicObject(SceneGraphLeaf *leaf) 
     1594{        
     1595        mDynamicObjects.push_back(leaf); 
     1596 
     1597        // add to scene graph 
     1598        mSceneGraph->GetRoot()->mChildren.push_back(leaf); 
     1599 
    15951600  if (mRayCaster) 
    15961601        mRayCaster->AddDynamicObjecs(leaf->mGeometry, leaf->GetTransformation()); 
     
    16021607SceneGraphLeaf *Preprocessor::LoadDynamicGeometry(const string &filename) 
    16031608{ 
    1604 #if DYNAMIC_OBJECTS_HACK 
    1605  
    16061609        const bool dynamic = true; 
    16071610        SceneGraphLeaf *leaf = new SceneGraphLeaf(dynamic); 
     
    16231626        if (parsed) 
    16241627        { 
    1625                 const float scale = 0.01f; 
    1626  
    16271628                ObjectContainer::const_iterator it, it_end = leaf->mGeometry.end(); 
    16281629 
     
    16331634                        Triangle3 t = tri->GetItem(); 
    16341635 
    1635                         // scale object appropriately 
     1636                        // hack: scale object appropriately 
     1637                        float scale = 0.01f; 
     1638 
    16361639                        t.mVertices[0] *= scale; 
    16371640                        t.mVertices[1] *= scale; 
     
    16411644                } 
    16421645 
    1643                 //leaf->ApplyTransform(ScaleMatrix(s, s, s)); 
    1644                 //leaf->ApplyTransform(TranslationMatrix(Vector3(0, 10, 0))); 
    1645  
    16461646                leaf->UpdateBox(); 
    1647                 mSceneGraph->GetRoot()->mChildren.push_back(leaf); 
    1648                 //mDynamicObjects.push_back(leaf); 
    1649  
    16501647                cout<<"Dynamic object loaded successfully: " << leaf->GetBox() << endl; 
    16511648 
     
    16541651                 
    16551652 
    1656 #endif 
    16571653        cout<<"Dynamic object loading failed."<<endl; 
    16581654        return NULL; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2695 r2702  
    3333class SceneGraphLeaf; 
    3434class GlRendererWidget; 
     35class IntersectableGroup; 
    3536 
    3637 
     
    197198                computation. 
    198199        */ 
    199         SceneGraphLeaf *RegisterDynamicGeometryWithRayCaster(SceneGraphLeaf *leaf); 
    200  
     200        void RegisterDynamicObject(SceneGraphLeaf *leaf); 
    201201         
    202202 
     
    226226        ViewCellsManager *mViewCellsManager; 
    227227 
    228 #if DYNAMIC_OBJECTS_HACK 
    229228        DynamicObjectsContainer mDynamicObjects; 
    230 #endif 
     229 
    231230        /// greedy optimized hierarchy for both objects and view cells 
    232231        VspOspTree *mVspOspTree; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp

    r2694 r2702  
    2020void ObjectPlacer::AddObject(SceneGraphLeaf *obj) 
    2121{ 
    22         mDynamicObjects.push_back(obj); 
     22        mLibraryObjects.push_back(obj); 
    2323} 
    2424 
     
    2626void ObjectPlacer::NextObject() 
    2727{ 
    28         mCurrentObject = (mCurrentObject + 1) % (int)mDynamicObjects.size(); 
     28        mCurrentObject = (mCurrentObject + 1) % (int)mLibraryObjects.size(); 
    2929} 
    3030 
     
    3232void ObjectPlacer::PreviousObject() 
    3333{ 
    34         mCurrentObject = (mCurrentObject - 1) % (int)mDynamicObjects.size(); 
     34        mCurrentObject = (mCurrentObject - 1) % (int)mLibraryObjects.size(); 
    3535} 
    3636 
     
    3838SceneGraphLeaf *ObjectPlacer::GetCurrentObject()  
    3939{  
    40         if (mCurrentObject >= mDynamicObjects.size()) 
     40        if (mCurrentObject >= mLibraryObjects.size()) 
    4141                return NULL; 
    4242 
    43         return mDynamicObjects[mCurrentObject]; 
     43        return mLibraryObjects[mCurrentObject]; 
    4444} 
    4545 
     
    4949        Vector3 p = pt; 
    5050 
    51         SceneGraphLeaf *obj = mDynamicObjects[mCurrentObject]; 
     51        SceneGraphLeaf *obj = mLibraryObjects[mCurrentObject]; 
    5252 
    5353        // set pivot to ground of object 
     
    5858} 
    5959 
    60  
    61 /*void TestApp::Placer(const String &parm) 
    62 { 
    63         if (parm.Empty()) 
    64         { 
    65                 OUT1("Object placement: place/load <libaryfile>/removelast/next/previous/save <objectfile>"); 
    66                 return; 
    67         } 
    68  
    69         ASM_RET(viewer->GetRoot(), "No scene"); 
    70          
    71         if (!placer) 
    72                 placer = new ObjectPlacer; 
    73  
    74         //-- make sure the placer visualization (which shows the already placed objects) is in the viewer 
    75         SearchNodeByNameVisitor search("placervis"); 
    76         search.Apply(viewer->GetRoot(), SearchNodeByNameVisitor::FIRST); 
    77         BranchGroup *placervis = search.GetNode(); 
    78         if (!placervis) 
    79         { 
    80                 placervis = placer->GetPlacedNodeVisualization(); 
    81                 viewer->GetRoot()->addChild(placervis); 
    82                 placervis->setName("placervis"); 
    83         } 
    84  
    85         if (parm == "place") 
    86         { 
    87                 int x, y; 
    88                 input_module->GetMousePos(x, y); 
    89  
    90                 Point3f pos = viewer->UnProject(x, y); 
    91                 if (viewer && viewer->GetRoot() && viewer->GetRoot()->getBoundingBox()->intersects(pos)) 
    92                 { 
    93                         placer->AddObject(pos); 
    94                         OUT1(x << " " << y << " " << pos); 
    95                 } 
    96                 else 
    97                 { 
    98                         OUT1("Point out of bounds"); 
    99                 } 
    100         } else if (parm == "removelast") { 
    101                 placer->RemoveLastObject(); 
    102         } else if (parm == "next") { 
    103                 placer->NextObject(); 
    104         } else if (parm == "previous") { 
    105                 placer->PreviousObject(); 
    106         } else if (parm.Left(5) == "save ") { 
    107                 String filename = parm.Right(parm.size()-5); 
    108                 if (!filename.Empty()) 
    109                         placer->SaveObjects(filename); 
    110         } else if (parm.Left(5) == "clear") { 
    111                 placer->Clear(); 
    112         } else if (parm.Left(5) == "load ") { 
    113                 String fn = sysutils::FindFile(parm.Right(parm.size()-5), settings->get_ObjectPath()); 
    114  
    115                 ASM_ELSE(!fn.empty(), "Couldn't find file " << fn) 
    116                 { 
    117                         OUT1("Loading library " << fn << "..."); 
    118                         SceneBasePtr<BranchGroup> root = ReadSceneGraph(fn, 0, 0, 1); 
    119  
    120                         BranchGroup *library = new BranchGroup; 
    121                         ASM_ELSE((root != NULL), "No scene found in file...") 
    122                         { 
    123                                 SearchNodeByNameVisitor search("start"); 
    124                                 search.Apply(root, SearchNodeByNameVisitor::FIRST); 
    125                                 BranchGroup *local_root = search.GetNode(); 
    126  
    127                                 if (local_root == NULL) 
    128                                 { 
    129                                         OUT1("Note: BranchGroup named \"start\" not found - using root node"); 
    130                                         local_root = root; 
    131                                 } 
    132  
    133                                 placer->SetLibrary(local_root); 
    134                                 BranchGroup *viz = placer->GetLibraryVisualization(); 
    135                                 mRenderArea->SetSceneRoot(viz); 
    136                                 mRenderArea->SetCamera(new Camera); 
    137                                 mRenderArea->GetCamera()->ViewAll(viz->getBoundingSphere()); 
    138                         } 
    139                 } 
    140         } else 
    141                 OUT1("Unknown placer command"); 
    14260} 
    143 */ 
    144  
    145 } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h

    r2694 r2702  
    1  #ifndef OBJECTPLACER_H 
     1#ifndef OBJECTPLACER_H 
    22#define OBJECTPLACER_H 
    33 
     
    1515{ 
    1616public: 
    17         /** Default constructor taking a pointer to the currently used preprocessor. 
     17        /** Default constructor. 
    1818        */ 
    19 //      ObjectPlacer(Preprocessor *prep); 
    2019        ObjectPlacer(); 
    2120 
    22         /** Sets library objects. 
     21        virtual ~ObjectPlacer() {} 
     22 
     23        /** Adds a library objects. 
    2324        */ 
    24         void AddObject(SceneGraphLeaf *object); 
    25  
     25        void AddObject(SceneGraphLeaf *obj); 
    2626        /** Selects the next library object. 
    2727        */ 
     
    3333        */ 
    3434        void PlaceObject(const Vector3 &p); 
    35  
     35        /** Returns the currently active object. 
     36        */ 
    3637        SceneGraphLeaf *GetCurrentObject(); 
    37  
    38         virtual ~ObjectPlacer() {} 
    39  
    40         DynamicObjectsContainer &GetDynamicObjects() { return mDynamicObjects; } 
     38        /** Returns a ref to the object container. 
     39        */ 
     40        DynamicObjectsContainer &GetDynamicObjects() { return mLibraryObjects; } 
    4141 
    4242 
    4343protected: 
    4444 
    45         //Preprocessor *mPreprocessor; 
    46  
    47         DynamicObjectsContainer mDynamicObjects; 
    48                  
     45        DynamicObjectsContainer mLibraryObjects; 
    4946        int mCurrentObject; 
    5047 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2697 r2702  
    6363   GLuint names, *ptr; 
    6464 
    65    cout << "hits = %d" << endl;; 
     65   cout << "hits: " << hits << endl;; 
    6666   ptr = (GLuint *) buffer; 
    6767 
     
    7171           names = *ptr; 
    7272 
    73            printf (" number of names for hit = %d\n", names); ptr++; 
    74            printf("  z1 is %g;", (float) *ptr/0x7fffffff); ptr++; 
    75            printf(" z2 is %g\n", (float) *ptr/0x7fffffff); ptr++; 
    76            printf ("   the name is "); 
    77  
    78            for (j = 0; j < names; j++) {     /*  for each name */ 
     73           printf ("number of names for hit: %d\n", names); ptr ++; 
     74           printf("z1: %g;", (float) *ptr / 0x7fffffff); ptr ++; 
     75           printf("z2: %g\n", (float) *ptr / 0x7fffffff); ptr ++; 
     76           printf ("the name is "); 
     77 
     78           // for each name  
     79           for (j = 0; j < names; j++)  
    7980                   printf ("%d ", *ptr); ptr++; 
    80            } 
     81 
    8182           printf ("\n"); 
    8283   } 
     
    555556        glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 
    556557 
    557 #if DYNAMIC_OBJECTS_HACK 
    558558        // handle dynamic objects 
    559         DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end(); 
    560  
    561         for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 
     559        DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicPvsObjects.end(); 
     560 
     561        for (dit = mDynamicPvsObjects.begin(); dit != dit_end; ++ dit) 
    562562        { 
    563563                _RenderDynamicObject(*dit); 
     
    565565 
    566566        // handle dynamic objects 
    567         dit, dit_end = mPendingDynamicObjects.end(); 
    568  
    569         for (dit = mPendingDynamicObjects.begin(); dit != dit_end; ++ dit) 
     567        Preprocessor *p = mViewCellsManager->GetPreprocessor(); 
     568        dit, dit_end = p->mDynamicObjects.end(); 
     569 
     570        for (dit = p->mDynamicObjects.begin(); dit != dit_end; ++ dit) 
    570571        { 
    571572                _RenderDynamicObject(*dit); 
     
    573574 
    574575        //_RenderDynamicObject(mPendingDynamicObject); 
    575 #endif 
    576576} 
    577577 
     
    586586        mPvsSize = pvs.GetSize(); 
    587587 
    588 #if DYNAMIC_OBJECTS_HACK 
    589         mDynamicObjects.clear(); 
    590 #endif 
     588        mDynamicPvsObjects.clear(); 
    591589 
    592590        ObjectPvsIterator it = pvs.GetIterator(); 
     
    604602                        } 
    605603                        break; 
    606 #if DYNAMIC_OBJECTS_HACK 
    607604 
    608605                case Intersectable::SCENEGRAPHLEAF_INTERSECTABLE: 
    609                         mDynamicObjects.push_back(static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem()); 
     606                        mDynamicPvsObjects.push_back(static_cast<SceneGraphLeafIntersectable *>(obj)->GetItem()); 
    610607                        break; 
    611 #endif 
    612608                default: 
    613609                        cerr << "PreparePvs: type " << Intersectable::GetTypeName(obj) << " not handled yet" << endl; 
     
    807803 
    808804                        mPlacer->PlaceObject(pt); 
    809                         //mPendingDynamicObjects.push_back( mPlacer->GetCurrentObject()); 
     805                        SceneGraphLeaf *leaf = mPlacer->GetCurrentObject(); 
     806 
     807                        // hack: should just pass a IntersectableGroup as a whole 
     808                        // instead we duplicate the object container and create a new 
     809                        // leaf 
     810                        SceneGraphLeaf *newObj = new SceneGraphLeaf(*leaf); 
     811 
     812                        mViewCellsManager->GetPreprocessor()->RegisterDynamicObject(newObj); 
     813                        //mPendingDynamicObjects.push_back(); 
    810814                } 
    811815        } 
     
    825829                const Vector3 pt = Unproject(x, y); 
    826830 
    827                 int num = FindDynamicObject(pt); 
    828                 cout << "\n*****************\n" << "here4" << num << endl; 
    829                 //processHits(buf); 
    830  
     831                int idx = FindDynamicObject(x, y); 
     832                 
     833                Preprocessor *p = GetPreprocessor(); 
     834 
     835                swap(p->mDynamicObjects[idx], p->mDynamicObjects.back()); 
     836                p->mDynamicObjects.pop_back(); 
    831837                /*if (mCurrentDynamicObjectIdx >= 0) { 
    832838                preprocessor->ScheduleUpdateDynamicObjects(); 
     
    933939        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    934940 
    935         if (1)  
    936         { 
    937                 SetupCameraProjection(width(), height()); 
    938                 SetupCamera(); 
    939  
    940                 if (mRenderErrors)  
    941                 { 
    942                         RenderErrors(); 
    943                 }  
    944                 else  
    945                 { 
    946                         glColor3f(0.6f, 0.6f, 0.6f); 
    947                         VisualizePvs(); 
    948                 } 
    949  
    950                 if (mShowRays)  
    951                 { 
    952                         RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1); 
    953                 } 
    954         } 
    955  
     941        SetupCameraProjection(width(), height()); 
     942        SetupCamera(); 
     943 
     944        if (mRenderErrors)  
     945                RenderErrors(); 
     946        else  
     947        { 
     948                glColor3f(0.6f, 0.6f, 0.6f); 
     949                VisualizePvs(); 
     950        } 
     951 
     952        if (mShowRays)  
     953                RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1); 
     954         
    956955        RenderInfo(); 
    957         mFrame ++; 
     956 
     957        ++ mFrame; 
    958958        //      cout<<"vp="<<mViewPoint<<" vd="<<mViewDirection<<endl; 
    959959} 
     
    23672367        vbox->layout()->addWidget(button); 
    23682368        connect(button, SIGNAL(clicked()), SIGNAL(ComputeGVS())); 
    2369  
    2370 #else 
    2371          
     2369#endif 
     2370 
     2371#if 1    
    23722372        button = new QPushButton("Replay view points", vbox); 
    23732373        vbox->layout()->addWidget(button); 
     
    23762376#endif 
    23772377 
    2378 #if DYNAMIC_OBJECTS_HACK 
    2379  
    23802378        button = new QPushButton("Load object", vbox); 
    23812379        vbox->layout()->addWidget(button); 
    23822380        connect(button, SIGNAL(clicked()), SIGNAL(LoadObject())); 
    2383 #endif 
    23842381 
    23852382        /*cb = new QCheckBox("Stats", vbox); 
     
    26502647 
    26512648 
    2652 int QtGlRendererWidget::FindDynamicObject(const Vector3 &pos)  
     2649int QtGlRendererWidget::FindDynamicObject(float x, float y)  
    26532650{  
     2651        makeCurrent(); 
    26542652        // we need to lock the rendering context  
    26552653        //glw.lockGLContext();  
     
    26602658        // see below for an explanation on the buffer content  
    26612659        GLuint buffer[maxSize];  
    2662         GLint viewport[4]; 
    2663  
    2664         glGetIntegerv(GL_VIEWPORT, viewport);  
    26652660        glSelectBuffer(maxSize, buffer);  
    26662661         
     
    26732668        glPushMatrix();  
    26742669        glLoadIdentity();  
    2675         gluPickMatrix((GLdouble)pos.x, (GLdouble)(viewport[3] - pos.y), 5.0f, 5.0f, viewport);  
    2676          
    2677         GLfloat x = (GLfloat)width() / height();  
    2678         glFrustum(-x, x, -1.0, 1.0, 4.0, 15.0);  
    2679          
    2680          glLoadName(1); 
    2681  
    2682         _RenderDynamicObject(mPendingDynamicObjects[0]); 
     2670 
     2671        glViewport(0, 0, width(), height()); 
     2672 
     2673        GLint viewport[4]; 
     2674        glGetIntegerv(GL_VIEWPORT, viewport);  
     2675 
     2676        const float w = 1.0f; 
     2677 
     2678        //gluPickMatrix(x, y, 1000.0, 1000.0, viewport); 
     2679        gluPickMatrix((GLdouble)x, (GLdouble)(viewport[3] - y), w, w, viewport);  
     2680 
     2681        GLfloat aspect = (GLfloat) width() / height();  
     2682        gluPerspective(70.0f, aspect, 0.1f, 2.0f * Magnitude(mSceneGraph->GetBox().Diagonal())); 
     2683         
     2684        glMatrixMode(GL_MODELVIEW); 
     2685        glPushMatrix();  
     2686        glLoadIdentity(); 
     2687        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     2688         
     2689         
     2690        SetupCamera(); 
     2691 
     2692        for (size_t i = 0; i < GetPreprocessor()->mDynamicObjects.size(); ++ i) 
     2693        { 
     2694                glLoadName(i); 
     2695                _RenderDynamicObject(GetPreprocessor()->mDynamicObjects[i]); 
     2696        } 
     2697 
     2698        glFlush(); 
     2699        glPopMatrix(); 
    26832700 
    26842701        glMatrixMode(GL_PROJECTION);  
    26852702        glPopMatrix(); 
    26862703 
     2704        //updateGL(); 
     2705 
     2706        int hits; 
    26872707        // finally release the rendering context again  
    2688         if (!glRenderMode(GL_RENDER))  
     2708        if ((hits = glRenderMode(GL_RENDER)) < 0)  
    26892709        {  
     2710                cout << "no object picked" << endl; 
    26902711                //glw.unlockGLContext();  
    26912712                return -1;  
    26922713        }  
     2714 
     2715 
     2716        //processHits(hits, buffer); 
     2717 
    26932718         
    26942719        //glw.unlockGLContext();  
     
    27032728        // (number of the surface).  
    27042729        // return the name of the clicked surface  
    2705          
    27062730        return buffer[3];  
    27072731} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2697 r2702  
    248248        ObjectPlacer *mPlacer; 
    249249 
    250 #if DYNAMIC_OBJECTS_HACK 
    251  
    252         DynamicObjectsContainer mPendingDynamicObjects; 
    253         DynamicObjectsContainer mDynamicObjects; 
    254  
    255 #endif 
     250        //DynamicObjectsContainer mPendingDynamicObjects; 
     251        DynamicObjectsContainer mDynamicPvsObjects; 
    256252 
    257253        QtGlRendererWidget(SceneGraph *sceneGraph, 
     
    329325        Vector3 Unproject(int x, int y); 
    330326         
    331         int FindDynamicObject(const Vector3 &pos); 
     327        int FindDynamicObject(float x, float y); 
    332328 
    333329 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp

    r2694 r2702  
    282282        mTrafo = IdentityMatrix(); 
    283283 
    284 #if DYNAMIC_OBJECTS_HACK 
    285284        mIntersectable = new SceneGraphLeafIntersectable(this, mBox); 
    286 #endif 
    287285} 
    288286 
     
    323321} 
    324322 
    325 } 
     323 
     324SceneGraphLeaf::SceneGraphLeaf(SceneGraphLeaf const& copy) 
     325{ 
     326        // hack: should just pass a IntersectableGroup as a whole 
     327        // instead we duplicate the object container and create a new 
     328        // leaf 
     329        mGeometry = copy.mGeometry; 
     330        //for (size_t i = 0; i < copy.mGeometry->size(); ++ i) 
     331        //      mGeometry.push_back(copy.mGeometry[i]); 
     332 
     333        mBox = copy.mBox; 
     334        mTrafo = copy.mTrafo; 
     335        mIsDynamic = copy.mIsDynamic; 
     336} 
     337 
     338} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h

    r2694 r2702  
    5555{ 
    5656public: 
    57  
     57        /** Copy constructor. 
     58        */ 
     59        SceneGraphLeaf(SceneGraphLeaf const&); 
    5860        SceneGraphLeaf(); 
    5961        SceneGraphLeaf(bool isDynamic); 
     
    7476        virtual void UpdateBox(); 
    7577 
    76 #if DYNAMIC_OBJECTS_HACK 
    7778        SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; } 
    78 #endif 
    7979 
    80         /// used as actual pvs entry 
     80        const Matrix4x4 &GetTransformation() const { return mTrafo; } 
     81 
     82        //void SetGeometry(ObjectContainer *geometry); 
     83 
     84        /// used as actual pvs entry: note should be pointer to geometry!! 
    8185        ObjectContainer mGeometry; 
    82   const Matrix4x4 &GetTransformation() const { return mTrafo; } 
     86 
     87 
    8388protected: 
    8489 
    85 #if DYNAMIC_OBJECTS_HACK 
    86          
    8790        SceneGraphLeafIntersectable *mIntersectable; 
    88         CKTB *mKtbTree; 
    89  
    90 #endif 
    9191 
    9292        bool mIsDynamic; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2696 r2702  
    369369{ 
    370370        // dynamic objects are scene graph leaves 
    371 #if DYNAMIC_OBJECTS_HACK 
    372371        if (ray.mTerminationObject->Type() == Intersectable::SCENEGRAPHLEAF_INTERSECTABLE) 
    373372                return ray.mTerminationObject; 
    374 #endif 
    375373 
    376374        if (mUseKdPvs) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/common.h

    r2699 r2702  
    2323#include <vector> 
    2424 
    25 #define DYNAMIC_OBJECTS_HACK 1 
    2625#define USE_HAVRAN_RAYCASTER 1 
    2726 
Note: See TracChangeset for help on using the changeset viewer.