Project

General

Profile

Download (40.5 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / mesh / MeshBase.java @ 524e4fe7

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library.mesh;
21

    
22
import android.opengl.GLES30;
23
import android.opengl.Matrix;
24
import android.util.Log;
25

    
26
import org.distorted.library.effect.MatrixEffect;
27
import org.distorted.library.effect.VertexEffect;
28
import org.distorted.library.effectqueue.EffectQueue;
29
import org.distorted.library.main.InternalBuffer;
30
import org.distorted.library.program.DistortedProgram;
31
import org.distorted.library.type.Static4D;
32

    
33
import java.io.DataOutputStream;
34
import java.io.IOException;
35
import java.io.DataInputStream;
36
import java.nio.ByteBuffer;
37
import java.nio.ByteOrder;
38
import java.nio.FloatBuffer;
39
import java.util.ArrayList;
40

    
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42
/**
43
 * Abstract class which represents a Mesh, ie an array of vertices (rendered as a TRIANGLE_STRIP).
44
 * <p>
45
 * If you want to render to a particular shape, extend from here, construct a float array
46
 * containing per-vertex attributes, and call back setAttribs().
47
 */
48
public abstract class MeshBase
49
   {
50
   private static final int MAX_EFFECT_COMPONENTS= 100;
51
   private static final int DEFAULT_ASSOCIATION = 0xffffffff;
52

    
53
   // sizes of attributes of an individual vertex.
54
   private static final int POS_DATA_SIZE= 3; // vertex coordinates: x,y,z
55
   private static final int NOR_DATA_SIZE= 3; // normal vector: x,y,z
56
   private static final int INF_DATA_SIZE= 3; // 'inflate' vector: x,y,z
57
   private static final int TEX_DATA_SIZE= 2; // texture coordinates: s,t
58
   private static final int COM_DATA_SIZE= 1; // component number, a single float
59

    
60
   static final int POS_ATTRIB   = 0;
61
   static final int NOR_ATTRIB   = POS_DATA_SIZE;
62
   static final int INF_ATTRIB   = POS_DATA_SIZE + NOR_DATA_SIZE;
63
   static final int TEX_ATTRIB   = 0;
64
   static final int COM_ATTRIB   = TEX_DATA_SIZE;
65

    
66
   static final int VERT1_ATTRIBS= POS_DATA_SIZE + NOR_DATA_SIZE + INF_DATA_SIZE;  // number of attributes of a vertex (the part changed by preapply)
67
   static final int VERT2_ATTRIBS= TEX_DATA_SIZE + COM_DATA_SIZE;                  // number of attributes of a vertex (the 'preapply invariant' part)
68
   static final int TRAN_ATTRIBS = POS_DATA_SIZE + NOR_DATA_SIZE + INF_DATA_SIZE;  // number of attributes of a transform feedback vertex
69

    
70
   private static final int BYTES_PER_FLOAT = 4;
71

    
72
   private static final int OFFSET_POS = POS_ATTRIB*BYTES_PER_FLOAT;
73
   private static final int OFFSET_NOR = NOR_ATTRIB*BYTES_PER_FLOAT;
74
   private static final int OFFSET_INF = INF_ATTRIB*BYTES_PER_FLOAT;
75
   private static final int OFFSET_TEX = TEX_ATTRIB*BYTES_PER_FLOAT;
76
   private static final int OFFSET_COM = COM_ATTRIB*BYTES_PER_FLOAT;
77

    
78
   private static final int TRAN_SIZE  = TRAN_ATTRIBS*BYTES_PER_FLOAT;
79
   private static final int VERT1_SIZE = VERT1_ATTRIBS*BYTES_PER_FLOAT;
80
   private static final int VERT2_SIZE = VERT2_ATTRIBS*BYTES_PER_FLOAT;
81

    
82
   private boolean mShowNormals;              // when rendering this mesh, draw normal vectors?
83
   private InternalBuffer mVBO1, mVBO2, mTFO; // main vertex buffer and transform feedback buffer
84
   private int mNumVertices;
85
   private float[] mVertAttribs1;             // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ
86
   private float[] mVertAttribs2;             // packed: TexS,TexT, Component
87
   private float mInflate;
88
   private int[] mEquAssociation;
89
   private int[] mAndAssociation;
90

    
91
   DeferredJobs.JobNode[] mJobNode;
92

    
93
   private static int[] mEquAssociationH = new int[EffectQueue.MAIN_VARIANTS];
94
   private static int[] mAndAssociationH = new int[EffectQueue.MAIN_VARIANTS];
95

    
96
   private static final int TEX_COMP_SIZE = 5; // 5 four-bytes entities inside the component
97

    
98
   private static class TexComponent
99
     {
100
     private int mEndIndex;
101
     private Static4D mTextureMap;
102

    
103
     TexComponent(int end)
104
       {
105
       mEndIndex  = end;
106
       mTextureMap= new Static4D(0,0,1,1);
107
       }
108
     TexComponent(TexComponent original)
109
       {
110
       mEndIndex = original.mEndIndex;
111

    
112
       float x = original.mTextureMap.get0();
113
       float y = original.mTextureMap.get1();
114
       float z = original.mTextureMap.get2();
115
       float w = original.mTextureMap.get3();
116
       mTextureMap = new Static4D(x,y,z,w);
117
       }
118

    
119
     void setMap(Static4D map)
120
       {
121
       mTextureMap.set(map.get0(),map.get1(),map.get2(),map.get3());
122
       }
123
     }
124

    
125
   private ArrayList<TexComponent> mTexComponent;
126
   private ArrayList<Integer> mEffComponent;
127

    
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

    
130
   MeshBase()
131
     {
132
     mShowNormals  = false;
133
     mInflate      = 0.0f;
134
     mTexComponent = new ArrayList<>();
135
     mEffComponent = new ArrayList<>();
136

    
137
     mEquAssociation= new int[MAX_EFFECT_COMPONENTS];
138
     mAndAssociation= new int[MAX_EFFECT_COMPONENTS];
139

    
140
     mJobNode = new DeferredJobs.JobNode[1];
141

    
142
     for(int i=0; i<MAX_EFFECT_COMPONENTS; i++)
143
       {
144
       mAndAssociation[i] = DEFAULT_ASSOCIATION;
145
       mEquAssociation[i] = i;
146
       }
147

    
148
     mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER             , GLES30.GL_STATIC_READ);
149
     mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER             , GLES30.GL_STATIC_READ);
150
     mTFO = new InternalBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, GLES30.GL_STATIC_READ);
