Changeset 1585


Ignore:
Timestamp:
10/09/06 15:10:29 (18 years ago)
Author:
bittner
Message:

renderer changes

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

Legend:

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

    r1581 r1585  
    1212#include "Triangle3.h" 
    1313#include "IntersectableWrapper.h" 
     14#include "BvHierarchy.h" 
    1415 
    1516//#include <Cg/cg.h> 
     
    126127        RenderTriangle(dynamic_cast<TriangleIntersectable *>(object)); 
    127128        break; 
     129  case Intersectable::BVH_INTERSECTABLE: { 
     130 
     131        BvhNode *node = (dynamic_cast<BvhIntersectable *>(object))->GetItem(); 
     132        //      RenderBvhNode(node); 
     133        RenderBox(node->GetBoundingBox()); 
     134        break; 
     135  } 
     136         
    128137  default: 
    129138        cerr<<"Rendering this object not yet implemented\n"; 
     
    564573 
    565574 
    566 } 
     575void 
     576GlRenderer::RenderBox(const AxisAlignedBox3 &box) 
     577{ 
     578 
     579  glBegin(GL_LINE_LOOP); 
     580  glVertex3d(box.Min().x, box.Max().y, box.Min().z ); 
     581  glVertex3d(box.Max().x, box.Max().y, box.Min().z ); 
     582  glVertex3d(box.Max().x, box.Min().y, box.Min().z ); 
     583  glVertex3d(box.Min().x, box.Min().y, box.Min().z ); 
     584  glEnd(); 
     585 
     586  glBegin(GL_LINE_LOOP); 
     587  glVertex3d(box.Min().x, box.Min().y, box.Max().z ); 
     588  glVertex3d(box.Max().x, box.Min().y, box.Max().z ); 
     589  glVertex3d(box.Max().x, box.Max().y, box.Max().z ); 
     590  glVertex3d(box.Min().x, box.Max().y, box.Max().z ); 
     591  glEnd(); 
     592 
     593  glBegin(GL_LINE_LOOP); 
     594  glVertex3d(box.Max().x, box.Min().y, box.Min().z ); 
     595  glVertex3d(box.Max().x, box.Min().y, box.Max().z ); 
     596  glVertex3d(box.Max().x, box.Max().y, box.Max().z ); 
     597  glVertex3d(box.Max().x, box.Max().y, box.Min().z ); 
     598  glEnd(); 
     599 
     600  glBegin(GL_LINE_LOOP); 
     601  glVertex3d(box.Min().x, box.Min().y, box.Min().z ); 
     602  glVertex3d(box.Min().x, box.Min().y, box.Max().z ); 
     603  glVertex3d(box.Min().x, box.Max().y, box.Max().z ); 
     604  glVertex3d(box.Min().x, box.Max().y, box.Min().z ); 
     605  glEnd(); 
     606 
     607  glBegin(GL_LINE_LOOP); 
     608  glVertex3d(box.Min().x, box.Min().y, box.Min().z ); 
     609  glVertex3d(box.Max().x, box.Min().y, box.Min().z ); 
     610  glVertex3d(box.Max().x, box.Min().y, box.Max().z ); 
     611  glVertex3d(box.Min().x, box.Min().y, box.Max().z ); 
     612  glEnd(); 
     613 
     614  glBegin(GL_LINE_LOOP); 
     615  glVertex3d(box.Min().x, box.Max().y, box.Min().z ); 
     616  glVertex3d(box.Max().x, box.Max().y, box.Min().z ); 
     617  glVertex3d(box.Max().x, box.Max().y, box.Max().z ); 
     618  glVertex3d(box.Min().x, box.Max().y, box.Max().z ); 
     619 
     620  glEnd(); 
     621 
     622} 
     623 
     624void 
     625GlRenderer::RenderBvhNode(BvhNode *node) 
     626{ 
     627  if (node->IsLeaf()) { 
     628        BvhLeaf *leaf = (BvhLeaf *) node; 
     629        for (int i=0; i < mObjects.size(); i++) 
     630          RenderIntersectable(mObjects[i]); 
     631  } else { 
     632        BvhInterior *in = (BvhInterior *)node; 
     633        RenderBvhNode(in->GetBack()); 
     634        RenderBvhNode(in->GetFront()); 
     635  } 
     636   
     637} 
     638 
     639} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r1581 r1585  
    2525class TransformedMeshInstance; 
    2626class TriangleIntersectable; 
    27  
     27  class BvhNode; 
     28   
    2829struct VssRayContainer; 
    2930 
     
    107108  RenderTriangle(TriangleIntersectable *object); 
    108109 
     110  void 
     111  RenderBox(const AxisAlignedBox3 &box); 
     112 
     113  void 
     114  RenderBvhNode(BvhNode *node); 
     115         
    109116  bool 
    110117  RenderScene(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1581 r1585  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: so 7. X 21:56:30 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: ne 8. X 23:47:35 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1584 r1585  
    426426        Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", mLoadViewCells); 
    427427        char buf[100]; 
    428          
     428 
    429429        if (mLoadViewCells) 
    430430        {        
     
    902902                  } 
    903903                if (i % 10000 == 0) 
    904                   cout<<"."; 
     904                  cout<<i<<"/"<<rays.size()<<"\r"; 
    905905        } 
    906906         
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1584 r1585  
    942942  glMatrixMode(GL_PROJECTION); 
    943943  glLoadIdentity(); 
    944   gluPerspective(angle, ww/(float)hh, 1.0f, 40.0f); 
     944  gluPerspective(angle, ww/(float)hh, 0.1f, 1000.0f); 
    945945  glMatrixMode(GL_MODELVIEW); 
    946946} 
     
    12191219        } 
    12201220         
    1221         RenderInfo(); 
    12221221  } 
    12231222 
     
    12501249        if (mShowRenderCost)  
    12511250          RenderRenderCost(); 
     1251 
     1252        RenderInfo(); 
    12521253  } 
    12531254  mFrame++; 
     
    14211422                for (int i=0;  i < costFunction.size(); i++) { 
    14221423                  //              cout<<i<<":"<<costFunction[i]<<" "; 
     1424                  // update cost function to an absolute value based on the total geometry count 
     1425                  costFunction[i]*=mSceneGraph->GetRoot()->mGeometry.size(); 
    14231426                  if (costFunction[i] > maxCost) 
    14241427                        maxCost = costFunction[i]; 
     
    14331436        if (currentPos < costFunction.size()) 
    14341437          currentCost = costFunction[currentPos]; 
    1435 #if 0    
     1438#if 1    
    14361439        cout<<"costFunction.size()="<<costFunction.size()<<endl; 
    14371440        cout<<"CP="<<currentPos<<endl; 
     
    14401443#endif 
    14411444        if (costFunction.size()) { 
     1445          float scaley = 1.0f/log10(maxCost); 
     1446          float scalex = 1.0f/(float)costFunction.size(); 
     1447 
    14421448          glDisable(GL_DEPTH_TEST); 
    14431449          // init ortographic projection 
    14441450          glMatrixMode(GL_PROJECTION); 
    1445  
    1446  
     1451           
    14471452          glPushMatrix(); 
    14481453           
     
    14601465           
    14611466          for (int i=0;  i < costFunction.size(); i++) { 
    1462                 float x =  i/(float)costFunction.size(); 
    1463                 float y = costFunction[i]/(maxCost*0.5f); 
     1467                float x =  i*scalex; 
     1468                float y = log10(costFunction[i])*scaley; 
    14641469                glVertex3f(x,y,0.0f); 
    14651470          } 
     
    14681473          glColor3f(1.0f,0,0); 
    14691474          glBegin(GL_LINES); 
    1470           float x =  currentPos/(float)costFunction.size(); 
     1475          float x =  currentPos*scalex; 
    14711476          glVertex3f(x,0.0,0.0f); 
    14721477          glVertex3f(x,1.0f,0.0f); 
     
    14831488 
    14841489          glBegin(GL_LINES); 
    1485           for (int i=0;  i < 50000 && i < costFunction.size(); i+=10000) { 
    1486                 float x =  i/(float)costFunction.size(); 
     1490          for (int i=0;  i < costFunction.size(); i += 1000) { 
     1491                float x =  i*scalex; 
    14871492                glVertex3f(x,0.0,0.0f); 
    14881493                glVertex3f(x,1.0f,0.0f); 
    14891494          } 
    14901495 
    1491           for (int i=0;  i < maxCost; i+=100) { 
    1492                 float y = i/(maxCost*0.5f); 
    1493                 glVertex3f(0,y,0.0f); 
    1494                 glVertex3f(1,y,0.0f); 
     1496          for (int i=0;  pow(10, i) < maxCost; i+=1) { 
     1497                float y = i*scaley; 
     1498                //              QString s; 
     1499                //              s.sprintf("%d", (int)pow(10,i)); 
     1500                //              renderText(width()/2+5, y*height(), s); 
     1501                glVertex3f(0.0f, y, 0.0f); 
     1502                glVertex3f(1.0f, y, 0.0f); 
    14951503          } 
    14961504 
     
    15131521QtGlRendererWidget::RenderInfo() 
    15141522{ 
     1523 
     1524  // $$JB temporal hack for two windows separation 
     1525  if (1) { 
     1526 
     1527        // model view  
     1528        glPushMatrix(); 
     1529        glLoadIdentity(); 
     1530         
     1531        // init ortographic projection 
     1532        glMatrixMode(GL_PROJECTION); 
     1533        glPushMatrix(); 
     1534         
     1535        glLoadIdentity(); 
     1536        gluOrtho2D(0, 1.0f, 0, 1.0f); 
     1537         
     1538        float w = 0.01f; 
     1539        float h = 1.0f; 
     1540        float px = 0.0f; 
     1541        float py = 0.0f; 
     1542         
     1543        glColor3f(0.8f, 0.8f, 0.8f); 
     1544        glBegin(GL_QUADS); 
     1545         
     1546        glVertex3f(px+w, py, 0); 
     1547        glVertex3f(px+w, py+h + w, 0); 
     1548        glVertex3f(px, py+h, 0); 
     1549        glVertex3f(px, py, 0); 
     1550        glEnd(); 
     1551         
     1552        // projection 
     1553        glPopMatrix(); 
     1554         
     1555        glMatrixMode(GL_MODELVIEW); 
     1556        // model view 
     1557        glPopMatrix(); 
     1558  } 
     1559 
     1560 
    15151561  QString s; 
    15161562  int vc = 0; 
     
    15211567        filter = mViewCellsManager->GetMaxFilterSize(); 
    15221568 
    1523   s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f) viewcells:%04d filter:%04d pvs:%04d error:%5.5f\%", 
     1569  glColor3f(1.0f,1.0f,1.0f); 
     1570 
     1571  s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 
    15241572                        mFrame, 
    15251573                        mViewPoint.x, 
     
    15281576                        mViewDirection.x, 
    15291577                        mViewDirection.y, 
    1530                         mViewDirection.z, 
     1578                        mViewDirection.z 
     1579                        ); 
     1580 
     1581  renderText(20,20,s); 
     1582 
     1583  s.sprintf("viewcells:%04d filter:%04d pvs:%04d error:%5.5f\%", 
    15311584                        vc, 
    1532  
    15331585                        filter, 
    15341586                        mPvsSize, 
    1535                         mRenderError*100.0f 
    1536                         ); 
    1537    
    1538   glColor3f(0.0f,0.0f,0.0f); 
    1539   renderText(0,20,s); 
     1587                        mRenderError*100.0f); 
     1588 
     1589 
     1590  renderText(20,40,s); 
     1591 
     1592   
     1593 
    15401594   
    15411595} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1583 r1585  
    427427 
    428428        if (mUseImportanceSampling) { 
    429           GenerateRays(mInitialSamples/3, SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
    430           GenerateRays(mInitialSamples/3, SamplingStrategy::OBJECT_BASED_DISTRIBUTION, rays); 
    431           GenerateRays(mInitialSamples/3, SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, rays); 
     429          GenerateRays(mInitialSamples/2, SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     430          //      GenerateRays(mInitialSamples/3, SamplingStrategy::OBJECT_BASED_DISTRIBUTION, rays); 
     431          GenerateRays(mInitialSamples/2, SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, rays); 
    432432          //    GenerateRays(mInitialSamples/4, OBJECT_DIRECTION_BASED_DISTRIBUTION, rays); 
    433433        } else { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1570 r1585  
    21632163ViewCellsTree::GetCostFunction(vector<float> &costFunction) 
    21642164{ 
    2165         TraversalQueue tqueue; 
    2166         tqueue.push(mRoot); 
    2167          
    2168         while (!tqueue.empty())  
    2169         { 
    2170                 ViewCell *vc = tqueue.top(); 
    2171                 tqueue.pop(); 
    2172                 // save the view cells if it is a leaf or if enough view cells have already been traversed 
    2173                 // because of the priority queue, this will be the optimal set of v 
    2174                 if (!vc->IsLeaf()) {     
    2175                         ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    2176                         costFunction.push_back(interior->GetMergeCost()); 
    2177  
    2178                         ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    2179  
    2180                         for (it = interior->mChildren.begin(); it != it_end; ++ it) { 
    2181                                 tqueue.push(*it); 
    2182                         } 
    2183  
    2184                 } 
     2165  TraversalQueue tqueue; 
     2166  tqueue.push(mRoot); 
     2167   
     2168  while (!tqueue.empty())  
     2169        { 
     2170          ViewCell *vc = tqueue.top(); 
     2171          tqueue.pop(); 
     2172          // save the view cells if it is a leaf or if enough view cells have already been traversed 
     2173          // because of the priority queue, this will be the optimal set of v 
     2174          if (!vc->IsLeaf()) {   
     2175                ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     2176                costFunction.push_back(interior->GetMergeCost()); 
     2177                 
     2178                ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     2179                 
     2180                for (it = interior->mChildren.begin(); it != it_end; ++ it) { 
     2181                  tqueue.push(*it); 
     2182                } 
     2183                 
     2184          } 
    21852185        } 
    21862186} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1584 r1585  
    66Scene { 
    77 
    8 #filename ../data/City4M/City4M.obj 
    9 #filename ../data/CityModel/CityModel.obj 
     8# filename ../data/City4M/City4M.obj 
     9filename ../data/CityModel/CityModel.obj 
    1010# filename ../data/GrandCanyon/grandcanyon1_RotXmin90.obj 
    1111# filename ../data/glasgow/glasgow1.x3d 
     
    1414# filename ../data/vienna/vienna-buildings.x3d 
    1515# filename ../data/vienna/city1500_flat_1.x3d 
    16 # filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d 
    17 #;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 
     16filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d 
     17 
     18# ../data/vienna/vienna-plane.x3d; 
    1819# filename ../data/vienna/viewcells-25-sel.x3d 
    1920#filename ../data/atlanta/atlanta2.x3d 
     
    5354        visibilityFilterWidth   0.01 
    5455        visibilityFile visibility.xml 
    55         loadMeshes true 
     56        loadMeshes false 
    5657        loadKdTree      false 
    5758        exportKdTree false 
     
    5960 
    6061ObjParser { 
    61         meshGrouping 1 
     62        meshGrouping 2 
    6263} 
    6364 
     
    144145                minCost 0.95 
    145146                maxDepth 30 
    146                 maxCostRatio 1.0 
     147                maxCostRatio 0.98 
    147148                ct_div_ci 0.5 
    148149                maxNodes 100000 
    149 #200000 
    150150#500000  
    151151        } 
     
    194194        #type vspKdTree 
    195195        #type bspTree 
    196         type vspBspTree 
     196#       type vspBspTree 
     197        type vspOspTree 
    197198        #type sceneDependent 
    198199         
     
    277278#       filename ../data/vienna/vienna-viewcells-5000.xml 
    278279#       filename ../data/vienna/vienna-viewcells-1000.xml.zip 
    279  
     280        filename ../data/vienna/vsposp-seq-viewCells.xml.gz 
    280281 
    281282#       filename ../data/PowerPlant/power_plant_viewcells1.xml 
     
    339340                missTolerance           6 
    340341                globalCostMissTolerance 4 
    341                 #minGlobalCostRatio      0.0000001 
    342                 minGlobalCostRatio      0.0001 
    343 # $$ MAX         
     342                minGlobalCostRatio      0.0000001 
     343#               minGlobalCostRatio      0.0001 
     344# $$MAXVIEWCELLS 
    344345                maxViewCells            5000 
    345346         
Note: See TracChangeset for help on using the changeset viewer.