Changeset 209 for trunk/VUT


Ignore:
Timestamp:
08/07/05 20:16:30 (19 years ago)
Author:
bittner
Message:

data added

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
6 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp

    r191 r209  
    14701470                                 float &minDistance, 
    14711471                                 float &maxDistance 
    1472                         ) const 
     1472                                 ) const 
    14731473{ 
    14741474 
     
    15031503  minDistance = sumMin; 
    15041504  maxDistance = sumMax; 
    1505  
    1506  
    15071505} 
    15081506 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r191 r209  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Aug 02 22:47:09 2005 
     3# Generated by qmake (1.07a) (Qt 3.3.2) on: Thu Aug 04 20:06:06 2005 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    6363                Pvs.cpp \ 
    6464                MutualVisibility.cpp \ 
    65                 Triangle3.cpp 
     65                Triangle3.cpp \ 
     66                Rectangle3.cpp \ 
     67                Plane3.cpp 
    6668OBJECTS =       Preprocessor.obj \ 
    6769                SamplingPreprocessor.obj \ 
     
    8789                Pvs.obj \ 
    8890                MutualVisibility.obj \ 
    89                 Triangle3.obj 
     91                Triangle3.obj \ 
     92                Rectangle3.obj \ 
     93                Plane3.obj 
    9094FORMS =  
    9195UICDECLS =       
     
    173177        -$(DEL_FILE) MutualVisibility.obj 
    174178        -$(DEL_FILE) Triangle3.obj 
     179        -$(DEL_FILE) Rectangle3.obj 
     180        -$(DEL_FILE) Plane3.obj 
    175181 
    176182 
     
    221227                common.h \ 
    222228                Ray.h \ 
     229                Pvs.h \ 
    223230                Preprocessor.h \ 
    224231                Mesh.h \ 
     
    226233                Intersectable.h \ 
    227234                Material.h \ 
    228                 Pvs.h \ 
    229235                Exporter.h \ 
    230236                 
     
    396402                Mesh.h \ 
    397403                MeshKdTree.h \ 
     404                Triangle3.h \ 
    398405                Matrix4x4.h \ 
    399406                Vector3.h \ 
     
    427434                Plane3.h \ 
    428435                Containers.h \ 
    429                 Intersectable.h \ 
    430                 Material.h \ 
    431                 Pvs.h \ 
     436                Pvs.h \ 
     437                Intersectable.h \ 
     438                Material.h \ 
    432439                 
    433440 
     
    476483                Ray.h \ 
    477484                MutualVisibility.h \ 
    478                 Containers.h \ 
    479                 Rectangle3.h \ 
    480                 Matrix4x4.h \ 
    481                 Vector3.h \ 
    482                 Plane3.h \ 
    483                 common.h \ 
     485                Exporter.h \ 
     486                Mesh.h \ 
     487                Triangle3.h \ 
     488                Containers.h \ 
     489                Pvs.h \ 
     490                Rectangle3.h \ 
     491                Matrix4x4.h \ 
     492                Vector3.h \ 
     493                Plane3.h \ 
     494                common.h \ 
     495                Material.h \ 
     496                Intersectable.h \ 
    484497                 
    485498 
     
    490503                 
    491504 
     505Rectangle3.obj: Rectangle3.cpp  \ 
     506                Rectangle3.h \ 
     507                Vector3.h \ 
     508                common.h \ 
     509                 
     510 
     511Plane3.obj: Plane3.cpp  \ 
     512                Plane3.h \ 
     513                Vector3.h \ 
     514                common.h \ 
     515                 
     516 
    492517####### Install 
    493518 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Matrix4x4.cpp

    r176 r209  
    77 
    88 
     9Matrix4x4::Matrix4x4(const Vector3 &a, const Vector3 &b, const Vector3 &c) 
     10{ 
     11  // first index is column [x], the second is row [y] 
     12  x[0][0] = a.x; 
     13  x[1][0] = a.y; 
     14  x[2][0] = a.z; 
     15  x[3][0] = 0.0f; 
     16 
     17  x[0][1] = b.x; 
     18  x[1][1] = b.y; 
     19  x[2][1] = b.z; 
     20  x[3][1] = 0.0f; 
     21 
     22  x[0][2] = c.x; 
     23  x[1][2] = c.y; 
     24  x[2][2] = c.z; 
     25  x[3][2] = 0.0f; 
     26 
     27  x[0][3] = 0.0f; 
     28  x[1][3] = 0.0f; 
     29  x[2][3] = 0.0f; 
     30  x[3][3] = 1.0f; 
     31} 
     32 
     33void 
     34Matrix4x4::SetColumns(const Vector3 &a, const Vector3 &b, const Vector3 &c) 
     35{ 
     36  // first index is column [x], the second is row [y] 
     37  x[0][0] = a.x; 
     38  x[1][0] = b.x; 
     39  x[2][0] = c.x; 
     40  x[3][0] = 0.0f; 
     41 
     42  x[0][1] = a.y; 
     43  x[1][1] = b.y; 
     44  x[2][1] = c.y; 
     45  x[3][1] = 0.0f; 
     46 
     47  x[0][2] = a.z; 
     48  x[1][2] = b.z; 
     49  x[2][2] = c.z; 
     50  x[3][2] = 0.0f; 
     51 
     52  x[0][3] = 0.0f; 
     53  x[1][3] = 0.0f; 
     54  x[2][3] = 0.0f; 
     55  x[3][3] = 1.0f; 
     56} 
    957 
    1058// full constructor 
     
    1462                     float x41, float x42, float x43, float x44) 
    1563{ 
    16  // first index is column [x], the second is row [y] 
     64  // first index is column [x], the second is row [y] 
    1765  x[0][0] = x11; 
    1866  x[1][0] = x12; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Matrix4x4.h

    r176 r209  
    2121           float x31, float x32, float x33, float x34, 
    2222           float x41, float x42, float x43, float x44); 
    23    
     23 
     24  Matrix4x4(const Vector3 &a, const Vector3 &b, const Vector3 &c); 
     25 
    2426 
    2527  // Assignment operators 
     
    3234  int Invert();               // Invert the matrix .. returns 0 = regular 
    3335  void Transpose();                             // Transpose the matrix 
     36 
     37  void 
     38  SetColumns(const Vector3 &a, const Vector3 &b, const Vector3 &c); 
     39 
     40  float Det3x3() const { 
     41    return (x[0][0]*x[1][1]*x[2][2] + \ 
     42            x[1][0]*x[2][1]*x[0][2] + \ 
     43            x[2][0]*x[0][1]*x[1][2] - \ 
     44            x[2][0]*x[1][1]*x[0][2] - \ 
     45            x[0][0]*x[2][1]*x[1][2] - \ 
     46            x[1][0]*x[0][1]*x[2][2]); 
     47  } 
     48   
     49 
    3450  friend Matrix4x4 Invert(const Matrix4x4 &M);  // Invert a given matrix 
    3551  friend Matrix4x4 Transpose(const Matrix4x4 &M);       // Transpose a given matrix 
     
    7692  // Construct rotation description according VRML'97 specification 
    7793  //  const CVector4D SFRotation(void) const; 
     94 
    7895   
     96 
    7997  // Overloaded output operator. 
    8098  friend ostream& operator<< (ostream &s, const Matrix4x4 &M); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp

    r191 r209  
    334334} 
    335335 
     336 
    336337void 
    337338Mesh::AddTriangle(const Triangle3 &triangle) 
     
    345346  AddFace(new Face(index + 0, index + 1, index + 2) ); 
    346347} 
     348 
     349void 
     350Mesh::AddRectangle(const Rectangle3 &rect) 
     351{ 
     352  int index = mVertices.size(); 
     353 
     354  for (int i=0; i < 4; i++) { 
     355    mVertices.push_back(rect.mVertices[i]); 
     356  } 
     357   
     358  AddFace(new Face(index + 0, index + 1, index + 2, index + 3) ); 
     359} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.h

    r191 r209  
    1010#include "Material.h" 
    1111 
    12 class Triangle3; 
     12struct Triangle3; 
    1313class MeshInstance; 
    1414class MeshKdTree; 
     
    7575 
    7676  void AddTriangle(const Triangle3 &triangle); 
     77  void AddRectangle(const Rectangle3 &triangle); 
    7778   
    7879  void AddFace(Face *face)  
  • trunk/VUT/GtpVisibilityPreprocessor/src/MutualVisibility.cpp

    r191 r209  
     1#include <assert.h> 
    12#include <stack> 
    23using namespace std; 
     
    56#include "Ray.h" 
    67#include "MutualVisibility.h" 
    7  
    8  
    9 void 
    10 TriangleSample::Init( 
    11                      const Triangle3 &source, 
    12                      const Triangle3 &target) 
     8#include "Exporter.h" 
     9#include "Mesh.h" 
     10#include "Triangle3.h" 
     11 
     12void 
     13RayShaft::Init( 
     14               const Rectangle3 &source, 
     15               const Rectangle3 &target) 
    1316{ 
    1417  mDepth = 0; 
     
    1922 
    2023Vector3 
    21 TriangleSample::GetIntersectionPoint(const int rayIndex, 
    22                                      const int depth) const 
     24RayShaft::GetIntersectionPoint(const int rayIndex, 
     25                               const int depth) const 
    2326{ 
    2427  Vector3 origin, direction; 
     
    2831 
    2932void 
    30 TriangleSample::GetRay(const int rayIndex, 
    31                        Vector3 &origin, 
    32                        Vector3 &direction) const 
    33 { 
    34   const int indices[][2] = { 
    35     {0,0}, {0,1}, {0,2}, 
    36     {1,0}, {1,1}, {1,2}, 
    37     {2,0}, {2,1}, {2,2} 
    38   }; 
    39    
    40   origin = mSource.mVertices[indices[rayIndex][0]]; 
    41   direction = mTarget.mVertices[indices[rayIndex][1]] - origin; 
     33RayShaft::GetRay(const int rayIndex, 
     34                 Vector3 &origin, 
     35                 Vector3 &direction) const 
     36{ 
     37   
     38  assert(rayIndex < 4); 
     39   
     40  origin = mSource.mVertices[rayIndex]; 
     41  direction = mTarget.mVertices[rayIndex] - origin; 
    4242} 
    4343 
    4444void 
    4545MutualVisibilitySampler::PerformSplit( 
    46                                       const TriangleSample &sample, 
     46                                      const RayShaft &sample, 
    4747                                      const bool splitSource, 
    48                                       const int edge, 
    49                                       const Vector3 &splitPoint, 
    50                                       const Ray &ray, 
    51                                       TriangleSample &sample1, 
    52                                       TriangleSample &sample2 
     48                                      const int axis, 
     49                                      RayShaft &sample1, 
     50                                      RayShaft &sample2 
    5351                                      ) 
    5452{ 
    55  
    56  
    57   const Triangle3 *triangle; 
    58   Triangle3 *triangle1, *triangle2; 
     53   
     54 
    5955  // split the triangles 
     56 
    6057  if (splitSource) { 
    6158    sample1.mTarget = sample.mTarget; 
    6259    sample2.mTarget = sample.mTarget; 
    63     triangle1 = &sample1.mSource; 
    64     triangle2 = &sample2.mSource; 
    65     triangle = &sample.mSource; 
     60    sample.mSource.Split( 
     61                         axis, 
     62                         sample1.mSource, 
     63                         sample2.mSource); 
    6664  } else { 
     65     
    6766    sample1.mSource = sample.mSource; 
    6867    sample2.mSource = sample.mSource; 
    69     triangle1 = &sample1.mTarget; 
    70     triangle2 = &sample2.mTarget; 
    71     triangle = &sample.mTarget; 
     68     
     69    sample.mTarget.Split( 
     70                         axis, 
     71                         sample1.mTarget, 
     72                         sample2.mTarget); 
    7273  } 
    7374   
    7475  // split the intersections 
    75   switch (edge) { 
     76  switch (axis) { 
    7677  case 0: 
    7778    sample1.mIntersections[0] = sample.mIntersections[0]; 
    78     sample1.mIntersections[1] = sample.mIntersections[1]; 
    79     triangle1->mVertices[0] = triangle->mVertices[0]; 
    80     triangle1->mVertices[1] = triangle->mVertices[1]; 
    81      
    82     sample2.mIntersections[0] = sample.mIntersections[2]; 
    83     sample2.mIntersections[1] = sample.mIntersections[0]; 
    84     triangle2->mVertices[0] = triangle->mVertices[2]; 
    85     triangle2->mVertices[1] = triangle->mVertices[0]; 
     79    sample1.mIntersections[3] = sample.mIntersections[3]; 
     80     
     81    sample2.mIntersections[1] = sample.mIntersections[1]; 
     82    sample2.mIntersections[2] = sample.mIntersections[2]; 
    8683    break; 
    8784 
     
    8986    sample1.mIntersections[0] = sample.mIntersections[0]; 
    9087    sample1.mIntersections[1] = sample.mIntersections[1]; 
    91     triangle1->mVertices[0] = triangle->mVertices[0]; 
    92     triangle1->mVertices[1] = triangle->mVertices[1]; 
    93  
    94     sample2.mIntersections[0] = sample.mIntersections[1]; 
    95     sample2.mIntersections[1] = sample.mIntersections[2]; 
    96     triangle2->mVertices[0] = triangle->mVertices[1]; 
    97     triangle2->mVertices[1] = triangle->mVertices[2]; 
     88 
     89    sample2.mIntersections[2] = sample.mIntersections[2]; 
     90    sample2.mIntersections[2] = sample.mIntersections[3]; 
    9891    break; 
    99      
    100   case 2: 
    101     sample1.mIntersections[0] = sample.mIntersections[2]; 
    102     sample1.mIntersections[1] = sample.mIntersections[0]; 
    103     triangle1->mVertices[0] = triangle->mVertices[2]; 
    104     triangle1->mVertices[1] = triangle->mVertices[0]; 
    105  
    106     sample2.mIntersections[0] = sample.mIntersections[1]; 
    107     sample2.mIntersections[1] = sample.mIntersections[2]; 
    108     triangle2->mVertices[0] = triangle->mVertices[1]; 
    109     triangle2->mVertices[1] = triangle->mVertices[2]; 
    110     break; 
    111   } 
    112    
    113   // the new sample 
    114   sample1.mIntersections[2] = ray.intersections; 
    115   sample2.mIntersections[2] = ray.intersections; 
    116   triangle1->mVertices[2] = splitPoint; 
    117   triangle2->mVertices[2] = splitPoint; 
    118    
    119   // establish the new samples 
     92  } 
     93 
     94  // the intersections for the new shaft rays will be established 
     95  // later 
    12096  sample1.mDepth = sample2.mDepth = sample.mDepth+1; 
    12197} 
    12298 
    12399float 
    124 MutualVisibilitySampler::GetSpatialAngle(const TriangleSample &sample, 
     100MutualVisibilitySampler::GetSpatialAngle(const RayShaft &sample, 
    125101                                         const Vector3 &point 
    126102                                         ) 
    127103{ 
    128   const int sampleIndices[][3]={ 
    129     (0,0,0), 
    130     (0,1,0), 
    131     (-1,-1,-1) 
     104  const int sampleIndices[][2]={ 
     105    (0,1,2), 
     106    (0,2,3) 
    132107  }; 
    133108   
     
    135110  int i; 
    136111   
    137   for (i=0; i < 10; i++) { 
     112  for (i=0; i < 2; i++) { 
    138113    Triangle3 triangle(sample.GetIntersectionPoint(sampleIndices[i][0], 0), 
    139                             sample.GetIntersectionPoint(sampleIndices[i][1], 0), 
    140                             sample.GetIntersectionPoint(sampleIndices[i][2], 0)); 
    141      
     114                       sample.GetIntersectionPoint(sampleIndices[i][1], 0), 
     115                       sample.GetIntersectionPoint(sampleIndices[i][2], 0)); 
    142116    sum += triangle.GetSpatialAngle(point); 
    143117  } 
     118 
    144119  return sum; 
    145120} 
     
    147122 
    148123void 
    149 MutualVisibilitySampler::ComputeError(TriangleSample &sample) 
     124MutualVisibilitySampler::ComputeError(RayShaft &sample) 
    150125{ 
    151126  // evaluate minimal error which can be achieved by more precise evaluation 
     
    166141 
    167142 
    168  
    169  
    170  
    171143void 
    172144MutualVisibilitySampler::ConstructInitialSamples( 
    173145                                                 const AxisAlignedBox3 &source, 
    174146                                                 const AxisAlignedBox3 &target, 
    175                                                  vector<TriangleSample *> &samples 
     147                                                 vector<RayShaft *> &samples 
    176148                                                 ) 
    177149{ 
    178   // get all rectangles potentially visible from the source box 
     150  Vector3 normal = target.Center() - source.Center(); 
     151 
     152  Plane3 sourcePlane(normal, source.GetVertex(0)); 
    179153  int i; 
    180   int sourceMask = 0; 
    181   for (i=0; i < 8; i++) 
    182     sourceMask |= source.GetFaceVisibilityMask(target.GetVertex(i)); 
    183  
    184   // now for each visble source face find all visible target faces 
    185   for (i=0; i < 6; i++) { 
    186     Rectangle3 sourceFace = source.GetFace(i); 
    187     if ( sourceMask &(1<<i) ) { 
    188       int mask = target.GetFaceVisibilityMask(sourceFace); 
    189       // construct triangle samples for all visible rectangles 
    190       for (int j=0; j < 6; j++) 
    191         if (mask & (1<<j)) { 
    192           AddInitialSamples(sourceFace, target.GetFace(j), samples); 
    193         } 
    194     } 
    195   } 
     154  for (i=1; i < 8; i++) { 
     155    Vector3 v = source.GetVertex(i); 
     156    if (sourcePlane.Distance(v) > 0) 
     157      sourcePlane = Plane3(normal, v); 
     158  } 
     159   
     160  Plane3 targetPlane(-normal, target.GetVertex(0)); 
     161  for (i=1; i < 8; i++) { 
     162    Vector3 v = target.GetVertex(i); 
     163    if (targetPlane.Distance(v) > 0) 
     164      targetPlane = Plane3(-normal, v); 
     165  } 
     166 
     167   
     168  Vector3 xBasis = CrossProd(Vector3(0,1,0), normal); 
     169 
     170  if (Magnitude(xBasis) > 1e-6) 
     171    xBasis.Normalize(); 
     172  else { 
     173    xBasis = CrossProd(Vector3(0,0,1), normal); 
     174  } 
     175 
     176  Vector3 yBasis = Normalize( CrossProd(normal, xBasis) ); 
     177   
     178  Plane3 bottomPlane(xBasis, source.Center()); 
     179  Plane3 sidePlane(yBasis, source.Center()); 
     180   
     181  // cast rays between corresponding vertices of the boxes 
     182  for (i=0; i < 8; i++) { 
     183     
     184     
     185  } 
     186   
     187  //  AddInitialSamples(sourceRectangle, targetRectangle, samples); 
    196188} 
    197189 
     
    200192                                           const Rectangle3 &sourceRect, 
    201193                                           const Rectangle3 &targetRect, 
    202                                            vector<TriangleSample *> &samples 
     194                                           vector<RayShaft *> &samples 
    203195                                           ) 
    204196{ 
    205   Triangle3 sourceTriangles[2]; 
    206   Triangle3 targetTriangles[2]; 
    207  
    208   sourceTriangles[0].Init(sourceRect.mVertices[0], 
    209                           sourceRect.mVertices[1], 
    210                           sourceRect.mVertices[2]); 
    211  
    212   sourceTriangles[1].Init(sourceRect.mVertices[0], 
    213                           sourceRect.mVertices[2], 
    214                           sourceRect.mVertices[3]); 
    215  
    216   targetTriangles[0].Init(targetRect.mVertices[0], 
    217                           targetRect.mVertices[1], 
    218                           targetRect.mVertices[2]); 
    219  
    220   targetTriangles[1].Init(targetRect.mVertices[0], 
    221                           targetRect.mVertices[2], 
    222                           targetRect.mVertices[3]); 
    223   int i, j; 
    224   for (i=0; i < 2; i++) 
    225     for (j=0; j < 2; j++) { 
    226       TriangleSample *sample = new TriangleSample(sourceTriangles[i],  
    227                                                   targetTriangles[j]); 
    228       samples.push_back(sample); 
     197 
     198  RayShaft *sample = new RayShaft(sourceRect,  
     199                                  targetRect); 
     200  samples.push_back(sample); 
     201} 
     202 
     203 
     204void 
     205MutualVisibilitySampler::ExportSamples(vector<RayShaft *> &samples) 
     206{ 
     207  static int id = 0; 
     208  char filename[64]; 
     209  if (id > 20) 
     210    return; 
     211                             
     212  for (int i=0; i < samples.size(); i++) { 
     213    sprintf(filename, "samples%04d-%02d.x3d", id++, i); 
     214    Exporter *exporter = Exporter::GetExporter(filename); 
     215    exporter->SetFilled(); 
     216 
     217 
     218    RayShaft *sample = samples[i]; 
     219    Mesh *mesh = new Mesh; 
     220    mesh->AddRectangle(sample->mSource); 
     221    mesh->AddRectangle(sample->mTarget); 
     222    vector<Ray> rays; 
     223    for (int j=0; j < 4; j++) { 
     224      Vector3 origin, direction; 
     225      sample->GetRay(j, origin, direction); 
     226      Ray ray(origin, direction, Ray::LINE_SEGMENT); 
     227      rays.push_back(ray); 
    229228    } 
     229     
     230    Material m = RandomMaterial(); 
     231    exporter->SetForcedMaterial(m); 
     232    MeshInstance mi(mesh); 
     233    exporter->ExportIntersectable(&mi); 
     234    exporter->ExportRays(rays, -1.0f, m.mDiffuseColor); 
     235    delete exporter; 
     236  } 
    230237} 
    231238 
     
    233240MutualVisibilitySampler::ComputeVisibility() 
    234241{ 
    235   stack<TriangleSample *> sampleStack; 
     242 
     243  vector<RayShaft *> samples; 
     244  ConstructInitialSamples(mSource, mTarget, samples); 
     245  ExportSamples(samples); 
     246 
     247  stack<RayShaft *> sampleStack; 
     248   
     249   
    236250   
    237251  Ray ray; 
    238252  // now process the samples as long as we have something to do 
    239253  while (!sampleStack.empty()) { 
    240     TriangleSample *sample = sampleStack.top(); 
     254    RayShaft *sample = sampleStack.top(); 
    241255    sampleStack.pop(); 
    242256     
     
    248262     
    249263//      // generate 2 new samples 
    250 //      TriangleSample newSamples[2]; 
     264//      RayShaft newSamples[2]; 
    251265//      sample.Split(triangleSplitEdge, ray, newSamples[0], newSamples[1]); 
    252266//      for (i=0; i < 2; i++) { 
     
    258272//    } 
    259273  } 
     274 
     275  for (int i=0; i < samples.size(); i++) 
     276    delete samples[i]; 
    260277  return INVISIBLE; 
    261278} 
     
    281298  MutualVisibilitySampler sampler(kdTree, source, target, solidAngleThreshold); 
    282299 
     300   
    283301  int visibility = sampler.ComputeVisibility(); 
    284302 
  • trunk/VUT/GtpVisibilityPreprocessor/src/MutualVisibility.h

    r191 r209  
    44#include "Vector3.h" 
    55#include "Ray.h" 
    6 #include "Triangle3.h" 
    76 
    87class Intersectable; 
    98class AxisAlignedBox3; 
    10  
    11  
    12  
    139 
    1410struct SimpleRay { 
     
    1814 
    1915 
    20 struct TriangleSample { 
     16struct RayShaft { 
    2117public: 
    2218  /// evaluted sampling error 
     
    2521  int mDepth; 
    2622  /// The source triangle 
    27   Triangle3 mSource; 
     23  Rectangle3 mSource; 
    2824  /// The target triangle 
    29   Triangle3 mTarget; 
     25  Rectangle3 mTarget; 
    3026   
    3127  /// intersections with the scene 
    32   vector<Ray::Intersection> mIntersections[9]; 
     28  vector<Ray::Intersection> mIntersections[4]; 
    3329   
    3430  void ComputeError(); 
    3531   
    36   TriangleSample () {} 
     32  RayShaft () {} 
    3733   
    38   TriangleSample ( 
    39                   const Triangle3 &source, 
    40                   const Triangle3 &target) 
     34  RayShaft ( 
     35            const Rectangle3 &source, 
     36            const Rectangle3 &target) 
    4137  { 
    4238    Init(source, target); 
    4339  } 
    44  
     40   
    4541  // initial triangle sample 
    4642  void Init( 
    47             const Triangle3 &source, 
    48             const Triangle3 &target); 
     43            const Rectangle3 &source, 
     44            const Rectangle3 &target); 
    4945   
    5046  Vector3 
    5147  GetIntersectionPoint(const int rayIndex, 
    5248                       const int depth) const; 
    53  
     49   
    5450  void GetRay(const int rayIndex, 
    5551              Vector3 &origin, 
    5652              Vector3 &direction) const; 
    57  
    5853}; 
    5954 
     
    8075                          const AxisAlignedBox3 &source, 
    8176                          const AxisAlignedBox3 &target, 
    82                           vector<TriangleSample *> &samples 
     77                          vector<RayShaft *> &samples 
    8378                          ); 
    8479 
     
    8782                    const Rectangle3 &sourceRect, 
    8883                    const Rectangle3 &targetRect, 
    89                     vector<TriangleSample *> &samples 
     84                    vector<RayShaft *> &samples 
    9085                    ); 
    9186 
     
    9489  bool 
    9590  SplitSample( 
    96               const TriangleSample &source, 
    97               TriangleSample &sample1, 
    98               TriangleSample &sample2 
     91              const RayShaft &source, 
     92              RayShaft &sample1, 
     93              RayShaft &sample2 
    9994              ); 
    10095  void 
    10196  PerformSplit( 
    102                const TriangleSample &sample, 
     97               const RayShaft &sample, 
    10398               const bool splitSource, 
    104                const int edge, 
    105                const Vector3 &splitPoint, 
    106                const Ray &ray, 
    107                TriangleSample &sample1, 
    108                TriangleSample &sample2 
     99               const int axis, 
     100               RayShaft &sample1, 
     101               RayShaft &sample2 
    109102               ); 
    110103   
     
    112105  bool 
    113106  SampleTerminationCriteriaMet( 
    114                                const TriangleSample &sample); 
     107                               const RayShaft &sample); 
    115108   
    116109  float 
    117   GetSpatialAngle(const TriangleSample &sample, 
     110  GetSpatialAngle(const RayShaft &sample, 
    118111                  const Vector3 &point 
    119112                  ); 
    120113 
    121114  void 
    122   ComputeError(TriangleSample &sample); 
     115  ComputeError(RayShaft &sample); 
     116 
     117  void 
     118  ExportSamples(vector<RayShaft *> &samples); 
    123119 
    124120 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Plane3.h

    r177 r209  
    2020    mNormal = Normalize(CrossProd(v2,v1)); 
    2121    mD = -DotProd(b, mNormal); 
     22  } 
    2223 
     24  Plane3(const Vector3 &normal, 
     25         const Vector3 &point 
     26         ):mNormal(normal) 
     27  { 
     28    mD = -DotProd(normal, point); 
    2329  } 
    2430 
     
    3036    return signum(Distance(v), threshold); 
    3137  } 
     38 
     39  Vector3 FindIntersection(const Vector3 &a, 
     40                           const Vector3 &b, 
     41                           float *t = NULL, 
     42                           bool *coplanar = NULL 
     43                           ) const; 
     44 
     45  friend bool 
     46  PlaneIntersection(const Plane3 &a, const Plane3 &b, const Plane3 &c, Vector3 &result); 
    3247   
    3348  friend ostream &operator<<(ostream &s, const Plane3 p) { 
     
    3651  } 
    3752 
     53   
    3854}; 
    3955   
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r191 r209  
    2121{ 
    2222public: 
    23   enum RayType { LOCAL_RAY, GLOBAL_RAY }; 
     23  enum RayType { LOCAL_RAY, GLOBAL_RAY, LINE_SEGMENT }; 
    2424 
    2525  enum { NO_INTERSECTION=0, INTERSECTION_OUT_OF_LIMITS, INTERSECTION }; 
     
    6666      const void *_originCell = NULL) { 
    6767    loc = wherefrom; 
    68     dir = Normalize(whichdir); 
     68    if (_type == LINE_SEGMENT) 
     69      dir = whichdir; 
     70    else 
     71      dir = Normalize(whichdir); 
    6972    mType = _type; 
    7073    depth = 0; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Rectangle3.h

    r191 r209  
    44#include "Vector3.h" 
    55 
     6/// rectangle vertices 
     7//   3 2 
     8//   0 1 
    69class Rectangle3 { 
    710public: 
    811  Vector3 mVertices[4]; 
    912 
     13  Rectangle3() {} 
     14   
    1015  Rectangle3(const Vector3 &v0, 
    1116             const Vector3 &v1, 
     
    2833  } 
    2934 
     35 
     36  void 
     37  Split(const int axis, 
     38        Rectangle3 &r1, 
     39        Rectangle3 &r2 
     40        ) const; 
     41 
     42         
    3043   
    3144}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r191 r209  
    124124      } 
    125125       
    126       if (0 && pvsSize && pass == 100 ) { 
     126      if (0 && pvsSize && pass == 50 ) { 
    127127        // mail all nodes from the pvs 
    128128        Intersectable::NewMail(); 
     
    147147             
    148148          } 
    149            
    150          
    151149          // now rank all the neighbors according to probability that a new 
    152150          // sample creates some contribution 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r191 r209  
    3636  stream<<"</Appearance>"<<endl; 
    3737   
    38   stream<<"<IndexedLineSet ccw=\"TRUE\" coordIndex=\""<<endl; 
     38  stream<<"<IndexedLineSet coordIndex=\""<<endl; 
    3939 
    4040  int index = 0; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r191 r209  
    88#       filename glasgow1.x3d 
    99#       filename vienna.x3d 
    10 #       filename atlanta2.x3d 
    11 #       filename soda.dat 
    12         filename soda5.dat 
     10        filename ../data/atlanta/atlanta2.x3d 
     11#       filename ../data/soda/soda.dat 
     12#       filename ../data/soda/soda5.dat 
    1313 
    1414} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro

    r191 r209  
    3232Matrix4x4.cpp Vector3.cpp AxisAlignedBox3.cpp Ray.cpp main.cpp Mesh.cpp \ 
    3333Exporter.cpp Camera.cpp X3dParser.cpp MeshKdTree.cpp Pvs.cpp \ 
    34 MutualVisibility.cpp Triangle3.cpp 
     34MutualVisibility.cpp Triangle3.cpp Rectangle3.cpp Plane3.cpp 
    3535 
    3636 
Note: See TracChangeset for help on using the changeset viewer.