Ignore:
Timestamp:
05/12/06 16:00:21 (19 years ago)
Author:
igarcia
Message:
 
Location:
GTP/trunk/Lib/Illum/GPUObscurancesGT/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/GPUObscurancesGT/src/CMesh.cpp

    r930 r953  
    9595} 
    9696 
     97float CMesh::getValue(const char *string, int &i) 
     98{ 
     99        int j = 0; 
     100        float value; 
     101        char substring[100]; 
     102 
     103        while ((string[i] != ' ') && (string[i] != '\0')) 
     104        { 
     105                substring[j] = string[i]; 
     106                i++; 
     107                j++; 
     108        } 
     109 
     110        substring[j] = '\0'; 
     111 
     112        value = atof(substring); 
     113 
     114        return (value); 
     115 
     116} 
     117 
    97118void CMesh::XMLToSNStr(char *name) 
    98119{ 
    99120        int i = 0, j = 0, k; 
    100         bool cont = true; 
     121        const char *string; 
     122        bool cont = true, color = false; 
    101123 
    102124        // Read root element and decide from there what type 
    103125    String response; 
     126        String::iterator iter; 
     127 
    104128        TiXmlDocument* doc = new TiXmlDocument(name); 
    105129    // Some double-parsing here but never mind   
     
    194218                tri = tri->FirstChildElement("vertexbuffer"); 
    195219 
     220                const char *cad = tri->Attribute("colours_diffuse"); 
     221 
     222                if (!strcmp(cad, "true")) color = true; 
     223 
     224 
    196225                m_pObject._geo[0]._triSet[i]._numVer = NVer; 
    197226                 
     
    225254                        m_pObject._geo[0]._triSet[i]._tex[2 * j + 1] = atof(aux1->Attribute("v")); 
    226255 
    227                         /*->aux1 = aux->FirstChildElement("colour_diffuse"); 
     256                        aux1 = aux->FirstChildElement("colour_diffuse"); 
    228257                        response = aux1->Attribute("value"); 
    229                         /*->m_pObject._geo[0]._triSet[i]._ver[3 * j] = atof(aux1->Attribute("x")); 
    230                         m_pObject._geo[0]._triSet[i]._ver[3 * j + 1] = atof(aux1->Attribute("y")); 
    231                         m_pObject._geo[0]._triSet[i]._ver[3 * j + 2] = atof(aux1->Attribute("z"));*/ 
    232  
    233                         m_pObject._geo[0]._triSet[i]._refl[3 * j] = 0.5; 
    234                         m_pObject._geo[0]._triSet[i]._refl[3 * j + 1] = 0.5; 
    235                         m_pObject._geo[0]._triSet[i]._refl[3 * j + 2] = 0.5; 
     258 
     259                        if (color) 
     260                        { 
     261                                string = response.c_str();                       
     262                                k = 0; 
     263                                m_pObject._geo[0]._triSet[i]._refl[3 * j] = getValue(string, k); 
     264                                k++; 
     265                                m_pObject._geo[0]._triSet[i]._refl[3 * j + 1] = getValue(string, k); 
     266                                k++; 
     267                                m_pObject._geo[0]._triSet[i]._refl[3 * j + 2] = getValue(string, k); 
     268                                k++; 
     269                                getValue(string, k); 
     270                        } 
     271                        else 
     272                        { 
     273                                m_pObject._geo[0]._triSet[i]._refl[3 * j] = 0.5; 
     274                                m_pObject._geo[0]._triSet[i]._refl[3 * j + 1] = 0.5; 
     275                                m_pObject._geo[0]._triSet[i]._refl[3 * j + 2] = 0.5; 
     276                        } 
    236277 
    237278                        aux = aux->NextSiblingElement(); 
  • GTP/trunk/Lib/Illum/GPUObscurancesGT/src/MyFrame.cpp

    r930 r953  
    226226        float r_float; 
    227227 
    228         i = 0; 
    229         j = 0;   
    230         while (i < (res * res * 4)) 
     228        for (i = 0, j = 0; i < (res * res * 4); i += 4, j += 3) 
    231229        { 
    232230                r_float = ObscuranceMap[i] * 255; 
     
    236234                r_float = ObscuranceMap[i+2] * 255; 
    237235                bmp[j + 2] = uchar(r_float); 
    238  
    239                 j += 3; 
    240                 i += 4; 
    241236        } 
    242237 
Note: See TracChangeset for help on using the changeset viewer.