Project

General

Profile

« Previous | Next » 

Revision 45ab4482

Added by Leszek Koltunski over 3 years ago

Progress with RubikControl.

View differences:

src/main/java/org/distorted/control/RubikControlWhole.java
19 19

  
20 20
package org.distorted.control;
21 21

  
22
import android.graphics.Bitmap;
23
import android.graphics.BitmapFactory;
24

  
22 25
import org.distorted.library.effect.MatrixEffectScale;
23 26
import org.distorted.library.main.DistortedEffects;
24 27
import org.distorted.library.main.DistortedNode;
......
27 30
import org.distorted.library.type.Dynamic;
28 31
import org.distorted.library.type.Dynamic3D;
29 32
import org.distorted.library.type.Static3D;
33
import org.distorted.main.R;
34
import org.distorted.main.RubikActivity;
35

  
36
import java.io.IOException;
37
import java.io.InputStream;
30 38

  
31 39
///////////////////////////////////////////////////////////////////////////////////////////////////
32 40

  
33 41
class RubikControlWhole
34 42
  {
35
  private static final int NUM_NODE = 1;
43
  private static final int NUM_NODE = 2;
44
  private static final int NUM_EFFE = 2;
36 45

  
37 46
  private final RubikControl mControl;
38 47
  private DistortedEffects[] mEffects;
......
42 51
  private Dynamic3D mDynamic;
43 52
  private MatrixEffectScale mScale;
44 53

  
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

  
56
   private Bitmap openBitmap(RubikActivity act, int resource)
57
     {
58
     try(InputStream is = act.getResources().openRawResource(resource) )
59
       {
60
       return BitmapFactory.decodeStream(is);
61
       }
62
     catch(IOException e)
63
       {
64
       // ignore
65
       }
66

  
67
     return null;
68
     }
69

  
45 70
///////////////////////////////////////////////////////////////////////////////////////////////////
46 71

  
47 72
  private void createEffects()
48 73
    {
49 74
    if( mEffects==null )
50 75
      {
51
      mEffects   = new DistortedEffects[NUM_NODE];
76
      mEffects   = new DistortedEffects[NUM_EFFE];
52 77
      mEffects[0]= new DistortedEffects();
78
      mEffects[1]= new DistortedEffects();
53 79

  
54
      Static3D scaleStart= new Static3D(1,1,1);
55
      Static3D scaleEnd  = new Static3D(1000,1000,1000);
80
      float scaleCirc = 150;
81
      float scaleHand = 300;
82

  
83
      Static3D scale0 = new Static3D(scaleCirc,scaleCirc,scaleCirc);
84
      Static3D scale1 = new Static3D(scaleHand,scaleHand,scaleHand);
56 85

  
57 86
      mDynamic = new Dynamic3D(10000,0.5f);
58
      mDynamic.add(scaleStart);
59
      mDynamic.add(scaleEnd  );
60
      mDynamic.add(scaleStart);
87
      mDynamic.add(scale0);
61 88
      mDynamic.setMode(Dynamic.MODE_PATH);
62 89

  
63 90
      mScale = new MatrixEffectScale(mDynamic);
64 91
      mScale.notifyWhenFinished(mControl);
65 92
      mEffectID = mScale.getID();
66 93
      mEffects[0].apply(mScale);
94
      mEffects[1].apply( new MatrixEffectScale(scale1));
67 95
      }
68 96
    else
69 97
      {
......
79 107
    if( mNodes==null )
80 108
      {
81 109
      mNodes = new DistortedNode[NUM_NODE];
82
      MeshQuad mesh = new MeshQuad();
83
      DistortedTexture texture = new DistortedTexture();
84
      texture.setColorARGB(0xffff0000);
85

  
86
      mNodes[0]= new DistortedNode(texture,mEffects[0],mesh);
110
      RubikActivity act = mControl.getActivity();
111

  
112
      if( act!=null )
113
        {
114
        MeshQuad mesh = new MeshQuad();
115

  
116
        Bitmap bmpCirc = openBitmap(act, R.drawable.ui_fading_circle);
117
        DistortedTexture textureCirc = new DistortedTexture();
118
        textureCirc.setTexture(bmpCirc);
119
        mNodes[0]= new DistortedNode(textureCirc,mEffects[0],mesh);
120

  
121
        Bitmap bmpHand = openBitmap(act, R.drawable.ui_hand_pointer);
122
        DistortedTexture textureHand = new DistortedTexture();
123
        textureHand.setTexture(bmpHand);
124
        mNodes[1]= new DistortedNode(textureHand,mEffects[1],mesh);
125
        }
126
      else
127
        {
128
        android.util.Log.e("D", "Activity NULL!!");
129
        }
87 130
      }
88 131
    }
89 132

  

Also available in: Unified diff