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 |
|
Convert RubikCube to the new V&F center schema!