151
     }
152

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154
// copy constructor
155

    
156
   MeshBase(MeshBase original, boolean deep)
157
     {
158
     mShowNormals= original.mShowNormals;
159
     mInflate    = original.mInflate;
160
     mNumVertices= original.mNumVertices;
161

    
162
     mAndAssociation= new int[MAX_EFFECT_COMPONENTS];
163
     System.arraycopy(original.mAndAssociation, 0, mAndAssociation, 0, MAX_EFFECT_COMPONENTS);
164
     mEquAssociation= new int[MAX_EFFECT_COMPONENTS];
165
     System.arraycopy(original.mEquAssociation, 0, mEquAssociation, 0, MAX_EFFECT_COMPONENTS);
166

    
167
     if( deep )
168
       {
169
       mJobNode = new DeferredJobs.JobNode[1];
170
       if( original.mJobNode[0]==null ) copy(original);
171
       else mJobNode[0] = DeferredJobs.copy(this,original);
172
       }
173
     else
174
       {
175
       mJobNode      = original.mJobNode;
176
       mVBO1         = original.mVBO1;
177
       mVertAttribs1 = original.mVertAttribs1;
178
       shallowCopy(original);
179
       }
180

    
181
     mTFO = new InternalBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, GLES30.GL_STATIC_READ);
182
     mTFO.invalidate();
183
     }
184

    
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186

    
187
   void copy(MeshBase original)
188
     {
189
     shallowCopy(original);
190

    
191
     mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
192
     mVertAttribs1= new float[mNumVertices*VERT1_ATTRIBS];
193
     System.arraycopy(original.mVertAttribs1,0,mVertAttribs1,0,mNumVertices*VERT1_ATTRIBS);
194
     mVBO1.invalidate();
195
     }
196

    
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

    
199
   private void shallowCopy(MeshBase original)
200
     {
201
     int texComSize = original.mTexComponent.size();
202
     mTexComponent = new ArrayList<>();
203

    
204
     for(int i=0; i<texComSize; i++)
205
       {
206
       TexComponent comp = new TexComponent(original.mTexComponent.get(i));
207
       mTexComponent.add(comp);
208
       }
209

    
210
     mEffComponent = new ArrayList<>();
211
     mEffComponent.addAll(original.mEffComponent);
212

    
213
     mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER, GLES30.GL_STATIC_READ);
214
     mVertAttribs2= new float[mNumVertices*VERT2_ATTRIBS];
215
     System.arraycopy(original.mVertAttribs2,0,mVertAttribs2,0,mNumVertices*VERT2_ATTRIBS);
216
     mVBO2.invalidate();
217
     }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

    
221
   void mergeTexComponentsNow()
222
     {
223
     int num = mTexComponent.size();
224

    
225
     if( num>1 )
226
       {
227
       mTexComponent.clear();
228
       mTexComponent.add(new TexComponent(mNumVertices-1));
229

    
230
       mVBO2.invalidate();
231
       }
232
     }
233

    
234
///////////////////////////////////////////////////////////////////////////////////////////////////
235

    
236
   void mergeEffComponentsNow()
237
     {
238
     int num = mEffComponent.size();
239

    
240
     if( num>1 )
241
       {
242
       mEffComponent.clear();
243
       mEffComponent.add(mNumVertices-1);
244

    
245
       for(int index=0; index<mNumVertices; index++)
246
         {
247
         mVertAttribs2[VERT2_ATTRIBS*index+COM_ATTRIB] = 0;
248
         }
249

    
250
       mVBO2.invalidate();
251
       }
252
     }
253

    
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255

    
256
   void applyMatrix(MatrixEffect effect, int andAssoc, int equAssoc)
257
     {
258
     float[] matrixP  = new float[16];
259
     float[] matrixV  = new float[16];
260
     float[] uniforms = new float[7];
261
     int start, end=-1, numComp = mEffComponent.size();
262

    
263
     Matrix.setIdentityM(matrixP,0);
264
     Matrix.setIdentityM(matrixV,0);
265
     effect.compute(uniforms,0,0,0);
266
     effect.apply(matrixP, matrixV, uniforms, 0);
267

    
268
     for(int i=0; i<numComp; i++)
269
       {
270
       start = end+1;
271
       end   = mEffComponent.get(i);
272

    
273
       if( (andAssoc & mAndAssociation[i]) != 0 || (equAssoc == mEquAssociation[i]) )
274
         {
275
         applyMatrixToComponent(matrixP, matrixV, start, end);
276
         }
277
       }
278

    
279
     mVBO1.invalidate();
280
     }
281

    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

    
284
   private void applyMatrixToComponent(float[] matrixP, float[] matrixV, int start, int end)
