Project

General

Profile

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

examples / src / main / java / org / distorted / examples / meshfile / MeshFileRenderer.java @ f804fce3

1 42aa970f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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.examples.meshfile;
21
22 1af8e143 Leszek Koltunski
import android.content.Context;
23
import android.content.res.Resources;
24 42aa970f Leszek Koltunski
import android.graphics.Bitmap;
25
import android.graphics.Canvas;
26
import android.graphics.Paint;
27
import android.opengl.GLSurfaceView;
28
29 8ac4c0bc Leszek Koltunski
import org.distorted.examples.R;
30 a65604a7 Leszek Koltunski
import org.distorted.library.effect.Effect;
31 6991ece5 Leszek Koltunski
import org.distorted.library.effect.EffectType;
32 42aa970f Leszek Koltunski
import org.distorted.library.effect.MatrixEffectQuaternion;
33
import org.distorted.library.effect.MatrixEffectScale;
34 39b925d5 Leszek Koltunski
import org.distorted.library.effect.VertexEffectDisappear;
35 42aa970f Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
36
import org.distorted.library.main.DistortedLibrary;
37
import org.distorted.library.main.DistortedScreen;
38
import org.distorted.library.main.DistortedTexture;
39 6991ece5 Leszek Koltunski
import org.distorted.library.mesh.MeshBase;
40 1af8e143 Leszek Koltunski
import org.distorted.library.mesh.MeshFile;
41 b2adcd57 Leszek Koltunski
import org.distorted.library.mesh.MeshMultigon;
42 1bb5d3b7 Leszek Koltunski
import org.distorted.library.mesh.MeshPolygon;
43 42aa970f Leszek Koltunski
import org.distorted.library.type.DynamicQuat;
44
import org.distorted.library.type.Static3D;
45
import org.distorted.library.type.Static4D;
46
47 1bb5d3b7 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
48 0dee575b Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
49
import org.distorted.objectlib.helpers.ObjectShape;
50 acb2aaae Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
51 1bb5d3b7 Leszek Koltunski
52 1af8e143 Leszek Koltunski
import java.io.DataInputStream;
53
import java.io.IOException;
54
import java.io.InputStream;
55
56 42aa970f Leszek Koltunski
import javax.microedition.khronos.egl.EGLConfig;
57
import javax.microedition.khronos.opengles.GL10;
58
59 b2adcd57 Leszek Koltunski
import static org.distorted.examples.meshfile.MeshFileActivity.MULTIGON;
60 1bb5d3b7 Leszek Koltunski
import static org.distorted.examples.meshfile.MeshFileActivity.POLYGON;
61 6991ece5 Leszek Koltunski
import static org.distorted.examples.meshfile.MeshFileActivity.PROCEDURAL;
62 baace8e9 Leszek Koltunski
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
63 6991ece5 Leszek Koltunski
64 42aa970f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
65
66 dc10a48d Leszek Koltunski
class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
67 42aa970f Leszek Koltunski
{
68 7edab735 Leszek Koltunski
    private static final float SQ3 = (float)Math.sqrt(3);
69 16b336db Leszek Koltunski
    private final float DEFAULT_SCALE = 0.3f;
70
71 140f2c4e Leszek Koltunski
    private final GLSurfaceView mView;
72 dc10a48d Leszek Koltunski
    private final Resources mResources;
73 140f2c4e Leszek Koltunski
    private final DistortedScreen mScreen;
74
    private final DistortedEffects mEffects;
75
    private final Static3D mScale;
76 dc10a48d Leszek Koltunski
77
    private DistortedTexture mTexture;
78
    private MeshBase mMesh;
79 48c88f57 Leszek Koltunski
    private long mTime;
80 16b336db Leszek Koltunski
    private float mCurrentScale;
81 42aa970f Leszek Koltunski
82
    Static4D mQuat1, mQuat2;
83
    int mScreenMin;
84
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
87
    MeshFileRenderer(GLSurfaceView v)
88
      {
89
      mView = v;
90 dc10a48d Leszek Koltunski
      mResources = v.getResources();
91
92 42aa970f Leszek Koltunski
      mScreen = new DistortedScreen();
93
      mScale= new Static3D(1,1,1);
94
      Static3D center=new Static3D(0,0,0);
95
96 16b336db Leszek Koltunski
      mCurrentScale = DEFAULT_SCALE;
97
98 42aa970f Leszek Koltunski
      mQuat1 = new Static4D(0,0,0,1);
99 fe032f52 Leszek Koltunski
      mQuat2 = new Static4D(0,0,0,1);
100 42aa970f Leszek Koltunski
101
      DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
102
      DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
103
104
      quatInt1.add(mQuat1);
105
      quatInt2.add(mQuat2);
106
107 39b925d5 Leszek Koltunski
      VertexEffectDisappear disappear = new VertexEffectDisappear();
108
      disappear.setMeshAssociation(1,-1);
109
110 42aa970f Leszek Koltunski
      mEffects = new DistortedEffects();
111
      mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
112
      mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
113
      mEffects.apply( new MatrixEffectScale(mScale));
114
115 39b925d5 Leszek Koltunski
      mEffects.apply( disappear );
116
117 42aa970f Leszek Koltunski
      mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
118 48c88f57 Leszek Koltunski
      mScreen.showFPS();
119 42aa970f Leszek Koltunski
      }
120
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122
   
123
    public void onDrawFrame(GL10 glUnused) 
124
      {
125
      mScreen.render( System.currentTimeMillis() );
126
      }
127
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129
    
130
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
131
      {
132
      mScreenMin = Math.min(width, height);
133 16b336db Leszek Koltunski
      float factor = mCurrentScale*mScreenMin;
134 42aa970f Leszek Koltunski
      mScale.set(factor,factor,factor);
135
      mScreen.resize(width, height);
136
      }
137
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139
    
140
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
141
      {
142
      if( mTexture==null ) mTexture = new DistortedTexture();
143
144 a65604a7 Leszek Koltunski
      Effect.enableEffects(EffectType.VERTEX);
145 04a21ed6 Leszek Koltunski
      DistortedLibrary.setMax(EffectType.VERTEX, 20);
146 ef02f5e0 Leszek Koltunski
      DistortedLibrary.needTransformFeedback();
147 dc10a48d Leszek Koltunski
      DistortedLibrary.onSurfaceCreated(this);
148 42aa970f Leszek Koltunski
      }
149
150 16b336db Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
151
//   0 ---> 0
152
//  50 ---> DEFAULT_SCALE
153
// 100 ---> 4*DEFAULT_SCALE
154
155
    void setScale(int scale)
156
      {
157
      if( scale<= 50 )
158
        {
159
        mCurrentScale = DEFAULT_SCALE * scale / 50.0f;
160
        }
161
      else
162
        {
163
        mCurrentScale = DEFAULT_SCALE * ( 3*(scale/50.0f) - 2.0f);
164
        }
165
166
      float factor = mCurrentScale*mScreenMin;
167
      mScale.set(factor,factor,factor);
168
      }
169
170 42aa970f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
171
172 1af8e143 Leszek Koltunski
    void open(int resourceID)
173 42aa970f Leszek Koltunski
      {
174 099d8f8b Leszek Koltunski
      if( mTexture==null ) mTexture = new DistortedTexture();
175 8ac4c0bc Leszek Koltunski
      mTexture.setTexture( createTexture(resourceID) );
176
177 acad428e Leszek Koltunski
      long t1 = System.currentTimeMillis();
178 6991ece5 Leszek Koltunski
179 1bb5d3b7 Leszek Koltunski
      if( resourceID==PROCEDURAL )
180 6991ece5 Leszek Koltunski
        {
181 1bb5d3b7 Leszek Koltunski
        createMesh();
182
        }
183
      else if( resourceID==POLYGON )
184
        {
185
        createPolygon();
186 6991ece5 Leszek Koltunski
        }
187 b2adcd57 Leszek Koltunski
      else if( resourceID==MULTIGON )
188
        {
189
        createMultigon();
190
        }
191 6991ece5 Leszek Koltunski
      else
192
        {
193 1bb5d3b7 Leszek Koltunski
        openMesh(resourceID);
194 6991ece5 Leszek Koltunski
        }
195
196 acad428e Leszek Koltunski
      long t2 = System.currentTimeMillis();
197
198 48c88f57 Leszek Koltunski
      mTime = t2-t1;
199 42aa970f Leszek Koltunski
200 71c7624f Leszek Koltunski
      mScreen.detachAll();
201 7198e5c9 Leszek Koltunski
      mScreen.attach(mTexture,mEffects,mMesh);
202 42aa970f Leszek Koltunski
      }
203
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205
206 1af8e143 Leszek Koltunski
    private Bitmap createTexture(int resourceID)
207 42aa970f Leszek Koltunski
      {
208 7edab735 Leszek Koltunski
      TextureFactory factory = TextureFactory.getInstance();
209
210
      float[] vertices;
211
      int[] colors;
212
      float F = 0.5f;
213
      float E = SQ3/2;
214
215 77e66c58 Leszek Koltunski
      if( resourceID == R.raw.deferredjob ||
216
          resourceID == R.raw.meshjoin    ||
217
          resourceID == PROCEDURAL        ||
218
          resourceID == POLYGON           ||
219 b2adcd57 Leszek Koltunski
          resourceID == MULTIGON          ||
220 77e66c58 Leszek Koltunski
          resourceID == R.raw.predeform    ) return createWhiteTexture();
221
222
      if( resourceID == R.raw.cube2       ||
223
          resourceID == R.raw.cube3       ||
224
          resourceID == R.raw.cube4       ||
225
          resourceID == R.raw.cube5        )
226
        {
227
        colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
228
        vertices = new float[] { -F,-F, +F,-F, +F,+F, -F,+F};
229
        return factory.createTexture(vertices,colors,0.10f, 0.10f, true);
230
        }
231
      if( resourceID == R.raw.pyra3       ||
232
          resourceID == R.raw.pyra4       ||
233
          resourceID == R.raw.pyra5        )
234
        {
235
        colors = new int[] { 0xffffff00, 0xff00ff00, 0xff0000ff, 0xffff0000 };
236
        vertices = new float[] { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
237
        return factory.createTexture(vertices,colors,0.05f, 0.05f, true);
238
        }
239
      if( resourceID == R.raw.dino )
240
        {
241
        colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
242
        vertices = new float[] { -F,F/3, 0,-2*F/3, +F,F/3 };
243
        return factory.createTexture(vertices,colors,0.05f, 0.03f, true);
244
        }
245
      if( resourceID == R.raw.skewb )
246
        {
247
        colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
248
        vertices = new float[] { -F+F/4,F/4, F/4,-F+F/4, F/4,F/4};
249
        return factory.createTexture(vertices,colors,0.05f, 0.08f, true);
250
        }
251 8ac4c0bc Leszek Koltunski
252 7edab735 Leszek Koltunski
      return null;
253 8ac4c0bc Leszek Koltunski
      }
254
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
257 7edab735 Leszek Koltunski
    private Bitmap createWhiteTexture()
258 8ac4c0bc Leszek Koltunski
      {
259 7edab735 Leszek Koltunski
      int SIZE = 1;
260 8ac4c0bc Leszek Koltunski
      Bitmap bitmap = Bitmap.createBitmap(SIZE,SIZE, Bitmap.Config.ARGB_8888);
261
      Canvas canvas = new Canvas(bitmap);
262
263
      Paint paint = new Paint();
264 36793c52 Leszek Koltunski
      paint.setColor(0xffffff55);
265 1beffb69 Leszek Koltunski
      paint.setStyle(Paint.Style.FILL);
266 7edab735 Leszek Koltunski
      canvas.drawRect(0, 0, SIZE, SIZE, paint);
267 6991ece5 Leszek Koltunski
268 72059460 Leszek Koltunski
      return bitmap;
269 6991ece5 Leszek Koltunski
      }
270
271 1bb5d3b7 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
272
273
    private void createPolygon()
274
      {
275
      float A = 0.5f;
276 46a0999e Leszek Koltunski
      float B = 0.04f;
277 1bb5d3b7 Leszek Koltunski
278 f804fce3 Leszek Koltunski
      int extraIndex    = 0;
279
      int extraVertices = 0;
280 1bb5d3b7 Leszek Koltunski
      float[] vertices = new float[] { -A,-A, A,-A, A,A, -A,A };
281 46a0999e Leszek Koltunski
282 bb6efcda Leszek Koltunski
      float C = 2f;
283 46a0999e Leszek Koltunski
      float[] bands = new float[] { 1.0f, 0.00f*C, 0.9f, 0.04f*C,  0.8f, 0.07f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C};
284
285
/*
286
      int numBands      = 5;
287 1bb5d3b7 Leszek Koltunski
      float[] bands = new float[2*numBands];
288
289
      for(int i=0; i<numBands; i++)
290
        {
291
        bands[2*i  ] = 1 + i/(1.0f-numBands);
292
        bands[2*i+1] = B/(numBands-1)*i;
293
        }
294 46a0999e Leszek Koltunski
*/
295 bb6efcda Leszek Koltunski
      boolean[] edgesUp = new boolean[] {true,true,false,false};
296 f804fce3 Leszek Koltunski
      boolean[] vertsUp = new boolean[] {false,false,false,false};
297 1bb5d3b7 Leszek Koltunski
298 bb6efcda Leszek Koltunski
      mMesh = new MeshPolygon(vertices,bands,edgesUp,vertsUp,extraIndex,extraVertices,0.0f,0.0f);
299 1bb5d3b7 Leszek Koltunski
      mMesh.setEffectAssociation(0,0,0);
300 f804fce3 Leszek Koltunski
      mMesh.setShowNormals(true);
301 b2adcd57 Leszek Koltunski
      }
302
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304
305
    private void createMultigon()
306
      {
307
      float A = 0.5f;
308 45b6b6b5 Leszek Koltunski
      int extraIndex    = 0;
309
      int extraVertices = 0;
310 b2adcd57 Leszek Koltunski
311 bb6efcda Leszek Koltunski
      float[] v1 = new float[] {  -A,-A,   A,-A,   A,  A,   -A,  A };
312
      float[] v2 = new float[] {   A,-A, 2*A,-A, 2*A,  A,    A,  A };
313
      float[] v3 = new float[] {-3*A,-A,  -A,-A,  -A,  A, -3*A,  A };
314
      float[] v4 = new float[] {  -A, A,   A, A,   A,3*A,   -A,3*A };
315
      float[] v5 = new float[] {-3*A, A,  -A, A,  -A,3*A, -3*A,3*A };
316 b2adcd57 Leszek Koltunski
317 bb6efcda Leszek Koltunski
      float[][] vertices = new float[][] {v1,v2,v3,v4,v5};
318
/*
319 b2adcd57 Leszek Koltunski
      float[] c1 = new float[] { 0,0 };
320
      float[] c2 = new float[] { 1.5f*A,0 };
321 bb6efcda Leszek Koltunski
      float[] c3 = new float[] {-1.5f*A,0 };
322
      float[] c4 = new float[] { 0,1.5f*A };
323
      float[] c5 = new float[] { -1.5f*A,1.5f*A };
324
325
      float[][] centers = new float[][] { c1,c2,c3,c4,c5 };
326
*/
327 f804fce3 Leszek Koltunski
      float C = 1f;
328 b2adcd57 Leszek Koltunski
      float[] bands = new float[] { 1.0f, 0.00f*C, 0.9f, 0.04f*C,  0.8f, 0.07f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C};
329
330 bb6efcda Leszek Koltunski
/*
331
      float B = 0.1f;
332
      int numBands = 7;
333 b2adcd57 Leszek Koltunski
      float[] bands = new float[2*numBands];
334
335
      for(int i=0; i<numBands; i++)
336
        {
337
        bands[2*i  ] = 1 + i/(1.0f-numBands);
338
        bands[2*i+1] = B/(numBands-1)*i;
339
        }
340 bb6efcda Leszek Koltunski
*/
341
      mMesh = new MeshMultigon(vertices,bands,extraIndex,extraVertices);
342 45b6b6b5 Leszek Koltunski
343
      int numEff = mMesh.getNumEffComponents();
344
345
      for(int i=0; i<numEff; i++)
346
        {
347
        mMesh.setEffectAssociation(i, 0, i);
348
        }
349
350 bb6efcda Leszek Koltunski
     // mMesh.setShowNormals(true);
351 1bb5d3b7 Leszek Koltunski
      }
352
353 6991ece5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
354
355
    private void createMesh()
356
      {
357 d2f57a83 Leszek Koltunski
      float A = 2.0f;
358
359 d1d5d7e2 Leszek Koltunski
      float[][] vertices =
360
          {
361
              { 0.5f, 0.5f, 0.5f },
362
              { 0.5f, 0.5f,-0.5f },
363
              { 0.5f,-0.5f, 0.5f },
364
              { 0.5f,-0.5f,-0.5f },
365
              {-0.5f, 0.5f, 0.5f },
366
              {-0.5f, 0.5f,-0.5f },
367
              {-0.5f,-0.5f, 0.5f },
368
              {-0.5f,-0.5f,-0.5f },
369
370 d2f57a83 Leszek Koltunski
              { 0.5f,   -A, 0.5f },
371
              { 0.5f,   -A,-0.5f },
372
              {-0.5f,   -A, 0.5f },
373
              {-0.5f,   -A,-0.5f },
374
375
              {   -A, 0.5f, 0.5f },
376
              {   -A, 0.5f,-0.5f },
377
              {   -A,-0.5f, 0.5f },
378
              {   -A,-0.5f,-0.5f },
379 d1d5d7e2 Leszek Koltunski
          };
380
381
      int[][][] vertIndices =
382
          {
383 d2f57a83 Leszek Koltunski
              { { 8, 9, 1, 0} },
384
              { {15,14,12,13} },
385
              { {11,10, 6, 7} },
386
              { {12, 0, 1,13} },
387
              { {11, 9, 8,10} },
388
              { {15, 7, 6,14} },
389
              { {14, 6, 4,12}, { 6, 2, 0, 4}, {10, 8, 2, 6} },
390
              { { 3, 7, 5, 1}, { 9,11, 7, 3}, { 7,15,13, 5} }
391 d1d5d7e2 Leszek Koltunski
          };
392
393 d2f57a83 Leszek Koltunski
      float height = 0.02f;
394 d1d5d7e2 Leszek Koltunski
      int num = 5;
395
      int extraI = 1;
396
      int extraV = 1;
397
398 d2f57a83 Leszek Koltunski
      float[][] bands= { {height,25,0.3f,0.5f,num,extraI,extraV} };
399 d1d5d7e2 Leszek Koltunski
400 d2f57a83 Leszek Koltunski
      int[] bandIndices = {0,0,0,0,0,0,0,0};
401 d1d5d7e2 Leszek Koltunski
      float[] convex = null;
402
403
      float[][] corners= { {0.036f,0.12f} };
404
      float[][] centers= { {0.0f, 0.0f, 0.0f} };
405 d2f57a83 Leszek Koltunski
      int[] ind    = { 0,0,-1,-1,-1,-1,-1,-1, 0,0,0,0,0,0,0,0 };
406 d1d5d7e2 Leszek Koltunski
407
      ObjectShape shape = new ObjectShape(vertices, vertIndices);
408
      ObjectFaceShape face = new ObjectFaceShape(bands, bandIndices, convex);
409
      ObjectVertexEffects effects = FactoryCubit.generateVertexEffect(vertices,corners,ind,centers,ind);
410
411
      int numFaces = shape.getNumFaces();
412
      int[] outer = new int[numFaces];
413 db9903e8 Leszek Koltunski
414 33647db9 Leszek Koltunski
      FactoryCubit factory = FactoryCubit.getInstance();
415 6983badf Leszek Koltunski
      factory.clear();
416 fa96775c Leszek Koltunski
      factory.createNewFaceTransform(shape,outer);
417 d1d5d7e2 Leszek Koltunski
      mMesh = factory.createRoundedSolid(shape,face,effects,MESH_NICE,numFaces);
418 6983badf Leszek Koltunski
419
      int numEff = mMesh.getNumEffComponents();
420 d32fe3d9 Leszek Koltunski
      for(int i=0; i<numEff; i++) mMesh.setEffectAssociation(i, 0, i);
421 6991ece5 Leszek Koltunski
      }
422 42aa970f Leszek Koltunski
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424
425 6991ece5 Leszek Koltunski
    private void openMesh(int resourceID)
426 42aa970f Leszek Koltunski
      {
427 1af8e143 Leszek Koltunski
      Context con = mView.getContext();
428
      Resources res = con.getResources();
429
      InputStream is = res.openRawResource(resourceID);
430
      DataInputStream dos = new DataInputStream(is);
431 7198e5c9 Leszek Koltunski
      mMesh = new MeshFile(dos);
432 1af8e143 Leszek Koltunski
433 6983badf Leszek Koltunski
      int numEff = mMesh.getNumEffComponents();
434 39b925d5 Leszek Koltunski
435
      for(int i=0; i<numEff; i++)
436
        {
437
        mMesh.setEffectAssociation(i, 0, i);
438
        }
439
440 1af8e143 Leszek Koltunski
      try
441
        {
442
        is.close();
443
        }
444
      catch(IOException e)
445
        {
446 48c88f57 Leszek Koltunski
        android.util.Log.e("MeshFile", "Error closing InputStream: "+e.toString());
447 1af8e143 Leszek Koltunski
        }
448 42aa970f Leszek Koltunski
      }
449 48c88f57 Leszek Koltunski
450 39b925d5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
451
452 6991ece5 Leszek Koltunski
    MeshBase getMesh()
453 39b925d5 Leszek Koltunski
      {
454
      return mMesh;
455
      }
456
457 48c88f57 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
458
459
    long getTime()
460
      {
461
      return mTime;
462
      }
463
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465
466
    int getBytes()
467
      {
468 6991ece5 Leszek Koltunski
      if( mMesh instanceof MeshFile )
469
        {
470
        return ((MeshFile)mMesh).getNumBytes();
471
        }
472
473
      return 0;
474 48c88f57 Leszek Koltunski
      }
475
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477
478
    int getVertices()
479
      {
480 7198e5c9 Leszek Koltunski
      return mMesh.getNumVertices();
481
      }
482
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484
485
    int getEndEffIndex(int component)
486
      {
487
      return mMesh.getLastVertexEff(component);
488
      }
489
490
///////////////////////////////////////////////////////////////////////////////////////////////////
491
492
    int getEndTexIndex(int component)
493
      {
494
      return mMesh.getLastVertexTex(component);
495
      }
496
497
///////////////////////////////////////////////////////////////////////////////////////////////////
498
499
    int getEffComponentNum()
500
      {
501 6983badf Leszek Koltunski
      return mMesh.getNumEffComponents();
502 7198e5c9 Leszek Koltunski
      }
503
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505
506
    int getTexComponentNum()
507
      {
508 6983badf Leszek Koltunski
      return mMesh.getNumTexComponents();
509 48c88f57 Leszek Koltunski
      }
510 dc10a48d Leszek Koltunski
511
///////////////////////////////////////////////////////////////////////////////////////////////////
512
513
    public void distortedException(Exception ex)
514
      {
515
      android.util.Log.e("MeshFile", ex.getMessage() );
516
      }
517
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519
520
    public InputStream localFile(int fileID)
521
      {
522
      return mResources.openRawResource(fileID);
523
      }
524
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526
527
    public void logMessage(String message)
528
      {
529
      android.util.Log.e("MeshFile", message );
530
      }
531 42aa970f Leszek Koltunski
}