Project

General

Profile

« Previous | Next » 

Revision de53cf3e

Added by Leszek Koltunski over 4 years ago

Make MeshBase.setTextureMap() work.

View differences:

src/main/java/org/distorted/library/mesh/MeshBase.java
92 92

  
93 93
     void setMap(float[] newMap)
94 94
       {
95
       mTextureMap = newMap;
95
       System.arraycopy(newMap,0,mTextureMap,0,4);
96 96
       }
97 97
     }
98 98

  
......
149 149
     setAttribs(mVertAttribs);
150 150
     }
151 151

  
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153
// change mVertAttribs from index 'begin' to index 'end' (inclusive) to the new Texture Map.
154
// x varies from -mBoundingX to +mBoundingX; y accordingly.
155

  
156
   private void changeTextureMap( float[] newMap, float[] oldMap, int begin, int end)
157
     {
158

  
159
     }
160

  
161 152
///////////////////////////////////////////////////////////////////////////////////////////////////
162 153

  
163 154
   int numComponents()
......
476 467
     int num_comp = mComponent.size();
477 468
     int num_maps = maps.length;
478 469
     int min = num_comp<num_maps ? num_comp : num_maps;
479
     int lastEnd = 0;
470
     int vertex = 0;
471
     int index  = TEX_ATTRIB;
472
     float[] newMap, oldMap;
473
     Component comp;
480 474

  
481 475
     for(int i=0; i<min; i++)
482 476
       {
483
       if( maps[i]!=null )
477
       if( maps[i]!=null && maps[i][2]!=0.0f && maps[i][3]!=0.0f )
484 478
         {
485
         Component comp = mComponent.get(i);
486
         changeTextureMap(maps[i],comp.mTextureMap,lastEnd,comp.mEndIndex);
487
         comp.setMap(maps[i]);
488
         lastEnd = comp.mEndIndex;
479
         comp = mComponent.get(i);
480
         newMap = maps[i];
481
         oldMap = comp.mTextureMap;
482

  
483
         for( ; vertex<=comp.mEndIndex; vertex++, index+=VERT_ATTRIBS)
484
           {
485
           mVertAttribs[index  ] = (newMap[2]/oldMap[2])*(mVertAttribs[index  ]-oldMap[0]) + newMap[0];
486
           mVertAttribs[index+1] = (newMap[3]/oldMap[3])*(mVertAttribs[index+1]-oldMap[1]) + newMap[1];
487
           }
488
         comp.setMap(newMap);
489 489
         }
490 490
       }
491 491

  

Also available in: Unified diff