285
     {
286
     float x,y,z;
287

    
288
     for(int index=start*VERT1_ATTRIBS; index<=end*VERT1_ATTRIBS; index+=VERT1_ATTRIBS )
289
       {
290
       x = mVertAttribs1[index+POS_ATTRIB  ];
291
       y = mVertAttribs1[index+POS_ATTRIB+1];
292
       z = mVertAttribs1[index+POS_ATTRIB+2];
293

    
294
       mVertAttribs1[index+POS_ATTRIB  ] = matrixP[0]*x + matrixP[4]*y + matrixP[ 8]*z + matrixP[12];
295
       mVertAttribs1[index+POS_ATTRIB+1] = matrixP[1]*x + matrixP[5]*y + matrixP[ 9]*z + matrixP[13];
296
       mVertAttribs1[index+POS_ATTRIB+2] = matrixP[2]*x + matrixP[6]*y + matrixP[10]*z + matrixP[14];
297

    
298
       x = mVertAttribs1[index+NOR_ATTRIB  ];
299
       y = mVertAttribs1[index+NOR_ATTRIB+1];
300
       z = mVertAttribs1[index+NOR_ATTRIB+2];
301

    
302
       mVertAttribs1[index+NOR_ATTRIB  ] = matrixV[0]*x + matrixV[4]*y + matrixV[ 8]*z;
303
       mVertAttribs1[index+NOR_ATTRIB+1] = matrixV[1]*x + matrixV[5]*y + matrixV[ 9]*z;
304
       mVertAttribs1[index+NOR_ATTRIB+2] = matrixV[2]*x + matrixV[6]*y + matrixV[10]*z;
305

    
306
       x = mVertAttribs1[index+NOR_ATTRIB  ];
307
       y = mVertAttribs1[index+NOR_ATTRIB+1];
308
       z = mVertAttribs1[index+NOR_ATTRIB+2];
309

    
310
       float len1 = (float)Math.sqrt(x*x + y*y + z*z);
311

    
312
       if( len1>0.0f )
313
         {
314
         mVertAttribs1[index+NOR_ATTRIB  ] /= len1;
315
         mVertAttribs1[index+NOR_ATTRIB+1] /= len1;
316
         mVertAttribs1[index+NOR_ATTRIB+2] /= len1;
317
         }
318

    
319
       x = mVertAttribs1[index+INF_ATTRIB  ];
320
       y = mVertAttribs1[index+INF_ATTRIB+1];
321
       z = mVertAttribs1[index+INF_ATTRIB+2];
322

    
323
       mVertAttribs1[index+INF_ATTRIB  ] = matrixV[0]*x + matrixV[4]*y + matrixV[ 8]*z;
324
       mVertAttribs1[index+INF_ATTRIB+1] = matrixV[1]*x + matrixV[5]*y + matrixV[ 9]*z;
325
       mVertAttribs1[index+INF_ATTRIB+2] = matrixV[2]*x + matrixV[6]*y + matrixV[10]*z;
326

    
327
       x = mVertAttribs1[index+INF_ATTRIB  ];
328
       y = mVertAttribs1[index+INF_ATTRIB+1];
329
       z = mVertAttribs1[index+INF_ATTRIB+2];
330

    
331
       float len2 = (float)Math.sqrt(x*x + y*y + z*z);
332

    
333
       if( len2>0.0f )
334
         {
335
         mVertAttribs1[index+INF_ATTRIB  ] /= len2;
336
         mVertAttribs1[index+INF_ATTRIB+1] /= len2;
337
         mVertAttribs1[index+INF_ATTRIB+2] /= len2;
338
         }
339
       }
340
     }
341

    
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343

    
344
   void setEffectAssociationNow(int component, int andAssociation, int equAssociation)
345
     {
346
     mAndAssociation[component] = andAssociation;
347
     mEquAssociation[component] = equAssociation;
348
     }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351
// when a derived class is done computing its mesh, it has to call this method.
352

    
353
   void setAttribs(float[] vert1Attribs, float[] vert2Attribs)
354
     {
355
     mNumVertices = vert1Attribs.length/VERT1_ATTRIBS;
356
     mVertAttribs1= vert1Attribs;
357
     mVertAttribs2= vert2Attribs;
358

    
359
     mTexComponent.add(new TexComponent(mNumVertices-1));
360
     mEffComponent.add(mNumVertices-1);
361

    
362
     mVBO1.invalidate();
363
     mVBO2.invalidate();
364
     }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

    
368
   void joinAttribs(MeshBase[] meshes)
