Project

General

Profile

« Previous | Next » 

Revision 48c88f57

Added by Leszek Koltunski almost 4 years ago

Progress with the MeshFile app.

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
26 26
import android.widget.AdapterView;
27 27
import android.widget.ArrayAdapter;
28 28
import android.widget.Spinner;
29
import android.widget.TextView;
29 30

  
30 31
import org.distorted.examples.R;
31 32
import org.distorted.library.main.DistortedLibrary;
......
97 98

  
98 99
    public void Open(View v)
99 100
      {
100
      MeshFileSurfaceView view = this.findViewById(R.id.meshfileSurfaceView);
101
      MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
101 102
      MeshFileRenderer renderer = view.getRenderer();
102 103

  
103 104
      renderer.open(mResource);
105

  
106
      int bytes    = renderer.getBytes();
107
      int vertices = renderer.getVertices();
108
      long time    = renderer.getTime();
109

  
110
      TextView byt = findViewById(R.id.meshfileSize);
111
      TextView ver = findViewById(R.id.meshfileVertices);
112
      TextView tim = findViewById(R.id.meshfileTime);
113

  
114
      byt.setText( String.format("%d", bytes   ) );
115
      ver.setText( String.format("%d", vertices) );
116
      tim.setText( String.format("%d", time    ) );
104 117
      }
105 118

  
106 119
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
56 56
    private DistortedEffects mEffects;
57 57
    private Static3D mScale;
58 58
    private MeshBase mMesh;
59
    private long mTime;
60
    private int mBytes;
61
    private int mVertices;
59 62

  
60 63
    Static4D mQuat1, mQuat2;
61 64
    int mScreenMin;
......
84 87
      mEffects.apply( new MatrixEffectScale(mScale));
85 88

  
86 89
      mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
90
      mScreen.showFPS();
87 91
      }
88 92

  
89 93
///////////////////////////////////////////////////////////////////////////////////////////////////
......
130 134
      mMesh = createMesh(resourceID);
131 135
      long t2 = System.currentTimeMillis();
132 136

  
133
      android.util.Log.e("file", "time: "+(t2-t1));
137
      mTime = t2-t1;
134 138

  
135 139
      mScreen.detachAll();
136 140
      mScreen.attach(mTexture,mEffects,mMesh);
......
276 280
      Resources res = con.getResources();
277 281
      InputStream is = res.openRawResource(resourceID);
278 282
      DataInputStream dos = new DataInputStream(is);
279
      MeshBase mesh = new MeshFile(dos);
283
      MeshFile mesh = new MeshFile(dos);
284

  
285
      mBytes = mesh.getNumBytes();
286
      mVertices = mesh.getNumVertices();
280 287

  
281 288
      try
282 289
        {
......
284 291
        }
285 292
      catch(IOException e)
286 293
        {
287
        android.util.Log.e("meshFile", "Error closing InputStream: "+e.toString());
294
        android.util.Log.e("MeshFile", "Error closing InputStream: "+e.toString());
288 295
        }
289 296

  
290 297
      return mesh;
291 298
      }
299

  
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

  
302
    long getTime()
303
      {
304
      return mTime;
305
      }
306

  
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308

  
309
    int getBytes()
310
      {
311
      return mBytes;
312
      }
313

  
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315

  
316
    int getVertices()
317
      {
318
      return mVertices;
319
      }
292 320
}
src/main/res/layout/meshfilelayout.xml
34 34

  
35 35
    </LinearLayout>
36 36

  
37
    <LinearLayout
38
        android:orientation="horizontal"
39
        android:layout_width="match_parent"
40
        android:layout_height="wrap_content">
41

  
42
        <TextView
43
                android:layout_width="wrap_content"
44
                android:layout_height="wrap_content"
45
                android:gravity="left"
46
                android:text="@string/vertices"
47
                android:textAppearance="?android:attr/textAppearanceMedium" />
48
        <TextView
49
                android:id="@+id/meshfileVertices"
50
                android:layout_width="0dp"
51
                android:layout_height="wrap_content"
52
                android:layout_weight="0.33"
53
                android:paddingLeft="5dp"
54
                android:gravity="right"
55
                android:textAppearance="?android:attr/textAppearanceSmall" />
56

  
57
        <TextView
58
                android:layout_width="wrap_content"
59
                android:layout_height="wrap_content"
60
                android:paddingLeft="5dp"
61
                android:gravity="left"
62
                android:text="@string/size"
63
                android:textAppearance="?android:attr/textAppearanceMedium" />
64
        <TextView
65
                android:id="@+id/meshfileSize"
66
                android:layout_width="0dp"
67
                android:layout_height="wrap_content"
68
                android:layout_weight="0.33"
69
                android:paddingLeft="5dp"
70
                android:gravity="right"
71
                android:textAppearance="?android:attr/textAppearanceSmall" />
72

  
73
        <TextView
74
                android:layout_width="wrap_content"
75
                android:layout_height="wrap_content"
76
                android:paddingLeft="5dp"
77
                android:gravity="left"
78
                android:text="@string/time"
79
                android:textAppearance="?android:attr/textAppearanceMedium" />
80
        <TextView
81
                android:id="@+id/meshfileTime"
82
                android:layout_width="0dp"
83
                android:layout_height="wrap_content"
84
                android:layout_weight="0.33"
85
                android:paddingLeft="5dp"
86
                android:gravity="right"
87
                android:textAppearance="?android:attr/textAppearanceSmall" />
88

  
89
    </LinearLayout>
90

  
37 91
</LinearLayout>
src/main/res/values/strings.xml
88 88
    <string name="rotate_left">Rotate Left</string>
89 89
    <string name="rotate_right">Rotate Right</string>
90 90
    <string name="open">Open</string>
91
    <string name="vertices">Vert</string>
92
    <string name="time">Time</string>
91 93

  
92 94
    <string name="quality0">Highest</string>
93 95
    <string name="quality1">High</string>

Also available in: Unified diff