| 138 |
138 |
|
| 139 |
139 |
MeshBase(MeshBase original, boolean deep)
|
| 140 |
140 |
{
|
| 141 |
|
mShowNormals = original.mShowNormals;
|
| 142 |
|
mInflate = original.mInflate;
|
| 143 |
|
mNumVertices = original.mNumVertices;
|
| 144 |
|
|
| 145 |
|
int size = original.mComponent.size();
|
| 146 |
|
mComponent = new ArrayList<>();
|
| 147 |
|
|
| 148 |
|
for(int i=0; i<size; i++)
|
| 149 |
|
{
|
| 150 |
|
Component comp = new Component(original.mComponent.get(i));
|
| 151 |
|
mComponent.add(comp);
|
| 152 |
|
}
|
|
141 |
mShowNormals= original.mShowNormals;
|
|
142 |
mInflate = original.mInflate;
|
|
143 |
mNumVertices= original.mNumVertices;
|
| 153 |
144 |
|
| 154 |
145 |
mAssociation= new int[MAX_COMPONENTS];
|
| 155 |
146 |
System.arraycopy(original.mAssociation, 0, mAssociation, 0, MAX_COMPONENTS);
|
| 156 |
147 |
|
| 157 |
148 |
if( deep )
|
| 158 |
149 |
{
|
| 159 |
|
mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
|
| 160 |
|
mVertAttribs1= new float[mNumVertices*VERT1_ATTRIBS];
|
| 161 |
|
|
| 162 |
150 |
mJobNode = new DeferredJobs.JobNode[1];
|
| 163 |
|
|
| 164 |
|
if( original.mJobNode[0]!=null )
|
| 165 |
|
{
|
| 166 |
|
mJobNode[0] = DeferredJobs.copy(this,original);
|
| 167 |
|
}
|
| 168 |
|
else
|
| 169 |
|
{
|
| 170 |
|
deepCopyAttribs1(original);
|
| 171 |
|
}
|
|
151 |
if( original.mJobNode[0]==null ) copy(original);
|
|
152 |
else mJobNode[0] = DeferredJobs.copy(this,original);
|
| 172 |
153 |
}
|
| 173 |
154 |
else
|
| 174 |
155 |
{
|
| 175 |
156 |
mJobNode = original.mJobNode;
|
| 176 |
157 |
mVBO1 = original.mVBO1;
|
| 177 |
158 |
mVertAttribs1 = original.mVertAttribs1;
|
|
159 |
shallowCopy(original);
|
| 178 |
160 |
}
|
| 179 |
161 |
|
| 180 |
|
mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
|
| 181 |
|
mVertAttribs2= new float[mNumVertices*VERT2_ATTRIBS];
|
| 182 |
|
System.arraycopy(original.mVertAttribs2,0,mVertAttribs2,0,mNumVertices*VERT2_ATTRIBS);
|
| 183 |
|
mVBO2.invalidate();
|
| 184 |
|
|
| 185 |
162 |
mTFO = new InternalBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, GLES30.GL_STATIC_READ);
|
| 186 |
163 |
mTFO.invalidate();
|
| 187 |
164 |
}
|
| 188 |
165 |
|
| 189 |
166 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 190 |
167 |
|
| 191 |
|
public static int getMaxComponents()
|
|
168 |
void copy(MeshBase original)
|
| 192 |
169 |
{
|
| 193 |
|
return MAX_COMPONENTS;
|
|
170 |
shallowCopy(original);
|
|
171 |
|
|
172 |
mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
|
|
173 |
mVertAttribs1= new float[mNumVertices*VERT1_ATTRIBS];
|
|
174 |
System.arraycopy(original.mVertAttribs1,0,mVertAttribs1,0,mNumVertices*VERT1_ATTRIBS);
|
|
175 |
mVBO1.invalidate();
|
| 194 |
176 |
}
|
| 195 |
177 |
|
| 196 |
178 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 197 |
179 |
|
| 198 |
|
public static void getUniforms(int mProgramH, int variant)
|
|
180 |
private void shallowCopy(MeshBase original)
|
| 199 |
181 |
{
|
| 200 |
|
mComponentAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComponAssoc");
|
| 201 |
|
}
|
|
182 |
int size = original.mComponent.size();
|
|
183 |
mComponent = new ArrayList<>();
|
| 202 |
184 |
|
| 203 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
185 |
for(int i=0; i<size; i++)
|
|
186 |
{
|
|
187 |
Component comp = new Component(original.mComponent.get(i));
|
|
188 |
mComponent.add(comp);
|
|
189 |
}
|
| 204 |
190 |
|
| 205 |
|
void deepCopyAttribs1(MeshBase original)
|
| 206 |
|
{
|
| 207 |
|
System.arraycopy(original.mVertAttribs1,0,mVertAttribs1,0,mNumVertices*VERT1_ATTRIBS);
|
| 208 |
|
mVBO1.invalidate();
|
|
191 |
mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
|
|
192 |
mVertAttribs2= new float[mNumVertices*VERT2_ATTRIBS];
|
|
193 |
System.arraycopy(original.mVertAttribs2,0,mVertAttribs2,0,mNumVertices*VERT2_ATTRIBS);
|
|
194 |
mVBO2.invalidate();
|
| 209 |
195 |
}
|
| 210 |
196 |
|
| 211 |
197 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 252 |
238 |
|
| 253 |
239 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 254 |
240 |
|
| 255 |
|
void joinAttrib1(MeshBase[] meshes, int origVertices)
|
|
241 |
void joinAttribs(MeshBase[] meshes)
|
| 256 |
242 |
{
|
| 257 |
243 |
MeshBase mesh;
|
|
244 |
Component comp;
|
| 258 |
245 |
int numMeshes = meshes.length;
|
| 259 |
|
int numVertices = origVertices;
|
| 260 |
|
|
| 261 |
|
float[] newAttribs1 = new float[VERT1_ATTRIBS*mNumVertices];
|
|
246 |
int origVertices = mNumVertices;
|
|
247 |
int origComponents=0,numComponents,numVertices;
|
| 262 |
248 |
|
| 263 |
249 |
if( origVertices>0 )
|
| 264 |
250 |
{
|
| 265 |
|
System.arraycopy(mVertAttribs1, 0, newAttribs1, 0, VERT1_ATTRIBS*numVertices);
|
| 266 |
|
System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS );
|
| 267 |
|
origVertices++;
|
| 268 |
|
|
| 269 |
|
if( numVertices%2==1 )
|
| 270 |
|
{
|
| 271 |
|
System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
|
| 272 |
|
origVertices++;
|
| 273 |
|
}
|
|
251 |
origComponents = mComponent.size();
|
|
252 |
mNumVertices+= ( mNumVertices%2==1 ? 2:1 );
|
|
253 |
mComponent.get(origComponents-1).mEndIndex = mNumVertices-1;
|
| 274 |
254 |
}
|
| 275 |
255 |
|
| 276 |
256 |
for(int i=0; i<numMeshes; i++)
|
| 277 |
257 |
{
|
| 278 |
258 |
mesh = meshes[i];
|
|
259 |
numComponents = mesh.mComponent.size();
|
| 279 |
260 |
numVertices = mesh.mNumVertices;
|
| 280 |
261 |
|
| 281 |
|
if( origVertices>0 )
|
| 282 |
|
{
|
| 283 |
|
System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS );
|
| 284 |
|
origVertices++;
|
| 285 |
|
}
|
| 286 |
|
System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS*numVertices);
|
| 287 |
|
origVertices+=numVertices;
|
|
262 |
int extraVerticesBefore = mNumVertices==0 ? 0:1;
|
|
263 |
int extraVerticesAfter = (i==numMeshes-1) ? 0 : (numVertices%2==1 ? 2:1);
|
| 288 |
264 |
|
| 289 |
|
if( i<numMeshes-1 )
|
|
265 |
for(int j=0; j<numComponents; j++)
|
| 290 |
266 |
{
|
| 291 |
|
System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
|
| 292 |
|
origVertices++;
|
|
267 |
comp = new Component(mesh.mComponent.get(j));
|
|
268 |
comp.mEndIndex += (extraVerticesBefore+mNumVertices+extraVerticesAfter);
|
|
269 |
mComponent.add(comp);
|
| 293 |
270 |
|
| 294 |
|
if( numVertices%2==1 )
|
|
271 |
if( origComponents<MAX_COMPONENTS )
|
| 295 |
272 |
{
|
| 296 |
|
System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
|
| 297 |
|
origVertices++;
|
|
273 |
mAssociation[origComponents] = mesh.mAssociation[j];
|
|
274 |
origComponents++;
|
| 298 |
275 |
}
|
| 299 |
276 |
}
|
| 300 |
|
}
|
| 301 |
|
|
| 302 |
|
mVertAttribs1 = newAttribs1;
|
| 303 |
|
mVBO1.invalidate();
|
| 304 |
|
}
|
| 305 |
277 |
|
| 306 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 307 |
|
|
| 308 |
|
private void joinAttrib2(MeshBase[] meshes, int origVertices)
|
| 309 |
|
{
|
| 310 |
|
MeshBase mesh;
|
| 311 |
|
int numMeshes = meshes.length;
|
| 312 |
|
int numVertices = origVertices;
|
|
278 |
mNumVertices += (extraVerticesBefore+numVertices+extraVerticesAfter);
|
|
279 |
}
|
| 313 |
280 |
|
|
281 |
float[] newAttribs1 = new float[VERT1_ATTRIBS*mNumVertices];
|
| 314 |
282 |
float[] newAttribs2 = new float[VERT2_ATTRIBS*mNumVertices];
|
|
283 |
numVertices = origVertices;
|
| 315 |
284 |
|
| 316 |
285 |
if( origVertices>0 )
|
| 317 |
286 |
{
|
|
287 |
System.arraycopy(mVertAttribs1, 0, newAttribs1, 0, VERT1_ATTRIBS*numVertices);
|
|
288 |
System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS );
|
| 318 |
289 |
System.arraycopy(mVertAttribs2, 0, newAttribs2, 0, VERT2_ATTRIBS*numVertices);
|
| 319 |
290 |
System.arraycopy(mVertAttribs2, VERT2_ATTRIBS*(origVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS );
|
| 320 |
291 |
origVertices++;
|
| 321 |
292 |
|
| 322 |
293 |
if( numVertices%2==1 )
|
| 323 |
294 |
{
|
|
295 |
System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
|
| 324 |
296 |
System.arraycopy(mVertAttribs2, VERT2_ATTRIBS*(origVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
|
| 325 |
297 |
origVertices++;
|
| 326 |
298 |
}
|
| ... | ... | |
| 333 |
305 |
|
| 334 |
306 |
if( origVertices>0 )
|
| 335 |
307 |
{
|
|
308 |
System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS );
|
| 336 |
309 |
System.arraycopy(mesh.mVertAttribs2, 0, newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS );
|
| 337 |
310 |
origVertices++;
|
| 338 |
311 |
}
|
|
312 |
System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS*numVertices);
|
| 339 |
313 |
System.arraycopy(mesh.mVertAttribs2, 0, newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS*numVertices);
|
| 340 |
314 |
origVertices+=numVertices;
|
| 341 |
315 |
|
| 342 |
316 |
if( i<numMeshes-1 )
|
| 343 |
317 |
{
|
|
318 |
System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
|
| 344 |
319 |
System.arraycopy(mesh.mVertAttribs2, VERT2_ATTRIBS*(numVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
|
| 345 |
320 |
origVertices++;
|
| 346 |
321 |
|
| 347 |
322 |
if( numVertices%2==1 )
|
| 348 |
323 |
{
|
|
324 |
System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
|
| 349 |
325 |
System.arraycopy(mesh.mVertAttribs2, VERT2_ATTRIBS*(numVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
|
| 350 |
326 |
origVertices++;
|
| 351 |
327 |
}
|
| ... | ... | |
| 366 |
342 |
for( ; index<=endIndex; index++) newAttribs2[VERT2_ATTRIBS*index+COM_ATTRIB] = component;
|
| 367 |
343 |
}
|
| 368 |
344 |
|
|
345 |
mVertAttribs1 = newAttribs1;
|
| 369 |
346 |
mVertAttribs2 = newAttribs2;
|
|
347 |
mVBO1.invalidate();
|
| 370 |
348 |
mVBO2.invalidate();
|
| 371 |
349 |
}
|
| 372 |
350 |
|
| ... | ... | |
| 375 |
353 |
|
| 376 |
354 |
void join(MeshBase[] meshes)
|
| 377 |
355 |
{
|
| 378 |
|
MeshBase mesh;
|
| 379 |
|
Component comp;
|
| 380 |
|
int origComponents=0, numComponents, numVertices, numMeshes = meshes.length;
|
| 381 |
|
int origVertices = mNumVertices;
|
|
356 |
boolean immediateJoin = true;
|
| 382 |
357 |
|
| 383 |
|
if( origVertices>0 )
|
|
358 |
for (MeshBase mesh : meshes)
|
| 384 |
359 |
{
|
| 385 |
|
origComponents = mComponent.size();
|
| 386 |
|
mNumVertices+= ( mNumVertices%2==1 ? 2:1 );
|
| 387 |
|
mComponent.get(origComponents-1).mEndIndex = mNumVertices-1;
|
|
360 |
if (mesh.mJobNode[0] != null)
|
|
361 |
{
|
|
362 |
immediateJoin = false;
|
|
363 |
break;
|
|
364 |
}
|
| 388 |
365 |
}
|
| 389 |
366 |
|
| 390 |
|
for(int i=0; i<numMeshes; i++)
|
| 391 |
|
{
|
| 392 |
|
mesh = meshes[i];
|
| 393 |
|
numComponents = mesh.mComponent.size();
|
|
367 |
if( immediateJoin ) joinAttribs(meshes);
|
|
368 |
else mJobNode[0] = DeferredJobs.join(this,meshes);
|
|
369 |
}
|
| 394 |
370 |
|
| 395 |
|
numVertices = mesh.mNumVertices;
|
|
371 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 396 |
372 |
|
| 397 |
|
int extraVerticesBefore = mNumVertices==0 ? 0:1;
|
| 398 |
|
int extraVerticesAfter = (i==numMeshes-1) ? 0 : (numVertices%2==1 ? 2:1);
|
|
373 |
void textureMap(Static4D[] maps)
|
|
374 |
{
|
|
375 |
int num_comp = mComponent.size();
|
|
376 |
int num_maps = maps.length;
|
|
377 |
int min = Math.min(num_comp, num_maps);
|
|
378 |
int vertex = 0;
|
|
379 |
Static4D newMap, oldMap;
|
|
380 |
Component comp;
|
|
381 |
float newW, newH, ratW, ratH, movX, movY;
|
| 399 |
382 |
|
| 400 |
|
for(int j=0; j<numComponents; j++)
|
|
383 |
for(int i=0; i<min; i++)
|
|
384 |
{
|
|
385 |
newMap = maps[i];
|
|
386 |
comp = mComponent.get(i);
|
|
387 |
|
|
388 |
if( newMap!=null )
|
| 401 |
389 |
{
|
| 402 |
|
comp = new Component(mesh.mComponent.get(j));
|
| 403 |
|
comp.mEndIndex += (extraVerticesBefore+mNumVertices+extraVerticesAfter);
|
| 404 |
|
mComponent.add(comp);
|
|
390 |
newW = newMap.get2();
|
|
391 |
newH = newMap.get3();
|
| 405 |
392 |
|
| 406 |
|
if( origComponents<MAX_COMPONENTS )
|
|
393 |
if( newW!=0.0f && newH!=0.0f )
|
| 407 |
394 |
{
|
| 408 |
|
mAssociation[origComponents] = mesh.mAssociation[j];
|
| 409 |
|
origComponents++;
|
|
395 |
oldMap = comp.mTextureMap;
|
|
396 |
ratW = newW/oldMap.get2();
|
|
397 |
ratH = newH/oldMap.get3();
|
|
398 |
movX = newMap.get0() - ratW*oldMap.get0();
|
|
399 |
movY = newMap.get1() - ratH*oldMap.get1();
|
|
400 |
|
|
401 |
for( int index=vertex*VERT2_ATTRIBS+TEX_ATTRIB ; vertex<=comp.mEndIndex; vertex++, index+=VERT2_ATTRIBS)
|
|
402 |
{
|
|
403 |
mVertAttribs2[index ] = ratW*mVertAttribs2[index ] + movX;
|
|
404 |
mVertAttribs2[index+1] = ratH*mVertAttribs2[index+1] + movY;
|
|
405 |
}
|
|
406 |
comp.setMap(newMap);
|
| 410 |
407 |
}
|
| 411 |
408 |
}
|
| 412 |
409 |
|
| 413 |
|
mNumVertices += (extraVerticesBefore+numVertices+extraVerticesAfter);
|
|
410 |
vertex= comp.mEndIndex+1;
|
| 414 |
411 |
}
|
| 415 |
412 |
|
| 416 |
|
if( mJobNode[0]!=null )
|
| 417 |
|
{
|
| 418 |
|
mJobNode[0] = DeferredJobs.join(this,meshes,origVertices);
|
| 419 |
|
}
|
| 420 |
|
else
|
| 421 |
|
{
|
| 422 |
|
joinAttrib1(meshes,origVertices);
|
| 423 |
|
}
|
|
413 |
mVBO2.invalidate();
|
|
414 |
}
|
|
415 |
|
|
416 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 424 |
417 |
|
| 425 |
|
joinAttrib2(meshes,origVertices);
|
|
418 |
public static int getMaxComponents()
|
|
419 |
{
|
|
420 |
return MAX_COMPONENTS;
|
|
421 |
}
|
|
422 |
|
|
423 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
424 |
|
|
425 |
public static void getUniforms(int mProgramH, int variant)
|
|
426 |
{
|
|
427 |
mComponentAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComponAssoc");
|
| 426 |
428 |
}
|
| 427 |
429 |
|
| 428 |
430 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 450 |
452 |
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK);
|
| 451 |
453 |
}
|
| 452 |
454 |
|
|
455 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
456 |
/**
|
|
457 |
* Not part of public API, do not document (public only because has to be used from the main package)
|
|
458 |
*
|
|
459 |
* @y.exclude
|
|
460 |
*/
|
|
461 |
public void debug()
|
|
462 |
{
|
|
463 |
if( mJobNode[0]!=null )
|
|
464 |
{
|
|
465 |
mJobNode[0].print(0);
|
|
466 |
}
|
|
467 |
else
|
|
468 |
{
|
|
469 |
android.util.Log.e("mesh", "JobNode null");
|
|
470 |
}
|
|
471 |
}
|
|
472 |
|
|
473 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
474 |
/**
|
|
475 |
* Not part of public API, do not document (public only because has to be used from the main package)
|
|
476 |
*
|
|
477 |
* @y.exclude
|
|
478 |
*/
|
|
479 |
public void print()
|
|
480 |
{
|
|
481 |
StringBuffer sb = new StringBuffer();
|
|
482 |
|
|
483 |
for(int i=0; i<mNumVertices; i++)
|
|
484 |
{
|
|
485 |
sb.append('(');
|
|
486 |
sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB ]);
|
|
487 |
sb.append(',');
|
|
488 |
sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+1]);
|
|
489 |
sb.append(',');
|
|
490 |
sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+2]);
|
|
491 |
sb.append(") ");
|
|
492 |
}
|
|
493 |
|
|
494 |
StringBuffer sb2 = new StringBuffer();
|
|
495 |
|
|
496 |
for(int i=0; i<mNumVertices; i++)
|
|
497 |
{
|
|
498 |
sb2.append(mVertAttribs2[VERT2_ATTRIBS*i+COM_ATTRIB]);
|
|
499 |
sb2.append(' ');
|
|
500 |
}
|
|
501 |
|
|
502 |
Log.d("mesh", sb.toString()+"\n"+sb2.toString());
|
|
503 |
}
|
|
504 |
|
| 453 |
505 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 454 |
506 |
/**
|
| 455 |
507 |
* Not part of public API, do not document (public only because has to be used from the main package)
|
| ... | ... | |
| 578 |
630 |
*/
|
| 579 |
631 |
public void mergeComponents()
|
| 580 |
632 |
{
|
| 581 |
|
if( mJobNode==null )
|
|
633 |
if( mJobNode[0]==null )
|
| 582 |
634 |
{
|
| 583 |
635 |
merge();
|
| 584 |
636 |
}
|
| ... | ... | |
| 643 |
695 |
*/
|
| 644 |
696 |
public void setTextureMap(Static4D[] maps)
|
| 645 |
697 |
{
|
| 646 |
|
int num_comp = mComponent.size();
|
| 647 |
|
int num_maps = maps.length;
|
| 648 |
|
int min = Math.min(num_comp, num_maps);
|
| 649 |
|
int vertex = 0;
|
| 650 |
|
Static4D newMap, oldMap;
|
| 651 |
|
Component comp;
|
| 652 |
|
float newW, newH, ratW, ratH, movX, movY;
|
| 653 |
|
|
| 654 |
|
for(int i=0; i<min; i++)
|
|
698 |
if( mJobNode[0]==null )
|
| 655 |
699 |
{
|
| 656 |
|
newMap = maps[i];
|
| 657 |
|
comp = mComponent.get(i);
|
| 658 |
|
|
| 659 |
|
if( newMap!=null )
|
| 660 |
|
{
|
| 661 |
|
newW = newMap.get2();
|
| 662 |
|
newH = newMap.get3();
|
| 663 |
|
|
| 664 |
|
if( newW!=0.0f && newH!=0.0f )
|
| 665 |
|
{
|
| 666 |
|
oldMap = comp.mTextureMap;
|
| 667 |
|
ratW = newW/oldMap.get2();
|
| 668 |
|
ratH = newH/oldMap.get3();
|
| 669 |
|
movX = newMap.get0() - ratW*oldMap.get0();
|
| 670 |
|
movY = newMap.get1() - ratH*oldMap.get1();
|
| 671 |
|
|
| 672 |
|
for( int index=vertex*VERT2_ATTRIBS+TEX_ATTRIB ; vertex<=comp.mEndIndex; vertex++, index+=VERT2_ATTRIBS)
|
| 673 |
|
{
|
| 674 |
|
mVertAttribs2[index ] = ratW*mVertAttribs2[index ] + movX;
|
| 675 |
|
mVertAttribs2[index+1] = ratH*mVertAttribs2[index+1] + movY;
|
| 676 |
|
}
|
| 677 |
|
comp.setMap(newMap);
|
| 678 |
|
}
|
| 679 |
|
}
|
| 680 |
|
|
| 681 |
|
vertex= comp.mEndIndex+1;
|
|
700 |
textureMap(maps);
|
|
701 |
}
|
|
702 |
else
|
|
703 |
{
|
|
704 |
mJobNode[0] = DeferredJobs.textureMap(this,maps);
|
| 682 |
705 |
}
|
| 683 |
|
|
| 684 |
|
mVBO2.invalidate();
|
| 685 |
706 |
}
|
| 686 |
707 |
|
| 687 |
708 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
DeferredJobs app/lib works now