369
     {
370
     MeshBase mesh;
371
     TexComponent comp;
372
     int numMeshes = meshes.length;
373
     int numVertices,origVertices = mNumVertices;
374
     int origTexComponents,numTexComponents;
375
     int origEffComponents=0,numEffComponents;
376

    
377
     if( origVertices>0 )
378
       {
379
       origTexComponents = mTexComponent.size();
380
       mNumVertices+= ( mNumVertices%2==1 ? 2:1 );
381
       mTexComponent.get(origTexComponents-1).mEndIndex = mNumVertices-1;
382
       origEffComponents = mEffComponent.size();
383
       mEffComponent.set(origEffComponents-1,mNumVertices-1);
384
       }
385

    
386
     for(int i=0; i<numMeshes; i++)
387
       {
388
       mesh = meshes[i];
389
       numTexComponents = mesh.mTexComponent.size();
390
       numEffComponents = mesh.mEffComponent.size();
391
       numVertices = mesh.mNumVertices;
392

    
393
       int extraVerticesBefore = mNumVertices==0 ? 0:1;
394
       int extraVerticesAfter  = (i==numMeshes-1) ? 0 : (numVertices%2==1 ? 2:1);
395

    
396
       for(int j=0; j<numTexComponents; j++)
397
         {
398
         comp = new TexComponent(mesh.mTexComponent.get(j));
399
         comp.mEndIndex += (extraVerticesBefore+mNumVertices);
400
         if( j==numTexComponents-1) comp.mEndIndex += extraVerticesAfter;
401
         mTexComponent.add(comp);
402
         }
403

    
404
       for(int j=0; j<numEffComponents; j++)
405
         {
406
         int index = mesh.mEffComponent.get(j);
407
         index += (extraVerticesBefore+mNumVertices);
408
         if( j==numEffComponents-1 ) index += extraVerticesAfter;
409
         mEffComponent.add(index);
410

    
411
         if( origEffComponents<MAX_EFFECT_COMPONENTS )
412
           {
413
           mAndAssociation[origEffComponents] = mesh.mAndAssociation[j];
414
           mEquAssociation[origEffComponents] = mesh.mEquAssociation[j];
415
           origEffComponents++;
416
           }
417
         }
418

    
419
       mNumVertices += (extraVerticesBefore+numVertices+extraVerticesAfter);
420
       }
421

    
422
     float[] newAttribs1 = new float[VERT1_ATTRIBS*mNumVertices];
423
     float[] newAttribs2 = new float[VERT2_ATTRIBS*mNumVertices];
424
     numVertices = origVertices;
425

    
426
     if( origVertices>0 )
427
       {
428
       System.arraycopy(mVertAttribs1,                              0, newAttribs1,                          0, VERT1_ATTRIBS*numVertices);
429
       System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS            );
430
       System.arraycopy(mVertAttribs2,                              0, newAttribs2,                          0, VERT2_ATTRIBS*numVertices);
431
       System.arraycopy(mVertAttribs2, VERT2_ATTRIBS*(origVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS            );
432
       origVertices++;
433

    
434
       if( numVertices%2==1 )
435
         {
436
         System.arraycopy(mVertAttribs1, VERT1_ATTRIBS*(origVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
437
         System.arraycopy(mVertAttribs2, VERT2_ATTRIBS*(origVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
438
         origVertices++;
439
         }
440
       }
441

    
442
     for(int i=0; i<numMeshes; i++)
443
       {
444
       mesh = meshes[i];
445
       numVertices = mesh.mNumVertices;
446

    
447
       if( origVertices>0 )
448
         {
449
         System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
450
         System.arraycopy(mesh.mVertAttribs2, 0, newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
451
         origVertices++;
452
         }
453
       System.arraycopy(mesh.mVertAttribs1, 0, newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS*numVertices);
454
       System.arraycopy(mesh.mVertAttribs2, 0, newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS*numVertices);
455
       origVertices+=numVertices;
456

    
457
       if( i<numMeshes-1 )
458
         {
459
         System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
460
         System.arraycopy(mesh.mVertAttribs2, VERT2_ATTRIBS*(numVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
461
         origVertices++;
462

    
463
         if( numVertices%2==1 )
464
           {
465
           System.arraycopy(mesh.mVertAttribs1, VERT1_ATTRIBS*(numVertices-1), newAttribs1, VERT1_ATTRIBS*origVertices, VERT1_ATTRIBS);
466
           System.arraycopy(mesh.mVertAttribs2, VERT2_ATTRIBS*(numVertices-1), newAttribs2, VERT2_ATTRIBS*origVertices, VERT2_ATTRIBS);
467
           origVertices++;
468
           }
469
         }
470
       }
471

    
472
     if( origVertices!=mNumVertices )
473
       {
474
       android.util.Log.e("mesh", "join: origVertices: "+origVertices+" numVertices: "+mNumVertices);
475
       }
476

    
477
     int endIndex, index=0, numEffComp = mEffComponent.size();
478

    
479
     for(int component=0; component<numEffComp; component++)
480
       {
481
       endIndex = mEffComponent.get(component);
482

    
483
       for( ; index<=endIndex; index++) newAttribs2[VERT2_ATTRIBS*index+COM_ATTRIB] = component;
484
       }
485

    
486
     mVertAttribs1 = newAttribs1;
487
     mVertAttribs2 = newAttribs2;
488
     mVBO1.invalidate();
489
     mVBO2.invalidate();
490
     }
491

    
492
///////////////////////////////////////////////////////////////////////////////////////////////////
493
// called from MeshJoined
494

    
495
   void join(MeshBase[] meshes)
496
     {
497
     boolean immediateJoin = true;
498

    
499
     for (MeshBase mesh : meshes)
500
       {
501
       if (mesh.mJobNode[0] != null)
502
         {
503
         immediateJoin = false;
504
         break;
505
         }
506
       }
507

    
508
     if( immediateJoin ) joinAttribs(meshes);
509
     else                mJobNode[0] = DeferredJobs.join(this,meshes);
510
     }
511

    
512
///////////////////////////////////////////////////////////////////////////////////////////////////
513

    
514
   void textureMap(Static4D[] maps, int startComponent)
515
     {
516
     int num_comp = mTexComponent.size();
517
     int num_maps = maps.length;
518
     int min = Math.min(num_comp-startComponent, num_maps);
519
     int vertex = startComponent>0 ? mTexComponent.get(startComponent-1).mEndIndex+1 : 0;
520
     Static4D newMap, oldMap;
521
     TexComponent comp;
522
     float newW, newH, ratW, ratH, movX, movY;
523

    
524
     for(int i=0; i<min; i++)
525
       {
526
       newMap = maps[i];
527
       comp = mTexComponent.get(i+startComponent);
528

    
529
       if( newMap!=null )
530
         {
531
         newW = newMap.get2();
532
         newH = newMap.get3();
533

    
534
         if( newW!=0.0f && newH!=0.0f )
535
           {
536
           oldMap = comp.mTextureMap;
537
           ratW = newW/oldMap.get2();
538
           ratH = newH/oldMap.get3();
539
           movX = newMap.get0() - ratW*oldMap.get0();
540
           movY = newMap.get1() - ratH*oldMap.get1();
541

    
542
           for( int index=vertex*VERT2_ATTRIBS+TEX_ATTRIB ; vertex<=comp.mEndIndex; vertex++, index+=VERT2_ATTRIBS)
543
             {
544
             mVertAttribs2[index  ] = ratW*mVertAttribs2[index  ] + movX;
545
             mVertAttribs2[index+1] = ratH*mVertAttribs2[index+1] + movY;
546
             }
547
           comp.setMap(newMap);
548
           }
549
         }
550

    
551
       vertex= comp.mEndIndex+1;
552
       }
553

    
554
     mVBO2.invalidate();
555
     }
556

    
557
///////////////////////////////////////////////////////////////////////////////////////////////////
558

    
559
   public static int getMaxEffComponents()
560
     {
561
     return MAX_EFFECT_COMPONENTS;
562
     }
563

    
564
///////////////////////////////////////////////////////////////////////////////////////////////////
565

    
566
   public static void getUniforms(int mProgramH, int variant)
567
     {
568
     mEquAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComEquAssoc");
569
     mAndAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComAndAssoc");
570
     }
571

    
572
///////////////////////////////////////////////////////////////////////////////////////////////////
573
/**
574
 * Not part of public API, do not document (public only because has to be used from the main package)
575
 *
576
 * @y.exclude
577
 */
578
   public void copyTransformToVertex()
579
     {
580
     ByteBuffer buffer = (ByteBuffer)GLES30.glMapBufferRange( GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0,
581
                                                              TRAN_SIZE*mNumVertices, GLES30.GL_MAP_READ_BIT);
582
     if( buffer!=null )
583
       {
584
       FloatBuffer feedback = buffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
585
       feedback.get(mVertAttribs1,0,VERT1_ATTRIBS*mNumVertices);
586
       mVBO1.update(mVertAttribs1);
587
       }
588
     else
589
       {
590
       int error = GLES30.glGetError();
591
       Log.e("mesh", "failed to map tf buffer, error="+error);
592
       }
593

    
594
     GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK);
595
     }
596

    
597
///////////////////////////////////////////////////////////////////////////////////////////////////
598
/**
599
 * Not part of public API, do not document (public only because has to be used from the main package)
600
 *
601
 * @y.exclude
602
 */
603
   public void debug()
604
     {
605
     if( mJobNode[0]!=null )
606
       {
607
       mJobNode[0].print(0);
608
       }
609
     else
610
       {
611
       android.util.Log.e("mesh", "JobNode null");
612
       }
613
     }
614

    
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616
/**
617
 * Not part of public API, do not document (public only because has to be used from the main package)
618
 *
619
 * @y.exclude
620
 */
621
   public void printPos()
622
     {
623
     StringBuilder sb = new StringBuilder();
624

    
625
     for(int i=0; i<mNumVertices; i++)
626
       {
627
       sb.append('(');
628
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB  ]);
629
       sb.append(',');
630
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+1]);
631
       sb.append(',');
632
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+2]);
633
       sb.append(") ");
634
       }
635
     Log.d("mesh", sb.toString());
636
     }
