Project

General

Profile

« Previous | Next » 

Revision 5ba13c05

Added by Leszek Koltunski almost 5 years ago

Convert RubikCube to the new V&F center schema!

View differences:

src/main/java/org/distorted/effect/sizechange/SizeChangeEffectTransparency.java
60 60
    Dynamic5D d1 = new Dynamic5D(duration/2, 0.5f);
61 61
    d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) );
62 62
    d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) );
63
    Static3D center = new Static3D(min*0.5f,min*0.5f,0);
63
    Static3D center = new Static3D(0,0,0);
64 64
    mNodeEffects[0][0] = new VertexEffectWave(d1, center, null);
65 65

  
66 66
    return 2;
......
96 96
    Dynamic5D d1 = new Dynamic5D(duration/2, 0.5f);
97 97
    d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) );
98 98
    d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) );
99
    Static3D center = new Static3D(min*0.5f,min*0.5f,0);
99
    Static3D center = new Static3D(0,0,0);
100 100
    mNodeEffects[1][0] = new VertexEffectWave(d1, center, null);
101 101

  
102 102
    return 2;
src/main/java/org/distorted/effect/win/WinEffectGlow.java
63 63
    degreeDyn.add(new Static1D(2.5f));
64 64
    degreeDyn.add(new Static1D(1.0f));
65 65

  
66
    float centerPoint = NODE_MESH_SIZE *0.5f;
67
    Static3D center = new Static3D(centerPoint,centerPoint,centerPoint);
68

  
66
    Static3D center = new Static3D(0,0,NODE_MESH_SIZE *0.5f);
69 67
    mNodeEffects[1] = new VertexEffectSink(degreeDyn,center);
70 68
    }
71 69

  
src/main/java/org/distorted/object/Cubit.java
160 160
    float z = position.get2();
161 161

  
162 162
    float nc = parent.mSize*0.5f;
163
    Static3D vector = new Static3D(x-nc, y-nc, z-nc);
163
    Static3D vector = new Static3D(x-nc+0.5f, y-nc+0.5f, z-nc+0.5f);
164 164

  
165 165
    mParent          = parent;
166 166
    mMesh            = mesh;
......
179 179
    mEffect.apply(mParent.mQuatAEffect);
180 180
    mEffect.apply(mParent.mQuatCEffect);
181 181
    mEffect.apply(mParent.mScaleEffect);
182
    mEffect.apply(mParent.mMoveEffect);
183 182

  
184 183
    mNode = new DistortedNode(mParent.mTexture,mEffect,mMesh);
185 184
    }
src/main/java/org/distorted/object/RubikObject.java
22 22
import android.content.SharedPreferences;
23 23

  
24 24
import org.distorted.library.effect.Effect;
25
import org.distorted.library.effect.MatrixEffectMove;
26 25
import org.distorted.library.effect.MatrixEffectQuaternion;
27 26
import org.distorted.library.effect.MatrixEffectScale;
28 27
import org.distorted.library.effect.VertexEffectSink;
......
48 47
  private final int NUM_CUBITS;
49 48
  private int mRotRow;
50 49
  private Static3D mRotAxis;
51
  private Static3D mMove, mScale, mNodeMove, mNodeScale;
50
  private Static3D mScale, mNodeScale;
52 51
  private Static4D mQuatAccumulated;
53 52
  private Cubit[] mCubits;
54 53

  
......
58 57
  DistortedTexture mTexture;
59 58

  
60 59
  VertexEffectSink mSinkEffect;
61
  MatrixEffectMove mMoveEffect;
62 60
  MatrixEffectScale mScaleEffect;
63 61
  MatrixEffectQuaternion mQuatCEffect;
64 62
  MatrixEffectQuaternion mQuatAEffect;
......
78 76
    mRotationAngleMiddle = new Static1D(0);
79 77
    mRotationAngleFinal  = new Static1D(0);
80 78

  
81
    mMove     = new Static3D(0,0,0);
82 79
    mScale    = new Static3D(1,1,1);
83
    mNodeMove = new Static3D(0,0,0);
84 80
    mNodeScale= new Static3D(1,1,1);
85 81

  
86 82
    mQuatAccumulated = quatAcc;
87 83

  
88
    Static3D sinkCenter = new Static3D(0.5f,0.5f,0.5f);
89
    Static3D matrCenter = new Static3D(0,0,0);
84
    Static3D center = new Static3D(0,0,0);
90 85
    Static4D region = new Static4D(0,0,0,0.72f);
91 86

  
92
    mSinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), sinkCenter, region );
93
    mMoveEffect = new MatrixEffectMove(mMove);
87
    mSinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), center, region );
94 88
    mScaleEffect = new MatrixEffectScale(mScale);
95
    mQuatCEffect = new MatrixEffectQuaternion(quatCur, matrCenter);
96
    mQuatAEffect = new MatrixEffectQuaternion(quatAcc, matrCenter);
89
    mQuatCEffect = new MatrixEffectQuaternion(quatCur, center);
90
    mQuatAEffect = new MatrixEffectQuaternion(quatAcc, center);
97 91

  
98
    MatrixEffectMove  nodeMoveEffect  = new MatrixEffectMove(mNodeMove);
99 92
    MatrixEffectScale nodeScaleEffect = new MatrixEffectScale(mNodeScale);
100 93

  
101 94
    effects.apply(nodeScaleEffect);
102
    effects.apply(nodeMoveEffect);
103 95

  
104 96
    mCubits = new Cubit[NUM_CUBITS];
105 97
    mTexture = new DistortedTexture();
......
167 159

  
168 160
///////////////////////////////////////////////////////////////////////////////////////////////////
169 161

  
170
  public void recomputeScaleFactor(int screenWidth, int screenHeight)
162
  public void recomputeScaleFactor(int scrWidth, int scrHeight)
171 163
    {
172
    float sizeX = getMesh().getStretchX();
173
    float sizeY = getMesh().getStretchY();
164
    float mx = getMesh().getStretchX();
165
    float my = getMesh().getStretchY();
166
    float factor = (my/mx > (float)scrHeight/scrWidth) ? (float)scrHeight/my : (float)scrWidth/mx;
167
    float scaleFactor = (OBJECT_SCREEN_RATIO*mx/mSize);
174 168

  
175
    if( sizeY/sizeX > (float)screenHeight/screenWidth )
176
      {
177
      float w = (screenHeight*sizeX)/sizeY;
178
      float factor = (float)screenHeight/sizeY;
179
      mNodeMove.set((screenWidth-w)*0.5f ,0, 0);
180
      mNodeScale.set(factor,factor,factor);
181
      }
182
    else
183
      {
184
      float h = (screenWidth*sizeY)/sizeX;
185
      float factor = (float)screenWidth/sizeX;
186
      mNodeMove.set(0,(screenHeight-h)*0.5f,0);
187
      mNodeScale.set(factor,factor,factor);
188
      }
189

  
190
    float scaleFactor = (OBJECT_SCREEN_RATIO*sizeX/mSize);
191

  
192
    mMove.set( sizeX*0.5f , sizeY*0.5f , 0.0f );
169
    mNodeScale.set(factor,factor,factor);
193 170
    mScale.set(scaleFactor,scaleFactor,scaleFactor);
194 171
    }
195 172

  

Also available in: Unified diff