Revision 40eef4b9
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
import org.distorted.library.Distorted; |
30 |
import org.distorted.library.DistortedObject; |
|
30 |
import org.distorted.library.DistortedEffectQueues; |
|
31 |
import org.distorted.library.DistortedTexture; |
|
31 | 32 |
import org.distorted.library.GridFlat; |
32 | 33 |
import org.distorted.library.EffectTypes; |
33 | 34 |
import org.distorted.library.type.Dynamic1D; |
... | ... | |
46 | 47 |
class CatAndDogRenderer implements GLSurfaceView.Renderer |
47 | 48 |
{ |
48 | 49 |
private GLSurfaceView mView; |
49 |
private DistortedObject mObject; |
|
50 |
private DistortedEffectQueues mQueues; |
|
51 |
private DistortedTexture mTexture; |
|
50 | 52 |
private GridFlat mGrid; |
51 |
private Static4D chromaRegion, alphaRegion; |
|
52 | 53 |
private int bmpHeight, bmpWidth; |
53 | 54 |
|
54 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
56 | 57 |
public CatAndDogRenderer(GLSurfaceView v) |
57 | 58 |
{ |
58 | 59 |
mView = v; |
59 |
|
|
60 |
chromaRegion= new Static4D( 530, 200,100,100); |
|
61 |
alphaRegion = new Static4D( 230, 200,100,100); |
|
60 |
|
|
61 |
mGrid = new GridFlat(1,1); // no vertex effects, grid can be a (1x1) quad. |
|
62 |
mQueues = new DistortedEffectQueues(); |
|
63 |
|
|
64 |
Static4D chromaRegion= new Static4D( 530, 200,100,100); |
|
65 |
Static4D alphaRegion = new Static4D( 230, 200,100,100); |
|
66 |
|
|
67 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
|
68 |
chromaDyn.add(new Static1D(1)); |
|
69 |
chromaDyn.add(new Static1D(0)); |
|
70 |
|
|
71 |
mQueues.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true); |
|
72 |
|
|
73 |
Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f); |
|
74 |
alphaDyn.add(new Static1D(1)); |
|
75 |
alphaDyn.add(new Static1D(0)); |
|
76 |
|
|
77 |
mQueues.alpha( alphaDyn, alphaRegion, false ); |
|
62 | 78 |
} |
63 | 79 |
|
64 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
66 | 82 |
public void onDrawFrame(GL10 glUnused) |
67 | 83 |
{ |
68 | 84 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
69 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
85 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
70 | 86 |
} |
71 | 87 |
|
72 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
94 | 110 |
bmpHeight = bitmap.getHeight(); |
95 | 111 |
bmpWidth = bitmap.getWidth(); |
96 | 112 |
|
97 |
mGrid = new GridFlat(1,1); // no vertex effects, grid can be a (1x1) quad. |
|
98 |
|
|
99 |
mObject = new DistortedObject(bmpWidth,bmpHeight,1); |
|
100 |
mObject.setTexture(bitmap); |
|
101 |
|
|
102 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
|
103 |
chromaDyn.add(new Static1D(1)); |
|
104 |
chromaDyn.add(new Static1D(0)); |
|
105 |
|
|
106 |
mObject.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true); |
|
107 |
|
|
108 |
Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f); |
|
109 |
alphaDyn.add(new Static1D(1)); |
|
110 |
alphaDyn.add(new Static1D(0)); |
|
113 |
mTexture = new DistortedTexture(bmpWidth,bmpHeight,0); |
|
114 |
mTexture.setTexture(bitmap); |
|
111 | 115 |
|
112 |
mObject.alpha( alphaDyn, alphaRegion, false ); |
|
113 |
|
|
114 | 116 |
try |
115 | 117 |
{ |
116 | 118 |
Distorted.onSurfaceCreated(mView.getContext()); |
... | ... | |
139 | 141 |
diRotate.add(new Static1D( 0)); |
140 | 142 |
diRotate.add(new Static1D(360)); |
141 | 143 |
|
142 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
144 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
143 | 145 |
|
144 |
mObject.move(diMove);
|
|
145 |
mObject.scale(diScale);
|
|
146 |
mObject.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
|
|
146 |
mQueues.move(diMove);
|
|
147 |
mQueues.scale(diScale);
|
|
148 |
mQueues.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
|
|
147 | 149 |
|
148 | 150 |
Distorted.onSurfaceChanged(width, height); |
149 | 151 |
} |
Also available in: Unified diff
Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.
Still does not compile, but pushing already.