637

    
638
///////////////////////////////////////////////////////////////////////////////////////////////////
639
/**
640
 * Not part of public API, do not document (public only because has to be used from the main package)
641
 *
642
 * @y.exclude
643
 */
644
   public void printCom()
645
     {
646
     StringBuilder sb = new StringBuilder();
647

    
648
     for(int i=0; i<mNumVertices; i++)
649
       {
650
       sb.append(mVertAttribs2[VERT2_ATTRIBS*i+COM_ATTRIB]);
651
       sb.append(' ');
652
       }
653

    
654
     Log.d("mesh", sb.toString());
655
     }
656

    
657
///////////////////////////////////////////////////////////////////////////////////////////////////
658
/**
659
 * Not part of public API, do not document (public only because has to be used from the main package)
660
 *
661
 * @y.exclude
662
 */
663
   public void printTex()
664
     {
665
     int vert=0;
666
     int num = numTexComponents();
667
     StringBuilder sb = new StringBuilder();
668
     sb.append("tex components: ").append(num);
669

    
670
     for(int i=0; i<num; i++)
671
       {
672
       int end = mTexComponent.get(i).mEndIndex;
673
       sb.append("\n");
674

    
675
       for( ; vert<=end; vert++)
676
         {
677
         sb.append(' ');
678
         sb.append('(');
679
         sb.append(mVertAttribs2[VERT2_ATTRIBS*vert+TEX_ATTRIB]);
680
         sb.append(',');
681
         sb.append(mVertAttribs2[VERT2_ATTRIBS*vert+TEX_ATTRIB+1]);
682
         sb.append(')');
683
         }
684
       }
685

    
686
     Log.d("mesh", sb.toString());
687
     }
688

    
689
///////////////////////////////////////////////////////////////////////////////////////////////////
690
/**
691
 * Not part of public API, do not document (public only because has to be used from the main package)
692
 *
693
 * @y.exclude
694
 */
695
   public int getTFO()
696
     {
697
     return mTFO.createImmediately(mNumVertices*TRAN_SIZE, null);
698
     }
699

    
700
///////////////////////////////////////////////////////////////////////////////////////////////////
701
/**
702
 * Not part of public API, do not document (public only because has to be used from the main package)
703
 *
704
 * @y.exclude
705
 */
706
   public int getNumVertices()
707
     {
708
     return mNumVertices;
709
     }
710

    
711
///////////////////////////////////////////////////////////////////////////////////////////////////
712
/**
713
 * Not part of public API, do not document (public only because has to be used from the main package)
714
 *
715
 * @y.exclude
716
 */
717
   public void send(int variant)
718
     {
719
     GLES30.glUniform1iv( mEquAssociationH[variant], MAX_EFFECT_COMPONENTS, mEquAssociation, 0);
720
     GLES30.glUniform1iv( mAndAssociationH[variant], MAX_EFFECT_COMPONENTS, mAndAssociation, 0);
721
     }
722

    
723
///////////////////////////////////////////////////////////////////////////////////////////////////
724
/**
725
 * Not part of public API, do not document (public only because has to be used from the main package)
726
 *
727
 * @y.exclude
728
 */
