Project

General

Profile

« Previous | Next » 

Revision 8982b894

Added by Leszek Koltunski over 4 years ago

Progress with MeshJoin.

View differences:

src/main/java/org/distorted/examples/meshjoin/MeshJoinActivity.java
20 20
package org.distorted.examples.meshjoin;
21 21

  
22 22
import android.app.Activity;
23
import android.opengl.GLSurfaceView;
23 24
import android.os.Bundle;
25
import android.view.View;
26
import android.widget.CheckBox;
24 27

  
28
import org.distorted.examples.R;
25 29
import org.distorted.library.main.DistortedLibrary;
26 30

  
27 31
///////////////////////////////////////////////////////////////////////////////////////////////////
28 32

  
29 33
public class MeshJoinActivity extends Activity
30 34
{
31
    private MeshJoinSurfaceView mView;
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
    
35 35
    @Override
36 36
    protected void onCreate(Bundle icicle) 
37 37
      {
38 38
      super.onCreate(icicle);
39
      mView = new MeshJoinSurfaceView(this);
40
      setContentView(mView);
39
      setContentView(R.layout.meshjoinlayout);
41 40
      }
42 41

  
43 42
///////////////////////////////////////////////////////////////////////////////////////////////////
......
45 44
    @Override
46 45
    protected void onPause() 
47 46
      {
48
      mView.onPause();
47
      GLSurfaceView view = this.findViewById(R.id.meshjoinSurfaceView);
48
      view.onPause();
49 49
      DistortedLibrary.onPause();
50 50
      super.onPause();
51 51
      }
......
56 56
    protected void onResume() 
57 57
      {
58 58
      super.onResume();
59
      mView.onResume();
59
      GLSurfaceView view = this.findViewById(R.id.meshjoinSurfaceView);
60
      view.onResume();
60 61
      }
61 62
    
62 63
///////////////////////////////////////////////////////////////////////////////////////////////////
......
67 68
      DistortedLibrary.onDestroy();
68 69
      super.onDestroy();
69 70
      }
70
    
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
    public void onClick(View view)
75
      {
76
      CheckBox box = (CheckBox)view;
77
      int id = box.getId();
78
      boolean checked = box.isChecked();
79
      MeshJoinSurfaceView sView = findViewById(R.id.meshjoinSurfaceView);
80

  
81
      switch(id)
82
        {
83
        case R.id.meshjoinCheckBox0  : sView.getRenderer().setChecked(0,checked); break;
84
        case R.id.meshjoinCheckBox1  : sView.getRenderer().setChecked(1,checked); break;
85
        case R.id.meshjoinCheckBox2  : sView.getRenderer().setChecked(2,checked); break;
86
        case R.id.meshjoinCheckBox3  : sView.getRenderer().setChecked(3,checked); break;
87
        }
88
      }
71 89
}
src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
135 135
        }
136 136
      }
137 137

  
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

  
140
    void setChecked(int number, boolean checked)
141
      {
142
      android.util.Log.e("renderer", "Checkbox "+number+" checked: "+checked);
143
      }
144

  
138 145
///////////////////////////////////////////////////////////////////////////////////////////////////
139 146

  
140 147
    private Bitmap createTetrahedronTexture()
......
225 232
      effect3.setMeshAssociation(15);  // apply to all 4 meshes
226 233
      effect4.setMeshAssociation(14);  // apply to mesh[1], [2] and [3]
227 234
      effect5.setMeshAssociation( 2);  // apply only to mesh[1]
228
      effect6.setMeshAssociation( 4);  // apply onlt to mesh[2]
235
      effect6.setMeshAssociation( 4);  // apply only to mesh[2]
229 236
      effect7.setMeshAssociation( 8);  // apply only to mesh[3]
230 237

  
231 238
      result.apply(effect1);
src/main/java/org/distorted/examples/meshjoin/MeshJoinSurfaceView.java
23 23
import android.content.Context;
24 24
import android.content.pm.ConfigurationInfo;
25 25
import android.opengl.GLSurfaceView;
26
import android.util.AttributeSet;
26 27
import android.view.MotionEvent;
27 28

  
28 29
///////////////////////////////////////////////////////////////////////////////////////////////////
......
35 36
	
36 37
///////////////////////////////////////////////////////////////////////////////////////////////////
37 38
   
38
    public MeshJoinSurfaceView(Context context)
39
    public MeshJoinSurfaceView(Context context, AttributeSet attrs)
39 40
      {
40
      super(context);
41
      super(context,attrs);
41 42
    
42 43
      mX = -1;
43 44
      mY = -1;
44 45

  
45
      mRenderer = new MeshJoinRenderer(this);
46
      final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
47
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
48
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
49
      setRenderer(mRenderer);
46
      if(!isInEditMode())
47
        {
48
        mRenderer = new MeshJoinRenderer(this);
49
        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
50
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
51
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
52
        setRenderer(mRenderer);
53
        }
50 54
      }
51 55

  
52 56
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/res/layout/meshjoinlayout.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="fill_parent"
4
    android:layout_height="fill_parent"
5
    android:orientation="vertical" >
6

  
7
    <org.distorted.examples.meshjoin.MeshJoinSurfaceView
8
        android:id="@+id/meshjoinSurfaceView"
9
        android:layout_width="fill_parent"
10
        android:layout_height="0dp"
11
        android:layout_weight="1" />
12

  
13
    <TextView
14
        android:layout_width="wrap_content"
15
        android:layout_height="wrap_content"
16
        android:layout_gravity="center"
17
        android:text="@string/association"
18
        android:textAppearance="?android:attr/textAppearanceMedium" />
19

  
20
    <LinearLayout
21
        android:orientation="horizontal"
22
        android:layout_width="match_parent"
23
        android:layout_height="wrap_content">
24

  
25
        <CheckBox
26
            android:layout_width="wrap_content"
27
            android:layout_height="match_parent"
28
            android:id="@+id/meshjoinCheckBox0"
29
            android:text="@string/color_yellow"
30
            android:onClick="onClick"
31
            android:layout_weight="1"
32
            android:checked="true"/>
33
        <CheckBox
34
            android:layout_width="wrap_content"
35
            android:layout_height="match_parent"
36
            android:id="@+id/meshjoinCheckBox1"
37
            android:text="@string/color_green"
38
            android:onClick="onClick"
39
            android:layout_weight="1"
40
            android:checked="true"/>
41
        <CheckBox
42
            android:layout_width="wrap_content"
43
            android:layout_height="match_parent"
44
            android:id="@+id/meshjoinCheckBox2"
45
            android:text="@string/color_blue"
46
            android:onClick="onClick"
47
            android:layout_weight="1"
48
            android:checked="true"/>
49
        <CheckBox
50
            android:layout_width="wrap_content"
51
            android:layout_height="match_parent"
52
            android:id="@+id/meshjoinCheckBox3"
53
            android:text="@string/color_red"
54
            android:onClick="onClick"
55
            android:layout_weight="1"
56
            android:checked="true"/>
57

  
58
    </LinearLayout>
59

  
60
</LinearLayout>
src/main/res/values/strings.xml
84 84
    <string name="scramble">Scramble</string>
85 85
    <string name="credits">Credits</string>
86 86
    <string name="start">Start</string>
87
    <string name="association">Sink Association</string>
87 88

  
88 89
    <string name="quality0">Highest</string>
89 90
    <string name="quality1">High</string>

Also available in: Unified diff