Revision 5974d2ae
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/object/RubikObject.java | ||
---|---|---|
42 | 42 |
public abstract class RubikObject extends DistortedNode |
43 | 43 |
{ |
44 | 44 |
static final float OBJECT_SCREEN_RATIO = 0.5f; |
45 |
static final int TEXTURE_SIZE = 100; |
|
46 | 45 |
final float[] LEGAL_QUATS; |
47 | 46 |
|
48 | 47 |
private static final int POST_ROTATION_MILLISEC = 500; |
... | ... | |
51 | 50 |
private Static3D mRotAxis; |
52 | 51 |
private Static3D mMove, mScale, mNodeMove, mNodeScale; |
53 | 52 |
private Static4D mQuatAccumulated; |
54 |
private DistortedTexture mNodeTexture; |
|
55 | 53 |
private Cubit[] mCubits; |
56 | 54 |
|
57 | 55 |
int mSize; |
... | ... | |
74 | 72 |
LEGAL_QUATS = getLegalQuats(); |
75 | 73 |
NUM_CUBITS = getNumCubits(size); |
76 | 74 |
|
77 |
mNodeTexture = texture; |
|
78 | 75 |
mSize = size; |
79 | 76 |
|
80 | 77 |
mRotationAngleStatic = new Static1D(0); |
... | ... | |
88 | 85 |
|
89 | 86 |
mQuatAccumulated = quatAcc; |
90 | 87 |
|
91 |
Static3D sinkCenter = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
|
|
88 |
Static3D sinkCenter = new Static3D(0.5f,0.5f,0.5f);
|
|
92 | 89 |
Static3D matrCenter = new Static3D(0,0,0); |
93 |
Static4D region = new Static4D(0,0,0, TEXTURE_SIZE*0.72f);
|
|
90 |
Static4D region = new Static4D(0,0,0,0.72f); |
|
94 | 91 |
|
95 | 92 |
mSinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), sinkCenter, region ); |
96 | 93 |
mMoveEffect = new MatrixEffectMove(mMove); |
... | ... | |
105 | 102 |
effects.apply(nodeMoveEffect); |
106 | 103 |
|
107 | 104 |
mCubits = new Cubit[NUM_CUBITS]; |
108 |
mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
|
|
105 |
mTexture = new DistortedTexture(); |
|
109 | 106 |
|
110 | 107 |
int vertices = (int)(24.0f/mSize + 2.0f); |
111 | 108 |
int[][] positions = getCubitPositions(size); |
... | ... | |
172 | 169 |
|
173 | 170 |
public void recomputeScaleFactor(int screenWidth, int screenHeight) |
174 | 171 |
{ |
175 |
int texW = mNodeTexture.getWidth();
|
|
176 |
int texH = mNodeTexture.getHeight();
|
|
172 |
int sizeX = getEffects().getStartchX();
|
|
173 |
int sizeY = getEffects().getStartchY();
|
|
177 | 174 |
|
178 |
if( (float)texH/texW > (float)screenHeight/screenWidth )
|
|
175 |
if( (float)sizeY/sizeX > (float)screenHeight/screenWidth )
|
|
179 | 176 |
{ |
180 |
int w = (screenHeight*texW)/texH;
|
|
181 |
float factor = (float)screenHeight/texH;
|
|
177 |
int w = (screenHeight*sizeX)/sizeY;
|
|
178 |
float factor = (float)screenHeight/sizeY;
|
|
182 | 179 |
mNodeMove.set((screenWidth-w)*0.5f ,0, 0); |
183 | 180 |
mNodeScale.set(factor,factor,factor); |
184 | 181 |
} |
185 | 182 |
else |
186 | 183 |
{ |
187 |
int h = (screenWidth*texH)/texW;
|
|
188 |
float factor = (float)screenWidth/texW;
|
|
184 |
int h = (screenWidth*sizeY)/sizeX;
|
|
185 |
float factor = (float)screenWidth/sizeX;
|
|
189 | 186 |
mNodeMove.set(0,(screenHeight-h)*0.5f,0); |
190 | 187 |
mNodeScale.set(factor,factor,factor); |
191 | 188 |
} |
192 | 189 |
|
193 |
float scaleFactor = (OBJECT_SCREEN_RATIO*texW/(TEXTURE_SIZE*mSize));
|
|
190 |
float scaleFactor = (OBJECT_SCREEN_RATIO*sizeX/mSize);
|
|
194 | 191 |
|
195 |
mMove.set( texW*0.5f , texH*0.5f , 0.0f );
|
|
192 |
mMove.set( sizeX*0.5f , sizeY*0.5f , 0.0f );
|
|
196 | 193 |
mScale.set(scaleFactor,scaleFactor,scaleFactor); |
197 | 194 |
} |
198 | 195 |
|
Also available in: Unified diff
Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)