729
   public void bindVertexAttribs(DistortedProgram program)
730
     {
731
     if( mJobNode[0]!=null )
732
       {
733
       mJobNode[0].execute();  // this will set itself to null
734
/*
735
       try
736
         {
737
         String name = "/sdcard/"+mNumVertices+".dmesh";
738
         DataOutputStream dos = new DataOutputStream(new FileOutputStream(name));
739
         write(dos);
740
         android.util.Log.e("mesh", "file written: "+name);
741
         }
742
       catch(FileNotFoundException ex)
743
         {
744
         android.util.Log.e("mesh", "file not found exception: "+ex.toString());
745
         }
746
 */
747
       }
748

    
749
     int index1 = mVBO1.createImmediately(mNumVertices*VERT1_SIZE, mVertAttribs1);
750
     int index2 = mVBO2.createImmediately(mNumVertices*VERT2_SIZE, mVertAttribs2);
751

    
752
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index1 );
753
     GLES30.glVertexAttribPointer(program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
754
     GLES30.glVertexAttribPointer(program.mAttribute[1], NOR_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_NOR);
755
     GLES30.glVertexAttribPointer(program.mAttribute[2], INF_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_INF);
756
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 );
757
     GLES30.glVertexAttribPointer(program.mAttribute[3], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX);
758
     GLES30.glVertexAttribPointer(program.mAttribute[4], COM_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_COM);
759
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
760
     }
761

    
762
///////////////////////////////////////////////////////////////////////////////////////////////////
763
/**
764
 * Not part of public API, do not document (public only because has to be used from the main package)
765
 *
766
 * @y.exclude
767
 */
768
   public void bindTransformAttribs(DistortedProgram program)
769
     {
770
     int index = mTFO.createImmediately(mNumVertices*TRAN_SIZE, null);
771

    
772
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index );
773
     GLES30.glVertexAttribPointer(program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
774
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
775
     }
776

    
777
///////////////////////////////////////////////////////////////////////////////////////////////////
778
/**
779
 * Not part of public API, do not document (public only because has to be used from the main package)
780
 *
781
 * @y.exclude
782
 */
783
   public void setInflate(float inflate)
784
     {
785
     mInflate = inflate;
786
     }
787

    
788
///////////////////////////////////////////////////////////////////////////////////////////////////
789
/**
790
 * Not part of public API, do not document (public only because has to be used from the main package)
791
 *
792
 * @y.exclude
793
 */
794
   public float getInflate()
795
     {
796
     return mInflate;
797
     }
798

    
799
///////////////////////////////////////////////////////////////////////////////////////////////////
800
// Return the number of bytes read.
801

    
802
   int read(DataInputStream stream)
803
     {
804
     byte[] buffer = new byte[BYTES_PER_FLOAT*4];
805
     int version, numEff, numTex;
806

    
807
     try
808
       {
809
       stream.read(buffer);
810
       ByteBuffer byteBuf = ByteBuffer.wrap(buffer);
811

    
812
       version = byteBuf.getInt(0);
813

    
814
       if( version==1 )
815
         {
816
         mNumVertices= byteBuf.getInt(4);
817
         numTex      = byteBuf.getInt(8);
818
         numEff      = byteBuf.getInt(12);
819
         }
820
       else
821
         {
822
         android.util.Log.e("mesh", "Error: unknown mesh file version "+String.format("0x%08X", version));
823
         return 0;
824
         }
825
       }
826
     catch(IOException e)
827
       {
828
       android.util.Log.e("mesh", "IOException1 trying to read file: "+e.toString());
829
       return 0;
830
       }
831

    
832
     if( mNumVertices>0 && numEff>0 && numTex>0 )
833
       {
834
       int size = numEff+TEX_COMP_SIZE*numTex;
835
       float[] tmp = new float[size];
836
       mVertAttribs1 = new float[VERT1_ATTRIBS*mNumVertices];
837
       mVertAttribs2 = new float[VERT2_ATTRIBS*mNumVertices];
838

    
839
       buffer = new byte[BYTES_PER_FLOAT*(size + mNumVertices*(VERT1_ATTRIBS+VERT2_ATTRIBS))];
840

    
841
       try
842
         {
843
         stream.read(buffer);
844
         }
845
       catch(IOException e)
846
         {
847
         android.util.Log.e("mesh", "IOException2 trying to read file: "+e.toString());
848
         return 0;
849
         }
850

    
851
       ByteBuffer byteBuf = ByteBuffer.wrap(buffer);
852
       FloatBuffer floatBuf = byteBuf.asFloatBuffer();
853

    
854
       floatBuf.get(tmp,0,size);
855
       floatBuf.get(mVertAttribs1, 0, VERT1_ATTRIBS*mNumVertices);
856
       floatBuf.get(mVertAttribs2, 0, VERT2_ATTRIBS*mNumVertices);
857

    
858
       TexComponent tex;
859
       int index, texComp;
860
       float x, y, z, w;
861

    
862
       for(texComp=0; texComp<numTex; texComp++)
863
         {
864
         index = (int)tmp[TEX_COMP_SIZE*texComp];
865

    
866
         x= tmp[TEX_COMP_SIZE*texComp+1];
867
         y= tmp[TEX_COMP_SIZE*texComp+2];
868
         z= tmp[TEX_COMP_SIZE*texComp+3];
869
         w= tmp[TEX_COMP_SIZE*texComp+4];
870

    
871
         tex = new TexComponent(index);
872
         tex.setMap(new Static4D(x,y,z,w));
873

    
874
         mTexComponent.add(tex);
875
         }
876

    
877
       for(int effComp=0; effComp<numEff; effComp++)
878
         {
879
         index = (int)tmp[TEX_COMP_SIZE*texComp + effComp ];
880
         mEffComponent.add(index);
881
         }
882
       }
883

    
884
     return BYTES_PER_FLOAT*( 4 + numEff+TEX_COMP_SIZE*numTex + VERT1_ATTRIBS*mNumVertices + VERT2_ATTRIBS*mNumVertices );
885
     }
