| 49 |
49 |
private boolean mCanRotate;
|
| 50 |
50 |
private RubikCube mCube;
|
| 51 |
51 |
|
|
52 |
private int mScreenWidth, mScreenHeight;
|
|
53 |
|
| 52 |
54 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 53 |
55 |
|
| 54 |
56 |
RubikRenderer(RubikSurfaceView v)
|
| ... | ... | |
| 62 |
64 |
mQuatCurrent = new Static4D(0,0,0,1);
|
| 63 |
65 |
mQuatAccumulated = initializeQuat();
|
| 64 |
66 |
|
|
67 |
mScreenWidth = mScreenHeight = 0;
|
|
68 |
|
| 65 |
69 |
mMove = new Static3D(0,0,0);
|
| 66 |
70 |
mScale = new Static3D(1,1,1);
|
| 67 |
71 |
|
| ... | ... | |
| 129 |
133 |
mScreen.setProjection( fovInDegrees, 0.1f);
|
| 130 |
134 |
mView.setScreenSize(width,height);
|
| 131 |
135 |
mView.setCameraDist(cameraDistance);
|
|
136 |
mScreen.resize(width, height);
|
| 132 |
137 |
|
| 133 |
|
mCubeSizeInScreenSpace = CUBE_SCREEN_RATIO*(width>height ? height:width);
|
| 134 |
|
float texSize = mCube.getTextureSize();
|
| 135 |
|
float scaleFactor = mCubeSizeInScreenSpace/(texSize*mCube.getSize());
|
| 136 |
|
|
| 137 |
|
mMove.set( (width-scaleFactor*texSize)/2 , (height-scaleFactor*texSize)/2 , -scaleFactor*texSize/2 );
|
| 138 |
|
mScale.set(scaleFactor,scaleFactor,scaleFactor);
|
|
138 |
recomputeScaleFactor(width,height);
|
| 139 |
139 |
|
| 140 |
|
mScreen.resize(width, height);
|
|
140 |
mScreenHeight = height;
|
|
141 |
mScreenWidth = width;
|
| 141 |
142 |
}
|
| 142 |
143 |
|
| 143 |
144 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 184 |
185 |
|
| 185 |
186 |
if( oldSize!=newSize )
|
| 186 |
187 |
{
|
| 187 |
|
if( mCube!=null )
|
|
188 |
mCube = new RubikCube(newSize, mMove, mScale, mQuatCurrent, mQuatAccumulated);
|
|
189 |
mCube.createTexture();
|
|
190 |
|
|
191 |
if( mScreenWidth!=0 )
|
| 188 |
192 |
{
|
| 189 |
|
mScreen.detachAll();
|
|
193 |
recomputeScaleFactor(mScreenWidth,mScreenHeight);
|
| 190 |
194 |
}
|
| 191 |
195 |
|
| 192 |
|
mCube = new RubikCube(newSize, mMove, mScale, mQuatCurrent, mQuatAccumulated);
|
|
196 |
mScreen.detachAll();
|
| 193 |
197 |
mCube.attachToScreen(mScreen);
|
| 194 |
198 |
}
|
| 195 |
199 |
}
|
| 196 |
200 |
|
|
201 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
202 |
|
|
203 |
void recomputeScaleFactor(int screenWidth, int screenHeight)
|
|
204 |
{
|
|
205 |
mCubeSizeInScreenSpace = CUBE_SCREEN_RATIO*(screenWidth>screenHeight ? screenHeight:screenWidth);
|
|
206 |
float texSize = mCube.getTextureSize();
|
|
207 |
float scaleFactor = mCubeSizeInScreenSpace/(texSize*mCube.getSize());
|
|
208 |
|
|
209 |
mMove.set( (screenWidth-scaleFactor*texSize)/2 , (screenHeight-scaleFactor*texSize)/2 , -scaleFactor*texSize/2 );
|
|
210 |
mScale.set(scaleFactor,scaleFactor,scaleFactor);
|
|
211 |
}
|
|
212 |
|
| 197 |
213 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 198 |
214 |
|
| 199 |
215 |
void scrambleCube()
|
App: some progress changing to cube size.