Changeset 1997


Ignore:
Timestamp:
01/18/07 21:09:55 (17 years ago)
Author:
bittner
Message:

sil mutation

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

Legend:

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

    r1990 r1997  
    115115   
    116116  glBegin(GL_TRIANGLES); 
     117  Vector3 normal = t.GetNormal(); 
     118  glNormal3f(normal.x, normal.y, normal.z); 
    117119  glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z); 
    118120  glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z); 
     
    315317  glEnable(GL_CULL_FACE); 
    316318  glShadeModel(GL_FLAT); 
     319  glDepthFunc( GL_LESS ); 
    317320  glEnable(GL_DEPTH_TEST); 
    318321  glEnable(GL_CULL_FACE); 
    319322   
    320323  InitExtensions(); 
    321    
    322 #if 0 
    323   GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  }; 
    324   /*  mat_specular and mat_shininess are NOT default values     */ 
    325   GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  }; 
    326   GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  }; 
    327   GLfloat mat_shininess[] = {  1.0  }; 
    328    
    329   GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  }; 
    330   GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  }; 
    331   GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  }; 
    332    
    333   GLfloat lmodel_ambient[] = {  0.3, 0.3, 0.3, 1.0  }; 
    334    
    335    
    336   // default Material 
    337   glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 
    338   glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 
    339   glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); 
    340   glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 
    341  
    342   // a light 
    343   glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
    344   glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
    345   glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
    346    
    347   glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 
    348   glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); 
    349   glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); 
    350    
    351   glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
    352    
    353   glEnable(GL_LIGHTING); 
    354   glEnable(GL_LIGHT0); 
    355   glEnable(GL_LIGHT1); 
    356    
    357    
    358   // set position of the light 
    359   GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  }; 
    360   glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); 
    361    
    362   // set position of the light2 
    363   GLfloat infinite_light2[] = {  -0.3, 1.5, 1.0, 0.0  }; 
    364   glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
    365    
    366   glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
    367   //   glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR); 
    368   glEnable(GL_COLOR_MATERIAL); 
    369    
    370   glShadeModel( GL_FLAT ); 
    371    
    372   glDepthFunc( GL_LESS ); 
    373   glEnable( GL_DEPTH_TEST ); 
    374 #endif 
    375324 
    376325  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r1983 r1997  
    149149  EvalPvsStat(); 
    150150 
    151   void InitGL(); 
     151  virtual void InitGL(); 
    152152 
    153153  virtual int GetWidth() const { return 0; } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1995 r1997  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 18. I 16:30:52 2007 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 18. I 20:30:31 2007 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    6363        $(MAKE) -f $(MAKEFILE).Debug uninstall 
    6464 
    65 Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
     65Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
    6666                C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 
    6767                C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp

    r1995 r1997  
    1818#define MUTATION_USE_CDF 0 
    1919#define USE_SILHOUETTE_MUTATIONS 0 
     20 
     21#define USE_SIL_TERMINATION_MUTATION 1 
     22 
    2023#define EVALUATE_MUTATION_STATS 1 
    2124 
     
    257260 
    258261 
     262Vector3 
     263MutationBasedDistribution::ComputeSilhouetteTerminationMutation(const VssRay &ray, 
     264                                                                                                                                const Vector3 &origin, 
     265                                                                                                                                const AxisAlignedBox3 &box, 
     266                                                                                                                                const Vector3 &U, 
     267                                                                                                                                const Vector3 &V, 
     268                                                                                                                                const Vector2 vr2, 
     269                                                                                                                                const float radius 
     270                                                                                                                                ) 
     271{ 
     272  const int packetSize = 16; 
     273 
     274  static int hit_triangles[packetSize]; 
     275  static float dist[packetSize]; 
     276  static Vector3 dirs[packetSize]; 
     277  // mutate the  
     278  float alpha = RandomValue(0.0f, 2.0f*M_PI); 
     279   
     280  // direction along which we will mutate the ray 
     281  Vector3 line = sin(alpha)*U + cos(alpha)*V; 
     282   
     283  //  cout<<line<<endl; 
     284  // create 16 rays along the selected dir 
     285   
     286  // cast rays to find silhouette ray 
     287  for (int i=0; i < packetSize; i++) { 
     288        dirs[i] = Normalize(ray.mTermination + ((radius/(packetSize - i))*line) - origin ); 
     289        mlrtaStoreRayAS16(&origin.x, 
     290                                          &dirs[i].x, 
     291                                          i); 
     292  } 
     293   
     294  mlrtaTraverseGroupAS16(&box.Min().x, 
     295                                                 &box.Max().x, 
     296                                                 hit_triangles, 
     297                                                 dist); 
     298   
     299  for (int i=0; i < packetSize; i++) { 
     300        if (hit_triangles[i] == -1 || !box.IsInside(origin + dist[i]*dirs[i])) { 
     301          // break on first passing ray 
     302          break; 
     303        } 
     304  } 
     305   
     306  if (i == packetSize) { 
     307        //      cerr<<"Warning: hit the same box here should never happen!"<<endl; 
     308        // shift the ray even a bit more 
     309        //      cout<<"W"<<i<<endl; 
     310        return ray.mTermination + (RandomValue(1.0f, 2.0f)*radius)*line; 
     311  } 
     312 
     313  //  cout<<i<<endl; 
     314  return dirs[i]; 
     315} 
    259316 
    260317 
     
    385442                                                                  mutationRadius); 
    386443   
     444#if USE_SIL_TERMINATION_MUTATION 
     445  termination += ComputeSilhouetteTerminationMutation(*ray, 
     446                                                                                                          origin, 
     447                                                                                                          box, 
     448                                                                                                          U, V, 
     449                                                                                                          Vector2(rr[2], rr[3]), 
     450                                                                                                          3.0f*objectRadius); 
     451#else 
    387452  termination += ComputeTerminationMutation(*ray, U, V, 
    388453                                                                                        Vector2(rr[2], rr[3]), 
    389454                                                                                        mutationRadius); 
    390    
     455#endif 
    391456  Vector3 direction = termination - origin; 
    392457   
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h

    r1991 r1997  
    7979                                                         ); 
    8080 
     81 
     82  Vector3 
     83  ComputeSilhouetteTerminationMutation(const VssRay &ray, 
     84                                                                           const Vector3 &origin, 
     85                                                                           const AxisAlignedBox3 &box, 
     86                                                                           const Vector3 &U, 
     87                                                                           const Vector3 &V, 
     88                                                                           const Vector2 vr2, 
     89                                                                           const float radius 
     90                                                                           ); 
     91 
    8192  RayEntry &GetEntry(const int index) { 
    8293        return mRays[(mBufferStart+index)%mRays.size()]; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r1983 r1997  
    303303 
    304304 
    305  
     305void 
     306QtGlRendererWidget::InitGL() 
     307{ 
     308  GlRenderer::InitGL(); 
     309 
     310  GLfloat mat_ambient[]   = {  0.5, 0.5, 0.5, 1.0  }; 
     311  /*  mat_specular and mat_shininess are NOT default values     */ 
     312  GLfloat mat_diffuse[]   = {  1.0, 1.0, 1.0, 1.0  }; 
     313  GLfloat mat_specular[]  = {  0.3, 0.3, 0.3, 1.0  }; 
     314  GLfloat mat_shininess[] = {  1.0  }; 
     315   
     316  GLfloat light_ambient[]  = {  0.2, 0.2, 0.2, 1.0  }; 
     317  GLfloat light_diffuse[]  = {  0.4, 0.4, 0.4, 1.0  }; 
     318  GLfloat light_specular[] = {  0.3, 0.3, 0.3, 1.0  }; 
     319   
     320  GLfloat lmodel_ambient[] = {  0.3, 0.3, 0.3, 1.0  }; 
     321   
     322   
     323  // default Material 
     324  glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 
     325  glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 
     326  glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); 
     327  glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 
     328 
     329  // a light 
     330  glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 
     331  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 
     332  glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 
     333   
     334  glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient); 
     335  glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); 
     336  glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular); 
     337   
     338  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 
     339   
     340  glEnable(GL_LIGHTING); 
     341  glEnable(GL_LIGHT0); 
     342  glEnable(GL_LIGHT1); 
     343   
     344   
     345  // set position of the light 
     346  GLfloat infinite_light[] = {  1.0, 0.8, 1.0, 0.0  }; 
     347  glLightfv (GL_LIGHT0, GL_POSITION, infinite_light); 
     348   
     349  // set position of the light2 
     350  GLfloat infinite_light2[] = {  -0.3, 1.5, 1.0, 0.0  }; 
     351  glLightfv (GL_LIGHT1, GL_POSITION, infinite_light2); 
     352   
     353  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 
     354  //   glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR); 
     355  glEnable(GL_COLOR_MATERIAL); 
     356   
     357  glShadeModel( GL_FLAT ); 
     358} 
    306359 
    307360 
     
    617670          RenderErrors(); 
    618671        } else { 
     672          glColor3f(0.6f, 0.6f, 0.6f); 
    619673          RenderPvs(); 
    620674        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r1948 r1997  
    172172        InitGL(); 
    173173  } 
     174 
     175  virtual void InitGL(); 
     176   
    174177  void resizeGL(int w, int h); 
    175178  void paintGL(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp

    r1983 r1997  
    5252        if (mRenderer->mRenderViewCells)  
    5353          mRenderer->RenderViewCells(); 
    54          
     54 
     55        glColor3f(0.8f, 0.8f, 0.8f); 
    5556        mRenderer->RenderPvs(); 
    5657 
Note: See TracChangeset for help on using the changeset viewer.