886

    
887
///////////////////////////////////////////////////////////////////////////////////////////////////
888
/**
889
 * @y.exclude
890
 */
891
   public int getLastVertexEff(int effComponent)
892
     {
893
     if( effComponent>=0 && effComponent<mTexComponent.size() )
894
       {
895
       return mEffComponent.get(effComponent);
896
       }
897

    
898
     return 0;
899
     }
900

    
901
///////////////////////////////////////////////////////////////////////////////////////////////////
902
/**
903
 * @y.exclude
904
 */
905
   public int getLastVertexTex(int texComponent)
906
     {
907
     if( texComponent>=0 && texComponent<mTexComponent.size() )
908
       {
909
       return mTexComponent.get(texComponent).mEndIndex;
910
       }
911

    
912
     return 0;
913
     }
914

    
915
///////////////////////////////////////////////////////////////////////////////////////////////////
916
// PUBLIC API
917
///////////////////////////////////////////////////////////////////////////////////////////////////
918
/**
919
 * Write the Mesh to a File.
920
 */
921
   public void write(DataOutputStream stream)
922
     {
923
     TexComponent tex;
924

    
925
     int numTex = mTexComponent.size();
926
     int numEff = mEffComponent.size();
927

    
928
     try
929
       {
930
       stream.writeInt(1);  // version
931
       stream.writeInt(mNumVertices);
932
       stream.writeInt(numTex);
933
       stream.writeInt(numEff);
934

    
935
       for(int i=0; i<numTex; i++)
936
         {
937
         tex = mTexComponent.get(i);
938

    
939
         stream.writeFloat((float)tex.mEndIndex);
940
         stream.writeFloat(tex.mTextureMap.get0());
941
         stream.writeFloat(tex.mTextureMap.get1());
942
         stream.writeFloat(tex.mTextureMap.get2());
943
         stream.writeFloat(tex.mTextureMap.get3());
944
         }
945

    
946
       for(int i=0; i<numEff; i++)
947
         {
948
         stream.writeFloat((float)mEffComponent.get(i));
949
         }
950

    
951
       ByteBuffer vertBuf1 = ByteBuffer.allocate(VERT1_SIZE*mNumVertices);
952
       vertBuf1.asFloatBuffer().put(mVertAttribs1);
953
       ByteBuffer vertBuf2 = ByteBuffer.allocate(VERT2_SIZE*mNumVertices);
954
       vertBuf2.asFloatBuffer().put(mVertAttribs2);
955

    
956
       stream.write(vertBuf1.array());
957
       stream.write(vertBuf2.array());
958
       }
959
     catch(IOException ex)
960
       {
961
       android.util.Log.e("mesh", "IOException trying to write a mesh: "+ex.toString());
962
       }
963
     }
964

    
965
///////////////////////////////////////////////////////////////////////////////////////////////////
966
/**
967
 * When rendering this Mesh, do we want to render the Normal vectors as well?
968
 * <p>
969
 * Will work only on OpenGL ES >= 3.0 devices.
970
 *
971
 * @param show Controls if we render the Normal vectors or not.
972
 */
973
   public void setShowNormals(boolean show)
974
     {
975
     mShowNormals = show;
976
     }
977

    
978
///////////////////////////////////////////////////////////////////////////////////////////////////
979
/**
980
 * When rendering this mesh, should we also draw the normal vectors?
981
 *
982
 * @return <i>true</i> if we do render normal vectors
983
 */
984
   public boolean getShowNormals()
985
     {
986
     return mShowNormals;
987
     }
988

    
989
///////////////////////////////////////////////////////////////////////////////////////////////////
990
/**
991
 * Merge all texture components of this Mesh into a single one.
992
 */
993
   public void mergeTexComponents()
994
     {
995
     if( mJobNode[0]==null )
996
       {
997
       mergeTexComponentsNow();
998
       }
999
     else
1000
       {
1001
       mJobNode[0] = DeferredJobs.mergeTex(this);
1002
       }
1003
     }
1004

    
1005
///////////////////////////////////////////////////////////////////////////////////////////////////
1006
/**
1007
 * Merge all effect components of this Mesh into a single one.
1008
 */
1009
   public void mergeEffComponents()
1010
     {
1011
     if( mJobNode[0]==null )
1012
       {
1013
       mergeEffComponentsNow();
1014
       }
1015
     else
1016
       {
1017
       mJobNode[0] = DeferredJobs.mergeEff(this);
1018
       }
1019
     }
1020

    
1021
///////////////////////////////////////////////////////////////////////////////////////////////////
1022
/**
1023
 * Release all internal resources.
1024
 */
1025
   public void markForDeletion()
1026
     {
1027
     mVertAttribs1 = null;
1028
     mVertAttribs2 = null;
1029

    
1030
     mVBO1.markForDeletion();
1031
     mVBO2.markForDeletion();
1032
     mTFO.markForDeletion();
1033
     }
1034

    
1035
///////////////////////////////////////////////////////////////////////////////////////////////////
1036
/**
1037
 * Apply a Matrix Effect to the components which match the (addAssoc,equAssoc) association.
1038
 * <p>
1039
 * This is a static, permanent modification of the vertices contained in this Mesh. If the effect
1040
 * contains any Dynamics, they will be evaluated at 0.
1041
 *
1042
 * @param effect List of Matrix Effects to apply to the Mesh.
1043
 * @param andAssoc 'Logical AND' association which defines which components will be affected.
1044
 * @param equAssoc 'equality' association which defines which components will be affected.
1045
 */
1046
   public void apply(MatrixEffect effect, int andAssoc, int equAssoc)
