Project

General

Profile

« Previous | Next » 

Revision 39b925d5

Added by Leszek Koltunski over 3 years ago

Progress with the MeshFile app: disappear works now.

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
33 33

  
34 34
import org.distorted.examples.R;
35 35
import org.distorted.library.main.DistortedLibrary;
36
import org.distorted.library.mesh.MeshFile;
36 37

  
37 38
///////////////////////////////////////////////////////////////////////////////////////////////////
38 39

  
......
40 41
                                                          SeekBar.OnSeekBarChangeListener,
41 42
                                                          View.OnClickListener
42 43
{
44
    private static final int OFFSET = 100000;
45

  
43 46
    private LinearLayout mLayout;
44 47
    private int mResource;
45 48
    private String[] mNames = new String[] { "deferredjob",
......
153 156
      TextView index = view.findViewById(R.id.meshfileComponentText);
154 157
      index.setText(String.valueOf(endIndex));
155 158

  
156
      Button butt = view.findViewById(R.id.meshfileComponentDisappear);
157
      butt.setId(component);
158
      butt.setOnClickListener(this);
159
      Button disappear = view.findViewById(R.id.meshfileComponentDisappear);
160
      disappear.setId(component);
161
      disappear.setOnClickListener(this);
162

  
163
      Button appear = view.findViewById(R.id.meshfileComponentAppear);
164
      appear.setId(component+OFFSET);
165
      appear.setOnClickListener(this);
159 166

  
160 167
      return view;
161 168
      }
......
190 197

  
191 198
///////////////////////////////////////////////////////////////////////////////////////////////////
192 199

  
193
  @Override
194
  public void onClick(View v)
195
    {
196
    int id = v.getId();
200
    @Override
201
    public void onClick(View v)
202
      {
203
      int id = v.getId();
204

  
205
      MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
206
      MeshFileRenderer renderer = view.getRenderer();
197 207

  
198
    android.util.Log.e("act", "clicked: "+id);
199
    }
208
      MeshFile mesh = renderer.getMesh();
209

  
210
      if( id>=OFFSET )
211
        {
212
        id -= OFFSET;
213
        mesh.setEffectAssociation(id,0,id);
214
        }
215
      else
216
        {
217
        mesh.setEffectAssociation(id,1,id);
218
        }
219
      }
200 220

  
201 221
///////////////////////////////////////////////////////////////////////////////////////////////////
202 222

  
src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
29 29
import org.distorted.examples.R;
30 30
import org.distorted.library.effect.MatrixEffectQuaternion;
31 31
import org.distorted.library.effect.MatrixEffectScale;
32
import org.distorted.library.effect.VertexEffectDisappear;
32 33
import org.distorted.library.main.DistortedEffects;
33 34
import org.distorted.library.main.DistortedLibrary;
34 35
import org.distorted.library.main.DistortedScreen;
......
83 84
      quatInt1.add(mQuat1);
84 85
      quatInt2.add(mQuat2);
85 86

  
87
      VertexEffectDisappear disappear = new VertexEffectDisappear();
88
      disappear.setMeshAssociation(1,-1);
89

  
86 90
      mEffects = new DistortedEffects();
87 91
      mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
88 92
      mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
89 93
      mEffects.apply( new MatrixEffectScale(mScale));
90 94

  
95
      mEffects.apply( disappear );
96

  
91 97
      mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
92 98
      mScreen.showFPS();
93 99
      }
......
115 121
      {
116 122
      if( mTexture==null ) mTexture = new DistortedTexture();
117 123

  
124
      VertexEffectDisappear.enable();
125

  
118 126
      DistortedLibrary.onCreate(mView.getContext(), this);
119 127
      }
120 128

  
......
304 312
      DataInputStream dos = new DataInputStream(is);
305 313
      mMesh = new MeshFile(dos);
306 314

  
315
      int numEff = mMesh.numEffComponents();
316

  
317
      for(int i=0; i<numEff; i++)
318
        {
319
        mMesh.setEffectAssociation(i, 0, i);
320
        }
321

  
307 322
      try
308 323
        {
309 324
        is.close();
......
314 329
        }
315 330
      }
316 331

  
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

  
334
    MeshFile getMesh()
335
      {
336
      return mMesh;
337
      }
338

  
317 339
///////////////////////////////////////////////////////////////////////////////////////////////////
318 340

  
319 341
    long getTime()
src/main/res/layout/meshfilecomponent.xml
22 22
          android:layout_marginTop="5dp"
23 23
          android:layout_weight="1"/>
24 24

  
25
     <Button
26
          android:id="@+id/meshfileComponentAppear"
27
          android:text="@string/appear"
28
          android:layout_width="wrap_content"
29
          android:layout_height="wrap_content"
30
          android:layout_weight="0.2"
31
          android:layout_marginEnd="5dp"
32
          android:layout_marginStart="5dp"
33
          android:layout_marginTop="5dp"/>
34

  
25 35
     <Button
26 36
          android:id="@+id/meshfileComponentDisappear"
27 37
          android:text="@string/disappear"
......
29 39
          android:layout_height="wrap_content"
30 40
          android:layout_weight="0.2"
31 41
          android:layout_marginEnd="5dp"
32
          android:layout_marginStart="10dp"
42
          android:layout_marginStart="5dp"
33 43
          android:layout_marginTop="5dp"/>
34 44
</LinearLayout>

Also available in: Unified diff