Changeset 1951


Ignore:
Timestamp:
01/07/07 18:39:35 (17 years ago)
Author:
mattausch
Message:

silly version

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

Legend:

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

    r1867 r1951  
    21832183Vector3 AxisAlignedBox3::Diagonal() const  
    21842184{  
    2185         return (mMax -mMin);  
     2185        return (mMax - mMin);  
    21862186} 
    21872187 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp

    r1950 r1951  
    2525static int texWidth = 256; 
    2626static int texHeight = 256; 
     27static Vector3 scaleFactor = Vector3(2000.0f, 2000.0f, 2000.0f); 
     28static Vector3 translFactor = Vector3(1000.0f, 1000.0f, 1000.0f); 
    2729 
    2830static void cgErrorCallback() 
     
    6466        //gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0); 
    6567        //gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 0.5, 10.0); 
    66         glOrtho(-1000, 1000, -1000, 1000, 1, 1000); 
     68        glOrtho(-1, 1, -1, 1, 0.5, 15); 
    6769} 
    6870 
     
    7072void Display() 
    7173{ 
    72         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    73         glMatrixMode(GL_MODELVIEW); 
    74         glPushMatrix(); 
    75          
    7674        //globalLinesRenderer->DrawGeometry(); 
    77          
    7875        globalLinesRenderer->CastGlobalLines(Beam(), 0); 
    79  
    8076        PrintGLerror("display"); 
    8177 
    82         glPopMatrix(); 
    8378        glutSwapBuffers(); 
    8479} 
     
    152147void GlobalLinesRenderer::DrawGeometry() 
    153148{  
    154         //mRenderer->mUseFalseColors = true; 
    155         ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 
    156  
    157         Intersectable::NewMail(); 
    158  
    159         for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 
    160         { 
    161                 RenderObject(*oit); 
    162         } 
     149        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     150        glMatrixMode(GL_MODELVIEW); 
     151 
     152        glPushMatrix(); 
     153        {  
     154                glLoadIdentity(); 
     155                //translFactor = Vector3(-1, -1, -1); 
     156                 
     157                glScalef(scaleFactor.x, scaleFactor.y, scaleFactor.z); 
     158                glTranslatef(translFactor.x, translFactor.y, translFactor.z); 
     159 
     160                //cout << "scale: " << scaleFactor << endl; 
     161                //cout << "transl: " << translFactor << endl; 
     162 
     163                //mRenderer->mUseFalseColors = true; 
     164                ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 
     165 
     166                Intersectable::NewMail(); 
     167 
     168                for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 
     169                { 
     170                        RenderObject(*oit); 
     171                } 
     172        } 
     173        glPopMatrix(); 
    163174} 
    164175 
     
    197208 
    198209        AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 
    199         const Vector3 midPoint = bbox.Center(); 
    200         //const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0); 
    201         const Vector3 viewPoint = midPoint + Vector3(2, 0, 0); 
    202  
    203         cout << "midPoint: " << midPoint << endl; 
    204         cout << "viewPoint: " << viewPoint << endl; 
     210         
     211        Vector3 center = bbox.Center(); 
     212        translFactor = -center; 
     213        //translFactor.z = 0; 
     214        //translFactor = Vector3(-1500, -1500, -1500); 
     215        float diag = 2.0f / Magnitude(bbox.Diagonal()); 
     216        scaleFactor = Vector3(diag, diag, diag); 
     217  
     218        Vector3 midPoint = Vector3(0, 0, 0); 
     219        Vector3 viewPoint = Vector3(0, 0, 500); 
     220 
     221        cout << "mid point: " << midPoint << endl; 
     222        cout << "view point: " << viewPoint << endl; 
    205223        cout << "scene: " << bbox << endl; 
    206224 
     
    246264                cgCreateProgramFromFile(sCgContext,  
    247265                                                                CG_SOURCE, 
    248                                                                 "../src/depth_peeling.cg",  
     266                                                                mNewBuffer->IsRectangleTexture() ?  
     267                                                                "../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg",  
    249268                                                                GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 
    250269                                                                NULL, 
     
    269288                cgGLLoadProgram(sCgPassThroughProgram); 
    270289        } 
    271  
    272290 
    273291    // setup the rendering context for the RenderTexture 
     
    289307                                  midPoint.x, midPoint.y, midPoint.z,  
    290308                                  0, 1, 0); 
    291  
    292309        } 
    293310        mNewBuffer->EndCapture(); 
     
    331348void GlobalLinesRenderer::ApplyDepthPeeling(Beam &beam, const int samples) 
    332349{ 
    333         //if (mNewBuffer->IsDoubleBuffered())  
    334         //      glDrawBuffer(GL_BACK); 
    335  
    336350        mNewBuffer->BeginCapture(); 
    337351        { 
    338352                //cgGLBindProgram(sCgPassThroughProgram); 
    339353                //cgGLEnableProfile(sCgFragmentProfile); 
    340                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    341                 glMatrixMode(GL_MODELVIEW); 
    342                 glPushMatrix(); 
    343                 {  
    344                         //glutSolidTorus(0.25, 1, 32, 64); 
    345                         DrawGeometry(); 
    346                 } 
    347                 glPopMatrix(); 
     354                DrawGeometry(); 
    348355        } 
    349356        mNewBuffer->EndCapture(); 
    350357         
    351358        //mNewBuffer->BindDepth(); 
    352         float *data = new float[texWidth * texHeight]; 
     359        /*float *data = new float[texWidth * texHeight]; 
    353360        //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 
    354361        const int texFormat = GL_LUMINANCE; 
     
    356363         
    357364        delete [] data; 
    358  
    359         PrintGLerror("get data"); 
     365*/ 
     366        PrintGLerror("firstpass"); 
    360367 
    361368        if (mNewBuffer->IsRectangleTexture()) cout << "rect" << endl; 
    362 //else cout << "haga"<<endl; 
    363369 
    364370        for(int i = 0; i < mMaxDepth; ++ i)  
     
    380386                        cgGLEnableTextureParameter(sTextureParam); 
    381387 
    382                         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    383                         glMatrixMode(GL_MODELVIEW); 
    384                         glPushMatrix(); 
    385                         {  
    386                                 //glutSolidTorus(0.25, 1, 32, 64); 
    387                                 DrawGeometry(); 
    388                         } 
     388                        //glutSolidTorus(0.25, 1, 32, 64); 
     389                        DrawGeometry(); 
     390                         
    389391                        glPopMatrix(); 
    390392 
     
    395397        } 
    396398 
    397         PrintGLerror("display 1"); 
     399        PrintGLerror("endpeeling"); 
    398400 
    399401        //mNewBuffer->Bind(); 
    400402        mNewBuffer->BindDepth(); 
    401403        mNewBuffer->EnableTextureTarget(); 
    402  
    403  
    404         PrintGLerror("display 2"); 
    405         glColor3f(1,1,1); 
    406         glBegin(GL_QUADS); 
    407     glTexCoord2f(0, 0); glVertex3f(-1000, -1000, -0.5f); 
    408     glTexCoord2f(1, 0); glVertex3f( 1000, -1000, -0.5f); 
    409     glTexCoord2f(1, 1); glVertex3f( 1000,  1000, -0.5f); 
    410     glTexCoord2f(0, 1); glVertex3f(-1000,  1000, -0.5f); 
    411     glEnd(); 
    412  
    413     if (mNewBuffer->IsFloatTexture()) 
    414         { 
    415                 // cgGLDisableTextureParameter(textureParam); 
    416                 // cgGLDisableProfile(theProfile); 
    417         } 
    418         else  
    419         { 
    420                 mNewBuffer->DisableTextureTarget(); 
    421         } 
    422 } 
    423  
    424  
    425 } 
     404         
     405        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     406         
     407        if (mNewBuffer->IsRectangleTexture()) 
     408        { 
     409                glBegin(GL_QUADS); 
     410                glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f); 
     411                glTexCoord2f(mNewBuffer->GetWidth(), 0); glVertex3f( 1, -1, -0.5f); 
     412                glTexCoord2f(mNewBuffer->GetWidth(), mNewBuffer->GetHeight()); glVertex3f( 1,  1, -0.5f); 
     413                glTexCoord2f(0, mNewBuffer->GetHeight()); glVertex3f(-1, 1, -0.5f); 
     414                glEnd(); 
     415        } 
     416        else 
     417        { 
     418                glBegin(GL_QUADS); 
     419                glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f); 
     420                glTexCoord2f(1, 0); glVertex3f( 1, -1, -0.5f); 
     421                glTexCoord2f(1, 1); glVertex3f( 1,  1, -0.5f); 
     422                glTexCoord2f(0, 1); glVertex3f(-1,  1, -0.5f); 
     423                glEnd(); 
     424        }   
     425 
     426        mNewBuffer->DisableTextureTarget(); 
     427        PrintGLerror("displaytexture"); 
     428} 
     429 
     430 
     431} 
Note: See TracChangeset for help on using the changeset viewer.