Changeset 1960


Ignore:
Timestamp:
01/10/07 02:10:23 (17 years ago)
Author:
mattausch
Message:

worked on depth peeling

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

Legend:

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

    r1944 r1960  
    251251 
    252252void 
    253 GlRenderer::SetupFalseColor(const int id) 
     253GlRenderer::SetupFalseColor(const unsigned int id) 
    254254{ 
    255255        // swap bits of the color 
     
    258258 
    259259 
    260 int GlRenderer::GetId(int r, int g, int b) const 
     260unsigned int GlRenderer::GetId(const unsigned char r,  
     261                                                           const unsigned char g,  
     262                                                           const unsigned char b) const 
    261263{ 
    262264        return r + (g << 8) + (b << 16); 
    263265} 
     266 
    264267 
    265268void 
     
    269272        glColor3fv(&(m->mDiffuseColor.r)); 
    270273} 
     274 
    271275 
    272276void 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r1949 r1960  
    106106  virtual void RandomViewPoint(); 
    107107 
    108   void SetupFalseColor(const int id); 
     108  void SetupFalseColor(const unsigned int id); 
    109109  void RenderIntersectable(Intersectable *); 
    110110  void RenderViewCell(ViewCell *vc); 
     
    152152  virtual int GetHeight() const { return 0; } 
    153153 
    154   int GetId(int r, int g, int b) const; 
     154  unsigned int GetId(const unsigned char r,  
     155                                         const unsigned char g,  
     156                                         const unsigned char b) const; 
    155157 
    156158  inline const bool GetSnapErrorFrames() { return mSnapErrorFrames; } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp

    r1958 r1960  
    55#include "Preprocessor.h" 
    66#include "GlRenderer.h" 
     7#include "Exporter.h" 
     8 
    79// the devil library 
    810#include <IL/il.h> 
     
    2729GlobalLinesRenderer *globalLinesRenderer = NULL; 
    2830 
    29 static int texWidth = 256; 
    30 static int texHeight = 256; 
    31  
     31static int texWidth = 128; 
     32static int texHeight = 128; 
     33 
     34static bool isDepth = true; 
    3235 
    3336static void InitDevIl() 
     
    8992 
    9093 
    91 void SetFrustum(int sizeX, int sizeY, float nearPlane, float farPlane) 
     94void SetFrustum(const int sizeX, const int sizeY,  
     95                                const float nearPlane, const float farPlane) 
    9296{ 
    9397        glMatrixMode(GL_PROJECTION); 
    9498        glLoadIdentity(); 
    9599 
    96         glOrtho(-sizeX / 2, sizeX / 2,  
    97                         -sizeY / 2, sizeY / 2,  
     100        glOrtho(-sizeX * 0.5, sizeX * 0.5,  
     101                        -sizeY * 0.5, sizeY * 0.5,  
    98102                        nearPlane, farPlane); 
    99103 
     
    107111        //globalLinesRenderer->DrawGeometry(); 
    108112        //globalLinesRenderer->CastGlobalLines(Beam(), 0); 
    109         globalLinesRenderer->DisplayBuffer(); 
     113        globalLinesRenderer->DisplayBuffer(isDepth); 
    110114        PrintGLerror("display"); 
    111115 
     
    132136 
    133137                        cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; 
     138                        CLEAR_CONTAINER(rays); 
    134139                        return; 
    135140                } 
     
    142147                         
    143148                        globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     149                        CLEAR_CONTAINER(rays); 
    144150                        return; 
    145151                } 
     
    148154                        //globalLinesRenderer->ApplyDepthPeeling(Beam(), 0); 
    149155                        globalLinesRenderer->ExportDepthBuffer(); 
     156                         
    150157                        return; 
    151158                } 
    152159        case '4': 
    153160                { 
     161                        //globalLinesRenderer->ApplyDepthPeeling(Beam(), 0); 
     162                        globalLinesRenderer->ExportItemBuffer(); 
     163                         
     164                        return; 
     165                } 
     166        case '8': 
     167                { 
     168                        isDepth = !isDepth; 
     169                        return; 
     170                } 
     171        case '9': 
     172                { 
    154173                        VssRayContainer rays; 
    155  
    156174                        globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     175                        VssRayContainer outRays; 
     176                        VssRayContainer::const_iterator vit, vit_end = rays.end(); 
     177 
     178                        const float p = 8.0f / (float)rays.size(); 
     179 
     180                        for (vit = rays.begin(); vit != vit_end; ++ vit) 
     181                        { 
     182                                if (Random(1.0f) < p) 
     183                                { 
     184                                        outRays.push_back(*vit); 
     185                                } 
     186                        } 
     187 
     188                        globalLinesRenderer->Visualize(rays); 
     189                        CLEAR_CONTAINER(rays); 
     190                        return; 
     191                } 
     192        case '0': 
     193                { 
     194                        VssRayContainer rays; 
     195                        globalLinesRenderer->ApplyDepthPeeling(rays, Beam(), 0); 
     196                        CLEAR_CONTAINER(rays); 
    157197                        return; 
    158198                } 
     
    185225 
    186226 
    187 void GlobalLinesRenderer::DisplayBuffer() 
    188 { 
    189         //mNewTexture->Bind(); 
    190         mNewTexture->BindDepth(); 
     227void GlobalLinesRenderer::DisplayBuffer(const bool isDepth) 
     228{ 
     229        if (!isDepth) 
     230                mNewTexture->Bind(); 
     231        else 
     232                mNewTexture->BindDepth(); 
    191233        mNewTexture->EnableTextureTarget(); 
    192234         
     
    262304                for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 
    263305                { 
     306                        cout << (*oit)->GetId() << " "; 
    264307                        RenderObject(*oit); 
    265308                } 
     
    297340        InitDevIl(); 
    298341 
    299         glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 
     342    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 
    300343        glutInitWindowPosition(50, 50); 
    301344        glutInitWindowSize(512, 512); 
     
    321364        // initialise the receiving buffers 
    322365        mNewDepthBuffer = new float[texWidth * texHeight]; 
     366        mNewItemBuffer = new unsigned char[texWidth * texHeight * 4]; 
     367 
    323368        mOldDepthBuffer = new float[texWidth * texHeight]; 
    324          
     369    mOldItemBuffer = new unsigned char[texWidth * texHeight * 4]; 
     370 
    325371        for (int i = 0; i < texWidth * texHeight; ++ i) 
    326372        { 
    327373                mNewDepthBuffer[i] = 1; 
    328374                mOldDepthBuffer[i] = 1; 
    329         } 
    330  
    331         mNewItemBuffer = new int[texWidth * texHeight *4]; 
    332         mOldItemBuffer = new int[texWidth * texHeight *4]; 
    333          
    334         for (int i = 0; i < texWidth * texHeight * 4; ++ i) 
    335         { 
    336                 mNewItemBuffer[i] = 0; 
    337                 mOldItemBuffer[i] = 0; 
     375 
     376                mNewItemBuffer[i * 4]     = 255; 
     377                mNewItemBuffer[i * 4 + 1] = 255; 
     378                mNewItemBuffer[i * 4 + 2] = 255; 
     379                mNewItemBuffer[i * 4 + 3] = 255; 
     380 
     381                mOldItemBuffer[i * 4]     = 255; 
     382                mOldItemBuffer[i * 4 + 1] = 255; 
     383                mOldItemBuffer[i * 4 + 2] = 255; 
     384                mOldItemBuffer[i * 4 + 3] = 255; 
    338385        } 
    339386 
    340387        AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 
    341388         
    342         mViewPoint = bbox.Center(); 
     389        Vector3 midPoint = bbox.Center(); 
    343390         
    344391        const float sceneSize = Magnitude(bbox.Diagonal()); 
    345         Vector3 viewPoint = mViewPoint + Vector3(0.5 * sceneSize, 0, 0); 
    346          
    347         cout << "mid point: " << mViewPoint << endl; 
    348         cout << "view point: " << viewPoint << endl; 
     392        mViewPoint = midPoint + Vector3(0.5 * sceneSize, 0, 0); 
     393         
     394        cout << "mid point: " << midPoint << endl; 
     395        cout << "view point: " << mViewPoint << endl; 
    349396        cout << "scene: " << bbox << endl; 
    350397 
    351         mEyeVec = Normalize(viewPoint - mViewPoint); 
     398        mNear = 1; 
     399        mFar = sceneSize; 
     400        mWidth = sceneSize; 
     401 
     402        mEyeVec = Normalize(midPoint - mViewPoint); 
    352403        mEyeVec.RightHandedBase(mUpVec, mLeftVec); 
    353404 
    354         /*gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z,  
     405        /*gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
    355406                          midPoint.x, midPoint.y, midPoint.z,  
    356407                          0, 1, 0); 
     
    422473                //Reshape(texWidth, texHeight); 
    423474                glViewport(0, 0, texWidth, texHeight); 
    424                 SetFrustum(sceneSize, sceneSize, 1, sceneSize); 
     475                SetFrustum(mWidth, mWidth, mNear, mFar); 
    425476 
    426477                // for item buffer: white means no color 
     
    430481                glFrontFace(GL_CCW); 
    431482                glCullFace(GL_BACK); 
    432                 glEnable(GL_CULL_FACE); 
     483 
     484                glDisable(GL_CULL_FACE); 
     485                //glEnable(GL_CULL_FACE); 
     486 
    433487                glShadeModel(GL_FLAT); 
    434488                glEnable(GL_DEPTH_TEST); 
     
    436490                glMatrixMode(GL_MODELVIEW); 
    437491                glLoadIdentity(); 
    438                 gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z,  
    439                                   mViewPoint.x, mViewPoint.y, mViewPoint.z,  
     492                gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
     493                                  midPoint.x, midPoint.y, midPoint.z,  
    440494                                  0, 1, 0); 
    441495 
    442                 //SetFrustum(sceneSize, sceneSize, 1, sceneSize); 
    443496        } 
    444497        mNewTexture->EndCapture(); 
     
    452505                //Reshape(texWidth, texHeight); 
    453506                glViewport(0, 0, texWidth, texHeight); 
    454                 SetFrustum(sceneSize, sceneSize, 1, sceneSize); 
     507                SetFrustum(mWidth, mWidth, mNear, mFar); 
    455508 
    456509                glMatrixMode(GL_MODELVIEW); 
     
    459512                glFrontFace(GL_CCW); 
    460513                glCullFace(GL_BACK); 
    461                 glEnable(GL_CULL_FACE); 
     514                 
     515                glDisable(GL_CULL_FACE); 
     516                //glEnable(GL_CULL_FACE); 
     517                 
    462518                glShadeModel(GL_FLAT); 
    463519                glEnable(GL_DEPTH_TEST); 
    464520                 
    465                 gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z,  
    466                                   mViewPoint.x, mViewPoint.y, mViewPoint.z,  
     521                gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,  
     522                                  midPoint.x, midPoint.y, midPoint.z,  
    467523                                  0, 1, 0); 
    468524 
     
    475531 
    476532 
    477 Intersectable *GetObject(const int index) 
    478 { 
    479         return NULL; 
    480 } 
    481  
    482  
    483 void GlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays) 
     533Intersectable *GlobalLinesRenderer::ExtractSamplePoint(float *depthBuffer, 
     534                                                                                                           unsigned char *itemBuffer, 
     535                                                                                                           const int x,  
     536                                                                                                           const int y, 
     537                                                                                                           Vector3 &hitPoint, 
     538                                                                                                           const bool isFrontBuffer) const 
     539{ 
     540        const int depthIndex = x + texWidth * y; 
     541        const int itemIndex = 4 * depthIndex; 
     542 
     543        const float depth = depthBuffer[depthIndex]; 
     544        const float eyeDist = mNear + (mFar - mNear) * depth; 
     545         
     546        const float leftDist = 0.5f * mWidth - mWidth * ((float)x + 0.5f) / texWidth; 
     547        //const float upDist = 0.5f * mWidth - (float)mWidth * ((float)y + 0.5f) / texHeight; 
     548        const float upDist = -0.5f * mWidth + mWidth * ((float)y + 0.5f) / texHeight; 
     549         
     550        hitPoint = mViewPoint +  
     551                       eyeDist * mEyeVec +  
     552                           leftDist * mUpVec +  
     553                           upDist * mLeftVec; 
     554                                 
     555        unsigned char r = itemBuffer[itemIndex]; 
     556        unsigned char g = itemBuffer[itemIndex + 1]; 
     557        unsigned char b = itemBuffer[itemIndex + 2]; 
     558                         
     559        // 3 times 255 means no valid object 
     560        if ((r == 255) && (g == 255) && (b == 255)) 
     561                return NULL; 
     562 
     563        const int id = mRenderer->GetId(r, g, b); 
     564        //cout << "r: " << (int)r << "g: " << (int)g << " b: " << (int)b << " id: " << id << "|"; 
     565        Intersectable *intersect = mPreprocessor->GetObjectById(id); 
     566 
     567        const Vector3 dir = isFrontBuffer ? mEyeVec : -mEyeVec; 
     568        // HACK: assume triangle intersectable 
     569        const Vector3 norm = intersect->GetNormal(0);  
     570 
     571        //if (DotProd(dir, norm) >= -Limits::Small)  
     572                return intersect; 
     573} 
     574 
     575 
     576void GlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays,  
     577                                                                                         const bool oldBufferInitialised) 
    484578{ 
    485579        GrabDepthBuffer(mNewDepthBuffer, mNewTexture); 
    486         GrabDepthBuffer(mOldDepthBuffer, mOldTexture); 
    487  
    488580        GrabItemBuffer(mNewItemBuffer, mNewTexture); 
    489         GrabItemBuffer(mOldItemBuffer, mOldTexture); 
     581 
     582        if (oldBufferInitialised) 
     583        { 
     584                GrabDepthBuffer(mOldDepthBuffer, mOldTexture); 
     585                GrabItemBuffer(mOldItemBuffer, mOldTexture); 
     586        } 
     587        else 
     588        { 
     589                for (int i = 0; i < texWidth * texHeight; ++ i) 
     590                { 
     591                        mOldDepthBuffer[i] = 0; 
     592 
     593                        mOldItemBuffer[i * 4]     = 255; 
     594                        mOldItemBuffer[i * 4 + 1] = 255; 
     595                        mOldItemBuffer[i * 4 + 2] = 255; 
     596                        mOldItemBuffer[i * 4 + 3] = 255; 
     597                } 
     598        } 
     599 
     600        cout << "vp: " << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 
    490601 
    491602        for (int y = 0; y < texHeight; ++ y) 
     
    493604                for (int x = 0; x < texWidth; ++ x) 
    494605                { 
    495                         const int index = x + texWidth * y; 
    496                         const float newDepth = mNewDepthBuffer[index]; 
    497                         const float oldDepth = mOldDepthBuffer[index]; 
    498  
    499                         float newDummy1 = mNear + (mFar - mNear) * newDepth; 
    500                         float oldDummy1 = mNear + (mFar - mNear) * oldDepth; 
    501  
    502                         float newDummy2 = x - texWidth / 2; 
    503                         float newDummy3 = y - texHeight / 2; 
    504  
    505                         float oldDummy2 = newDummy2; 
    506                         float oldDummy3 = newDummy3; 
    507  
    508                         const Vector3 newPt = mViewPoint + newDepth * mEyeVec + newDummy1 * mLeftVec + newDummy2 * mUpVec; 
    509                         const Vector3 oldPt = mViewPoint + oldDepth * mEyeVec + oldDummy1 * mLeftVec + oldDummy2 * mUpVec; 
    510  
    511                         //cout << "viewpoint: " << mViewPoint << " new: " << newPt << " old: " << newPt << endl; 
    512                          
    513                         int r = mNewItemBuffer[index]; 
    514                         int g = mNewItemBuffer[index + 1]; 
    515                         int b = mNewItemBuffer[index + 2]; 
    516                          
    517                         Intersectable *termObj1 = NULL; 
    518                         Intersectable *termObj2 = NULL; 
    519  
    520                         // 3 times 255 means no valid object 
    521                         if (!((r == 255) && (g == 255) && (b == 255))) 
     606                        Vector3 newPt, oldPt; 
     607 
     608                        Intersectable *termObj1 = ExtractSamplePoint(mNewDepthBuffer,  
     609                                                                                                                 mNewItemBuffer,  
     610                                                                                                                 x,  
     611                                                                                                                 y,  
     612                                                                                                                 newPt,  
     613                                                                                                                 true); 
     614 
     615                        Intersectable *termObj2 = ExtractSamplePoint(mOldDepthBuffer,  
     616                                                                                                                 mOldItemBuffer,  
     617                                                                                                                 x,  
     618                                                                                                                 y,  
     619                                                                                                                 oldPt,  
     620                                                                                                                 false); 
     621 
     622                        // create rays in both directions 
     623                        if (termObj1) 
    522624                        { 
    523                                 const int id = mRenderer->GetId(r, g, b); 
    524                                 cout << id << " "; 
    525                                 //termObj1 = mPreprocessor->GetObjectById(id); 
     625                                vssRays.push_back(new VssRay(oldPt, newPt, NULL, termObj1)); 
     626                                //cout << "new pt: " << newPt << endl; 
    526627                        } 
    527628 
    528                         /*r = mOldItemBuffer[index]; 
    529                         g = mOldItemBuffer[index + 1]; 
    530                         b = mOldItemBuffer[index + 2]; 
    531  
    532                         if (!((r == 255) && (g == 255) && (b == 255))) 
    533                                 Intersectable *termObj2 = mPreprocessor->GetObjectById(mRenderer->GetId(r, g, b)); 
    534 */ 
    535                         // create rays in both directions 
    536                         //vssRays.push_back(new VssRay(oldPt, newPt, NULL, termObj1)); 
    537                         //vssRays.push_back(new VssRay(newPt, oldPt, NULL, termObj2)); 
     629                        //if (termObj2) 
     630                        //{ 
     631                        //      vssRays.push_back(new VssRay(oldPt, newPt, NULL, termObj2)); 
     632                        //      cout << "old pt: " << oldPt << endl; 
     633                        //} 
    538634                } 
    539635        } 
     
    544640{ 
    545641        glutMainLoop(); 
     642} 
     643 
     644 
     645void SetupFalseColor(const unsigned int id,  
     646                                         unsigned char &r, 
     647                                         unsigned char &g, 
     648                                         unsigned char &b 
     649                                         ) 
     650{ 
     651        // swap bits of the color 
     652        r = id & 255; 
     653        g = (id >> 8) & 255; 
     654        b = (id >> 16) & 255; 
     655} 
     656 
     657 
     658void GlobalLinesRenderer::Visualize(const VssRayContainer &vssRays) 
     659{ 
     660        Exporter *exporter = Exporter::GetExporter("globalLines.wrl"); 
     661         
     662        if (!exporter) 
     663                return; 
     664 
     665        exporter->SetWireframe(); 
     666        //exporter->ExportGeometry(preprocessor->mObjects); 
     667        exporter->SetFilled(); 
     668 
     669        VssRayContainer::const_iterator vit, vit_end = vssRays.end(); 
     670 
     671        for (vit = vssRays.begin(); vit != vit_end; ++ vit) 
     672        { 
     673                VssRay *ray = *vit; 
     674                Intersectable *obj = (*vit)->mTerminationObject;         
     675                exporter->ExportIntersectable(obj); 
     676                 
     677                unsigned char r, g, b; 
     678                SetupFalseColor(obj->GetId(), r, g, b); 
     679                int id = mRenderer->GetId(r, g, b); 
     680 
     681                if (id != obj->GetId()) 
     682                        cout << "error!" << endl; 
     683                else cout <<"x"; 
     684        }        
     685 
     686        exporter->ExportRays(vssRays); 
     687 
     688        delete exporter; 
    546689} 
    547690 
     
    560703 
    561704 
    562 void GlobalLinesRenderer::GrabItemBuffer(int *data, RenderTexture *rt) 
     705void GlobalLinesRenderer::GrabItemBuffer(unsigned char *data, RenderTexture *rt) 
    563706{ 
    564707        rt->Bind(); 
     
    567710 
    568711        const int texFormat = GL_RGBA; 
    569         glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_FLOAT, data); 
     712        glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_UNSIGNED_BYTE, data); 
    570713 
    571714        mNewTexture->DisableTextureTarget(); 
     
    579722        cout << "depth: " << mNewTexture->GetDepthBits() << endl; 
    580723 
    581         const bool components = 1;//mNewTexture->GetDepthBits() / 8; 
     724        const int components = 1;//mNewTexture->GetDepthBits() / 8; 
    582725 
    583726        float *data = new float[texWidth * texHeight * components]; 
     
    609752} 
    610753 
    611  
    612754/* 
    613755void GlobalLinesRenderer::ExportItemBuffer() 
    614756{ 
    615         mNewTexture->BindDepth(); 
     757        mNewTexture->Bind(); 
    616758        mNewTexture->EnableTextureTarget(); 
    617759        cout << "depth: " << mNewTexture->GetDepthBits() << endl; 
    618760 
    619         const bool components = 1;//mNewTexture->GetDepthBits() / 8; 
    620  
    621         float *data = new float[texWidth * texHeight * components]; 
    622         //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 
    623         const int texFormat = GL_DEPTH_COMPONENT; 
    624         //const int texFormat = GL_RGBA; 
     761        const int components = 4;//mNewTexture->GetDepthBits() / 8; 
     762 
     763        float *data = new float[texWidth * texHeight * components*8]; 
     764        const int texFormat = GL_RGBA; 
    625765        glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_FLOAT, data); 
    626766 
    627         string filename("depth.tga"); 
     767        string filename("items.tga"); 
    628768        ilRegisterType(IL_FLOAT); 
    629769 
     
    631771        const int bpp = components; 
    632772 
    633         ilTexImage(texWidth, texHeight, depth, bpp, IL_LUMINANCE, IL_FLOAT, data); 
     773        cout << "saving items to file " << endl; 
     774 
     775        ilTexImage(16, 16, depth, bpp, IL_RGBA, IL_FLOAT, data); 
    634776        ilSaveImage((char *const)filename.c_str()); 
    635777 
     
    641783} 
    642784*/ 
     785void GlobalLinesRenderer::ExportItemBuffer() 
     786{ 
     787        mNewTexture->Bind(); 
     788        mNewTexture->EnableTextureTarget(); 
     789        cout << "depth: " << mNewTexture->GetDepthBits() << endl; 
     790 
     791        const int components = 4;//mNewTexture->GetDepthBits() / 8; 
     792 
     793        unsigned char *data = new unsigned char [texWidth * texHeight * components]; 
     794        //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 
     795        const int texFormat = GL_RGBA; 
     796        glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_UNSIGNED_BYTE, data); 
     797 
     798        string filename("items.jpg"); 
     799        ilRegisterType(IL_UNSIGNED_BYTE); 
     800 
     801        const int depth = 1; 
     802        const int bpp = components; 
     803 
     804        ilTexImage(texWidth, texHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data); 
     805        ilSaveImage((char *const)filename.c_str()); 
     806 
     807        cout << "finished" << endl; 
     808        delete data; 
     809        cout << "data deleted" << endl; 
     810        mNewTexture->DisableTextureTarget(); 
     811        PrintGLerror("grab texture"); 
     812} 
    643813 
    644814 
     
    659829 
    660830        // process the buffers for the first layer 
    661         ProcessDepthBuffer(rays); 
     831        ProcessDepthBuffer(rays, false); 
    662832 
    663833        for(int i = 0; i < mMaxDepth; ++ i)  
     
    685855                        cgGLDisableTextureParameter(sTextureParam); 
    686856                        cgGLDisableProfile(sCgFragmentProfile); 
    687  
    688                         // process the buffers for following layer 
    689                         ProcessDepthBuffer(rays); 
    690  
    691857                } 
    692858                mNewTexture->EndCapture(); 
     859 
     860                // process the buffers for following layer 
     861                ProcessDepthBuffer(rays, true); 
    693862        } 
    694863 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h

    r1958 r1960  
    4848        */ 
    4949        void DrawGeometry(); 
    50 void Run(); 
    51 void GrabDepthBuffer(float *data, RenderTexture *rt); 
    52 void GrabItemBuffer(int *data, RenderTexture *rt); 
    53 void ApplyDepthPeeling(VssRayContainer &rays, Beam &beam, const int samples); 
    54 void ExportDepthBuffer(); 
    55 void ProcessDepthBuffer(VssRayContainer &vssRays); 
    56 void DisplayBuffer(); 
     50        void Run(); 
     51        void GrabDepthBuffer(float *data, RenderTexture *rt); 
     52        void GrabItemBuffer(unsigned char *data, RenderTexture *rt); 
     53        void ApplyDepthPeeling(VssRayContainer &rays, Beam &beam, const int samples); 
     54        void ExportDepthBuffer(); 
     55        void ExportItemBuffer(); 
     56        void ProcessDepthBuffer(VssRayContainer &vssRays, const bool oldBufferInitialised); 
     57        void DisplayBuffer(const bool isDepth); 
     58         
     59        Intersectable *ExtractSamplePoint(float *depthBuffer, 
     60                                                                          unsigned char *itemBuffer, 
     61                                                                          const int x,  
     62                                                                          const int y, 
     63                                                                          Vector3 &hitPoint, 
     64                                                                          const bool isFrontBuffer) const; 
     65 
     66        void Visualize(const VssRayContainer &vssRays); 
    5767 
    5868        int mMaxDepth; 
     
    6272        float mFar; 
    6373        float mNear; 
     74        float mWidth; 
    6475 
    6576        Vector3 mViewPoint; 
     
    6778        float *mNewDepthBuffer; 
    6879        float *mOldDepthBuffer; 
    69         int *mNewItemBuffer; 
    70         int *mOldItemBuffer; 
    71 RenderTexture *mNewTexture; 
     80        unsigned char *mNewItemBuffer; 
     81        unsigned char *mOldItemBuffer; 
     82         
     83        RenderTexture *mNewTexture; 
    7284        RenderTexture *mOldTexture; 
    7385 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r1952 r1960  
    1313 
    1414 
    15 IntelRayCaster::IntelRayCaster(const Preprocessor &preprocessor, const string externKdTree): 
     15IntelRayCaster::IntelRayCaster(const Preprocessor &preprocessor,  
     16                                                           const string externKdTree): 
    1617RayCaster(preprocessor) 
    1718{ 
     
    7475                Vector3 dir = -simpleRay.mDirection; 
    7576                hittriangle = mlrtaIntersectAS( 
    76                         &simpleRay.mOrigin.x, 
    77                         &dir.x, 
    78                         normal, 
    79                         dist); 
     77                                                                                &simpleRay.mOrigin.x, 
     78                                                                                &dir.x, 
     79                                                                                normal, 
     80                                                                                dist); 
    8081 
    8182                Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1958 r1960  
    12971297Intersectable *Preprocessor::GetObjectById(const int id) 
    12981298{ 
    1299 #if 0 
     1299#if 1 
    13001300        // create a dummy mesh instance to be able to use stl 
    13011301        MeshInstance object(NULL); 
     
    13151315        } 
    13161316#else 
    1317         return mObjects[id]; 
     1317        return mObjects[id - 1]; 
    13181318#endif 
    13191319} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp

    r1715 r1960  
    124124        { 
    125125                const Vector3 a = (*ri)->GetOrigin(); 
    126                 const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 
     126                const Vector3 b = (*ri)->mTerminationObject ?  
     127                        (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 
    127128 
    128129#if GTP_DEBUG 
     
    130131                if (!a.CheckValidity()) 
    131132                { 
    132                         cout << "error a"<<endl; 
     133                        cout << "error a" << endl; 
    133134                        isnan = true; 
    134135                } 
     
    136137                if (!b.CheckValidity()) 
    137138                { 
    138                         cout << "error b"<<endl; 
     139                        cout << "error b" << endl; 
    139140                        isnan = true; 
    140141                } 
Note: See TracChangeset for help on using the changeset viewer.