Changeset 1832


Ignore:
Timestamp:
11/30/06 16:17:35 (17 years ago)
Author:
bittner
Message:

gl render updates - separate gl viewer widget

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r1824 r1832  
    154154  inline void SetSnapPrefix(const string &pref) { mSnapPrefix = pref; } 
    155155 
     156public: 
     157  int mFrame; 
     158  bool mWireFrame; 
     159         
    156160protected: 
    157161 
     
    171175  HaltonSequence halton; 
    172176   
    173   int mFrame; 
    174   bool mWireFrame; 
    175177   
    176178  bool mDetectEmptyViewSpace; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1824 r1832  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: út 28. XI 19:46:06 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 30. XI 15:32:50 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1824 r1832  
    2727 
    2828 
    29 #define CAMERA_VIEW_WIDTH 0.5f 
    3029   
    3130class ViewCellsManager; 
     
    305304{ 
    306305  if (!mTopView) { 
    307         int ww = w*CAMERA_VIEW_WIDTH; 
     306        int ww = w; 
    308307        int hh = h; 
    309308        glViewport(0, 0, ww, hh); 
     
    313312        glMatrixMode(GL_MODELVIEW); 
    314313  } else { 
    315         int ww = w*CAMERA_VIEW_WIDTH; 
     314        int ww = w; 
    316315        int hh = h; 
    317316        glViewport(0, 0, ww, hh); 
     
    323322} 
    324323 
    325 void 
    326 QtGlRendererWidget::SetupManipulatorProjection(const int w, const int h, const float angle) 
    327 { 
    328   int ww = w*(1.0f - CAMERA_VIEW_WIDTH); 
    329   int hh = h; 
    330   glViewport(w - ww, 0, ww, hh); 
    331   glMatrixMode(GL_PROJECTION); 
    332   glLoadIdentity(); 
    333   gluPerspective(angle, ww/(float)hh, 0.1f, 1000.0f); 
    334   glMatrixMode(GL_MODELVIEW); 
    335 } 
    336324 
    337325 
     
    380368#endif 
    381369          } else 
    382                         pvs = viewcell->GetPvs(); 
     370                pvs = viewcell->GetPvs(); 
     371 
     372          emit PvsUpdated(); 
    383373        } 
    384374 
     
    584574  int diffy = -(mousePoint.y - y); 
    585575   
    586   if (x < width()*CAMERA_VIEW_WIDTH) { 
    587         if (e->modifiers() & Qt::ControlModifier) { 
    588           mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY/2.0; 
    589           mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY/2.0; 
    590         } else { 
    591           mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY); 
    592           float adiff = TURN_ANGLE*(x - mousePoint.x)*-TURN_SENSITIVITY; 
    593           float angle = atan2(mViewDirection.x, mViewDirection.z); 
    594           mViewDirection.x = sin(angle+adiff); 
    595           mViewDirection.z = cos(angle+adiff); 
    596         } 
     576  if (e->modifiers() & Qt::ControlModifier) { 
     577        mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY/2.0; 
     578        mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY/2.0; 
    597579  } else { 
    598         float W = width()*(1.0f-CAMERA_VIEW_WIDTH); 
    599         float H = height(); 
    600         int xx = x - width()*CAMERA_VIEW_WIDTH; 
    601         int mxx = mousePoint.x - width()*CAMERA_VIEW_WIDTH; 
    602     if (e->modifiers() & Qt::ControlModifier) { 
    603           mManipulatorScale = mManipulatorScale * (1.0 + (((float) (-diffy)) / H)); 
    604         } else { 
    605           float quat[4]; 
    606           trackball(quat, 
    607                                 (2.0 * mxx - W) / W, 
    608                                 (H - 2.0 * mousePoint.y) / H, 
    609                                 (2.0 * xx - W) / W, 
    610                                 (H - 2.0 * y) / H 
    611                                 ); 
    612           add_quats(quat, mManipulatorLastQuat, mManipulatorLastQuat); 
    613         } 
     580        mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY); 
     581        float adiff = TURN_ANGLE*(x - mousePoint.x)*-TURN_SENSITIVITY; 
     582        float angle = atan2(mViewDirection.x, mViewDirection.z); 
     583        mViewDirection.x = sin(angle+adiff); 
     584        mViewDirection.z = cos(angle+adiff); 
    614585  } 
    615586   
     
    651622  } 
    652623 
    653   mFrame++; 
    654  
    655   if (1) { 
    656         // render into the right side of the window buffer 
    657         SetupManipulatorProjection(width(), height()); 
    658         SetupManipulator(); 
    659          
    660          
    661         if (mRenderViewCells)  
    662           RenderViewCells(); 
    663          
    664         RenderPvs(); 
    665          
    666         if (0) { 
    667           mWireFrame = true; 
    668           RenderScene(); 
    669           mWireFrame = false; 
    670         } 
    671          
    672         if (mShowRays) { 
    673           RssPreprocessor *p = (RssPreprocessor *)mViewCellsManager->GetPreprocessor(); 
    674           if (p->mRssTree) { 
    675                 VssRayContainer rays; 
    676                 p->mRssTree->CollectRays(rays, 10000); 
    677                 RenderRays(rays); 
    678           } 
    679         } 
    680  
    681         if (mShowRenderCost)  
    682           RenderRenderCost(); 
    683  
    684         RenderInfo(); 
    685   } 
     624  RenderInfo(); 
     625 
    686626  mFrame++; 
    687627   
     
    727667} 
    728668 
    729 void 
    730 QtGlRendererWidget::SetupManipulator() 
    731 { 
    732   float m[4][4]; 
    733  
    734   glLoadIdentity(); 
    735   gluLookAt(0.0, 0.0, 30.0,  /* eye is at (0,0,30) */ 
    736                         0.0, 0.0, 0.0,      /* center is at (0,0,0) */ 
    737                         0.0, 1.0, 0.);      /* up is in positive Y direction */ 
    738    
    739   build_rotmatrix(m, mManipulatorLastQuat); 
    740   glMultMatrixf(&m[0][0]); 
    741    
    742   float scale = mManipulatorScale*20.0f/Magnitude(mSceneGraph->GetBox().Diagonal()); 
    743   glScalef(scale, scale, scale); 
    744    
    745   Vector3 t = -mSceneGraph->GetBox().Center(); 
    746   glTranslatef(t.x, t.y, t.z); 
    747    
    748 } 
    749669 
    750670void 
     
    797717  mRenderVisibilityEstimates = false; 
    798718  mTransferFunction = 0.2f; 
    799   mManipulatorScale = 1.0f; 
    800   trackball(mManipulatorLastQuat, 0.0f, 0.0f, 0.0f, 0.0f); 
     719 
    801720  bool tmp; 
    802721 
     
    990909QtGlRendererWidget::RenderInfo() 
    991910{ 
    992  
    993   // $$JB temporal hack for two windows separation 
    994   if (1) { 
    995  
    996         // model view  
    997         glPushMatrix(); 
    998         glLoadIdentity(); 
    999          
    1000         // init ortographic projection 
    1001         glMatrixMode(GL_PROJECTION); 
    1002         glPushMatrix(); 
    1003          
    1004         glLoadIdentity(); 
    1005         gluOrtho2D(0, 1.0f, 0, 1.0f); 
    1006          
    1007         float w = 0.01f; 
    1008         float h = 1.0f; 
    1009         float px = 0.0f; 
    1010         float py = 0.0f; 
    1011          
    1012         glColor3f(0.8f, 0.8f, 0.8f); 
    1013         glBegin(GL_QUADS); 
    1014          
    1015         glVertex3f(px+w, py, 0); 
    1016         glVertex3f(px+w, py+h + w, 0); 
    1017         glVertex3f(px, py+h, 0); 
    1018         glVertex3f(px, py, 0); 
    1019         glEnd(); 
    1020          
    1021         // projection 
    1022         glPopMatrix(); 
    1023          
    1024         glMatrixMode(GL_MODELVIEW); 
    1025         // model view 
    1026         glPopMatrix(); 
    1027   } 
    1028  
    1029  
     911   
    1030912  QString s; 
    1031913  int vc = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.h

    r1824 r1832  
    147147  float mTransferFunction; 
    148148 
    149   float mManipulatorLastQuat[4]; 
    150   float mManipulatorScale; 
    151149   
    152150  QtRendererControlWidget *mControlWidget; 
     
    169167 
    170168  virtual void SetupCamera(); 
    171   // setup a transformation for manipulator 
    172   void 
    173   SetupManipulator(); 
    174169 
    175170  void initializeGL() { 
     
    204199  virtual void 
    205200  SetupCameraProjection(const int w, const int h, const float angle = 70.0f); 
    206  
    207   virtual void 
    208   SetupManipulatorProjection(const int w, const int h, const float angle = 70.0f); 
    209201 
    210202  void 
     
    310302  } 
    311303 
    312  
     304  signals: 
     305  void PvsUpdated(); 
    313306}; 
    314307 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Renderer.h

    r860 r1832  
    2626        void SetViewCellsManager(ViewCellsManager *vcm); 
    2727 
    28 protected: 
     28public: 
    2929        ViewCellsManager *mViewCellsManager; 
    3030        SceneGraph *mSceneGraph; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1829 r1832  
    28642864         
    28652865        // $$  
    2866         // sumWeights = leaf->mTotalRays; 
     2866        sumWeights = leaf->mTotalRays; 
    28672867 
    28682868        //$$ test 30.11. 2006  
    28692869        // normalize per volume of the cell not the number of rays! 
    2870         sumWeights = spatialArea*dirArea; 
     2870        // sumWeights = spatialArea*dirArea; 
    28712871         
    28722872        if (sumWeights != 0.0f) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h

    r1715 r1832  
    446446   
    447447  void AddRay(const RayInfo &data) { 
    448         mValidPvs = false; 
     448                mValidPvs = false; 
    449449    rays.push_back(data); 
    450         mTotalRays++; 
    451         data.mRay->Ref(); 
     450                mTotalRays++; 
     451                data.mRay->Ref(); 
    452452  } 
    453453         
  • GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.cpp

    r1715 r1832  
    211211    
    212212   float cosTheta = 1.0f - 2*r1; 
    213   float sinTheta = sqrt(1 - sqr(cosTheta)); 
    214   float fi = 2.0f*M_PI*r2; 
    215    
    216   Vector3 dir(sinTheta*sin(fi), 
    217                           cosTheta, 
    218                           sinTheta*cos(fi)); 
     213        float sinTheta = sqrt(1 - sqr(cosTheta)); 
     214        float fi = 2.0f*M_PI*r2; 
     215   
     216        Vector3 dir(sinTheta*sin(fi), 
     217                                                        cosTheta, 
     218                                                        sinTheta*cos(fi)); 
    219219   
    220220  return dir; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1830 r1832  
    3232 
    3333// $$JB HACK 
    34 #define USE_KD_PVS 0 
     34#define USE_KD_PVS 1 
     35 
    3536#define KD_PVS_AREA (1e-5f) 
    3637 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1785 r1832  
    4040#include "QtPreprocessorThread.h" 
    4141#include "QtGlRenderer.h" 
     42#include "QtGlViewer.h" 
    4243#endif 
    4344 
     
    295296                if (!rendererWidget)  
    296297                { 
    297                    
    298298                  if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 
    299299                        QMessageBox::information(0, "OpenGL pbuffers",  
     
    303303                  } 
    304304                   
    305                    
    306305                  rendererWidget = new QtGlRendererWidget(preprocessor->mSceneGraph, 
    307                                                                                                   preprocessor->mViewCellsManager, 
    308                                                                                                   preprocessor->mKdTree); 
    309  
    310                   ((QtGlRendererWidget *)rendererWidget)->SetThread((QtPreprocessorThread *)pt); 
     306                                                                                                                                                                                        preprocessor->mViewCellsManager, 
     307                                                                                                                                                                                        preprocessor->mKdTree); 
     308                         
     309                  //((QtGlRendererWidget *)rendererWidget)->SetThread((QtPreprocessorThread *)pt); 
    311310                  rendererWidget->Show(); 
    312                   guiSupported = true;  
     311 
     312                        QtGlViewer *viewer = new QtGlViewer(NULL, 
     313                                                                                                                                                                        (QtGlRendererWidget *) 
     314                                                                                                                                                                        rendererWidget); 
     315                        viewer->show(); 
     316                        guiSupported = true;  
    313317                } 
    314318 
     
    321325                  preprocessor->renderer =  
    322326                        new QtGlRendererBuffer(512, 512, 
    323                                                                   preprocessor->mSceneGraph, 
    324                                                                   preprocessor->mViewCellsManager, 
    325                                                                   preprocessor->mKdTree); 
     327                                                                                                                preprocessor->mSceneGraph, 
     328                                                                                                                preprocessor->mViewCellsManager, 
     329                                                                                                                preprocessor->mKdTree); 
    326330                  //            preprocessor->Getrenderer->makeCurrent(); 
    327331                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro

    r1757 r1832  
    8585# Input 
    8686HEADERS += Halton.h VssRay.h VssPreprocessor.h RssTree.h GlRenderer.h \ 
    87 PreprocessorThread.h Preprocessor.h Beam.h 
     87PreprocessorThread.h Preprocessor.h Beam.h QtGlViewer.h 
    8888 
    8989 
     
    107107InternalRayCaster.cpp IntelRayCaster.cpp \ 
    108108RayCaster.cpp PreprocessorFactory.cpp GvsPreprocessor.cpp \ 
    109 Trackball.cpp ObjExporter.cpp SubdivisionCandidate.cpp 
     109Trackball.cpp ObjExporter.cpp SubdivisionCandidate.cpp QtGlViewer.cpp 
    110110 
    111111 
Note: See TracChangeset for help on using the changeset viewer.