Project

General

Profile

« Previous | Next » 

Revision c279ea6d

Added by Leszek Koltunski over 2 years ago

Progress with BandagedCreator.

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java
41 41
public class BandagedCreatorActivity extends AppCompatActivity
42 42
{
43 43
    private static final int ACTIVITY_NUMBER = 3;
44
    private static final float RATIO_BAR   = 0.10f;
45
    private static final float RATIO_SCROLL= 0.30f;
44
    static final float RATIO_BAR   = 0.10f;
45
    static final float RATIO_SCROLL= 0.30f;
46 46

  
47 47
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
48 48
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java
38 38
   private final GLSurfaceView mView;
39 39
   private final DistortedScreen mScreen;
40 40
   private final Static3D mScale;
41
   private final Static3D mMoveWhole;
41 42
   private final Static3D[] mMove;
43
   private final Static3D[] mMoveUnscaled;
44
   private final BandagedCubit[] mCubits;
45

  
46
   private final int COLOR_DEFAULT = 0xffffff55;
42 47

  
43 48
   private final float[][] POSITIONS = new float[][]
44 49
        {
......
80 85
     final float BRIGHTNESS = 0.333f;
81 86

  
82 87
     mQuat1 = new Static4D(0,0,0,1);
83
     mQuat2 = new Static4D(0,0,0,1);
88
     mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
84 89

  
85 90
     mView = v;
86 91

  
87 92
     mScreen = new DistortedScreen();
88 93
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
89 94
     mScale= new Static3D(1,1,1);
95
     mMoveWhole = new Static3D(0,0,0);
90 96

  
91 97
     int len = POSITIONS.length;
92
     mMove = new Static3D[len];
98
     mMove         = new Static3D[len];
99
     mMoveUnscaled = new Static3D[len];
93 100

  
94
     for(int i=0; i<len; i++) mMove[i] = new Static3D(0,0,0);
101
     for(int i=0; i<len; i++)
102
       {
103
       mMove[i] = new Static3D(0,0,0);
104
       mMoveUnscaled[i] = new Static3D(0,0,0);
105
       }
95 106

  
96
     BandagedCubit[] cubits = createCubits();
107
     mCubits = createCubits();
97 108
     }
98 109

  
99 110
///////////////////////////////////////////////////////////////////////////////////////////////////
......
105 116

  
106 117
     for(int c=0; c<len; c++)
107 118
       {
108
       computeMove(mMove[c],POSITIONS[c]);
109
       cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,mMove[c],mScale);
110
       DistortedNode node = cubits[c].getNode();
111
       mScreen.attach(node);
119
       computeMove(mMoveUnscaled[c],POSITIONS[c]);
120
       cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,mMove[c],mMoveWhole,mScale, COLOR_DEFAULT);
112 121
       }
113 122

  
114 123
     return cubits;
......
152 161
      final float Q = 0.15f;
153 162
      float scale = width<height ? Q*width : Q*height;
154 163

  
164
      mScreen.detachAll();
155 165
      int len = POSITIONS.length;
156 166

  
157 167
      for(int i=0; i<len; i++)
158 168
        {
159
        float x = mMove[i].get0();
160
        float y = mMove[i].get1();
161
        float z = mMove[i].get2();
169
        float x = mMoveUnscaled[i].get0();
170
        float y = mMoveUnscaled[i].get1();
171
        float z = mMoveUnscaled[i].get2();
162 172

  
163 173
        mMove[i].set(x*scale,y*scale,z*scale);
174

  
175
        mCubits[i].setTexture(COLOR_DEFAULT);
176
        DistortedNode node = mCubits[i].getNode();
177
        mScreen.attach(node);
164 178
        }
165 179

  
180
      float RB = BandagedCreatorActivity.RATIO_BAR;
181
      float RS = BandagedCreatorActivity.RATIO_SCROLL;
182
      float yOffset = (0.5f*RB/(1-RS))*height;
183
      mMoveWhole.set1(yOffset);
184

  
166 185
      mScale.set( scale,scale,scale );
167 186
      mScreenMin = Math.min(width, height);
168 187
      mScreen.resize(width,height);
src/main/java/org/distorted/bandaged/BandagedCubit.java
46 46
// PUBLIC API
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
48 48

  
49
    public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, Static3D move, Static3D scale)
49
    public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, Static3D move1, Static3D move2, Static3D scale, int color)
50 50
      {
51 51
      mPosition = position;
52 52

  
......
54 54
      mMesh = factory.createMesh(position);
55 55

  
56 56
      mTexture = new DistortedTexture();
57
      mTexture.setColorARGB(0xffffff55);
57
      mTexture.setColorARGB(color);
58 58

  
59 59
      MatrixEffectScale scaleEffect = new MatrixEffectScale(scale);
60 60
      MatrixEffectQuaternion quat1Effect = new MatrixEffectQuaternion(quat1, CENTER);
61 61
      MatrixEffectQuaternion quat2Effect = new MatrixEffectQuaternion(quat2, CENTER);
62
      MatrixEffectMove moveEffect = new MatrixEffectMove(move);
62
      MatrixEffectMove move1Effect = new MatrixEffectMove(move1);
63
      MatrixEffectMove move2Effect = new MatrixEffectMove(move2);
63 64

  
64 65
      mEffects = new DistortedEffects();
65 66
      mEffects.apply(scaleEffect);
66
      mEffects.apply(moveEffect);
67
      mEffects.apply(move1Effect);
67 68
      mEffects.apply(quat2Effect);
68 69
      mEffects.apply(quat1Effect);
70
      mEffects.apply(move2Effect);
69 71

  
70 72
      mNode = new DistortedNode(mTexture,mEffects,mMesh);
71 73
      }
72 74

  
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

  
77
    public void setTexture(int color)
78
      {
79
      mTexture.setColorARGB(color);
80
      }
81

  
73 82
///////////////////////////////////////////////////////////////////////////////////////////////////
74 83

  
75 84
    public DistortedNode getNode()

Also available in: Unified diff