Revision 39a0d81b
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
96 | 96 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
97 | 97 |
{ |
98 | 98 |
mScreenMin = width<height ? width:height; |
99 |
|
|
100 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
101 |
float factor; |
|
102 |
|
|
103 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
|
104 |
{ |
|
105 |
factor = (0.75f*height)/mObjHeight; |
|
106 |
} |
|
107 |
else |
|
108 |
{ |
|
109 |
factor = (0.75f*width)/mObjWidth; |
|
110 |
} |
|
111 | 99 |
|
112 |
mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
113 |
mEffects.scale(factor);
|
|
114 |
Static3D center = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, 0.0f );
|
|
100 |
float q= ((float)width/height)*((float)mObjHeight/mObjWidth);
|
|
101 |
float scale = 0.7f;
|
|
102 |
Static3D center = new Static3D(0,0,0);
|
|
115 | 103 |
|
104 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
116 | 105 |
mEffects.quaternion(mQuatInt1, center); |
117 | 106 |
mEffects.quaternion(mQuatInt2, center); |
118 |
|
|
107 |
mEffects.scale( q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)) ); |
|
108 |
|
|
119 | 109 |
mScreen.resize(width, height); |
120 | 110 |
} |
121 | 111 |
|
src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
---|---|---|
150 | 150 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
151 | 151 |
{ |
152 | 152 |
mScreenMin = width<height ? width:height; |
153 |
|
|
154 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
155 |
float factor; |
|
156 |
|
|
157 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
|
158 |
{ |
|
159 |
factor = (0.8f*height)/mObjHeight; |
|
160 |
} |
|
161 |
else |
|
162 |
{ |
|
163 |
factor = (0.8f*width)/mObjWidth; |
|
164 |
} |
|
165 | 153 |
|
166 |
mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
167 |
mEffects.scale(factor);
|
|
168 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0);
|
|
154 |
float q= ((float)width/height)*((float)mObjHeight/mObjWidth);
|
|
155 |
float scale = 0.8f;
|
|
156 |
Static3D center = new Static3D(0,0,0);
|
|
169 | 157 |
|
158 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
170 | 159 |
mEffects.quaternion(mQuatInt1, center); |
171 | 160 |
mEffects.quaternion(mQuatInt2, center); |
172 |
|
|
161 |
mEffects.scale( q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)) ); |
|
162 |
|
|
173 | 163 |
mScreen.resize(width, height); |
174 | 164 |
} |
175 | 165 |
|
src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java | ||
---|---|---|
50 | 50 |
if( savedState==null ) |
51 | 51 |
{ |
52 | 52 |
distanceBar.setProgress(50); |
53 |
rangeBar.setProgress(10);
|
|
53 |
rangeBar.setProgress(50);
|
|
54 | 54 |
} |
55 | 55 |
} |
56 | 56 |
|
src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
---|---|---|
68 | 68 |
}; |
69 | 69 |
|
70 | 70 |
private static final int NUM_OBJECTS = MOVE_VEC.length/3; |
71 |
private static final int OBJ_SIZE = 100; |
|
72 | 71 |
|
73 | 72 |
private GLSurfaceView mView; |
74 | 73 |
private DistortedTexture mTex1, mTex2; |
... | ... | |
83 | 82 |
private DynamicQuat mQuatInt1, mQuatInt2; |
84 | 83 |
private int mDistance; |
85 | 84 |
private boolean[] mBlurStatus; |
85 |
private int mScreenW, mScreenH; |
|
86 | 86 |
|
87 | 87 |
Static4D mQuat1, mQuat2; |
88 | 88 |
int mScreenMin; |
... | ... | |
114 | 114 |
fpsTexture.setTexture(fpsBitmap); |
115 | 115 |
fpsCanvas = new Canvas(fpsBitmap); |
116 | 116 |
fpsEffects = new DistortedEffects(); |
117 |
fpsEffects.move( new Static3D(5,5,0) ); |
|
118 | 117 |
durations = new long[NUM_FRAMES+1]; |
119 | 118 |
currDuration = 0; |
120 | 119 |
|
... | ... | |
149 | 148 |
|
150 | 149 |
MeshCubes mesh = new MeshCubes(1,1,false); |
151 | 150 |
|
152 |
mTex1 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
|
|
153 |
mTex2 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
|
|
151 |
mTex1 = new DistortedTexture(1,1);
|
|
152 |
mTex2 = new DistortedTexture(1,1);
|
|
154 | 153 |
|
155 | 154 |
mQuat1 = new Static4D(0,0,0,1); // unity |
156 | 155 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
... | ... | |
196 | 195 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
197 | 196 |
{ |
198 | 197 |
mScreenMin = width<height ? width:height; |
198 |
mScreenW = width; |
|
199 |
mScreenH = height; |
|
199 | 200 |
|
200 |
float factor = 0.15f*mScreenMin/OBJ_SIZE; |
|
201 |
Static3D center = new Static3D( (float)OBJ_SIZE/2, (float)OBJ_SIZE/2, 0.0f ); |
|
202 |
Static3D moveVec= new Static3D( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0); |
|
201 |
fpsEffects.abortAllEffects(); |
|
202 |
fpsEffects.move( new Static3D( -0.5f + (fpsW/2 + 5.0f)/width, -0.5f + (fpsH/2 + 5.0f)/height,0.0f) ); |
|
203 |
fpsEffects.scale( new Static3D( (float)fpsW/width, (float)fpsH/height, 1.0f) ); |
|
204 |
|
|
205 |
float q= (float)width/height; |
|
206 |
float scale = 0.15f; |
|
207 |
Static3D center = new Static3D(0,0,0); |
|
208 |
Static3D factor = (q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q))); |
|
203 | 209 |
|
204 | 210 |
for(int i=0; i<NUM_OBJECTS; i++) |
205 | 211 |
{ |
206 | 212 |
mEffects[i].abortEffects(EffectTypes.MATRIX); |
207 | 213 |
|
208 |
mEffects[i].move(moveVec); |
|
209 |
mEffects[i].scale(factor); |
|
210 | 214 |
mEffects[i].quaternion(mQuatInt1, center); |
211 | 215 |
mEffects[i].quaternion(mQuatInt2, center); |
212 | 216 |
mEffects[i].move(mMoveDynamic[i]); |
217 |
mEffects[i].scale(factor); |
|
213 | 218 |
} |
214 | 219 |
|
215 | 220 |
computeMoveVectors(); |
... | ... | |
275 | 280 |
|
276 | 281 |
private void computeMoveVectors() |
277 | 282 |
{ |
278 |
float size= 0.026f*OBJ_SIZE*mDistance; |
|
283 |
float size = 2.6f*mDistance; |
|
284 |
float sizeX= size/mScreenW; |
|
285 |
float sizeY= size/mScreenH; |
|
279 | 286 |
|
280 | 287 |
for(int i=0; i<NUM_OBJECTS; i++) |
281 | 288 |
{ |
282 |
mMoveVector[i].set(size*MOVE_VEC[3*i], size*MOVE_VEC[3*i+1], size*MOVE_VEC[3*i+2]);
|
|
289 |
mMoveVector[i].set(sizeX*MOVE_VEC[3*i], sizeY*MOVE_VEC[3*i+1], sizeX*MOVE_VEC[3*i+2]);
|
|
283 | 290 |
} |
284 | 291 |
} |
285 | 292 |
|
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
98 | 98 |
|
99 | 99 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
100 | 100 |
{ |
101 |
float qx = (float)width ; |
|
102 |
float qy = (float)height; |
|
101 |
float q= (float)width/height; |
|
103 | 102 |
float scale = 0.5f; |
104 | 103 |
|
105 | 104 |
mEffects.abortEffects(EffectTypes.MATRIX); |
106 | 105 |
mEffects.quaternion( mRot, new Static3D(0,0,0) ); |
107 |
mEffects.scale( qx<qy ? (new Static3D(scale,scale*qx/qy,scale)) : (new Static3D(scale*qy/qx,scale,scale)) );
|
|
106 |
mEffects.scale( q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)) );
|
|
108 | 107 |
|
109 | 108 |
mScreen.resize(width, height); |
110 | 109 |
} |
Also available in: Unified diff
Convert next 4 APPs to the new Matrix effects.