Changeset 333


Ignore:
Timestamp:
10/17/05 21:51:45 (19 years ago)
Author:
bittner
Message:

code merge

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
14 edited

Legend:

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

    r329 r333  
    17191719 
    17201720                // compute angle to reference point 
    1721                 for (int i = 1; i < (int)planePoly->mVertices.size(); ++ i) 
     1721                for (i = 1; i < (int)planePoly->mVertices.size(); ++ i) 
    17221722                { 
    17231723                        float angle =  
     
    17301730 
    17311731                // update vertices 
    1732                 for (int i = 1; i < (int)planePoly->mVertices.size(); ++ i) 
     1732                for (i = 1; i < (int)planePoly->mVertices.size(); ++ i) 
    17331733                        planePoly->mVertices[i] = vertexData[i - 1].mVertex; 
    17341734        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp

    r311 r333  
    163163      bool mOnlyDrivingAxis = false; 
    164164      if (mOnlyDrivingAxis) { 
    165         axis = box.Size().DrivingAxis(); 
    166         costRatio = BestCostRatio(leaf, 
    167                                   box, 
    168                                   axis, 
    169                                   position, 
    170                                   objectsBack, 
    171                                   objectsFront); 
     165                                axis = box.Size().DrivingAxis(); 
     166                                costRatio = BestCostRatio(leaf, 
     167                                                                                                                                        box, 
     168                                                                                                                                        axis, 
     169                                                                                                                                        position, 
     170                                                                                                                                        objectsBack, 
     171                                                                                                                                        objectsFront); 
    172172      } else { 
    173         costRatio = MAX_FLOAT; 
    174         for (int i=0; i < 3; i++) { 
    175           float p; 
    176           float r = BestCostRatio(leaf, 
    177                                   box, 
    178                                   i, 
    179                                   p, 
    180                                   objectsBack, 
    181                                   objectsFront); 
    182           if (r < costRatio) { 
    183             costRatio = r; 
    184             axis = i; 
    185             position = p; 
    186           } 
    187         } 
     173                                costRatio = MAX_FLOAT; 
     174                                for (int i=0; i < 3; i++) { 
     175                                        float p; 
     176                                        float r = BestCostRatio(leaf, 
     177                                                                                                                                        box, 
     178                                                                                                                                        i, 
     179                                                                                                                                        p, 
     180                                                                                                                                        objectsBack, 
     181                                                                                                                                        objectsFront); 
     182                                        if (r < costRatio) { 
     183                                                costRatio = r; 
     184                                                axis = i; 
     185                                                position = p; 
     186                                        } 
     187                                } 
    188188      } 
    189189       
    190190      if (costRatio > mMaxCostRatio) { 
    191         //      cout<<"Too big cost ratio "<<costRatio<<endl; 
    192         axis = -1; 
     191                                //      cout<<"Too big cost ratio "<<costRatio<<endl; 
     192                                axis = -1; 
    193193      } 
    194194      break; 
     
    415415float 
    416416KdTree::BestCostRatio( 
    417                       KdLeaf *node, 
    418                       const AxisAlignedBox3 &box, 
    419                       const int axis, 
    420                       float &position, 
    421                       int &objectsBack, 
    422                       int &objectsFront 
    423                       ) 
     417                                                                                        KdLeaf *node, 
     418                                                                                        const AxisAlignedBox3 &box, 
     419                                                                                        const int axis, 
     420                                                                                        float &position, 
     421                                                                                        int &objectsBack, 
     422                                                                                        int &objectsFront 
     423                                                                                        ) 
    424424{ 
    425425 
     
    439439      totalIntersections += (*ci).intersectable->IntersectionComplexity(); 
    440440    } 
    441  
     441         
    442442  float intersectionsLeft = 0; 
    443443  float intersectionsRight = totalIntersections; 
    444  
     444         
    445445  int objectsLeft = 0, objectsRight = node->mObjects.size(); 
    446446   
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r258 r333  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Sep 06 13:22:58 2005 
     3# Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Sep 06 13:46:00 2005 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    1313LEX             = flex 
    1414YACC            = byacc 
    15 CFLAGS  =       -nologo -Zm200 -W0 -MDd -Zi -GX  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT 
    16 CXXFLAGS        =       -nologo -Zm200 -W0 -MDd -Zi -GX  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT 
     15CFLAGS  =       -nologo -Zm200 -W0 -MD -O2 -GX  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG 
     16CXXFLAGS        =       -nologo -Zm200 -W0 -MD -O2 -GX  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG 
    1717LEXFLAGS        = 
    1818YACCFLAGS       =-d 
    1919INCPATH =        -I"..\src" -I"..\support\xerces\include" -I"..\support\zlib\include" -I"..\support\boost" -I"..\support\devil\include" -I"$(QTDIR)\include" -I"d:\gametools\svn\trunk\VUT\GtpVisibilityPreprocessor\src" -I"C:\Qt\3.3.2\mkspecs\win32-msvc" 
    2020LINK    =       link 
    21 LFLAGS  =       /NOLOGO /DEBUG /SUBSYSTEM:console /LIBPATH:"../support/xerces/lib" /LIBPATH:"../support/devil/lib" /LIBPATH:"$(QTDIR)\lib" 
     21LFLAGS  =       /NOLOGO delayimp.lib /DELAYLOAD:comdlg32.dll /DELAYLOAD:oleaut32.dll /DELAYLOAD:winmm.dll /DELAYLOAD:wsock32.dll /DELAYLOAD:winspool.dll /SUBSYSTEM:console /LIBPATH:"../support/xerces/lib" /LIBPATH:"../support/devil/lib" /LIBPATH:"$(QTDIR)\lib" 
    2222LIBS    =        "qt-mt332.lib" "qtmain.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "imm32.lib" "winmm.lib" "wsock32.lib" "winspool.lib" "xerces-c_2.lib" "devil.lib" "ilu.lib" "ilut.lib" "opengl32.lib" "glu32.lib" "delayimp.lib" 
    2323MOC             =       $(QTDIR)\bin\moc.exe 
     
    188188        -$(DEL_FILE) ViewCell.obj 
    189189        -$(DEL_FILE) ViewCellBsp.obj 
    190         -$(DEL_FILE) preprocessor.pdb 
    191         -$(DEL_FILE) preprocessor.ilk 
    192         -$(DEL_FILE) vc*.pdb 
    193         -$(DEL_FILE) vc*.idb 
    194  
    195190 
    196191 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp

    r308 r333  
    5050int 
    5151Mesh::CastRayToFace( 
    52                     const int faceIndex, 
    53                     Ray &ray, 
    54                     float &nearestT, 
    55                     int &nearestFace, 
    56                     Intersectable *instance 
    57                     ) 
     52                                                                                const int faceIndex, 
     53                                                                                Ray &ray, 
     54                                                                                float &nearestT, 
     55                                                                                int &nearestFace, 
     56                                                                                Intersectable *instance 
     57                                                                                ) 
    5858{ 
    5959  float t; 
     
    7272    case Ray::LINE_SEGMENT: 
    7373      if (t <= 1.0f) { 
    74         ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex)); 
    75         hit++; 
     74                                ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex)); 
     75                                hit++; 
    7676      } 
    7777      break; 
     
    8383int 
    8484Mesh::CastRay( 
    85               Ray &ray, 
    86               MeshInstance *instance 
    87               ) 
     85                                                        Ray &ray, 
     86                                                        MeshInstance *instance 
     87                                                        ) 
    8888{ 
    8989  if (mKdTree) { 
     
    100100 
    101101  for ( ; 
    102         faceIndex < mFaces.size(); 
    103         faceIndex++) { 
     102                                faceIndex < mFaces.size(); 
     103                                faceIndex++) { 
    104104    hits += CastRayToFace(faceIndex, ray, nearestT, nearestFace, instance); 
    105105    if (mIsConvex && nearestFace != -1) 
     
    119119int 
    120120Mesh::CastRayToSelectedFaces( 
    121                             Ray &ray, 
    122                             const vector<int> &faces, 
    123                             Intersectable *instance 
    124                             ) 
     121                                                                                                                Ray &ray, 
     122                                                                                                                const vector<int> &faces, 
     123                                                                                                                Intersectable *instance 
     124                                                                                                                ) 
    125125{ 
    126126  vector<int>::const_iterator fi; 
     
    134134 
    135135  for ( fi = faces.begin(); 
    136         fi != faces.end(); 
    137         fi++) { 
     136                                fi != faces.end(); 
     137                                fi++) { 
    138138    hits += CastRayToFace(*fi, ray, nearestT, nearestFace, instance); 
    139139    if (mIsConvex && nearestFace != -1) 
     
    157157inline int 
    158158int_lineseg(float px, 
    159             float py, 
    160             float u1, 
    161             float v1, 
    162             float u2, 
    163             float v2) 
     159                                                float py, 
     160                                                float u1, 
     161                                                float v1, 
     162                                                float u2, 
     163                                                float v2) 
    164164{ 
    165165  float t; 
     
    180180  if (fabs(ydiff) < Limits::Small) {      // denominator near 0 
    181181    if (((fabs(v1) > Limits::Small) || 
    182         (u1 > 0) || (u2 > 0))) 
     182                                (u1 > 0) || (u2 > 0))) 
    183183      return 0; 
    184184    return 1; 
     
    195195int 
    196196Mesh::RayFaceIntersection(const int faceIndex, 
    197                           const Ray &ray, 
    198                           float &t, 
    199                           const float nearestT 
    200                           ) 
     197                                                                                                        const Ray &ray, 
     198                                                                                                        float &t, 
     199                                                                                                        const float nearestT 
     200                                                                                                        ) 
    201201{ 
    202202  Face *face  = mFaces[faceIndex]; 
     
    242242      // line u1, v1, u2, v2 
    243243      if ((v2 - v1)*(u1 - u) > (u2 - u1)*(v1 - v)) 
    244         return Ray::NO_INTERSECTION; 
     244                                return Ray::NO_INTERSECTION; 
    245245      u1 = u2; 
    246246      v1 = v2; 
     
    288288int 
    289289MeshInstance::CastRay( 
    290                       Ray &ray 
    291                       ) 
     290                                                                                        Ray &ray 
     291                                                                                        ) 
    292292{ 
    293293  int res = mMesh->CastRay(ray, this); 
     
    297297int 
    298298MeshInstance::CastRay( 
    299                       Ray &ray, 
    300                       const vector<int> &faces 
    301                       ) 
     299                                                                                        Ray &ray, 
     300                                                                                        const vector<int> &faces 
     301                                                                                        ) 
    302302{ 
    303303  return mMesh->CastRayToSelectedFaces(ray, faces, this); 
     
    325325  Face *face = mFaces[faceIndex]; 
    326326  return Plane3(mVertices[face->mVertexIndices[0]], 
    327                 mVertices[face->mVertexIndices[1]], 
    328                 mVertices[face->mVertexIndices[2]]); 
     327                                                                mVertices[face->mVertexIndices[1]], 
     328                                                                mVertices[face->mVertexIndices[2]]); 
    329329} 
    330330 
    331331int 
    332332TransformedMeshInstance::CastRay( 
    333                                 Ray &ray 
    334                                 ) 
     333                                                                                                                                Ray &ray 
     334                                                                                                                                ) 
    335335{ 
    336336  ray.ApplyTransform(Invert(mWorldTransform)); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.h

    r327 r333  
    107107  int 
    108108  CastRay( 
    109           Ray &ray, 
    110            MeshInstance *instance 
    111           ); 
    112  
     109                                        Ray &ray, 
     110                                        MeshInstance *instance 
     111                                        ); 
     112         
    113113  int 
    114114  CastRayToSelectedFaces( 
    115                         Ray &ray, 
    116                         const vector<int> &faces, 
    117                         Intersectable *instance 
    118                         ); 
    119  
     115                                                                                                Ray &ray, 
     116                                                                                                const vector<int> &faces, 
     117                                                                                                Intersectable *instance 
     118                                                                                                ); 
     119         
    120120  int 
    121121  CastRayToFace( 
    122                 const int faceIndex, 
    123                 Ray &ray, 
    124                 float &nearestT, 
    125                 int &nearestFace, 
    126                 Intersectable *instance 
    127                 ); 
    128  
     122                                                                const int faceIndex, 
     123                                                                Ray &ray, 
     124                                                                float &nearestT, 
     125                                                                int &nearestFace, 
     126                                                                Intersectable *instance 
     127                                                                ); 
     128         
    129129   
    130130  int 
    131131  RayFaceIntersection(const int faceIndex, 
    132                       const Ray &ray, 
    133                       float &t, 
    134                       const float nearestT 
    135                       ); 
     132                                                                                        const Ray &ray, 
     133                                                                                        float &t, 
     134                                                                                        const float nearestT 
     135                                                                                        ); 
    136136   
    137137  Plane3 GetFacePlane(const int faceIndex); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h

    r329 r333  
    2424public: 
    2525        Polygon3(); 
     26 
    2627        Polygon3(const VertexContainer &vertices); 
    2728        Polygon3(MeshInstance *parent); 
     29 
     30        ~Polygon3(); 
     31 
    2832        // creates an "infinite" polygon from this plane 
    2933        //Polygon3(Plane3 plane); 
     
    7579        /** Returns the surface normal. 
    7680        */ 
    77         inline Vector3 GetNormal() const; 
     81        Vector3 GetNormal() const; 
    7882 
    7983        /** Includes polygons to axis aligned box. 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r332 r333  
    234234 
    235235 
    236 void 
     236int 
    237237SamplingPreprocessor::CastEdgeSamples( 
    238238                                                                                                                                                        Intersectable *object, 
    239239                                                                                                                                                        const Vector3 &point, 
    240                                                                                                                                                         Mesh &mesh, 
     240                                                                                                                                                        MeshInstance *mi, 
    241241                                                                                                                                                        const int samples 
    242242                                                                                                                                                        ) 
    243243{ 
    244244        Ray ray; 
     245        int maxTries = samples*10; 
    245246        int i; 
    246         for (i=0; i < samples; i++) { 
     247        int rays = 0; 
     248        int edgeSamplesContributions = 0; 
     249        for (i=0; i < maxTries && rays < samples; i++) { 
    247250                // pickup a random face of each mesh  
    248                 int face = RandomValue(0, mesh.mFaces.size()-1); 
    249                  
    250                 Polygon3 poly(mesh.mFaces[face], &mesh); 
     251                Mesh *mesh = mi->GetMesh(); 
     252                int face = RandomValue(0, mesh->mFaces.size()-1); 
     253                 
     254                Polygon3 poly(mesh->mFaces[face], mesh); 
    251255                poly.Scale(1.001); 
    252256                // now extend a random edge of the face 
     
    256260                                                                                                                                                                                                                                                                                 poly.mVertices.size()]; 
    257261                SetupRay(ray, point, target - point); 
    258           CastRay(object, ray); 
     262                if (!mesh->CastRay(ray, mi)) { 
     263                        // the rays which intersect the mesh have been discarded since they are not tangent 
     264                        // to the mesh 
     265                        rays++; 
     266                        edgeSamplesContributions += CastRay(object, ray); 
     267                } 
    259268        } 
     269        return edgeSamplesContributions; 
    260270} 
    261271 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h

    r331 r333  
    2626  int mBspConstructionSamples; 
    2727 
     28         
    2829  SamplingPreprocessor(); 
    2930 
     
    4748        CastRay(Intersectable *object, Ray &ray); 
    4849 
    49         void 
     50        int 
    5051        CastEdgeSamples( 
    5152                                                                        Intersectable *object, 
    5253                                                                        const Vector3 &point, 
    53                                                                         Mesh &mesh, 
     54                                                                        MeshInstance *mi, 
    5455                                                                        const int samples 
    5556                                                                        ); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r323 r333  
    7272         
    7373        // add top vertices      
    74         for (int i = 0; i < 3; ++ i) 
     74        for (i = 0; i < 3; ++ i) 
    7575                mesh->mVertices.push_back(baseTri.mVertices[i] + height * triNorm); 
    7676         
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r329 r333  
    249249        VertexContainer::const_iterator vi;   
    250250         
    251         for (int index = 0; index < (int)poly->mVertices.size(); ++ index)  
     251        for (index = 0; index < (int)poly->mVertices.size(); ++ index)  
    252252                stream << index << " "; 
    253253         
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp

    r318 r333  
    506506        } 
    507507 
    508  
    509     for (int i = 0; i < mCurrentVertexIndices.size(); i += 3) 
    510         { 
     508        for (i = 0; i < mCurrentVertexIndices.size(); i += 3) 
     509                { 
    511510                Triangle3 baseTri(vertices[mCurrentVertexIndices[i + 0]],  
    512511                                                  vertices[mCurrentVertexIndices[i + 1]], 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r326 r333  
    3030        sahUseFaces true 
    3131        Termination { 
    32                 minCost 2 
     32                minCost 1 
    3333                maxDepth 18 
    34                 maxCostRatio 0.9 
     34                maxCostRatio 0.95 
    3535                ct_div_ci 0.5 
    3636        } 
     
    4343MeshKdTree { 
    4444        Termination { 
    45                 minCost 4 
    46                 maxDepth 18 
    47                 maxCostRatio 0.9 
     45                minCost 1 
     46                maxDepth 12 
     47                maxCostRatio 0.95 
    4848                ct_div_ci 0.5 
    4949        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r332 r333  
    9696   
    9797    
    98   if (1) { 
     98  if (0) { 
    9999    p->ComputeVisibility(); 
    100100    p->ExportPreprocessedData("scene.vis"); 
     
    104104    Camera camera; 
    105105    //camera.LookAtBox(p->mKdTree->GetBox()); 
    106         camera.LookInBox(p->mKdTree->GetBox()); 
    107         camera.SetPosition(camera.mPosition + Vector3(0,300,0)); 
     106                camera.LookInBox(p->mKdTree->GetBox()); 
     107                camera.SetPosition(camera.mPosition + Vector3(0,300,0)); 
    108108    camera.SnapImage("camera.jpg", p->mKdTree); 
    109  
     109                 
    110110     
    111111    camera.LookInBox(p->mKdTree->GetBox()); 
    112112    camera.SetPosition(camera.mPosition - Vector3(0,100,0)); 
    113     camera.SnapImage("camera2.png", p->mKdTree); 
     113    camera.SnapImage("camera2.jpg", p->mKdTree); 
    114114  } 
    115115 
  • trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro

    r258 r333  
    1313 
    1414# debuc config 
    15 CONFIG          += console warn_off thread debug 
     15CONFIG          += console warn_off thread release 
    1616 
    1717# RELEASE CONFIG 
Note: See TracChangeset for help on using the changeset viewer.