Changeset 1543


Ignore:
Timestamp:
09/29/06 14:26:17 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared/GeoTool
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h

    r1526 r1543  
    8686 
    8787using   namespace       Geometry; 
     88using   namespace       std; 
    8889 
    8990class GeoToolIndexData : public Geometry::IndexData 
    9091{ 
    91 public: 
    92         GeoToolIndexData(unsigned int submeshes):Geometry::IndexData(){ 
    93                 submeshcount = submeshes; 
    94                 indices=new unsigned int*[submeshcount]; 
    95                 indexCount=new unsigned int[submeshcount]; 
    96                 for (int i=0; i<submeshcount; i++) 
    97                 { 
    98                         indices[i]=NULL; 
    99                         indexCount[i]=0; 
     92        public: 
     93                GeoToolIndexData(unsigned int submeshes):Geometry::IndexData(){ 
     94                        submeshcount = submeshes; 
     95                        indices=new unsigned int*[submeshcount]; 
     96                        indexCount=new unsigned int[submeshcount]; 
     97                        for (int i=0; i<submeshcount; i++) 
     98                        { 
     99                                indices[i]=NULL; 
     100                                indexCount[i]=0; 
     101                        } 
    100102                } 
    101         } 
    102         virtual ~GeoToolIndexData(void){ 
    103                 for (int i=0; i<submeshcount; i++) 
    104                         if (indices[i]) 
    105                                 delete[] indices[i]; 
    106                 delete[] indices; 
    107                 delete[] indexCount; 
    108         } 
    109  
    110         virtual void Begin(unsigned int submesh, unsigned int numinds){ 
    111                 if (indices[submesh])            
    112                         delete[] indices[submesh]; 
    113                 indices[submesh] = new unsigned int[numinds];      
    114                 indexCount[submesh] = numinds; 
    115                 modifySubmesh=submesh; 
    116         } 
    117  
    118         virtual void SetIndex(unsigned int i, unsigned int index){ 
    119                 indices[modifySubmesh][i] = index; 
    120         } 
    121  
    122         virtual void End(void){} 
    123         virtual void BorrowIndexData(const IndexData *){} 
    124  
    125         unsigned int submeshcount; 
    126         unsigned int **indices; 
    127         unsigned int *indexCount; 
    128         unsigned int modifySubmesh; 
     103                virtual ~GeoToolIndexData(void){ 
     104                        for (int i=0; i<submeshcount; i++) 
     105                                if (indices[i]) 
     106                                        delete[] indices[i]; 
     107                        delete[] indices; 
     108                        delete[] indexCount; 
     109                } 
     110 
     111                virtual void Begin(unsigned int submesh, unsigned int numinds){ 
     112                        if (indices[submesh])            
     113                                delete[] indices[submesh]; 
     114                        indices[submesh] = new unsigned int[numinds];      
     115                        indexCount[submesh] = numinds; 
     116                        modifySubmesh=submesh; 
     117                } 
     118 
     119                virtual void SetIndex(unsigned int i, unsigned int index){ 
     120                        indices[modifySubmesh][i] = index; 
     121                } 
     122 
     123                virtual void End(void){} 
     124                virtual void BorrowIndexData(const IndexData *){} 
     125 
     126                unsigned int submeshcount; 
     127                unsigned int **indices; 
     128                unsigned int *indexCount; 
     129                unsigned int modifySubmesh; 
    129130}; 
    130131 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r1526 r1543  
    399399            : fltk::GlWindow(x,y,w,h,l) 
    400400{ 
    401                 mStripColors            =       NULL; 
    402                 mSharedPosArray         =       NULL; 
    403                 mSharedNorArray         =       NULL; 
    404                 mSharedTexCoordArray=   NULL; 
    405                 mPosArray                       =       NULL; 
    406                 mNorArray                       =       NULL; 
    407                 mTexCoordArray          =       NULL; 
    408                 mIndexArray                     =       NULL; 
    409                 vAng                            = 0.0; 
    410                 hAng                                                    =       0.0; 
    411                 size                                                    =       0.0; 
    412                 mSizeY                                          =       0; 
    413                 xshift                                          =       0.0; 
    414                 yshift                                          =       0.0; 
    415                 geoMesh                                         =       0; 
    416                 mRotate                                         =       true; 
    417                 mPan                                                    =       false; 
    418                 mLodStrip                                       =       false; 
    419                 mLodTree                                        =       false; 
    420                 mIdVisualList                   =       0; 
    421                 mSubMeshCount                   =       0; 
    422                 mStripColorsCount       =       0; 
    423                  
    424                 //      Initialize the model view. 
    425                 deactiveWire(); 
    426                 deactiveSolid(); 
    427                 activeRotate(); 
    428                 deactiveCW(); 
    429                 activeCCW(); 
    430                  
    431                 //      Initialize start time for FPS. 
    432                 mStartTime      =       clock(); 
    433  
    434                 //      Cross Reference. 
    435                 mGeoMeshViewUI  =       geoMeshViewUI; 
    436  
    437                 current_texture = 0; 
    438                 current_texture_submesh=NULL; 
    439                 use_texture_mapping = true; 
     401        mStripColors                                    =       NULL; 
     402        mSharedPosArray                         =       NULL; 
     403        mSharedNorArray                         =       NULL; 
     404        mSharedTexCoordArray    =       NULL; 
     405        mPosArray                                                       =       NULL; 
     406        mNorArray                                                       =       NULL; 
     407        mTexCoordArray                          =       NULL; 
     408        mIndexArray                                             =       NULL; 
     409        vAng                                                                    = 0.0; 
     410        hAng                                                                    =       0.0; 
     411        size                                                                    =       0.0; 
     412        mSizeY                                                          =       0; 
     413        xshift                                                          =       0.0; 
     414        yshift                                                          =       0.0; 
     415        geoMesh                                                         =       0; 
     416        mRotate                                                         =       true; 
     417        mPan                                                                    =       false; 
     418        mLodStrip                                                       =       false; 
     419        mLodTree                                                        =       false; 
     420        mIdVisualList                                   =       0; 
     421        mSubMeshCount                                   =       0; 
     422        mStripColorsCount                       =       0; 
     423 
     424        //      Initialize the model view. 
     425        deactiveWire(); 
     426        deactiveSolid(); 
     427        activeRotate(); 
     428        deactiveCW(); 
     429        activeCCW(); 
     430 
     431        //      Initialize start time for FPS. 
     432        mStartTime      =       clock(); 
     433 
     434        //      Cross Reference. 
     435        mGeoMeshViewUI  =       geoMeshViewUI; 
     436        current_texture = 0; 
     437 
     438        current_texture_submesh =       NULL; 
     439        use_texture_mapping             =       true; 
    440440} 
    441441 
     
    464464 
    465465        if (current_texture_submesh) 
    466                 delete[] current_texture_submesh; 
    467         current_texture_submesh=new GLuint[getSubMeshCount()]; 
     466        { 
     467                delete  []      current_texture_submesh; 
     468        } 
     469 
     470        current_texture_submesh =       new GLuint[getSubMeshCount()]; 
     471 
    468472        for (int i=0; i<getSubMeshCount(); i++) 
    469                 current_texture_submesh[i]=0; 
     473        { 
     474                current_texture_submesh[i]      =       0; 
     475        } 
    470476} 
    471477 
     
    505511                mSharedPosArray = new GLfloat[vertex_buffer->mVertexCount * 3]; 
    506512                mSharedNorArray = new GLfloat[vertex_buffer->mVertexCount * 3]; 
     513 
    507514                if (vertex_buffer->mTexCoords) 
     515                { 
    508516                        mSharedTexCoordArray = new GLfloat[vertex_buffer->mVertexCount * 2]; 
     517                } 
    509518                else 
     519                { 
    510520                        mSharedTexCoordArray = NULL; 
     521                } 
    511522 
    512523                for (int vertex = 0; vertex < vertex_buffer->mVertexCount; vertex++) 
    513524                { 
    514                         mSharedPosArray[3 * vertex]                     =       vertex_buffer->mPosition[vertex].x; 
     525                        mSharedPosArray[3 * vertex]                             =       vertex_buffer->mPosition[vertex].x; 
    515526                        mSharedPosArray[(3 * vertex) + 1]       =       vertex_buffer->mPosition[vertex].y; 
    516527                        mSharedPosArray[(3 * vertex) + 2]       =       vertex_buffer->mPosition[vertex].z; 
    517528 
    518                         mSharedNorArray[3 * vertex]                     =       vertex_buffer->mNormal[vertex].x; 
     529                        mSharedNorArray[3 * vertex]                             =       vertex_buffer->mNormal[vertex].x; 
    519530                        mSharedNorArray[(3 * vertex) + 1]       =       vertex_buffer->mNormal[vertex].y; 
    520531                        mSharedNorArray[(3 * vertex) + 2]       =       vertex_buffer->mNormal[vertex].z; 
     
    522533                        if (vertex_buffer->mTexCoords) 
    523534                        { 
    524                                 mSharedTexCoordArray[2 * vertex]                =       vertex_buffer->mTexCoords[vertex].x; 
    525                                 mSharedTexCoordArray[(2 * vertex) + 1]  =       vertex_buffer->mTexCoords[vertex].y; 
     535                                mSharedTexCoordArray[2 * vertex]                                =       vertex_buffer-> 
     536                                                                                                                                                                                                        mTexCoords[vertex].x; 
     537 
     538                                mSharedTexCoordArray[(2 * vertex) + 1]  =       vertex_buffer-> 
     539                                                                                                                                                                                                        mTexCoords[vertex].y; 
    526540                        } 
    527541                } 
     
    529543         
    530544        //      Build the arrays of vertices and indices. 
    531         mPosArray               =       new GLfloat*[geomesh->mSubMeshCount]; 
    532         mNorArray               =       new GLfloat*[geomesh->mSubMeshCount]; 
     545        mPosArray                               =       new GLfloat*[geomesh->mSubMeshCount]; 
     546        mNorArray                               =       new GLfloat*[geomesh->mSubMeshCount]; 
    533547        mTexCoordArray  =       new GLfloat*[geomesh->mSubMeshCount]; 
    534         mIndexArray             =       new GLuint*[geomesh->mSubMeshCount]; 
     548        mIndexArray                     =       new GLuint*[geomesh->mSubMeshCount]; 
    535549 
    536550        //      For each submesh. 
     
    555569 
    556570                        //      Allocate memory for vertices of the actual submesh. 
    557                         mPosArray[submesh]      =       new GLfloat[vertex_buffer->mVertexCount * 3]; 
    558                         mNorArray[submesh]      =       new GLfloat[vertex_buffer->mVertexCount * 3]; 
     571                        mPosArray[submesh]                      =       new GLfloat[vertex_buffer->mVertexCount * 3]; 
     572                        mNorArray[submesh]                      =       new GLfloat[vertex_buffer->mVertexCount * 3]; 
    559573                        mTexCoordArray[submesh] =       new GLfloat[vertex_buffer->mVertexCount * 2]; 
    560574 
     
    577591                else 
    578592                { 
    579                         mPosArray[submesh]      =       NULL; 
    580                         mNorArray[submesh]      =       NULL; 
     593                        mPosArray[submesh]                      =       NULL; 
     594                        mNorArray[submesh]                      =       NULL; 
    581595                        mTexCoordArray[submesh] =       NULL; 
    582596                } 
     
    880894{ 
    881895        SubMesh         *geosubmesh; 
    882         Index           position; 
     896        Index                   position; 
    883897        Vector3         vector3; 
    884898        Vector2         vector2; 
     899        float                   x,y,z; 
     900        float                   r,g,b; 
     901        int                             color_index; 
     902        int                             current_strip; 
     903 
     904        //      Initialize current strip. 
     905        current_strip = 0; 
     906 
     907        //      For each submesh. 
     908        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     909        { 
     910                // bind current texture to use 
     911                bool usetex = SetTextureRenderingState(submesh); 
     912 
     913                color_index     =       0; 
     914 
     915                //      Gets the actual submesh. 
     916                geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
     917 
     918                //      For each one of the strips. 
     919                int indices_to_render = lodStripsLib->GetValidIndexCount(submesh); 
     920                int offset                                              =       lodStripsLib->GetValidOffset(submesh); 
     921 
     922                glBegin(GL_TRIANGLE_STRIP); 
     923 
     924                for (   int index = 0; 
     925                                        index < mGeoMeshViewUI->lod_index_data->indexCount[submesh]; 
     926                                        index ++) 
     927                { 
     928                        position        =       mGeoMeshViewUI->lod_index_data->indices[submesh][index]; 
     929 
     930                        //      Gets the vertex normal. 
     931                        vector3 =       geosubmesh->mVertexBuffer->mNormal[position]; 
     932 
     933                        x                               =       vector3[0]; 
     934                        y                               =       vector3[1]; 
     935                        z                               =       vector3[2]; 
     936 
     937                        //      Sets the vertex normal. 
     938                        glNormal3f(x,y,z); 
     939 
     940                        // set the texture coordinates if needed 
     941                        if (usetex) 
     942                        { 
     943                                vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 
     944                                x                               =       vector2[0]; 
     945                                y                               =       vector2[1]; 
     946 
     947                                glTexCoord2f(x,y); 
     948                        } 
     949 
     950                        //      Gets the vertex coordinates. 
     951                        vector3 =       geosubmesh->mVertexBuffer->mPosition[position]; 
     952 
     953                        x                               =       vector3[0]; 
     954                        y                               =       vector3[1]; 
     955                        z                               =       vector3[2]; 
     956 
     957                        //      Sets the vertex position. 
     958                        glVertex3f(x,y,z); 
     959                } 
     960                glEnd(); 
     961 
     962        } 
     963         
     964}//End drawTriangleStrip. 
     965 
     966//--------------------------------------------------------------------------- 
     967//      Paint lodtree object. 
     968//--------------------------------------------------------------------------- 
     969void GeoMeshView::drawLodTree() 
     970{ 
     971        SubMesh *geosubmesh; 
     972        Index           position; 
     973        Vector3 vector3; 
     974        Vector2 vector2; 
    885975        float           x,y,z; 
    886976        float           r,g,b; 
     
    889979 
    890980        //      Initialize current strip. 
    891         current_strip = 0; 
    892  
     981        current_strip   =       0; 
     982 
     983        // DRAW THE TRUNK AS A LODSTRIP OBJECT 
    893984        //      For each submesh. 
    894985        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    895986        { 
     987                if (submesh == lodTreeLib->GetLeavesSubMesh()) 
     988                { 
     989                        continue; 
     990                } 
     991 
    896992                // bind current texture to use 
    897993                bool usetex = SetTextureRenderingState(submesh); 
     
    903999 
    9041000                //      For each one of the strips. 
    905                 int indices_to_render = lodStripsLib->GetValidIndexCount(submesh); 
    906                 int offset = lodStripsLib->GetValidOffset(submesh); 
    907  
     1001                int indices_to_render = lodTreeLib->GetValidTrunkIndexCount(submesh); 
     1002                int begin_index                         =       lodTreeLib->GetValidTrunkOffset(submesh); 
     1003                         
    9081004                glBegin(GL_TRIANGLE_STRIP); 
    909 //              for (int index = offset; index < indices_to_render+offset; index ++) 
    910                 for (int index = 0; index < mGeoMeshViewUI->lod_index_data->indexCount[submesh]; index ++) 
    911                 { 
    912 //                      position = lodStripsLib->dataRetrievalInterface->GetIndex(index); 
     1005 
     1006                for (   int index = 0; 
     1007                                        index < mGeoMeshViewUI->lod_index_data->indexCount[submesh]; 
     1008                                        index ++) 
     1009                { 
    9131010                        position = mGeoMeshViewUI->lod_index_data->indices[submesh][index]; 
    9141011 
     
    9431040                } 
    9441041                glEnd(); 
    945  
    946         } 
    947  
    948          
    949 }//End drawTriangleStrip. 
    950  
    951 //--------------------------------------------------------------------------- 
    952 //      Paint lodtree object. 
    953 //--------------------------------------------------------------------------- 
    954 void GeoMeshView::drawLodTree() 
    955 { 
    956         SubMesh                         *geosubmesh; 
    957         Index                                   position; 
    958         Vector3                         vector3; 
    959         Vector2                         vector2; 
    960         float                                   x,y,z; 
    961         float                                   r,g,b; 
    962         int                                             color_index; 
    963         int                                             current_strip; 
    964  
    965         //      Initialize current strip. 
    966         current_strip   =       0; 
    967  
    968         // DRAW THE TRUNK AS A LODSTRIP OBJECT 
    969         //      For each submesh. 
    970         for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    971         { 
    972                 //if (submesh==leavesSubMesh) 
    973                 if (submesh == lodTreeLib->GetLeavesSubMesh()) 
    974                         continue; 
    975  
    976                 // bind current texture to use 
    977                 bool usetex = SetTextureRenderingState(submesh); 
    978  
    979                 color_index     =       0; 
    980  
    981                 //      Gets the actual submesh. 
    982                 geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
    983  
    984                 //      For each one of the strips. 
    985                 int indices_to_render = lodTreeLib->GetValidTrunkIndexCount(submesh); 
    986                 int begin_index = lodTreeLib->GetValidTrunkOffset(submesh); 
    987                          
    988                 glBegin(GL_TRIANGLE_STRIP); 
    989 //              for (int index = begin_index; index < indices_to_render+begin_index; index ++) 
    990                 for (int index = 0; index < mGeoMeshViewUI->lod_index_data->indexCount[submesh]; index ++) 
    991                 { 
    992 //                      position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); 
    993                         position = mGeoMeshViewUI->lod_index_data->indices[submesh][index]; 
    994  
    995                         //      Gets the vertex normal. 
    996                         vector3 =       geosubmesh->mVertexBuffer->mNormal[position]; 
    997  
    998                         x                               =       vector3[0]; 
    999                         y                               =       vector3[1]; 
    1000                         z                               =       vector3[2]; 
    1001  
    1002                         //      Sets the vertex normal. 
    1003                         glNormal3f(x,y,z); 
    1004  
    1005                         // set the texture coordinates if needed 
    1006                         if (usetex) 
    1007                         { 
    1008                                 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 
    1009                                 x                               =       vector2[0]; 
    1010                                 y                               =       vector2[1]; 
    1011                                 glTexCoord2f(x,y); 
    1012                         } 
    1013  
    1014                         //      Gets the vertex coordinates. 
    1015                         vector3 =       geosubmesh->mVertexBuffer->mPosition[position]; 
    1016  
    1017                         x                               =       vector3[0]; 
    1018                         y                               =       vector3[1]; 
    1019                         z                               =       vector3[2]; 
    1020  
    1021                         //      Sets the vertex position. 
    1022                         glVertex3f(x,y,z); 
    1023                 } 
    1024                 glEnd(); 
    10251042        } 
    10261043 
     
    10341051 
    10351052        glBegin(GL_TRIANGLES); 
    1036         Geometry::SubMesh & foliageSubMesh = geoMesh->mSubMesh[lodTreeLib->GetLeavesSubMesh()]; 
    1037         Geometry::Vector3 auxv; 
    1038         for (int j=0; j<mGeoMeshViewUI->lod_index_data->indexCount[lodTreeLib->GetLeavesSubMesh()]; j++) 
    1039         {                
    1040                 int k = mGeoMeshViewUI->lod_index_data->indices[lodTreeLib->GetLeavesSubMesh()][j]; 
     1053 
     1054        SubMesh & foliageSubMesh = geoMesh->mSubMesh[lodTreeLib->GetLeavesSubMesh()]; 
     1055        Vector3 auxv; 
     1056 
     1057        for (   int     j       =       0; 
     1058                                j < mGeoMeshViewUI->lod_index_data-> 
     1059                                                indexCount[lodTreeLib->GetLeavesSubMesh()]; 
     1060                                j++) 
     1061        { 
     1062                int     k       =       mGeoMeshViewUI->lod_index_data-> 
     1063                                                indices[lodTreeLib->GetLeavesSubMesh()][j]; 
     1064 
    10411065                if (usetex) 
    10421066                { 
    1043                         Geometry::Vector2 tc = foliageSubMesh.mVertexBuffer->mTexCoords[k]; 
     1067                        Vector2 tc = foliageSubMesh.mVertexBuffer->mTexCoords[k]; 
    10441068                        glTexCoord2f(tc.x,tc.y); 
    10451069                } 
    1046                 auxv = foliageSubMesh.mVertexBuffer->mNormal[k]; 
     1070 
     1071                auxv    =       foliageSubMesh.mVertexBuffer->mNormal[k]; 
     1072 
    10471073                glNormal3f(auxv.x,auxv.y,auxv.z); 
    1048                 auxv = foliageSubMesh.mVertexBuffer->mPosition[k]; 
     1074 
     1075                auxv    =       foliageSubMesh.mVertexBuffer->mPosition[k]; 
     1076 
    10491077                glVertex3f(auxv.x,auxv.y,auxv.z); 
    10501078        } 
     1079 
    10511080        glEnd(); 
    10521081 
    10531082        glColor3f(1,1,1); 
    10541083        glDisable(GL_ALPHA_TEST); 
    1055         glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0);        
     1084        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0); 
    10561085} 
    10571086 
     
    10801109{ 
    10811110        if (mLodStrip) 
     1111        { 
    10821112                lodStripsLib->GoToLod(lod); 
     1113        } 
     1114 
    10831115        if (mLodTree) 
     1116        { 
    10841117                lodTreeLib->GoToTrunkLod(lod); 
     1118        } 
     1119 
    10851120        draw(); 
    10861121} 
     
    10921127{ 
    10931128        if (mLodTree) 
     1129        { 
    10941130                lodTreeLib->GoToFoliageLod(lod); 
     1131        } 
     1132 
    10951133        draw(); 
    10961134} 
     
    11171155 
    11181156        GLfloat light_ambient[] =       {0.3,0.3,0.3,1.0}; 
    1119         GLfloat luzpos[]                =       {0.0,0.0,1.0,0.0}; 
    1120         GLfloat luzcolor[]              =       {1.0,1.0,1.0,1.0}; 
     1157        GLfloat luzpos[]                                =       {0.0,0.0,1.0,0.0}; 
     1158        GLfloat luzcolor[]                      =       {1.0,1.0,1.0,1.0}; 
    11211159 
    11221160        //      glLightModelfv(GL_LIGHT_MODEL_AMBIENT, light_ambient); 
     
    11431181        //      Set white color to the object. 
    11441182        glColor3d(1.0, 1.0, 1.0); 
     1183 
    11451184        GLfloat color_blanco[]  =       {1.0f,1.0f,1.0f,1.0f}; 
     1185 
    11461186        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 
    11471187 
     
    11831223                //glDisable(GL_LIGHTING); 
    11841224                glColor3d(0.0, 0.0, 0.0); 
     1225 
    11851226                GLfloat color[] =       {0.0f,0.0f,0.0f,1.0f}; 
     1227 
    11861228                glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color); 
    11871229 
     
    12151257 
    12161258        current_texture = ilutGLLoadImage((const ILstring)imgfile); 
     1259 
    12171260        if (!current_texture) 
     1261        { 
    12181262                fltk::alert("Error loading texture!"); 
     1263        } 
    12191264 
    12201265        ilShutDown(); 
     
    12281273 
    12291274        current_texture_submesh[isubmesh] = ilutGLLoadImage((const ILstring)imgfile); 
     1275 
    12301276        if (!current_texture_submesh[isubmesh]) 
     1277        { 
    12311278                fltk::alert("Error loading texture!"); 
     1279        } 
    12321280 
    12331281        ilShutDown(); 
     
    12391287        { 
    12401288                glDeleteTextures(1,&current_texture); 
    1241                 current_texture=0; 
    1242         } 
     1289 
     1290                current_texture =       0; 
     1291        } 
     1292 
    12431293        if (current_texture_submesh) 
    12441294        { 
    12451295                glDeleteTextures(getSubMeshCount(),current_texture_submesh); 
    1246                 for (int i=0; i<getSubMeshCount(); i++) 
    1247                         current_texture_submesh[i]=0; 
     1296 
     1297                for (int        i       =       0;      i < getSubMeshCount(); i++) 
     1298                { 
     1299                        current_texture_submesh[i]      =       0; 
     1300                } 
    12481301        } 
    12491302} 
     
    12511304bool    GeoMeshView::SetTextureRenderingState(int submesh) 
    12521305{ 
    1253         GLuint usetex = 0; 
     1306        GLuint usetex   =       0; 
     1307 
    12541308        if (use_texture_mapping) 
    12551309        { 
    12561310                if (current_texture_submesh[submesh]) 
    1257                         usetex=current_texture_submesh[submesh]; 
     1311                { 
     1312                        usetex  =       current_texture_submesh[submesh]; 
     1313                } 
    12581314                else if (current_texture) 
    1259                         usetex=current_texture; 
    1260         } 
     1315                { 
     1316                        usetex  =       current_texture; 
     1317                } 
     1318        } 
     1319 
    12611320        if (usetex) 
     1321        { 
    12621322                glEnable(GL_TEXTURE_2D); 
     1323        } 
    12631324        else 
     1325        { 
    12641326                glDisable(GL_TEXTURE_2D); 
     1327        } 
    12651328 
    12661329        glBindTexture(GL_TEXTURE_2D,usetex); 
    12671330 
    1268         return (usetex!=0); 
     1331        return (usetex != 0); 
    12691332} 
    12701333 
    12711334int             GeoMeshView::findLeavesSubMesh(void) 
    12721335{ 
    1273         for (int i=0; i<geoMesh->mSubMeshCount; i++) 
    1274                 if (geoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 
    1275                         return i; 
    1276         return -1; 
    1277 } 
    1278  
     1336        for (int i      =       0; i < geoMesh->mSubMeshCount; i++) 
     1337        { 
     1338                if (geoMesh->mSubMesh[i].mType == GEO_TRIANGLE_LIST) 
     1339                { 
     1340                        return  i; 
     1341                } 
     1342        } 
     1343 
     1344        return  -1; 
     1345} 
     1346 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r1526 r1543  
    11481148                //      Refresh geometry attributes. 
    11491149                refreshApplicationBar(); 
     1150 
     1151                //      Set textures. 
     1152                geoMeshView->resetTextures(); 
     1153                setTextures(); 
    11501154        } 
    11511155         
     
    12891293                //      Refresh data aplication. 
    12901294                refreshApplicationBar(); 
     1295 
     1296                //      Set textures. 
     1297                geoMeshView->resetTextures(); 
     1298                setTextures(); 
    12911299        }        
    12921300} 
     
    16451653        showEdgeCollapse(); 
    16461654 
     1655        //      Deactive VMI option. 
     1656        mViewPointDriven->deactivate(); 
     1657 
    16471658        mButtonBuild->set_visible(); 
    16481659        //mButtonBuild->activate(); 
     
    16591670        //      Shows the simplify panel. 
    16601671        showEdgeCollapse(); 
     1672 
     1673        //      Deactive VMI option. 
     1674        mViewPointDriven->deactivate(); 
    16611675 
    16621676        mButtonBuild->set_visible(); 
     
    22642278                //      Repaint the window. 
    22652279                mMainWindow->redraw(); 
     2280 
     2281                //      Set textures. 
     2282                geoMeshView->resetTextures(); 
     2283                setTextures(); 
    22662284        } 
    22672285} 
     
    24922510        { 
    24932511                material        = string(mGeoMesh->mSubMesh[submesh].mMaterialName); 
    2494                                  
     2512 
    24952513                if (loader->existsMaterial(material)) 
    2496                 { 
    2497                         //      Debug. 
    2498                         cout    <<      "Material " 
    2499                                                 <<      material 
    2500                                                 <<      " found." 
    2501                                                 <<      endl; 
    2502                          
     2514                {                        
    25032515                        filename        =       loader->getTextureFileName(material); 
    25042516 
    2505                         //      Debug. 
    2506                         cout    <<      "File: " 
    2507                                                 <<      filename.c_str() 
    2508                                                 <<      endl; 
    2509                          
    25102517                        geoMeshView->LoadTextureSubMesh(submesh,        filename.c_str()); 
    25112518                } 
     
    31213128} 
    31223129 
    3123  
     3130//      Build Textures menu. 
    31243131void GeoMeshViewUI::BuildLoadTextureSubMeshMenu(void) 
    31253132{ 
     
    31273134        { 
    31283135                menuLoadTextures->clear(); 
    3129                 for (int i=0; i<numSubMeshNames; i++) 
     3136 
     3137                for (int i      =       0; i < numSubMeshNames; i++) 
    31303138                { 
    31313139                        delete[] SubMeshNames[i]; 
     
    31353143 
    31363144        menuFileLoadTexture = new fltk::Item("Entire model"); 
     3145 
    31373146        menuFileLoadTexture->callback((fltk::Callback*)cb_menuFileLoadTexture); 
    31383147        menuLoadTextures->add(menuFileLoadTexture); 
    31393148 
    3140         numSubMeshNames=geoMeshView->getSubMeshCount(); 
    3141         SubMeshNames=new char*[numSubMeshNames]; 
    3142  
    3143         for (int i=0; i<numSubMeshNames; i++) 
    3144         { 
    3145                 SubMeshNames[i]=new char[10]; 
     3149        numSubMeshNames =       geoMeshView->getSubMeshCount(); 
     3150        SubMeshNames            =       new char*[numSubMeshNames]; 
     3151 
     3152        for (int i      =       0; i < numSubMeshNames; i++) 
     3153        { 
     3154                SubMeshNames[i] =       new char[10]; 
    31463155 
    31473156                sprintf(SubMeshNames[i],"submesh %d",i); 
    3148                 fltk::Item *item = new fltk::Item(SubMeshNames[i]); 
     3157 
     3158                fltk::Item *item        =       new fltk::Item(SubMeshNames[i]); 
     3159 
    31493160                item->callback((fltk::Callback*)cb_menuFileLoadTextureSubMesh); 
    31503161                menuLoadTextures->add(item); 
    31513162        } 
    31523163} 
     3164 
Note: See TracChangeset for help on using the changeset viewer.