1047
     {
1048
     if( mJobNode[0]==null )
1049
       {
1050
       applyMatrix(effect,andAssoc,equAssoc);
1051
       }
1052
     else
1053
       {
1054
       mJobNode[0] = DeferredJobs.matrix(this,effect,andAssoc,equAssoc);
1055
       }
1056
     }
1057

    
1058
///////////////////////////////////////////////////////////////////////////////////////////////////
1059
/**
1060
 * Apply a Vertex Effect to the vertex mesh.
1061
 * <p>
1062
 * This is a static, permanent modification of the vertices contained in this Mesh. If the effects
1063
 * contain any Dynamics, the Dynamics will be evaluated at 0.
1064
 *
1065
 * We would call this several times building up a list of Effects to do. This list of effects gets
1066
 * lazily executed only when the Mesh is used for rendering for the first time.
1067
 *
1068
 * @param effect Vertex Effect to apply to the Mesh.
1069
 */
1070
   public void apply(VertexEffect effect)
1071
     {
1072
     mJobNode[0] = DeferredJobs.vertex(this,effect);
1073
     }
1074

    
1075
///////////////////////////////////////////////////////////////////////////////////////////////////
1076
/**
1077
 * Sets texture maps for (some of) the components of this mesh.
1078
 * <p>
1079
 * Format: ( x of lower-left corner, y of lower-left corner, width, height ).
1080
 * For example maps[0] = new Static4D( 0.0, 0.5, 0.5, 0.5 ) sets the 0th component texture map to the
1081
 * upper-left quadrant of the texture.
1082
 * <p>
1083
 * Probably the most common user case would be sending as many maps as there are components in this
1084
 * Mesh. One can also send less, or more (the extraneous ones will be ignored) and set some of them
1085
 * to null (those will be ignored as well). So if there are 5 components, and we want to set the map
1086
 * of the 2nd and 4rd one, call this with
1087
 * maps = new Static4D[4]
1088
 * maps[0] = null
1089
 * maps[1] = the map for the 2nd component
1090
 * maps[2] = null
1091
 * maps[3] = the map for the 4th component
1092
 *
1093
 * A map's width and height have to be non-zero (but can be negative!)
1094
 *
1095
 * @param maps            List of texture maps to apply to the texture's components.
1096
 * @param startComponent  the component the first of the maps refers to.
1097
 */
1098
   public void setTextureMap(Static4D[] maps, int startComponent)
1099
     {
1100
     if( mJobNode[0]==null )
1101
       {
1102
       textureMap(maps,startComponent);
1103
       }
1104
     else
1105
       {
1106
       mJobNode[0] = DeferredJobs.textureMap(this,maps,startComponent);
1107
       }
1108
     }
1109

    
1110
///////////////////////////////////////////////////////////////////////////////////////////////////
1111
/**
1112
 * Return the texture map of one of the components.
1113
 *
1114
 * @param component The component number whose texture map we want to retrieve.
1115
 */
1116
   public Static4D getTextureMap(int component)
1117
     {
1118
     return (component>=0 && component<mTexComponent.size()) ? mTexComponent.get(component).mTextureMap : null;
1119
     }
1120

    
1121
///////////////////////////////////////////////////////////////////////////////////////////////////
1122
/**
1123
 * Set Effect association.
1124
 *
1125
 * This creates an association between a Component of this Mesh and a Vertex Effect.
1126
 * One can set two types of associations - an 'logical and' and a 'equal' associations and the Effect
1127
 * will only be active on vertices of Components such that
1128
 *
1129
 * (effect andAssoc) & (component andAssoc) != 0 || (effect equAssoc) == (mesh equAssoc)
1130
 *
1131
 * (see main_vertex_shader)
1132
 *
1133
 * The point: this way we can configure the system so that each Vertex Effect acts only on a certain
1134
 * subset of a Mesh, thus potentially significantly reducing the number of render calls.
1135
 */
1136
   public void setEffectAssociation(int component, int andAssociation, int equAssociation)
1137
     {
1138
     if( component>=0 && component<MAX_EFFECT_COMPONENTS )
1139
       {
1140
       if( mJobNode[0]==null )
1141
         {
1142
         setEffectAssociationNow(component, andAssociation, equAssociation);
1143
         }
1144
       else
1145
         {
1146
         mJobNode[0] = DeferredJobs.effectAssoc(this,component,andAssociation,equAssociation);
1147
         }
1148
       }
1149
     }
1150

    
1151
///////////////////////////////////////////////////////////////////////////////////////////////////
1152
/**
1153
 * Return the number of texture components, i.e. individual subsets of the whole set of vertices
1154
 * which can be independently textured.
1155
 *
1156
 * @return The number of Texture Components of this Mesh.
1157
 */
1158
   public int numTexComponents()
1159
     {
1160
     return mTexComponent.size();
1161
     }
1162

    
1163
///////////////////////////////////////////////////////////////////////////////////////////////////
1164
/**
1165
 * Return the number of 'effect' components, i.e. individual subsets of the whole set of vertices
1166
 * to which a VertexEffect can be addressed, independently of other vertices.
1167
 *
1168
 * @return The number of Effect Components of this Mesh.
1169
 */
1170
   public int numEffComponents()
1171
     {
1172
     return mEffComponent.size();
1173
     }
1174

    
1175
///////////////////////////////////////////////////////////////////////////////////////////////////
1176
/**
1177
 * Copy the Mesh.
1178
 *
1179
 * @param deep If to be a deep or shallow copy of mVertAttribs1, i.e. the array holding vertices,
1180
 *             normals and inflates (the rest, in particular the mVertAttribs2 containing texture
1181
 *             coordinates and effect associations, is always deep copied)
1182
 */
1183
   public abstract MeshBase copy(boolean deep);
1184
   }
(2-2/9)