Ignore:
Timestamp:
01/18/08 16:28:30 (16 years ago)
Author:
mattausch
Message:

worked on dynamic objects

Location:
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
Files:
4 edited

Legend:

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

    r2613 r2614  
    386386        for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 
    387387        { 
     388                //cerr << "here45\n****"<<endl; 
    388389                RenderIntersectable(*dit); 
    389390        } 
     
    659660        int diffy = -(mousePoint.y - y); 
    660661 
     662        const float t = 1.0f; 
     663 
    661664        if (e->modifiers() & Qt::ControlModifier)  
    662665        { 
     
    664667                mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 
    665668        }  
    666         else  
     669        else if (e->modifiers() & Qt::AltModifier) 
     670        { 
     671                if (mCurrentDynamicObjectIdx >= 0) 
     672                { 
     673                        Matrix4x4 tm; 
     674                        TransformedMeshInstance *tmi; 
     675 
     676                        switch (mTrafoType) 
     677                        { 
     678                        case 0: 
     679                                { 
     680                                        const Vector3 transl(diffx, 0, diffy); 
     681                                        tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 
     682                                        tm = TranslationMatrix(transl); 
     683                                } 
     684                                break; 
     685                        case 1: 
     686                                { 
     687                                        float scalef = 1.0f + 0.01f * (diffx + diffy); 
     688                                        if (scalef < 0.9) scalef = 0.9f; 
     689                                        else if (scalef > 1.1f) scalef = 1.1f; 
     690                                        tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 
     691                                        tm = ScaleMatrix(scalef, scalef, scalef); 
     692                                } 
     693                                break; 
     694                        case 2: 
     695                                { 
     696                                        tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 
     697                                        tm = RotationXMatrix(diffx) * RotationYMatrix(diffy); 
     698                                } 
     699                                break; 
     700                        default: 
     701                                cerr << "not implemented" << endl; 
     702                        } 
     703 
     704                        tmi->ApplyWorldTransform(tm); 
     705                        updateGL(); 
     706                } 
     707        } 
     708        else 
    667709        { 
    668710                mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY); 
     
    889931        mShowWeightedTriangles = false; 
    890932        mShowDistribution = 15; 
     933        mCurrentDynamicObjectIdx = -1; 
    891934 
    892935        mSpatialFilterSize = 0.01; 
    893936        mPvsSize = 0; 
    894937        mRayVisualizationMethod = 0; 
     938        mTrafoType = 0; 
     939 
    895940        mRenderError = 0.0f; 
    896941        mShowRays = false; 
     
    950995        connect(mControlWidget, SIGNAL(SetShowDistribution4(bool)), this, SLOT(SetShowDistribution4(bool))); 
    951996 
    952  
    953997        connect(mControlWidget, SIGNAL(SetShowRays(bool)), this, SLOT(SetShowRays(bool))); 
    954998 
     999        connect(mControlWidget, SIGNAL(SetTranslation(bool)), this, SLOT(SetTranslation(bool))); 
     1000        connect(mControlWidget, SIGNAL(SetRotation(bool)), this, SLOT(SetRotation(bool))); 
     1001        connect(mControlWidget, SIGNAL(SetScale(bool)), this, SLOT(SetScale(bool))); 
     1002         
    9551003        // setting the size here 
    9561004        resize(800, 600); 
     
    10091057void QtGlRendererWidget::LoadObject() 
    10101058{ 
    1011         string filename("../data/bunny.bn"); 
     1059        string filename("../data/teapot.bn"); 
    10121060         
    10131061        cout << "Loading model << " << filename << endl; 
     1062 
     1063        ++ mCurrentDynamicObjectIdx; 
    10141064 
    10151065        if (mViewCellsManager->GetPreprocessor()->LoadDynamicGeometry(filename)) 
     
    15871637         
    15881638        rb1 = new QRadioButton("random colors", parent); 
    1589         rb1->setText("wireframe"); 
     1639        rb1->setText("random"); 
    15901640        connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool))); 
    15911641 
     
    16271677 
    16281678 
     1679QGroupBox *QtRendererControlWidget::CreateTrafoPanel(QWidget *parent) 
     1680{ 
     1681        QRadioButton *rb1, *rb2, *rb3; 
     1682         
     1683        rb1 = new QRadioButton("translation", parent); 
     1684        rb1->setText("translation"); 
     1685        connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetTranslation(bool))); 
     1686 
     1687        // Create a check box to be in the group box 
     1688        rb2 = new QRadioButton("scale", parent); 
     1689        rb2->setText("scale"); 
     1690        //vl->addWidget(rb1); 
     1691        connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetScale(bool))); 
     1692 
     1693        rb3 = new QRadioButton("rotation", parent); 
     1694        rb3->setText("rotation"); 
     1695        connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetRotation(bool))); 
     1696     
     1697        QVBoxLayout *vbox2 = new QVBoxLayout; 
     1698        QGroupBox *groupBox = new QGroupBox("Trafo types"); 
     1699 
     1700        vbox2->addWidget(rb1); 
     1701        vbox2->addWidget(rb2); 
     1702        vbox2->addWidget(rb3); 
     1703         
     1704        rb1->setChecked(true); 
     1705 
     1706        vbox2->addStretch(1); 
     1707        groupBox->setLayout(vbox2); 
     1708 
     1709        return groupBox; 
     1710} 
     1711 
     1712 
    16291713 
    16301714QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent) 
     
    16461730 
    16471731        QGroupBox *groupBox = new QGroupBox("Render cost options"); 
    1648  
    16491732        QVBoxLayout *vbox2 = new QVBoxLayout; 
    16501733     
     
    18571940        QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox); 
    18581941        vh->addWidget(groupBox3, 0, 0); 
     1942 
     1943        QGroupBox *groupBox4 = CreateTrafoPanel(hbox); 
     1944        vh->addWidget(groupBox4, 0, 0); 
    18591945 
    18601946        ////////////////////////////////// 
     
    20322118        cb->setChecked(false); 
    20332119        connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics()));*/ 
     2120 
    20342121        if (0)  
    20352122        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2609 r2614  
    9191 
    9292  QGroupBox *CreateVisualizationPanel(QWidget *parent); 
     93  QGroupBox *CreateTrafoPanel(QWidget *parent); 
    9394 
    9495  public slots: 
     
    156157  void SetShowDistribution3(bool); 
    157158  void SetShowDistribution4(bool); 
     159 
     160  void SetTranslation(bool); 
     161  void SetRotation(bool); 
     162  void SetScale(bool); 
    158163}; 
    159164 
     
    204209        int mShowDistribution; 
    205210 
     211        int mCurrentDynamicObjectIdx; 
     212 
    206213        // some statistics 
    207214        int mPvsSize; 
     
    214221 
    215222        int mRayVisualizationMethod; 
     223        int mTrafoType; 
    216224 
    217225        QtRendererControlWidget *mControlWidget; 
     
    267275        virtual int GetHeight() const { return height(); } 
    268276 
    269         // virtual void 
    270         //  SetupProjection(const int w, const int h, const float angle = 70.0f); 
    271  
    272277        virtual void 
    273278                SetupCameraProjection(const int w, const int h, const float angle = 70.0f); 
     
    479484                mRayVisualizationMethod = 3; 
    480485        } 
    481          
     486 
     487        void SetTranslation(bool b) 
     488        { 
     489                mTrafoType = 0; 
     490        } 
     491 
     492        void SetScale(bool b) 
     493        { 
     494                mTrafoType = 1; 
     495        } 
     496         
     497        void SetRotation(bool b) 
     498        { 
     499                mTrafoType = 2; 
     500        } 
     501 
    482502        void SetShowDistribution1(bool b) 
    483503        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r2609 r2614  
    242242QtGlViewer::mouseMoveEvent(QMouseEvent *event) 
    243243{ 
    244   int dx = event->x() - lastPos.x(); 
    245   int dy = event->y() - lastPos.y();   
    246    
    247   if (event->modifiers() & Qt::CTRL) 
    248                 { 
    249                         scale = scale*(1.0f - dy/(float)height()); 
    250                         if (scale < 0.01f) 
    251                                 scale = 0.01f; 
    252                         updateGL(); 
    253                 } 
    254   else { 
     244        int dx = event->x() - lastPos.x(); 
     245        int dy = event->y() - lastPos.y();   
     246 
     247        if (event->modifiers() & Qt::CTRL) 
     248        { 
     249                scale = scale*(1.0f - dy/(float)height()); 
     250                if (scale < 0.01f) 
     251                        scale = 0.01f; 
     252                updateGL(); 
     253        } 
     254        else 
     255        { 
    255256                float W = width(); 
    256257                float H = height(); 
     
    259260                int y = event->y(); 
    260261                int lastY = lastPos.y(); 
    261          
     262 
    262263                float quat[4]; 
    263264                trackball(quat, 
    264                                   (2.0 * lastX - W) / W, 
    265                                   (H - 2.0 * lastY) / H, 
    266                                   (2.0 * x - W) / W, 
    267                                   (H - 2.0 * y) / H 
    268                                   ); 
     265                        (2.0 * lastX - W) / W, 
     266                        (H - 2.0 * lastY) / H, 
     267                        (2.0 * x - W) / W, 
     268                        (H - 2.0 * y) / H 
     269                        ); 
    269270 
    270271                add_quats(quat, manipulatorLastQuat, manipulatorLastQuat); 
    271   } 
    272    
    273   lastPos = event->pos(); 
    274   updateGL(); 
    275 } 
    276  
    277 void QtGlViewer::timerEvent(QTimerEvent *event)  
    278 { 
    279         update(); 
    280 } 
    281  
    282  
    283 } 
    284  
     272        } 
     273 
     274        lastPos = event->pos(); 
     275        updateGL(); 
     276} 
     277 
     278        void QtGlViewer::timerEvent(QTimerEvent *event)  
     279        { 
     280                update(); 
     281        } 
     282 
     283 
     284} 
     285 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h

    r2567 r2614  
    5858        float scale; 
    5959        QPoint lastPos; 
    60  
    6160}; 
    6261 
Note: See TracChangeset for help on using the changeset viewer.