Ignore:
Timestamp:
05/24/06 10:47:49 (18 years ago)
Author:
gumbau
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r895 r980  
    200200//      Set the color to the submesh sumbmeshIndex 
    201201//--------------------------------------------------------------------------- 
    202 void    GeoMeshView::setColorSubmeshi(int submeshIndex) 
    203 { 
    204         colorsubmeshi   =       submeshIndex; 
     202void    GeoMeshView::setSubMeshSelected(int submeshIndex) 
     203{ 
     204        mSubMeshSelected        =       submeshIndex; 
    205205} 
    206206 
     
    208208//      Sets the leaves submesh index. 
    209209//--------------------------------------------------------------------------- 
    210 void    GeoMeshView::setLeavesSubmesh(int submeshIndex) 
    211 { 
    212         leavesSubmesh   =       submeshIndex; 
     210void    GeoMeshView::setLeavesSubMesh(int submeshIndex) 
     211{ 
     212        leavesSubMesh   =       submeshIndex; 
    213213} 
    214214 
     
    216216//      Gets the leaves submesh index. 
    217217//--------------------------------------------------------------------------- 
    218 int     GeoMeshView::getLeavesSubmesh() 
    219 { 
    220         return  leavesSubmesh; 
     218int     GeoMeshView::getLeavesSubMesh() 
     219{ 
     220        return  leavesSubMesh; 
    221221} 
    222222 
     
    277277} 
    278278 
     279/* 
    279280//--------------------------------------------------------------------------- 
    280281//      Get the bounding box of the object. 
     
    386387        return  bounds; 
    387388} 
     389*/ 
    388390 
    389391//--------------------------------------------------------------------------- 
     
    446448        GLfloat color_blanco[]  =       {1.0f,1.0f,1.0f,1.0f}; 
    447449 
    448         this->geoMesh   =       geomesh; 
    449         colorsubmeshi   =       -1; 
    450         leavesSubmesh   =       -1; 
     450        this->geoMesh                   =       geomesh; 
     451        mSubMeshSelected        =       -1; 
     452        leavesSubMesh                   =       -1; 
     453        mScaleFactor                    =       geomesh->mMeshBounds.scaleFactor; 
    451454         
    452455        //      Refresh vertices to the vertex array. 
     
    577580//      Repaint the Mesh. 
    578581//--------------------------------------------------------------------------- 
    579 void GeoMeshView::drawGeoMesh(int selectedMesh) 
     582void GeoMeshView::drawGeoMesh(bool      paintWire) 
    580583{ 
    581584        SubMesh *geosubmesh; 
     
    601604                                if (geosubmesh->mType   ==      GEO_TRIANGLE_LIST) 
    602605                                { 
    603                                         if (selectedMesh == submesh) 
     606                                        if (mSubMeshSelected == submesh) 
    604607                                        { 
    605608                                                submesh_selected        = true; 
     
    611614                                         
    612615                                        //      Draw the actual submesh in triangle list. 
    613                                         drawTriangleList(submesh,submesh_selected); 
     616                                        drawTriangleList(submesh,submesh_selected,paintWire); 
    614617                                } 
    615618                                else 
     
    618621                                        drawTriangleStrip(submesh); 
    619622                                } 
    620                         }                
    621                 } 
    622                 /* 
    623                 //      Choose the render operation. 
    624                 else if (geoMesh->mType == GEO_TRIANGLE_LIST) 
    625                 { 
    626                         //      Paint vertices. 
    627                         drawTriangleList(selectedMesh); 
    628                 } 
    629                 else 
    630                 { 
    631                         //      Paint vertices. 
    632                         drawTriangleStrip(); 
    633                 } 
    634                 */ 
     623                        } 
     624                } 
    635625        } 
    636626}//     End drawGeoMesh. 
     
    743733//--------------------------------------------------------------------------- 
    744734void GeoMeshView::drawTriangleList(     int                     submesh, 
    745                                                                                                                                                 bool            selectedSubMesh) 
     735                                                                                                                                                bool            selectedSubMesh, 
     736                                                                                                                                                bool            paintWire) 
    746737{ 
    747738        SubMesh *geosubmesh; 
     
    761752        geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
    762753         
    763         //      If a mesh is selected. 
    764         if (selectedSubMesh) 
    765         { 
    766                 glColor3d(1.0,0.0,0.0); 
    767                 GLfloat red[]   =       {1.0f,0.0f,0.0f,1.0f}; 
    768                 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,red); 
    769         } 
    770         //      If is a tree. 
    771         else if (leavesSubmesh >= 0) 
    772         { 
    773                 glColor3d(1.0, 0.5, 0.5); 
    774                 GLfloat brown[] =       {1.0f,0.5f,0.5f,1.0f}; 
    775                 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,brown); 
    776  
    777                 //      For each index of the strip. 
    778                 if (submesh == leavesSubmesh) 
    779                 { 
    780                         glColor3d(0.0,1.0,0.0); 
    781                         GLfloat green[] =       {0.0f,1.0f,0.0f,1.0f}; 
    782                         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,green); 
    783                 } 
    784         } 
    785         //      If is NOT a tree. 
    786         else 
    787         { 
    788                 //      Set white color to the object. 
    789                 glColor3d(1.0, 1.0, 1.0); 
    790                 GLfloat white[] =       {1.0f,1.0f,1.0f,1.0f}; 
    791                 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white); 
    792         } 
    793  
    794  
     754        //      If wire is not selected. 
     755        if (!paintWire) 
     756        { 
     757                //      If a mesh is selected. 
     758                if (selectedSubMesh) 
     759                { 
     760                        glColor3d(1.0,0.0,0.0); 
     761                        GLfloat red[]   =       {1.0f,0.0f,0.0f,1.0f}; 
     762                        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,red); 
     763                } 
     764                //      If is a tree. 
     765                else if (leavesSubMesh >= 0) 
     766                { 
     767                        glColor3d(1.0, 0.5, 0.5); 
     768                        GLfloat brown[] =       {1.0f,0.5f,0.5f,1.0f}; 
     769                        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,brown); 
     770 
     771                        //      For each index of the strip. 
     772                        if (submesh == leavesSubMesh) 
     773                        { 
     774                                glColor3d(0.0,1.0,0.0); 
     775                                GLfloat green[] =       {0.0f,1.0f,0.0f,1.0f}; 
     776                                glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,green); 
     777                        } 
     778                } 
     779                //      If is NOT a tree. 
     780                else 
     781                { 
     782                        //      Set white color to the object. 
     783                        glColor3d(1.0, 1.0, 1.0); 
     784                        GLfloat white[] =       {1.0f,1.0f,1.0f,1.0f}; 
     785                        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white); 
     786                } 
     787        } 
     788         
    795789        //      Enable arrays. 
    796790        glEnableClientState(GL_VERTEX_ARRAY); 
     
    10561050        //      Frustrum. 
    10571051        glViewport(0,0,w(),h()); 
    1058         gluPerspective(60,1,0.1,1000); 
     1052        gluPerspective(60,(float)w()/(float)h(),0.1,1000); 
    10591053 
    10601054        glMatrixMode(GL_MODELVIEW); 
     
    10821076        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    10831077 
    1084         gluLookAt(0,0,mScaleFactor*2+size, 0,0,0, 0,1,0); 
     1078        gluLookAt(0,0,2/*mScaleFactor*/ + size * 0.25, 0,0,0, 0,1,0); 
    10851079 
    10861080        glTranslatef(xshift,yshift,0); 
    10871081        glRotatef(hAng,0,1,0); 
    10881082        glRotatef(vAng,1,0,0); 
    1089         glTranslatef(-xMed,-yMed,-zMed); 
     1083        //glTranslatef(-xMed,-yMed,-zMed); 
    10901084 
    10911085        //      Set white color to the object. 
     
    10941088        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 
    10951089 
     1090        glClearColor(0,0,0,0); 
     1091         
    10961092        if (mCW) 
    10971093        { 
     
    11171113                glDisable(GL_LIGHTING); 
    11181114                glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 
    1119                 drawGeoMesh(colorsubmeshi); 
     1115                drawGeoMesh(false); 
    11201116        } 
    11211117        else 
     
    11301126                glColor3d(0.0, 0.0, 1.0); 
    11311127                glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 
    1132                 drawGeoMesh(-1); 
     1128                drawGeoMesh(true); 
    11331129        } 
    11341130        else 
     
    11391135                        glEnable(GL_LIGHTING); 
    11401136                        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 
    1141                         drawGeoMesh(colorsubmeshi); 
     1137                        drawGeoMesh(false); 
    11421138                } 
    11431139        } 
Note: See TracChangeset for help on using the changeset viewer.