Project

General

Profile

« Previous | Next » 

Revision f0fa83ae

Added by Leszek Koltunski over 4 years ago

Some fixes for the Pyraminx.

View differences:

src/main/java/org/distorted/effect/scramble/ScrambleEffect.java
124 124
    }
125 125

  
126 126
///////////////////////////////////////////////////////////////////////////////////////////////////
127
// only works if basicAngle<=4, i.e. wont work for something whose basic rotations are by less
127
// only works if basicAngle<=4, i.e. wont work for something whose basic rotations are by no less
128 128
// than 90 degrees.
129 129

  
130 130
  private void addNewScramble()
......
154 154
        android.util.Log.e("effect", "ERROR: "+mNumDoubleScramblesLeft);
155 155
        }
156 156

  
157
      mCurrentBaseEffectID = mObject.addNewRotation(mLastVector, row, angle*90, durationMillis, this );
157
      mCurrentBaseEffectID = mObject.addNewRotation(mLastVector, row, angle*(360/mBasicAngle), durationMillis, this );
158 158
      }
159 159
    else
160 160
      {
src/main/java/org/distorted/object/RubikCube.java
25 25
import org.distorted.library.effect.MatrixEffect;
26 26
import org.distorted.library.effect.MatrixEffectMove;
27 27
import org.distorted.library.effect.MatrixEffectRotate;
28
import org.distorted.library.effect.VertexEffectSink;
28 29
import org.distorted.library.main.DistortedEffects;
29 30
import org.distorted.library.main.DistortedTexture;
30 31
import org.distorted.library.mesh.MeshBase;
......
117 118
    return FACE_COLORS.length;
118 119
    }
119 120

  
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122

  
123
  float getScreenRatio()
124
    {
125
    return 0.5f;
126
    }
127

  
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

  
130
  VertexEffectSink getSink(int size)
131
    {
132
    Static3D center = new Static3D(0,0,0);
133
    Static4D region = new Static4D(0,0,0,0.72f);
134
    float strength;
135

  
136
    switch(size)
137
      {
138
      case 1 : strength= 1.1f; break;
139
      case 2 : strength= 1.5f; break;
140
      case 3 : strength= 1.8f; break;
141
      case 4 : strength= 2.0f; break;
142
      default: strength= 3.0f - 4.0f/size;
143
      }
144

  
145
    return new VertexEffectSink( new Static1D(strength), center, region );
146
    }
147

  
120 148
///////////////////////////////////////////////////////////////////////////////////////////////////
121 149

  
122 150
  Static3D[] getRotationAxis()
src/main/java/org/distorted/object/RubikObject.java
46 46
public abstract class RubikObject extends DistortedNode
47 47
  {
48 48
  static final int TEXTURE_HEIGHT = 128;
49
  static final float OBJECT_SCREEN_RATIO = 0.5f;
50 49
  final float[] LEGAL_QUATS;
51 50
  final Static3D[] ROTATION_AXIS;
52 51

  
52
  static float OBJECT_SCREEN_RATIO;
53

  
53 54
  private static final int POST_ROTATION_MILLISEC = 500;
54 55
  private final int NUM_CUBITS;
55 56
  private int mRotRow;
......
83 84
    LEGAL_QUATS = getLegalQuats();
84 85
    NUM_CUBITS  = mOrigPos.length;
85 86
    ROTATION_AXIS = getRotationAxis();
87
    OBJECT_SCREEN_RATIO = getScreenRatio();
86 88

  
87 89
    mSize = size;
88 90
    computeStartAndStep(mOrigPos);
......
97 99
    mQuatAccumulated = quatAcc;
98 100

  
99 101
    Static3D center = new Static3D(0,0,0);
100
    Static4D region = new Static4D(0,0,0,0.65f); // 0.72 for a Cube  // TODO
101 102

  
102
    mSinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), center, region );
103
    mSinkEffect  = getSink(mSize);
103 104
    mScaleEffect = new MatrixEffectScale(mScale);
104 105
    mQuatCEffect = new MatrixEffectQuaternion(quatCur, center);
105 106
    mQuatAEffect = new MatrixEffectQuaternion(quatAcc, center);
......
199 200
    rotationAngle.add(mRotationAngleFinal);
200 201
    }
201 202

  
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

  
204
  private float getSinkStrength()
205
    {
206
    switch(mSize)
207
      {
208
      case 1 : return 1.1f;
209
      case 2 : return 1.5f;
210
      case 3 : return 1.8f;
211
      case 4 : return 2.0f;
212
      default: return 3.0f - 4.0f/mSize;
213
      }
214
    }
215

  
216 203
///////////////////////////////////////////////////////////////////////////////////////////////////
217 204
// Clamp all rotated positions to one of those original ones to avoid accumulating errors.
218 205

  
......
296 283

  
297 284
  public void recomputeScaleFactor(int scrWidth, int scrHeight)
298 285
    {
299
    float factor = scrWidth>scrHeight ? scrHeight : scrWidth;
286
    float factor = Math.min(scrWidth,scrHeight);
300 287
    float scaleFactor = OBJECT_SCREEN_RATIO*NODE_FBO_SIZE/mSize;
301 288

  
302 289
    mNodeScale.set(factor,factor,factor);
......
465 452

  
466 453
///////////////////////////////////////////////////////////////////////////////////////////////////
467 454

  
455
  abstract float getScreenRatio();
456
  abstract VertexEffectSink getSink(int size);
468 457
  abstract Static3D[] getCubitPositions(int size);
469 458
  abstract float[] getLegalQuats();
470 459
  abstract int getNumFaces();
src/main/java/org/distorted/object/RubikPyraminx.java
26 26
import org.distorted.library.effect.MatrixEffectMove;
27 27
import org.distorted.library.effect.MatrixEffectRotate;
28 28
import org.distorted.library.effect.MatrixEffectScale;
29
import org.distorted.library.effect.VertexEffectSink;
29 30
import org.distorted.library.main.DistortedEffects;
30 31
import org.distorted.library.main.DistortedTexture;
31 32
import org.distorted.library.mesh.MeshBase;
......
191 192
    return FACE_COLORS.length;
192 193
    }
193 194

  
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

  
197
  float getScreenRatio()
198
    {
199
    return 0.7f;
200
    }
201

  
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

  
204
  VertexEffectSink getSink(int size)
205
    {
206
    Static3D center = new Static3D(0,0,0);
207
    Static4D region = new Static4D(0,0,0,0.6f);
208
    return new VertexEffectSink( new Static1D(1.3f), center, region );
209
    }
210

  
194 211
///////////////////////////////////////////////////////////////////////////////////////////////////
195 212

  
196 213
  Static3D[] getRotationAxis()
......
203 220
  void createFaceTexture(Canvas canvas, Paint paint, int face)
204 221
    {
205 222
    int xoffset = face*TEXTURE_HEIGHT;
206
    float STROKE = 0.05f*TEXTURE_HEIGHT;
223
    float STROKE = 0.06f*TEXTURE_HEIGHT;
207 224
    float OFF = STROKE/2 -1;
208 225
    float OFF2 = 0.5f*TEXTURE_HEIGHT + OFF;
209 226
    float HEIGHT = TEXTURE_HEIGHT - OFF;
src/main/java/org/distorted/object/RubikPyraminxMovement.java
40 40

  
41 41
    public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
42 42
      {
43
      float cubeHalfSize= RubikObject.OBJECT_SCREEN_RATIO*0.5f;
44

  
45 43
      return false;
46 44
      }
47 45

  

Also available in: Unified diff