Revision 630703d1
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
102 | 102 |
|
103 | 103 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
104 | 104 |
{ |
105 |
float qx = (float)width /bmpWidth; |
|
106 |
float qy = (float)height/bmpHeight; |
|
107 |
|
|
108 | 105 |
mEffects.abortEffects(EffectTypes.MATRIX); |
109 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
106 |
|
|
107 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
108 |
{ |
|
109 |
int w = (height*bmpWidth)/bmpHeight; |
|
110 |
float factor = (float)height/bmpHeight; |
|
111 |
|
|
112 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
113 |
mEffects.scale(factor); |
|
114 |
} |
|
115 |
else |
|
116 |
{ |
|
117 |
int h = (width*bmpHeight)/bmpWidth; |
|
118 |
float factor = (float)width/bmpWidth; |
|
119 |
|
|
120 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
121 |
mEffects.scale(factor); |
|
122 |
} |
|
110 | 123 |
|
111 | 124 |
mScreen.resize(width, height); |
112 | 125 |
} |
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
134 | 134 |
|
135 | 135 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
136 | 136 |
{ |
137 |
// 1 cycle = 10000 ms = 10 seconds long |
|
138 |
int duration = 10000; |
|
139 |
|
|
140 |
// First abort all effect we might have had before |
|
141 |
// (we will if we got here from a brief stay in the background) |
|
142 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
143 |
|
|
144 |
// Now start applying the effects. Matrix effects are, like the name suggests, multiplications |
|
145 |
// of the Mesh by certain Projective Transformation Matrix. As such, those are - confusingly - |
|
146 |
// applied in exactly the opposite order than given, i.e. here the last SCALE would be the |
|
147 |
// first effect applied to each vertex of our Mesh, followed by a ROTATION, and only then by |
|
148 |
// the MOVE ! |
|
149 |
|
|
150 |
// MOVES ///////// |
|
151 |
// Now, after the SCALE and ROTATE, the center of our Mesh is still exactly at the center of |
|
152 |
// the Screen. Thus we move the Mesh back and forth between (0.5,0.5,0) and (-0.5,-0.5,0) , |
|
153 |
// i.e. between the lower right and upper left corners of the screen. |
|
137 |
int duration = 10000; // 10 seconds |
|
138 |
|
|
154 | 139 |
Dynamic3D diMove = new Dynamic3D(duration,0.0f); |
155 |
Static3D lowerRight = new Static3D( +0.5f, +0.5f, 0); |
|
156 |
Static3D upperLeft = new Static3D( -0.5f, -0.5f, 0); |
|
157 |
diMove.add(lowerRight); |
|
158 |
diMove.add(upperLeft); |
|
159 |
mEffects.move(diMove); |
|
160 |
|
|
161 |
// ROTATION ////// |
|
162 |
// Now, after the SCALE, our Texture is positioned at the center of the screen - coords (0,0,0). |
|
163 |
// Rotate the whole Mesh around this point, along the (0,0,1) axis (i.e. vector perpendicular to |
|
164 |
// the surface of the screen) starting from 0 degrees to 360 and back. |
|
140 |
diMove.add(new Static3D(width-bmpWidth,height-bmpHeight,0)); |
|
141 |
diMove.add(new Static3D(0,0,0)); |
|
142 |
|
|
143 |
Dynamic3D diScale = new Dynamic3D(duration,0.0f); |
|
144 |
diScale.add(new Static3D(1,1,1)); |
|
145 |
diScale.add(new Static3D(0.33f,0.33f,1)); |
|
146 |
|
|
165 | 147 |
Dynamic1D diRotate = new Dynamic1D(duration,0.0f); |
166 | 148 |
diRotate.add(new Static1D( 0)); |
167 | 149 |
diRotate.add(new Static1D(360)); |
168 |
Static3D axis = new Static3D(0,0,1); |
|
169 |
Static3D center = new Static3D(0,0,0); |
|
170 |
mEffects.rotate( diRotate, axis, center ); |
|
171 |
|
|
172 |
// SCALING /////// |
|
173 |
// Before we apply any effects, at the very start, out Mesh skinned by the 'Cat and Dog' texture |
|
174 |
// fills up the whole Screen. First we need to scale it down so that the resolution of the |
|
175 |
// original 'Cat and Dog' bitmap are preserved, (qx/qy part) and also apply a Dynamic switching |
|
176 |
// the size from 80% of the Screen to 20% and back. |
|
177 |
Dynamic3D diScale = new Dynamic3D(duration,0.0f); |
|
178 |
float qx = (float)width /bmpWidth; |
|
179 |
float qy = (float)height/bmpHeight; |
|
180 |
float start_scale = 0.8f; |
|
181 |
float end_scale = 0.2f; |
|
182 |
diScale.add(qx<qy ? (new Static3D( start_scale,start_scale*qx/qy,1)) : (new Static3D(start_scale*qy/qx,start_scale,1))); |
|
183 |
diScale.add(qx<qy ? (new Static3D( end_scale ,end_scale *qx/qy,1)) : (new Static3D(end_scale *qy/qx,end_scale ,1))); |
|
150 |
|
|
151 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
152 |
|
|
153 |
mEffects.move(diMove); |
|
184 | 154 |
mEffects.scale(diScale); |
155 |
mEffects.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) ); |
|
185 | 156 |
|
186 |
// Finally, tell the Screen itself the underlying OpenGL surface has changed dimensions. |
|
187 | 157 |
mScreen.resize(width, height); |
188 | 158 |
} |
189 | 159 |
} |
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
88 | 88 |
|
89 | 89 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
90 | 90 |
{ |
91 |
float qx = (float)width /bmpWidth; |
|
92 |
float qy = (float)height/bmpHeight; |
|
93 |
|
|
94 | 91 |
mEffects.abortEffects(EffectTypes.MATRIX); |
95 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
92 |
|
|
93 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
94 |
{ |
|
95 |
int w = (height*bmpWidth)/bmpHeight; |
|
96 |
float factor = (float)height/bmpHeight; |
|
97 |
|
|
98 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
99 |
mEffects.scale(factor); |
|
100 |
} |
|
101 |
else |
|
102 |
{ |
|
103 |
int h = (width*bmpHeight)/bmpWidth; |
|
104 |
float factor = (float)width/bmpWidth; |
|
105 |
|
|
106 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
107 |
mEffects.scale(factor); |
|
108 |
} |
|
96 | 109 |
|
97 | 110 |
mScreen.resize(width, height); |
98 | 111 |
} |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
100 | 100 |
fpsTexture.setTexture(fpsBitmap); |
101 | 101 |
fpsCanvas = new Canvas(fpsBitmap); |
102 | 102 |
fpsEffects = new DistortedEffects(); |
103 |
fpsEffects.move( new Static3D(5,5,0) ); |
|
103 | 104 |
|
104 | 105 |
mPaint = new Paint(); |
105 | 106 |
mPaint.setAntiAlias(true); |
... | ... | |
107 | 108 |
mPaint.setTextSize(0.7f*fpsH); |
108 | 109 |
|
109 | 110 |
stretchEffects = new DistortedEffects(); |
110 |
stretchEffects.scale(0.5f); |
|
111 | 111 |
|
112 | 112 |
mRegion = new Static4D(0,0,0,0); |
113 | 113 |
|
... | ... | |
205 | 205 |
scrHeight = height; |
206 | 206 |
scrWidth = width; |
207 | 207 |
|
208 |
fpsEffects.abortAllEffects(); |
|
209 |
fpsEffects.move( new Static3D( -0.5f + (fpsW/2 + 5.0f)/width, -0.5f + (fpsH/2 + 5.0f)/height,0.0f) ); |
|
210 |
fpsEffects.scale( new Static3D( (float)fpsW/width, (float)fpsH/height, 1.0f) ); |
|
211 |
|
|
212 | 208 |
mRegion.set3(mRadius*scrWidth); |
213 | 209 |
|
214 | 210 |
Canvas stretchCanvas; |
... | ... | |
235 | 231 |
if( stretchTexture==null ) stretchTexture = new DistortedTexture(w,h); |
236 | 232 |
stretchTexture.setTexture(stretchBitmap); |
237 | 233 |
|
234 |
stretchEffects.abortAllEffects(); |
|
235 |
stretchEffects.move( new Static3D(scrWidth/4,scrHeight/4,0) ); |
|
236 |
|
|
238 | 237 |
mScreen.detachAll(); |
239 | 238 |
mScreen.attach(stretchTexture,stretchEffects,stretchMesh); |
240 | 239 |
mScreen.attach(fpsTexture,fpsEffects,fpsMesh); |
... | ... | |
270 | 269 |
if( xt>scrWidth/2 ) xt=scrWidth/2; |
271 | 270 |
if( yt<0 ) yt=0; |
272 | 271 |
if( yt>scrHeight/2 ) yt=scrHeight/2; |
272 |
|
|
273 |
touchPoint.set(xt,yt,0); |
|
273 | 274 |
|
274 | 275 |
switch(mMode) |
275 | 276 |
{ |
276 | 277 |
case DISTORT: vDistort[0].set(0,0,0); |
277 |
touchPoint.set(xt,yt,0); |
|
278 | 278 |
mLastEffect = stretchEffects.distort( mMovingDistortDynamic, touchPoint, mRegion); |
279 | 279 |
break; |
280 | 280 |
case DEFORM : vDeform[0].set(0,0,0); |
281 |
touchPoint.set(xt,yt,0); |
|
282 | 281 |
mLastEffect = stretchEffects.deform( mMovingDeformDynamic, touchPoint, mRegion); |
283 | 282 |
break; |
284 | 283 |
case SHEAR : vShear[0].set(0,0,0); |
285 |
touchPoint.set( (float)xt/scrWidth, (float)yt/scrHeight,0); |
|
286 | 284 |
mLastEffect = stretchEffects.shear(mMovingShearDynamic, touchPoint); |
287 | 285 |
break; |
288 | 286 |
} |
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
105 | 105 |
|
106 | 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 107 |
|
108 |
public void onDrawFrame(GL10 glUnused)
|
|
108 |
public void onDrawFrame(GL10 glUnused)
|
|
109 | 109 |
{ |
110 | 110 |
mScreen.render( System.currentTimeMillis() ); |
111 | 111 |
} |
112 | 112 |
|
113 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
114 | 114 |
|
115 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
116 |
{
|
|
117 |
for(int i=NUM-1; i>=0; i--)
|
|
118 |
{
|
|
119 |
mEffects[i].abortEffects(EffectTypes.MATRIX); |
|
120 |
} |
|
115 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
116 |
{
|
|
117 |
for(int i=NUM-1; i>=0; i--)
|
|
118 |
{
|
|
119 |
mEffects[i].abortEffects(EffectTypes.MATRIX);
|
|
120 |
}
|
|
121 | 121 |
|
122 |
float qx = (float)width /bmpWidth; |
|
123 |
float qy = (float)height/bmpHeight; |
|
124 |
|
|
125 |
if( qx > NUM*qy ) // screen more 'horizontal' than NUM bitmaps next to each other |
|
126 |
{ |
|
127 |
for(int i=0; i<NUM; i++) |
|
128 |
{ |
|
129 |
mEffects[i].move( new Static3D( qy*((0.5f+i)/NUM-0.5f), 0, 0) ); |
|
130 |
mEffects[i].scale( new Static3D( qy/qx, 1, 1) ); |
|
131 |
} |
|
132 |
} |
|
133 |
else |
|
134 |
{ |
|
135 |
for(int i=0; i<NUM; i++) |
|
136 |
{ |
|
137 |
mEffects[i].move( new Static3D( (0.5f+i)/NUM-0.5f, 0, 0) ); |
|
138 |
mEffects[i].scale( new Static3D( 1.0f/NUM, (qx/qy)/NUM, 1) ); |
|
139 |
} |
|
140 |
} |
|
122 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
|
123 |
{ |
|
124 |
int w = (height*bmpWidth)/bmpHeight; |
|
125 |
float factor = (float)height/bmpHeight; |
|
126 |
|
|
127 |
for(int i=NUM-1; i>=0; i--) |
|
128 |
{ |
|
129 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) ); |
|
130 |
mEffects[i].scale(factor); |
|
131 |
} |
|
132 |
} |
|
133 |
else |
|
134 |
{ |
|
135 |
int w = width/NUM; |
|
136 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
|
137 |
float factor = (float)width/(bmpWidth*NUM); |
|
138 |
|
|
139 |
for(int i=NUM-1; i>=0; i--) |
|
140 |
{ |
|
141 |
mEffects[i].move( new Static3D(i*w,(height-h)/2,0) ); |
|
142 |
mEffects[i].scale(factor); |
|
143 |
} |
|
144 |
} |
|
141 | 145 |
|
142 |
mScreen.resize(width, height); |
|
143 |
} |
|
146 |
mScreen.resize(width, height);
|
|
147 |
}
|
|
144 | 148 |
|
145 | 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
146 | 150 |
|
147 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
148 |
{ |
|
149 |
Bitmap bitmap0= readBitmap(R.raw.dog); |
|
150 |
Bitmap bitmap1= readBitmap(R.raw.face); |
|
151 |
Bitmap bitmap2= readBitmap(R.raw.cat); |
|
151 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
152 |
{
|
|
153 |
Bitmap bitmap0= readBitmap(R.raw.dog);
|
|
154 |
Bitmap bitmap1= readBitmap(R.raw.face);
|
|
155 |
Bitmap bitmap2= readBitmap(R.raw.cat);
|
|
152 | 156 |
|
153 |
bmpHeight = bitmap0.getHeight(); |
|
154 |
bmpWidth = bitmap0.getWidth(); |
|
157 |
bmpHeight = bitmap0.getHeight();
|
|
158 |
bmpWidth = bitmap0.getWidth();
|
|
155 | 159 |
|
156 |
if( mTexture==null ) |
|
157 |
{ |
|
158 |
mTexture = new DistortedTexture[NUM]; |
|
160 |
if( mTexture==null )
|
|
161 |
{
|
|
162 |
mTexture = new DistortedTexture[NUM];
|
|
159 | 163 |
|
160 |
for(int i=0; i<NUM; i++) |
|
161 |
mTexture[i] = new DistortedTexture(bmpWidth,bmpHeight); |
|
162 |
} |
|
164 |
for(int i=0; i<NUM; i++)
|
|
165 |
mTexture[i] = new DistortedTexture(bmpWidth,bmpHeight);
|
|
166 |
}
|
|
163 | 167 |
|
164 |
mTexture[0].setTexture(bitmap0); |
|
165 |
mTexture[1].setTexture(bitmap1); |
|
166 |
mTexture[2].setTexture(bitmap2); |
|
168 |
mTexture[0].setTexture(bitmap0);
|
|
169 |
mTexture[1].setTexture(bitmap1);
|
|
170 |
mTexture[2].setTexture(bitmap2);
|
|
167 | 171 |
|
168 |
MeshFlat mesh = new MeshFlat(30,30*bmpHeight/bmpWidth); |
|
172 |
MeshFlat mesh = new MeshFlat(30,30*bmpHeight/bmpWidth);
|
|
169 | 173 |
|
170 |
mScreen.detachAll(); |
|
171 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mesh); |
|
174 |
mScreen.detachAll();
|
|
175 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mesh);
|
|
172 | 176 |
|
173 |
DistortedEffects.enableEffect(EffectNames.SINK); |
|
174 |
DistortedEffects.enableEffect(EffectNames.DISTORT); |
|
177 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
178 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
175 | 179 |
|
176 |
try |
|
177 |
{ |
|
178 |
Distorted.onCreate(mView.getContext()); |
|
179 |
} |
|
180 |
catch(Exception ex) |
|
181 |
{ |
|
182 |
android.util.Log.e("Renderer", ex.getMessage() ); |
|
183 |
} |
|
184 |
} |
|
180 |
try
|
|
181 |
{
|
|
182 |
Distorted.onCreate(mView.getContext());
|
|
183 |
}
|
|
184 |
catch(Exception ex)
|
|
185 |
{
|
|
186 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
187 |
}
|
|
188 |
}
|
|
185 | 189 |
} |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
111 | 111 |
{ |
112 | 112 |
mEffects[i].abortEffects(EffectTypes.MATRIX); |
113 | 113 |
} |
114 |
|
|
115 |
float qx = (float)width /bmpWidth; |
|
116 |
float qy = (float)height/bmpHeight; |
|
117 |
|
|
118 |
if( qx > NUM*qy ) // screen more 'horizontal' than NUM bitmaps next to each other |
|
114 |
|
|
115 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
|
119 | 116 |
{ |
120 |
for(int i=0; i<NUM; i++) |
|
117 |
int w = (height*bmpWidth)/bmpHeight; |
|
118 |
float factor = (float)height/bmpHeight; |
|
119 |
|
|
120 |
for(int i=NUM-1; i>=0; i--) |
|
121 | 121 |
{ |
122 |
mEffects[i].move( new Static3D( qy*((0.5f+i)/NUM-0.5f), 0, 0) );
|
|
123 |
mEffects[i].scale( new Static3D( qy/qx, 1, 1) );
|
|
122 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
|
|
123 |
mEffects[i].scale(factor);
|
|
124 | 124 |
} |
125 | 125 |
} |
126 | 126 |
else |
127 | 127 |
{ |
128 |
for(int i=0; i<NUM; i++) |
|
128 |
int w = width/NUM; |
|
129 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
|
130 |
float factor = (float)width/(bmpWidth*NUM); |
|
131 |
|
|
132 |
for(int i=NUM-1; i>=0; i--) |
|
129 | 133 |
{ |
130 |
mEffects[i].move( new Static3D( (0.5f+i)/NUM-0.5f, 0, 0) );
|
|
131 |
mEffects[i].scale( new Static3D( 1.0f/NUM, (qx/qy)/NUM, 1) );
|
|
134 |
mEffects[i].move( new Static3D(i*w, (height-h)/2, 0) );
|
|
135 |
mEffects[i].scale(factor);
|
|
132 | 136 |
} |
133 | 137 |
} |
134 | 138 |
|
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
---|---|---|
34 | 34 |
import org.distorted.library.DistortedTexture; |
35 | 35 |
import org.distorted.library.Distorted; |
36 | 36 |
import org.distorted.library.EffectNames; |
37 |
import org.distorted.library.EffectTypes; |
|
37 | 38 |
import org.distorted.library.message.EffectListener; |
38 | 39 |
import org.distorted.library.message.EffectMessage; |
40 |
import org.distorted.library.type.Static3D; |
|
39 | 41 |
|
40 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 43 |
|
... | ... | |
125 | 127 |
|
126 | 128 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
127 | 129 |
{ |
130 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
131 |
mEffects.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) ); |
|
128 | 132 |
mScreen.resize(width,height); |
129 | 133 |
mView.setScreenSize(width,height); |
130 | 134 |
} |
src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
---|---|---|
103 | 103 |
|
104 | 104 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
105 | 105 |
{ |
106 |
float qx = (float)width /lisaWidth; |
|
107 |
float qy = (float)height/lisaHeight; |
|
108 |
|
|
109 | 106 |
mEffects.abortEffects(EffectTypes.MATRIX); |
110 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
107 |
|
|
108 |
if( (float)lisaHeight/lisaWidth > (float)height/width ) |
|
109 |
{ |
|
110 |
int w = (height*lisaWidth)/lisaHeight; |
|
111 |
float factor = (float)height/lisaHeight; |
|
112 |
|
|
113 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
114 |
mEffects.scale(factor); |
|
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
int h = (width*lisaHeight)/lisaWidth; |
|
119 |
float factor = (float)width/lisaWidth; |
|
120 |
|
|
121 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
122 |
mEffects.scale(factor); |
|
123 |
} |
|
111 | 124 |
|
112 | 125 |
mScreen.resize(width, height); |
113 | 126 |
} |
... | ... | |
151 | 164 |
mGridTexture.setTexture(bitmap2); |
152 | 165 |
DistortedEffects gridEffects = new DistortedEffects(); |
153 | 166 |
|
167 |
mEffects.abortAllEffects(); |
|
168 |
|
|
154 | 169 |
mRoot = new DistortedNode(mLisaTexture, mEffects,new MeshFlat(1,1)); |
155 | 170 |
mRoot.attach(mGridTexture,gridEffects,new MeshCubes(10,10,false)); |
156 | 171 |
|
... | ... | |
159 | 174 |
mScreen.detachAll(); |
160 | 175 |
mScreen.attach(mRoot); |
161 | 176 |
|
162 |
gridEffects.scale(0.5f); |
|
177 |
float factor = lisaWidth/(2.0f*gridWidth); |
|
178 |
|
|
179 |
gridEffects.move( new Static3D( (lisaWidth-factor*gridWidth)/2,(lisaHeight-factor*gridHeight)/2,0) ); |
|
180 |
gridEffects.scale(factor); |
|
163 | 181 |
|
164 | 182 |
Dynamic1D rotDyn = new Dynamic1D(12000,0.0f); |
165 | 183 |
rotDyn.add(new Static1D( 0)); |
166 | 184 |
rotDyn.add(new Static1D(360)); |
167 | 185 |
rotDyn.setMode(Dynamic.MODE_JUMP); |
168 | 186 |
|
169 |
gridEffects.rotate(rotDyn, new Static3D(1,0,0), new Static3D(0,0,1.0f/10) );
|
|
187 |
gridEffects.rotate(rotDyn, new Static3D(1,0,0), new Static3D(gridWidth/2,gridHeight/2,gridHeight/10) );
|
|
170 | 188 |
|
171 | 189 |
Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f); |
172 | 190 |
sinkDyn.add(new Static1D(1.0f)); |
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
159 | 159 |
|
160 | 160 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
161 | 161 |
{ |
162 |
float qx = (float)width /bmpWidth; |
|
163 |
float qy = (float)height/bmpHeight; |
|
164 |
|
|
165 | 162 |
mEffects.abortEffects(EffectTypes.MATRIX); |
166 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
163 |
|
|
164 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
165 |
{ |
|
166 |
int w = (height*bmpWidth)/bmpHeight; |
|
167 |
float factor = (float)height/bmpHeight; |
|
168 |
|
|
169 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
170 |
mEffects.scale(factor); |
|
171 |
} |
|
172 |
else |
|
173 |
{ |
|
174 |
int h = (width*bmpHeight)/bmpWidth; |
|
175 |
float factor = (float)width/bmpWidth; |
|
176 |
|
|
177 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
178 |
mEffects.scale(factor); |
|
179 |
} |
|
167 | 180 |
|
168 | 181 |
mScreen.resize(width, height); |
169 | 182 |
} |
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
110 | 110 |
|
111 | 111 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
112 | 112 |
{ |
113 |
float qx = (float)width /bmpWidth; |
|
114 |
float qy = (float)height/bmpHeight; |
|
115 |
|
|
116 | 113 |
mEffects.abortEffects(EffectTypes.MATRIX); |
117 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
114 |
|
|
115 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
116 |
{ |
|
117 |
int w = (height*bmpWidth)/bmpHeight; |
|
118 |
float factor = (float)height/bmpHeight; |
|
119 |
|
|
120 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
121 |
mEffects.scale(factor); |
|
122 |
} |
|
123 |
else |
|
124 |
{ |
|
125 |
int h = (width*bmpHeight)/bmpWidth; |
|
126 |
float factor = (float)width/bmpWidth; |
|
127 |
|
|
128 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
129 |
mEffects.scale(factor); |
|
130 |
} |
|
118 | 131 |
|
119 | 132 |
mScreen.resize(width, height); |
120 | 133 |
} |
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
86 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 87 |
|
88 | 88 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
89 |
{ |
|
90 |
float qx = (float)width /bmpWidth; |
|
91 |
float qy = (float)height/bmpHeight; |
|
92 |
|
|
89 |
{ |
|
93 | 90 |
mEffects.abortEffects(EffectTypes.MATRIX); |
94 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
91 |
|
|
92 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
93 |
{ |
|
94 |
int w = (height*bmpWidth)/bmpHeight; |
|
95 |
float factor = (float)height/bmpHeight; |
|
96 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
97 |
mEffects.scale(factor); |
|
98 |
} |
|
99 |
else |
|
100 |
{ |
|
101 |
int h = (width*bmpHeight)/bmpWidth; |
|
102 |
float factor = (float)width/bmpWidth; |
|
103 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
104 |
mEffects.scale(factor); |
|
105 |
} |
|
95 | 106 |
|
96 | 107 |
mScreen.resize(width, height); |
97 | 108 |
} |
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
78 | 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
79 | 79 |
|
80 | 80 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
81 |
{ |
|
82 |
float qx = (float)width /bmpWidth; |
|
83 |
float qy = (float)height/bmpHeight; |
|
84 |
|
|
81 |
{ |
|
85 | 82 |
mEffects.abortEffects(EffectTypes.MATRIX); |
86 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
83 |
|
|
84 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
85 |
{ |
|
86 |
int w = (height*bmpWidth)/bmpHeight; |
|
87 |
float factor = (float)height/bmpHeight; |
|
87 | 88 |
|
89 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
90 |
mEffects.scale( factor ); |
|
91 |
} |
|
92 |
else |
|
93 |
{ |
|
94 |
int h = (width*bmpHeight)/bmpWidth; |
|
95 |
float factor = (float)width/bmpWidth; |
|
96 |
|
|
97 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
98 |
mEffects.scale( factor ); |
|
99 |
} |
|
100 |
|
|
88 | 101 |
mScreen.resize(width, height); |
89 | 102 |
} |
90 | 103 |
|
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
207 | 207 |
if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion(); |
208 | 208 |
mCrawlBackgroundTexture = new DistortedTexture(w,(int)(h*Math.sin(angleA)/Math.sin(angleB))); |
209 | 209 |
|
210 |
int randomTime; |
|
211 |
float randomX, randomY, randomS, randomAlpha1, randomAlpha2; |
|
212 |
|
|
213 |
float starScaleX = (float)mStarTexture.getWidth()/w; |
|
214 |
float starScaleY = (float)mStarTexture.getHeight()/h; |
|
215 |
|
|
210 |
int randomA, randomX, randomY, randomTime; |
|
211 |
float randomS, randomAlpha1, randomAlpha2; |
|
212 |
|
|
213 |
Static3D center = new Static3D(0,0,0); |
|
214 |
Static3D axis = new Static3D(0,0,1); |
|
216 | 215 |
Static1D alphaNoise = new Static1D(0.4f); |
217 | 216 |
|
218 | 217 |
for(int i=0; i<NUM_STARS; i++) |
219 | 218 |
{ |
220 |
randomX = mRnd.nextFloat() -0.5f;
|
|
221 |
randomY = mRnd.nextFloat() -0.5f;
|
|
219 |
randomX = mRnd.nextInt(w);
|
|
220 |
randomY = mRnd.nextInt(h);
|
|
222 | 221 |
randomS = 0.2f+ 0.8f*mRnd.nextFloat(); |
222 |
randomA = (int)(180*mRnd.nextFloat()); |
|
223 | 223 |
randomAlpha1 = 0.2f + 0.8f*mRnd.nextFloat(); |
224 | 224 |
randomAlpha2 = 0.8f + 0.2f*mRnd.nextFloat(); |
225 | 225 |
randomTime = 500+mRnd.nextInt(2000); |
226 | 226 |
|
227 | 227 |
mStarEffects[i].move( new Static3D(randomX,randomY,0) ); |
228 |
mStarEffects[i].scale( new Static3D(randomS*starScaleX, randomS*starScaleY, 1) ); |
|
229 |
|
|
228 |
mStarEffects[i].scale(randomS); |
|
229 |
mStarEffects[i].rotate( new Static1D(randomA), axis, center ); |
|
230 |
|
|
230 | 231 |
Dynamic1D di = new Dynamic1D(randomTime,0.0f); |
231 | 232 |
di.setNoise(alphaNoise); |
232 | 233 |
di.add(new Static1D(randomAlpha1)); |
... | ... | |
236 | 237 |
|
237 | 238 |
mScreen.attach(mStarTexture, mStarEffects[i], mQuad); |
238 | 239 |
} |
239 |
|
|
240 |
float qx = (float)mGFFATexture.getWidth()/w; |
|
241 |
float qy = (float)mGFFATexture.getHeight()/h; |
|
242 |
|
|
240 |
|
|
241 |
float scale = (0.5f*w/mGFFATexture.getWidth()); |
|
242 |
|
|
243 | 243 |
Dynamic1D di = new Dynamic1D(6000,0.5f); |
244 | 244 |
di.add(new Static1D(1.0f)); |
245 | 245 |
di.add(new Static1D(1.0f)); |
246 | 246 |
di.add(new Static1D(0.0f)); |
247 | 247 |
|
248 |
mGFFAEffects.move( new Static3D(qx/2-0.3f,qy/2-0.16f,0) );
|
|
249 |
mGFFAEffects.scale( new Static3D(qx,qy,1) );
|
|
248 |
mGFFAEffects.move( new Static3D(w/5,h/3,0) );
|
|
249 |
mGFFAEffects.scale( new Static3D(scale,scale,scale) );
|
|
250 | 250 |
mGFFAEffects.alpha(di); |
251 | 251 |
|
252 | 252 |
mScreen.attach(mGFFATexture, mGFFAEffects, mQuad); |
... | ... | |
380 | 380 |
mScreen.detach(mGFFAEffects); |
381 | 381 |
mGFFATexture.markForDeletion(); |
382 | 382 |
|
383 |
float qx= (float)mScreen.getWidth() /mLogoTexture.getWidth() ; |
|
384 |
float qy= (float)mScreen.getHeight()/mLogoTexture.getHeight(); |
|
385 |
|
|
386 |
float initSize= 3.0f; |
|
387 |
float finaSize= 0.1f; |
|
383 |
int screenW=mScreen.getWidth(); |
|
384 |
int screenH=mScreen.getHeight(); |
|
385 |
|
|
386 |
int logoW = mLogoTexture.getWidth(); |
|
387 |
int logoH = mLogoTexture.getHeight(); |
|
388 |
|
|
389 |
int initSize= (int)(3.0f*screenW/logoW); |
|
390 |
int finaSize= (int)(0.1f*screenW/logoW); |
|
388 | 391 |
|
389 | 392 |
Dynamic3D di = new Dynamic3D(10000,0.5f); |
390 |
di.add(qx<qy ? (new Static3D(initSize,initSize*qx/qy,1)) : (new Static3D(initSize*qy/qx,initSize,1)));
|
|
391 |
di.add(qx<qy ? (new Static3D(finaSize,finaSize*qx/qy,1)) : (new Static3D(finaSize*qy/qx,finaSize,1)));
|
|
393 |
di.add(new Static3D(initSize,initSize,1));
|
|
394 |
di.add(new Static3D(finaSize,finaSize,1));
|
|
392 | 395 |
|
396 |
mLogoEffects.move( new Static3D(screenW/2,screenH/2,0) ); |
|
393 | 397 |
mLogoEffects.scale(di); |
394 |
|
|
398 |
mLogoEffects.move( new Static3D(-logoW/2,-logoH/2,0) ); |
|
399 |
|
|
395 | 400 |
mScreen.attach(mLogoTexture, mLogoEffects,mQuad); |
396 | 401 |
mLogoEffects.registerForMessages(this); |
397 | 402 |
} |
... | ... | |
407 | 412 |
int backH = mCrawlBackgroundTexture.getHeight(); |
408 | 413 |
float scale= (float)screenW/crawlW; |
409 | 414 |
|
410 |
//mCrawlBackgroundEffects.move( new Static3D(0,screenH-backH,0) ); |
|
411 |
mCrawlBackgroundEffects.rotate( new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0.5f,1.0f,0.0f) ); |
|
412 |
mCrawlBackgroundEffects.scale( new Static3D(1.0f, (float)backH/screenH,1.0f) ); |
|
415 |
mCrawlBackgroundEffects.move( new Static3D(0,screenH-backH,0) ); |
|
416 |
mCrawlBackgroundEffects.rotate( new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,backH,0) ); |
|
413 | 417 |
|
414 | 418 |
final int transpDist = 5; |
415 | 419 |
Static4D region = new Static4D(screenW/2,(1-transpDist)*backH,transpDist*backH,transpDist*backH); |
416 |
//mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist*0.6f), region, true);
|
|
420 |
mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist*0.6f), region, true); |
|
417 | 421 |
|
418 | 422 |
Dynamic3D di = new Dynamic3D(70000,0.5f); |
419 | 423 |
di.add(new Static3D(screenW/2,+backH , 0)); |
420 | 424 |
di.add(new Static3D(screenW/2,-scale*crawlH, 0)); |
421 | 425 |
|
422 |
//mCrawlEffects.move(di);
|
|
423 |
//mCrawlEffects.scale( new Static3D(scale,scale,scale) );
|
|
424 |
//mCrawlEffects.move( new Static3D(-crawlW/2,0,0) );
|
|
426 |
mCrawlEffects.move(di); |
|
427 |
mCrawlEffects.scale( new Static3D(scale,scale,scale) ); |
|
428 |
mCrawlEffects.move( new Static3D(-crawlW/2,0,0) ); |
|
425 | 429 |
|
426 | 430 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad); |
427 | 431 |
mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad); |
Also available in: Unified diff
Revert "Major refactoring: convert the Matrix Effects to be independent of the resolution of the surface we render to."
This reverts commit d79a56d3bc6cc7a22b21abeb180353a1818bd6ad.