Revision 16b22aab
Added by Leszek Koltunski about 5 years ago
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
60 | 60 |
private MeshFlat mMesh; |
61 | 61 |
private int mScreenW, mScreenH; |
62 | 62 |
private int mPrevRendered, mCurrRendered; |
63 |
private Static3D mMove, mScale;
|
|
63 |
private Static3D mScale; |
|
64 | 64 |
|
65 | 65 |
private DistortedNode[] mCircleNode = new DistortedNode[NUM_CIRCLES]; |
66 | 66 |
private DistortedEffects[] mEffects = new DistortedEffects[NUM_LEAVES]; |
... | ... | |
96 | 96 |
mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE); |
97 | 97 |
DistortedTexture surface = new DistortedTexture(3*LEAF_SIZE,3*LEAF_SIZE); |
98 | 98 |
mMesh = new MeshFlat(1,1); |
99 |
mMove = new Static3D(0,0,0); |
|
100 | 99 |
mScale= new Static3D(1,1,1); |
101 | 100 |
|
102 | 101 |
DistortedEffects effects = new DistortedEffects(); |
103 |
effects.apply(new MatrixEffectMove(mMove)); |
|
104 | 102 |
effects.apply(new MatrixEffectScale(mScale)); |
105 | 103 |
|
106 | 104 |
mScreenW = 9*LEAF_SIZE; |
107 | 105 |
mScreenH = 9*LEAF_SIZE; |
108 |
mRoot = new DistortedNode(new DistortedTexture(mScreenW,mScreenH), effects, mMesh); |
|
106 |
DistortedTexture rootTexture = new DistortedTexture(mScreenW,mScreenH); |
|
107 |
mRoot = new DistortedNode(rootTexture, effects, mMesh); |
|
109 | 108 |
|
110 | 109 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
111 | 110 |
rot.setMode(Dynamic1D.MODE_JUMP); |
... | ... | |
113 | 112 |
rot.add(new Static1D(360)); |
114 | 113 |
|
115 | 114 |
int[] colors = new int[] {0,0,1, 0,0,0, 1,0,0, 1,1,0, 0,1,0}; // blue, black, red, yellow, green |
116 |
int[] positions = new int[] {0,4*LEAF_SIZE, 3*LEAF_SIZE,4*LEAF_SIZE, 6*LEAF_SIZE,4*LEAF_SIZE, 3*LEAF_SIZE/2,3*LEAF_SIZE/2, 9*LEAF_SIZE/2,3*LEAF_SIZE/2}; |
|
115 |
int[] positions = new int[] {-3*LEAF_SIZE , LEAF_SIZE , |
|
116 |
0 , LEAF_SIZE , |
|
117 |
3*LEAF_SIZE , LEAF_SIZE , |
|
118 |
-3*LEAF_SIZE/2,-3*LEAF_SIZE/2, |
|
119 |
3*LEAF_SIZE/2,-3*LEAF_SIZE/2 }; |
|
117 | 120 |
|
118 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0);
|
|
121 |
Static3D center = new Static3D(0,0,0);
|
|
119 | 122 |
Static3D axis = new Static3D(0,0,1); |
120 |
Static3D moveVector = new Static3D(0,LEAF_SIZE,0);
|
|
123 |
Static3D moveVector = new Static3D(-LEAF_SIZE,0,0);
|
|
121 | 124 |
|
122 | 125 |
for(int j=0; j<NUM_LEAVES; j++) |
123 | 126 |
{ |
... | ... | |
169 | 172 |
|
170 | 173 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
171 | 174 |
{ |
172 |
if( (float)mScreenH/mScreenW > (float)height/width ) |
|
173 |
{ |
|
174 |
int w = (height*mScreenW)/mScreenH; |
|
175 |
float factor = (float)height/mScreenH; |
|
176 |
mMove.set((width-w)/2 ,0, 0); |
|
177 |
mScale.set(factor,factor,factor); |
|
178 |
} |
|
179 |
else |
|
180 |
{ |
|
181 |
int h = (width*mScreenH)/mScreenW; |
|
182 |
float factor = (float)width/mScreenW; |
|
183 |
mMove.set(0,(height-h)/2,0); |
|
184 |
mScale.set(factor,factor,factor); |
|
185 |
} |
|
186 |
|
|
175 |
float horiRatio = (float)width / mScreenW; |
|
176 |
float vertRatio = (float)height/ mScreenH; |
|
177 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio; |
|
178 |
|
|
179 |
mScale.set(factor,factor,factor); |
|
187 | 180 |
mScreen.resize(width, height); |
188 | 181 |
} |
189 | 182 |
|
Also available in: Unified diff
Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.