Revision 698ad0a8
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
68 | 68 |
|
69 | 69 |
mView = view; |
70 | 70 |
mManager = new AroundTheWorldEffectsManager(); |
71 |
mEffects = new DistortedEffects(1);
|
|
71 |
mEffects = new DistortedEffects(); |
|
72 | 72 |
mEffects.apply(new MatrixEffectScale(mScale)); |
73 | 73 |
mEffects.apply(new MatrixEffectMove(mMove)); |
74 | 74 |
|
... | ... | |
136 | 136 |
mObjWidth = bitmap.getWidth(); |
137 | 137 |
mObjHeight= bitmap.getHeight(); |
138 | 138 |
|
139 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
140 |
|
|
141 | 139 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
142 | 140 |
mTexture.setTexture(bitmap); |
143 | 141 |
|
144 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
|
142 |
if( mMesh==null ) |
|
143 |
{ |
|
144 |
mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
|
145 |
mMesh.setStretch(mObjWidth,mObjHeight,0); |
|
146 |
} |
|
145 | 147 |
|
146 | 148 |
mScreen.detachAll(); |
147 | 149 |
mScreen.attach(mTexture, mEffects, mMesh); |
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
88 | 88 |
mMove = new Static3D(0,0,0); |
89 | 89 |
mScale= new Static3D(1,1,1); |
90 | 90 |
|
91 |
mEffects = new DistortedEffects(1);
|
|
91 |
mEffects = new DistortedEffects(); |
|
92 | 92 |
mEffects.apply( new VertexEffectDistort(dynLeft , pointLeft , regionLeft) ); |
93 | 93 |
mEffects.apply( new VertexEffectDistort(dynRight, pointRight, regionRight)); |
94 | 94 |
mEffects.apply( new MatrixEffectScale(mScale) ); |
... | ... | |
149 | 149 |
mObjHeight = bitmap.getHeight(); |
150 | 150 |
mObjWidth = bitmap.getWidth(); |
151 | 151 |
|
152 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
153 |
|
|
154 | 152 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
155 | 153 |
mTexture.setTexture(bitmap); |
156 |
if( mMesh==null ) mMesh = new MeshRectangles(25,25*mObjHeight/mObjWidth); |
|
154 |
if( mMesh==null ) |
|
155 |
{ |
|
156 |
mMesh = new MeshRectangles(25,25*mObjHeight/mObjWidth); |
|
157 |
mMesh.setStretch(mObjWidth,mObjHeight,0); |
|
158 |
} |
|
157 | 159 |
|
158 | 160 |
mScreen.detachAll(); |
159 | 161 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
---|---|---|
55 | 55 |
private DistortedEffects mEffects, mBufferEffects; |
56 | 56 |
private DistortedScreen mScreen; |
57 | 57 |
private DistortedFramebuffer mBuffer; |
58 |
private MeshRectangles mMesh; |
|
58 |
private MeshRectangles mMesh, mMeshBuffer;
|
|
59 | 59 |
private Static1D mRadiusSta; |
60 | 60 |
private int mObjHeight, mObjWidth; |
61 | 61 |
private Static3D mMove, mScale, mBufferMove, mBufferScale; |
... | ... | |
64 | 64 |
|
65 | 65 |
BlurRenderer(GLSurfaceView v) |
66 | 66 |
{ |
67 |
mView = v; |
|
68 |
mMesh = new MeshRectangles(1,1); |
|
69 |
mScreen = new DistortedScreen(); |
|
70 |
mBuffer = new DistortedFramebuffer(SIZE,SIZE,1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL); |
|
67 |
mView = v; |
|
68 |
mMesh = new MeshRectangles(1,1); |
|
69 |
mMeshBuffer = new MeshRectangles(1,1); |
|
70 |
mScreen = new DistortedScreen(); |
|
71 |
mBuffer = new DistortedFramebuffer(SIZE,SIZE,1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL); |
|
71 | 72 |
|
72 | 73 |
mRadiusSta = new Static1D(5); |
73 | 74 |
Dynamic1D radiusDyn = new Dynamic1D(); |
... | ... | |
78 | 79 |
mBufferMove = new Static3D(0,0,0); |
79 | 80 |
mBufferScale= new Static3D(1,1,1); |
80 | 81 |
|
81 |
mBufferEffects = new DistortedEffects(1);
|
|
82 |
mBufferEffects = new DistortedEffects(); |
|
82 | 83 |
mBufferEffects.apply(new MatrixEffectScale(mBufferScale)); |
83 | 84 |
mBufferEffects.apply(new MatrixEffectMove(mBufferMove)); |
84 | 85 |
|
85 |
mEffects = new DistortedEffects(1);
|
|
86 |
mEffects = new DistortedEffects(); |
|
86 | 87 |
mEffects.apply( new PostprocessEffectBlur(radiusDyn) ); |
87 | 88 |
mEffects.apply(new MatrixEffectScale(mScale)); |
88 | 89 |
mEffects.apply(new MatrixEffectMove(mMove)); |
... | ... | |
155 | 156 |
mObjHeight = bitmap.getHeight(); |
156 | 157 |
mObjWidth = bitmap.getWidth(); |
157 | 158 |
|
158 |
mEffects.setStretch(mObjWidth,mObjHeight,0);
|
|
159 |
mBufferEffects.setStretch(SIZE,SIZE,0);
|
|
159 |
mMesh.setStretch(mObjWidth,mObjHeight,0);
|
|
160 |
mMeshBuffer.setStretch(SIZE,SIZE,0);
|
|
160 | 161 |
|
161 | 162 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
162 | 163 |
mTexture.setTexture(bitmap); |
163 | 164 |
|
164 | 165 |
mScreen.detachAll(); |
165 |
mScreen.attach(mBuffer, mBufferEffects, mMesh); |
|
166 |
mScreen.attach(mBuffer, mBufferEffects, mMeshBuffer);
|
|
166 | 167 |
mBuffer.attach(new DistortedNode(mTexture,mEffects,mMesh)); |
167 | 168 |
|
168 | 169 |
PostprocessEffectBlur.enable(); |
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
92 | 92 |
diRotate.add(new Static1D( 0)); |
93 | 93 |
diRotate.add(new Static1D(360)); |
94 | 94 |
|
95 |
mEffects = new DistortedEffects(1);
|
|
95 |
mEffects = new DistortedEffects(); |
|
96 | 96 |
|
97 | 97 |
mEffects.apply( new MatrixEffectRotate( diRotate, new Static3D(0,0,1), mRotate) ); |
98 | 98 |
mEffects.apply( new MatrixEffectScale(diScale)); |
... | ... | |
142 | 142 |
mObjWidth = bitmap.getWidth(); |
143 | 143 |
mRotate.set(mObjWidth/2,mObjHeight/2,0); |
144 | 144 |
|
145 |
mEffects.setStretch(mObjWidth,mObjHeight,0);
|
|
145 |
mMesh.setStretch(mObjWidth,mObjHeight,0);
|
|
146 | 146 |
|
147 | 147 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
148 | 148 |
mTexture.setTexture(bitmap); |
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
92 | 92 |
mScale = new Static3D(1,1,1); |
93 | 93 |
mCenter = new Static3D(0,0,0); |
94 | 94 |
|
95 |
mEffects = new DistortedEffects(1);
|
|
95 |
mEffects = new DistortedEffects(); |
|
96 | 96 |
mEffects.apply(new MatrixEffectScale(mScale)); |
97 | 97 |
mEffects.apply(new MatrixEffectMove(mMove)); |
98 | 98 |
|
... | ... | |
181 | 181 |
mObjHeight = bitmap.getHeight(); |
182 | 182 |
mObjWidth = bitmap.getWidth(); |
183 | 183 |
|
184 |
mEffects.setStretch(mObjWidth,mObjHeight,0); |
|
185 |
|
|
186 | 184 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
187 | 185 |
mTexture.setTexture(bitmap); |
188 | 186 |
|
189 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
|
187 |
if( mMesh==null ) |
|
188 |
{ |
|
189 |
mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
|
190 |
mMesh.setStretch(mObjWidth,mObjHeight,0); |
|
191 |
} |
|
190 | 192 |
|
191 | 193 |
mScreen.detachAll(); |
192 | 194 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
81 | 81 |
{ |
82 | 82 |
mView = view; |
83 | 83 |
|
84 |
mEffects = new DistortedEffects(1);
|
|
84 |
mEffects = new DistortedEffects(); |
|
85 | 85 |
mRegion = new Static4D(0,0,0,0); |
86 | 86 |
mMove = new Static3D(0,0,0); |
87 | 87 |
mTouchPoint = new Static3D(0,0,0); |
... | ... | |
192 | 192 |
int h=height/2; |
193 | 193 |
|
194 | 194 |
if( mMesh!=null ) mMesh.markForDeletion(); |
195 |
|
|
196 | 195 |
mMesh = new MeshRectangles(50,50*h/w); |
196 |
mMesh.setStretch(w,h,0); |
|
197 |
|
|
197 | 198 |
Bitmap stretchBitmap = Bitmap.createBitmap(w,h, Bitmap.Config.ARGB_8888); |
198 | 199 |
stretchCanvas = new Canvas(stretchBitmap); |
199 | 200 |
|
... | ... | |
209 | 210 |
stretchCanvas.drawRect( 0, h*i/NUM_LINES-1, w , h*i/NUM_LINES+1, paint); |
210 | 211 |
} |
211 | 212 |
|
212 |
mEffects.setStretch(w,h,0); |
|
213 |
|
|
214 | 213 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
215 | 214 |
mTexture.setTexture(stretchBitmap); |
216 | 215 |
|
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
72 | 72 |
Static3D mPoint = new Static3D(305, 220, 0); |
73 | 73 |
|
74 | 74 |
mEffects = new DistortedEffects[NUM]; |
75 |
mEffects[0] = new DistortedEffects(1);
|
|
75 |
mEffects[0] = new DistortedEffects(); |
|
76 | 76 |
for(int i=1; i<NUM; i++) |
77 | 77 |
mEffects[i] = new DistortedEffects(mEffects[0], DistortedLibrary.CLONE_VERTEX| DistortedLibrary.CLONE_FRAGMENT); |
78 | 78 |
|
... | ... | |
174 | 174 |
bmpHeight = bitmap0.getHeight(); |
175 | 175 |
bmpWidth = bitmap0.getWidth(); |
176 | 176 |
|
177 |
mEffects[0].setStretch(bmpWidth,bmpHeight,0); |
|
178 |
|
|
179 | 177 |
if( mTexture==null ) |
180 | 178 |
{ |
181 | 179 |
mTexture = new DistortedTexture[NUM]; |
... | ... | |
188 | 186 |
mTexture[1].setTexture(bitmap1); |
189 | 187 |
mTexture[2].setTexture(bitmap2); |
190 | 188 |
|
191 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
189 |
if( mMesh==null ) |
|
190 |
{ |
|
191 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
192 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
193 |
} |
|
192 | 194 |
|
193 | 195 |
mScreen.detachAll(); |
194 | 196 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mMesh); |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
83 | 83 |
|
84 | 84 |
mEffects = new DistortedEffects[NUM]; |
85 | 85 |
|
86 |
for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffects(1);
|
|
86 |
for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffects(); |
|
87 | 87 |
|
88 | 88 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
89 | 89 |
sink.add(new Static1D( 1)); |
... | ... | |
173 | 173 |
bmpHeight = bitmap.getHeight(); |
174 | 174 |
bmpWidth = bitmap.getWidth(); |
175 | 175 |
|
176 |
for(int i=0; i<NUM; i++) |
|
177 |
{ |
|
178 |
mEffects[i].setStretch(bmpWidth, bmpHeight, 0); |
|
179 |
} |
|
176 |
if( mMesh==null ) |
|
177 |
{ |
|
178 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
179 |
mMesh.setStretch(bmpWidth, bmpHeight, 0); |
|
180 |
} |
|
180 | 181 |
|
181 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
182 | 182 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
183 | 183 |
mTexture.setTexture(bitmap); |
184 | 184 |
|
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
---|---|---|
62 | 62 |
mView = v; |
63 | 63 |
mMesh = new MeshRectangles(1,1); |
64 | 64 |
mScreen = new DistortedScreen(); |
65 |
mEffects = new DistortedEffects(); |
|
65 | 66 |
} |
66 | 67 |
|
67 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
90 | 91 |
|
91 | 92 |
if( mTexture!=null ) mTexture.markForDeletion(); |
92 | 93 |
mTexture= new DistortedTexture(); |
93 |
mEffects = new DistortedEffects(texW, texH, 0);
|
|
94 |
mMesh.setStretch(texW,texH,0);
|
|
94 | 95 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
95 | 96 |
mCanvas = new Canvas(mBitmap); |
96 | 97 |
|
src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
---|---|---|
116 | 116 |
scale.add(mScaleFactor); |
117 | 117 |
|
118 | 118 |
mMesh = new MeshSphere(LEVEL); |
119 |
mMesh.setStretch(SIZE,SIZE,SIZE); |
|
119 | 120 |
mTexture = new DistortedTexture(); |
120 | 121 |
|
121 | 122 |
mObjWidth = mObjHeight = mObjDepth = SIZE; |
... | ... | |
129 | 130 |
quatInt1.add(mQuat1); |
130 | 131 |
quatInt2.add(mQuat2); |
131 | 132 |
|
132 |
mEffects = new DistortedEffects(SIZE,SIZE,SIZE);
|
|
133 |
mEffects = new DistortedEffects(); |
|
133 | 134 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
134 | 135 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
135 | 136 |
mEffects.apply( new MatrixEffectScale(scale)); |
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
---|---|---|
78 | 78 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale); |
79 | 79 |
|
80 | 80 |
mMesh = new MeshRectangles(MESH_QUALITY,MESH_QUALITY*texHeight/texWidth); |
81 |
mMesh.setStretch(texWidth,texHeight,0); |
|
82 |
|
|
81 | 83 |
mTexture = new DistortedTexture(); |
82 |
mEffects = new DistortedEffects(texWidth,texHeight,0);
|
|
84 |
mEffects = new DistortedEffects(); |
|
83 | 85 |
mEffects.apply(scaleEffect); |
84 | 86 |
|
85 | 87 |
mScreen = new DistortedScreen(); |
src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
---|---|---|
54 | 54 |
private DistortedScreen mScreen; |
55 | 55 |
private Dynamic5D mWaveDyn; |
56 | 56 |
private Static5D mWaveSta1, mWaveSta2; |
57 |
private int mObjWidth, mObjHeight; |
|
57 |
private int mObjWidth, mObjHeight, mObjDepth;
|
|
58 | 58 |
private Static3D mMove, mScale, mCenter; |
59 | 59 |
|
60 | 60 |
Static4D mQuat1, mQuat2; |
... | ... | |
73 | 73 |
final Static4D mapLR = new Static4D(0.0f,0.0f,1.0f/GRIDX,1.0f ); |
74 | 74 |
final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f ,1.0f/GRIDY); |
75 | 75 |
|
76 |
mObjWidth = 500; |
|
77 |
mObjHeight= 300; |
|
78 |
mObjDepth = 5; |
|
79 |
|
|
76 | 80 |
MeshCubes mesh = new MeshCubes(GRIDX,GRIDY,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
81 |
mesh.setStretch(mObjWidth,mObjHeight,mObjDepth); |
|
77 | 82 |
|
78 | 83 |
mTexture = new DistortedTexture(); |
79 | 84 |
|
80 |
mObjWidth = 500; |
|
81 |
mObjHeight= 300; |
|
82 |
|
|
83 | 85 |
mWaveDyn = new Dynamic5D(1000,0.0f); |
84 | 86 |
mWaveSta1= new Static5D(0,0,-180,0,0); // all other values besides the |
85 | 87 |
mWaveSta2= new Static5D(0,0,+180,0,0); // fourth will be set from the UI |
... | ... | |
91 | 93 |
mQuat1 = new Static4D( 0, 0, 0, 1); // unity quaternion |
92 | 94 |
mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); // something semi-random that looks good |
93 | 95 |
|
94 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0); // middle of the right edge
|
|
96 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, mObjDepth/2); // middle of the right edge
|
|
95 | 97 |
Static4D waveRegion = new Static4D(0,0,0,mObjWidth); |
96 | 98 |
|
97 |
DistortedEffects effects = new DistortedEffects(mObjWidth,mObjHeight,1);
|
|
99 |
DistortedEffects effects = new DistortedEffects(); |
|
98 | 100 |
effects.apply( new VertexEffectWave(mWaveDyn, waveCenter, waveRegion) ); |
99 | 101 |
|
100 | 102 |
mMove = new Static3D(0,0,0); |
... | ... | |
163 | 165 |
{ |
164 | 166 |
mScreenMin = width<height ? width:height; |
165 | 167 |
float factor = ( width*mObjHeight > height*mObjWidth ) ? (0.8f*height)/mObjHeight : (0.8f*width)/mObjWidth; |
166 |
mMove.set((width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
|
|
168 |
mMove.set((width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , -factor*mObjDepth/2);
|
|
167 | 169 |
mScale.set(factor,factor,factor); |
168 |
mCenter.set(mObjWidth/2,mObjHeight/2, 0);
|
|
170 |
mCenter.set(mObjWidth/2,mObjHeight/2,mObjDepth/2);
|
|
169 | 171 |
mScreen.resize(width, height); |
170 | 172 |
} |
171 | 173 |
|
src/main/java/org/distorted/examples/generic/GenericActivity2.java | ||
---|---|---|
80 | 80 |
mShowNormal = false; |
81 | 81 |
mUseOIT = false; |
82 | 82 |
|
83 |
mEffects= new DistortedEffects(1);
|
|
83 |
mEffects= new DistortedEffects(); |
|
84 | 84 |
|
85 | 85 |
int maxsize = numCols > numRows ? (numCols>numSlic ? numCols:numSlic) : (numRows>numSlic ? numRows:numSlic) ; |
86 | 86 |
|
... | ... | |
100 | 100 |
|
101 | 101 |
mMesh = new MeshCubes(numCols, str, numSlic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
102 | 102 |
} |
103 |
mEffects.setStretch(numCols,numRows,numSlic);
|
|
103 |
mMesh.setStretch(numCols,numRows,numSlic);
|
|
104 | 104 |
break; |
105 | 105 |
case 1: mMesh = new MeshRectangles(numCols,numRows); |
106 |
mEffects.setStretch(numCols,numRows,0);
|
|
106 |
mMesh.setStretch(numCols,numRows,0);
|
|
107 | 107 |
break; |
108 | 108 |
case 2: mMesh = new MeshSphere(numRows); |
109 |
mEffects.setStretch(numRows,numRows,numRows);
|
|
109 |
mMesh.setStretch(numRows,numRows,numRows);
|
|
110 | 110 |
break; |
111 | 111 |
case 3: mMesh = new MeshQuad(); |
112 |
mMesh.setStretch(1,1,0); |
|
112 | 113 |
break; |
113 | 114 |
} |
114 | 115 |
|
... | ... | |
206 | 207 |
|
207 | 208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
208 | 209 |
|
209 |
public int getWidth()
|
|
210 |
public float getWidth()
|
|
210 | 211 |
{ |
211 |
return mEffects==null ? 0: mEffects.getStartchX();
|
|
212 |
return mMesh==null ? 0: mMesh.getStretchX();
|
|
212 | 213 |
} |
213 | 214 |
|
214 | 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
215 | 216 |
|
216 |
public int getHeight()
|
|
217 |
public float getHeight()
|
|
217 | 218 |
{ |
218 |
return mEffects==null ? 0: mEffects.getStartchY();
|
|
219 |
return mMesh==null ? 0: mMesh.getStretchY();
|
|
219 | 220 |
} |
220 | 221 |
|
221 | 222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
222 | 223 |
|
223 |
public int getDepth()
|
|
224 |
public float getDepth()
|
|
224 | 225 |
{ |
225 |
return mEffects==null ? 0: mEffects.getStartchZ();
|
|
226 |
return mMesh==null ? 0: mMesh.getStretchZ();
|
|
226 | 227 |
} |
227 | 228 |
|
228 | 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/generic/GenericRenderer.java | ||
---|---|---|
35 | 35 |
import org.distorted.library.main.DistortedScreen; |
36 | 36 |
import org.distorted.library.main.DistortedTexture; |
37 | 37 |
import org.distorted.library.mesh.MeshBase; |
38 |
import org.distorted.library.mesh.MeshRectangles;
|
|
38 |
import org.distorted.library.mesh.MeshQuad;
|
|
39 | 39 |
import org.distorted.library.mesh.MeshSphere; |
40 | 40 |
import org.distorted.library.type.Static3D; |
41 | 41 |
import org.distorted.library.type.Static4D; |
... | ... | |
55 | 55 |
|
56 | 56 |
private GLSurfaceView mView; |
57 | 57 |
private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture; |
58 |
private DistortedEffects mObjectEffects,mBackgroundEffects,mCenterEffects,mRegionEffects;
|
|
58 |
private DistortedEffects mObjectEffects; |
|
59 | 59 |
private DistortedScreen mScreen; |
60 |
private MeshQuad mRegionQuad, mCenterQuad, mBackgroundQuad; |
|
60 | 61 |
private DistortedNode mCenterNode, mRegionNode; |
61 |
private int mObjWidth, mObjHeight, mObjDepth;
|
|
62 |
private float mObjWidth, mObjHeight, mObjDepth;
|
|
62 | 63 |
private Static3D mCenterPoint, mRegionPoint, mRegionScalePoint; |
63 | 64 |
private Static3D mRotateCen, mMoveObject, mScaleObject, mMoveCenter, mScaleCenter, mMoveRegion, mMoveBackground, mScaleBackground; |
64 | 65 |
private boolean mShowingCenter=false; |
... | ... | |
94 | 95 |
|
95 | 96 |
mFactorObj = 1.0f; |
96 | 97 |
|
97 |
mObjectEffects = act.getEffects();
|
|
98 |
mBackgroundEffects = new DistortedEffects(1);
|
|
99 |
mCenterEffects = new DistortedEffects(1);
|
|
100 |
mRegionEffects = new DistortedEffects(1);
|
|
98 |
mObjectEffects = act.getEffects(); |
|
99 |
DistortedEffects backgroundEffects = new DistortedEffects();
|
|
100 |
DistortedEffects centerEffects = new DistortedEffects();
|
|
101 |
DistortedEffects regionEffects = new DistortedEffects();
|
|
101 | 102 |
|
102 |
MeshBase mesh = act.getMesh(); |
|
103 |
MeshRectangles quad = new MeshRectangles(1,1); |
|
103 |
MeshBase mesh = act.getMesh(); |
|
104 |
mRegionQuad = new MeshQuad(); |
|
105 |
mCenterQuad = new MeshQuad(); |
|
106 |
mBackgroundQuad = new MeshQuad(); |
|
104 | 107 |
|
105 | 108 |
mFactor = mesh instanceof MeshSphere ? 1.0f : 0.7f; |
106 | 109 |
|
... | ... | |
115 | 118 |
mRegionPoint= new Static3D(0,0,0); |
116 | 119 |
mRegionScalePoint = new Static3D(0,0,0); |
117 | 120 |
|
118 |
mCenterNode = new DistortedNode(mCenterTexture, mCenterEffects, quad);
|
|
119 |
mRegionNode = new DistortedNode(mRegionTexture, mRegionEffects, quad);
|
|
121 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, mCenterQuad);
|
|
122 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, mRegionQuad);
|
|
120 | 123 |
|
121 | 124 |
mScreen = new DistortedScreen(); |
122 | 125 |
mScreen.setProjection(FOV, NEAR); |
123 |
mScreen.attach(mBackgroundTexture, mBackgroundEffects, quad );
|
|
124 |
mScreen.attach(mObjectTexture , mObjectEffects , mesh );
|
|
126 |
mScreen.attach(mBackgroundTexture, backgroundEffects, mBackgroundQuad );
|
|
127 |
mScreen.attach(mObjectTexture , mObjectEffects , mesh ); |
|
125 | 128 |
|
126 |
int regionSize = mRegionEffects.getStartchX();
|
|
129 |
float regionSize = mRegionQuad.getStretchX();
|
|
127 | 130 |
mRotateCen = new Static3D(0 ,0, 0); |
128 | 131 |
|
129 | 132 |
MatrixEffectQuaternion quat1cen = new MatrixEffectQuaternion(mQuat1, mRotateCen); |
130 | 133 |
MatrixEffectQuaternion quat2cen = new MatrixEffectQuaternion(mQuat2, mRotateCen); |
131 | 134 |
MatrixEffectMove centerMove = new MatrixEffectMove(mCenterPoint); |
132 | 135 |
|
133 |
mCenterEffects.apply( new MatrixEffectScale(mScaleCenter) );
|
|
134 |
mCenterEffects.apply( centerMove );
|
|
135 |
mCenterEffects.apply( new MatrixEffectMove(mMoveCenter) );
|
|
136 |
mCenterEffects.apply(quat2cen);
|
|
137 |
mCenterEffects.apply(quat1cen);
|
|
136 |
centerEffects.apply( new MatrixEffectScale(mScaleCenter) );
|
|
137 |
centerEffects.apply( centerMove );
|
|
138 |
centerEffects.apply( new MatrixEffectMove(mMoveCenter) );
|
|
139 |
centerEffects.apply(quat2cen);
|
|
140 |
centerEffects.apply(quat1cen);
|
|
138 | 141 |
|
139 |
mRegionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize*0.5f , -regionSize*0.5f , 0)) );
|
|
140 |
mRegionEffects.apply( new MatrixEffectScale(mRegionScalePoint) );
|
|
141 |
mRegionEffects.apply( new MatrixEffectMove(mRegionPoint) );
|
|
142 |
mRegionEffects.apply( centerMove );
|
|
143 |
mRegionEffects.apply( new MatrixEffectMove(mMoveRegion) );
|
|
144 |
mRegionEffects.apply(quat2cen);
|
|
145 |
mRegionEffects.apply(quat1cen);
|
|
142 |
regionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize*0.5f , -regionSize*0.5f , 0)) );
|
|
143 |
regionEffects.apply( new MatrixEffectScale(mRegionScalePoint) );
|
|
144 |
regionEffects.apply( new MatrixEffectMove(mRegionPoint) );
|
|
145 |
regionEffects.apply( centerMove );
|
|
146 |
regionEffects.apply( new MatrixEffectMove(mMoveRegion) );
|
|
147 |
regionEffects.apply(quat2cen);
|
|
148 |
regionEffects.apply(quat1cen);
|
|
146 | 149 |
|
147 | 150 |
resetMatrixEffects(); |
148 | 151 |
|
149 | 152 |
// quite tricky: move the background exactly to the FAR plane! (see InternalOutputSurface.setProjection() ) |
150 |
mBackgroundEffects.apply(new MatrixEffectScale(mScaleBackground) );
|
|
151 |
mBackgroundEffects.apply(new MatrixEffectMove(mMoveBackground) );
|
|
153 |
backgroundEffects.apply(new MatrixEffectScale(mScaleBackground) );
|
|
154 |
backgroundEffects.apply(new MatrixEffectMove(mMoveBackground) );
|
|
152 | 155 |
} |
153 | 156 |
|
154 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
216 | 219 |
|
217 | 220 |
void setRegion(float x, float y, float z, float r) |
218 | 221 |
{ |
219 |
float factorReg = 2*mFactorObj*r/mRegionEffects.getStartchX();
|
|
222 |
float factorReg = 2*mFactorObj*r/mRegionQuad.getStretchX();
|
|
220 | 223 |
mRegionPoint.set(mFactorObj*x,mFactorObj*y, mFactorObj*z); |
221 | 224 |
mRegionScalePoint.set(factorReg,factorReg,factorReg); |
222 | 225 |
} |
... | ... | |
243 | 246 |
mScreenMin = width<height ? width:height; |
244 | 247 |
|
245 | 248 |
float factorCen; |
246 |
int centerSize = mCenterEffects.getStartchX();
|
|
249 |
float centerSize = mCenterQuad.getStretchX();
|
|
247 | 250 |
|
248 | 251 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
249 | 252 |
{ |
... | ... | |
267 | 270 |
mScaleCenter.set(factorCen,factorCen,factorCen); |
268 | 271 |
mMoveRegion.set( (width -mFactorObj*mObjWidth )/2 ,(height-mFactorObj*mObjHeight)/2 , 12 ); |
269 | 272 |
|
270 |
int backgroundSize = mBackgroundEffects.getStartchX();
|
|
273 |
float backgroundSize = mBackgroundQuad.getStretchX();
|
|
271 | 274 |
float factorBackX = ((float)width)/backgroundSize; |
272 | 275 |
float factorBackY = ((float)height)/backgroundSize; |
273 | 276 |
|
src/main/java/org/distorted/examples/generic/GenericTab.java | ||
---|---|---|
20 | 20 |
package org.distorted.examples.generic; |
21 | 21 |
|
22 | 22 |
import android.os.Bundle; |
23 |
import android.support.annotation.NonNull; |
|
23 | 24 |
import android.support.v4.app.Fragment; |
24 | 25 |
import android.view.LayoutInflater; |
25 | 26 |
import android.view.View; |
... | ... | |
62 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 64 |
|
64 | 65 |
@Override |
65 |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) |
|
66 |
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
|
66 | 67 |
{ |
67 | 68 |
Bundle args = getArguments(); |
68 | 69 |
|
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
115 | 115 |
diHips.add(dMiddle); |
116 | 116 |
diHips.add(dBegin); |
117 | 117 |
|
118 |
mEffects = new DistortedEffects(1);
|
|
118 |
mEffects = new DistortedEffects(); |
|
119 | 119 |
|
120 | 120 |
mEffects.apply( new VertexEffectSink ( diSink, pLeft , sinkRegion) ); |
121 | 121 |
mEffects.apply( new VertexEffectSink ( diSink, pRight, sinkRegion) ); |
... | ... | |
210 | 210 |
bmpHeight = bitmap.getHeight(); |
211 | 211 |
bmpWidth = bitmap.getWidth(); |
212 | 212 |
|
213 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
214 |
|
|
215 | 213 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
216 | 214 |
mTexture.setTexture(bitmap); |
217 | 215 |
|
218 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
216 |
if( mMesh==null ) |
|
217 |
{ |
|
218 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
219 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
220 |
} |
|
219 | 221 |
|
220 | 222 |
mScreen.detachAll(); |
221 | 223 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/glow/GlowRenderer.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.main.DistortedEffects; |
33 | 33 |
import org.distorted.library.main.DistortedScreen; |
34 | 34 |
import org.distorted.library.main.DistortedTexture; |
35 |
import org.distorted.library.mesh.MeshRectangles;
|
|
35 |
import org.distorted.library.mesh.MeshQuad;
|
|
36 | 36 |
import org.distorted.library.type.Static1D; |
37 | 37 |
import org.distorted.library.type.Static3D; |
38 | 38 |
import org.distorted.library.type.Static4D; |
... | ... | |
74 | 74 |
|
75 | 75 |
mGlow = new PostprocessEffectGlow(mRadius,mColor); |
76 | 76 |
|
77 |
DistortedEffects effects = new DistortedEffects(mRootW,mRootH,0);
|
|
77 |
DistortedEffects effects = new DistortedEffects(); |
|
78 | 78 |
effects.apply(new MatrixEffectScale(mScale)); |
79 | 79 |
effects.apply(new MatrixEffectMove(mMove)); |
80 | 80 |
effects.apply(mGlow); |
81 | 81 |
|
82 |
MeshQuad quad = new MeshQuad(); |
|
83 |
quad.setStretch(mRootW,mRootH,0); |
|
84 |
|
|
82 | 85 |
mScreen = new DistortedScreen(); |
83 |
mScreen.attach(mLeaf, effects, new MeshRectangles(1,1) );
|
|
86 |
mScreen.attach(mLeaf, effects, quad );
|
|
84 | 87 |
mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
85 | 88 |
mScreen.showFPS(); |
86 | 89 |
} |
src/main/java/org/distorted/examples/inflate/InflateActivity2.java | ||
---|---|---|
122 | 122 |
|
123 | 123 |
mMesh = new MeshCubes(mNumCols, str, mNumSlic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
124 | 124 |
} |
125 |
mMesh.setStretch(mNumCols,mNumRows,mNumSlic); |
|
125 | 126 |
break; |
126 | 127 |
case 1: mMesh = new MeshRectangles(mNumCols,mNumRows); |
128 |
mMesh.setStretch(mNumCols,mNumRows,0); |
|
127 | 129 |
break; |
128 | 130 |
case 2: mMesh = new MeshSphere(mNumRows); |
131 |
mMesh.setStretch(mNumRows,mNumRows,mNumRows); |
|
129 | 132 |
break; |
130 | 133 |
case 3: mMesh = new MeshQuad(); |
134 |
mMesh.setStretch(1,1,0); |
|
131 | 135 |
break; |
132 | 136 |
} |
133 | 137 |
|
src/main/java/org/distorted/examples/inflate/InflateRenderer.java | ||
---|---|---|
50 | 50 |
private DistortedEffects mEffects; |
51 | 51 |
private MeshBase mMesh; |
52 | 52 |
private DistortedScreen mScreen; |
53 |
private int mObjWidth, mObjHeight, mObjDepth;
|
|
53 |
private float mObjWidth, mObjHeight, mObjDepth;
|
|
54 | 54 |
private Static3D mMove, mScale, mCenter; |
55 | 55 |
private Static1D mAlpha; |
56 | 56 |
|
... | ... | |
74 | 74 |
mTexture = act.getTexture(); |
75 | 75 |
mMesh = act.getMesh(); |
76 | 76 |
|
77 |
mObjWidth = act.getNumCols();
|
|
78 |
mObjHeight= act.getNumRows();
|
|
79 |
mObjDepth = act.getNumSlic();
|
|
77 |
mObjWidth = mMesh.getStretchX();
|
|
78 |
mObjHeight= mMesh.getStretchY();
|
|
79 |
mObjDepth = mMesh.getStretchZ();
|
|
80 | 80 |
|
81 | 81 |
mQuat1 = new Static4D(0,0,0,1); // unity |
82 | 82 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
... | ... | |
87 | 87 |
quatInt1.add(mQuat1); |
88 | 88 |
quatInt2.add(mQuat2); |
89 | 89 |
|
90 |
mEffects = new DistortedEffects(mObjWidth,mObjHeight,mObjDepth);
|
|
90 |
mEffects = new DistortedEffects(); |
|
91 | 91 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
92 | 92 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
93 | 93 |
mEffects.apply( new MatrixEffectScale(mScale)); |
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
163 | 163 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
164 | 164 |
mTexture.setTexture(bitmap); |
165 | 165 |
|
166 |
if( mMesh==null ) mMesh = new MeshRectangles(50,50*bmpHeight/bmpWidth); |
|
166 |
if( mMesh==null ) |
|
167 |
{ |
|
168 |
mMesh = new MeshRectangles(50,50*bmpHeight/bmpWidth); |
|
169 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
170 |
} |
|
167 | 171 |
|
168 | 172 |
if( mEffects==null ) |
169 | 173 |
{ |
170 |
mEffects = new DistortedEffects(bmpWidth,bmpHeight,0);
|
|
174 |
mEffects = new DistortedEffects(); |
|
171 | 175 |
mEffects.apply(new MatrixEffectScale(mScale)); |
172 | 176 |
mEffects.apply(new MatrixEffectMove(mMove)); |
173 | 177 |
} |
src/main/java/org/distorted/examples/mirror/MirrorRenderer.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.main.DistortedFramebuffer; |
33 | 33 |
import org.distorted.library.main.DistortedScreen; |
34 | 34 |
import org.distorted.library.main.DistortedTexture; |
35 |
import org.distorted.library.mesh.MeshRectangles;
|
|
35 |
import org.distorted.library.mesh.MeshQuad;
|
|
36 | 36 |
import org.distorted.library.type.Static1D; |
37 | 37 |
import org.distorted.library.type.Static3D; |
38 | 38 |
|
... | ... | |
60 | 60 |
private DistortedTexture mTextureMirror, mTextureHead; |
61 | 61 |
private DistortedFramebuffer mOffScreen1, mOffScreen2; |
62 | 62 |
private DistortedScreen mScreen; |
63 |
private MeshRectangles mQuad;
|
|
63 |
private MeshQuad mQuad1, mQuad2, mQuadMirror, mQuadHead;
|
|
64 | 64 |
private Static3D mHeadPosition, mScaleMirror, mMoveOffscreen2, mScaleHead; |
65 | 65 |
|
66 | 66 |
private int mX; |
... | ... | |
72 | 72 |
MirrorRenderer(GLSurfaceView view) |
73 | 73 |
{ |
74 | 74 |
mView = view; |
75 |
mQuad = new MeshRectangles(1,1); |
|
76 | 75 |
mScreen = new DistortedScreen(); |
77 | 76 |
|
78 |
mEffectsMirror = new DistortedEffects(1); |
|
79 |
mEffectsHead = new DistortedEffects(1); |
|
80 |
mEffectsOffscreen1= new DistortedEffects(1); |
|
81 |
mEffectsOffscreen2= new DistortedEffects(1); |
|
82 |
mEffectsScreen = new DistortedEffects(1); |
|
77 |
mQuad1 = new MeshQuad(); |
|
78 |
mQuad2 = new MeshQuad(); |
|
79 |
mQuadMirror= new MeshQuad(); |
|
80 |
mQuadHead = new MeshQuad(); |
|
81 |
|
|
82 |
mEffectsMirror = new DistortedEffects(); |
|
83 |
mEffectsHead = new DistortedEffects(); |
|
84 |
mEffectsOffscreen1= new DistortedEffects(); |
|
85 |
mEffectsOffscreen2= new DistortedEffects(); |
|
86 |
mEffectsScreen = new DistortedEffects(); |
|
83 | 87 |
|
84 | 88 |
mX = MirrorActivity.INIT_POSITION; |
85 | 89 |
|
... | ... | |
143 | 147 |
int offscreen2W = (int)(MIRROR_SCALE*mScreenW); |
144 | 148 |
int offscreen2H = (int)(MIRROR_SCALE*mScreenH); |
145 | 149 |
|
146 |
mEffectsOffscreen1.setStretch(offscreen1W, offscreen1H, 0); |
|
147 |
mEffectsOffscreen2.setStretch(offscreen2W, offscreen2H, 0); |
|
148 |
mEffectsScreen.setStretch(offscreen1W, offscreen1H, 0); |
|
150 |
mQuad1.setStretch(offscreen1W, offscreen1H, 0); |
|
151 |
mQuad2.setStretch(offscreen2W, offscreen2H, 0); |
|
149 | 152 |
|
150 | 153 |
mOffScreen1 = new DistortedFramebuffer( offscreen1W, offscreen1H, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL ); |
151 | 154 |
mOffScreen2 = new DistortedFramebuffer( offscreen2W, offscreen2H, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL ); |
... | ... | |
158 | 161 |
mHeadPosition.set1( mScreenH*MIRROR_MARGIN*mMirrorW/mMirrorH ); |
159 | 162 |
setPosition(mX); |
160 | 163 |
|
161 |
mOffScreen1.attach( mTextureMirror, mEffectsMirror , mQuad ); |
|
162 |
mOffScreen1.attach( mOffScreen2 , mEffectsOffscreen2, mQuad ); |
|
163 |
mOffScreen1.attach( mTextureHead , mEffectsHead , mQuad ); |
|
164 |
mOffScreen2.attach( mOffScreen1 , mEffectsOffscreen1, mQuad ); |
|
164 |
mOffScreen1.attach( mTextureMirror, mEffectsMirror , mQuadMirror );
|
|
165 |
mOffScreen1.attach( mOffScreen2 , mEffectsOffscreen2, mQuad2 );
|
|
166 |
mOffScreen1.attach( mTextureHead , mEffectsHead , mQuadHead );
|
|
167 |
mOffScreen2.attach( mOffScreen1 , mEffectsOffscreen1, mQuad1 );
|
|
165 | 168 |
|
166 | 169 |
mScreen.detachAll(); |
167 |
mScreen.attach ( mOffScreen1 , mEffectsScreen , mQuad ); |
|
170 |
mScreen.attach ( mOffScreen1 , mEffectsScreen , mQuad1 );
|
|
168 | 171 |
mScreen.resize(mScreenW,mScreenH); |
169 | 172 |
} |
170 | 173 |
} |
... | ... | |
198 | 201 |
mHeadW = bitmapH.getWidth(); |
199 | 202 |
mHeadH = bitmapH.getHeight(); |
200 | 203 |
|
201 |
mEffectsMirror.setStretch(mMirrorW,mMirrorH,0);
|
|
202 |
mEffectsHead.setStretch(mHeadW, mHeadH,0);
|
|
204 |
mQuadMirror.setStretch(mMirrorW,mMirrorH,0);
|
|
205 |
mQuadHead.setStretch(mHeadW, mHeadH,0);
|
|
203 | 206 |
|
204 | 207 |
if( mTextureMirror==null ) mTextureMirror = new DistortedTexture(); |
205 | 208 |
if( mTextureHead ==null ) mTextureHead = new DistortedTexture(); |
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
84 | 84 |
dRight.add( new Static3D( 0, 0, 0) ); |
85 | 85 |
dRight.add( new Static3D( 20, 10, 0) ); |
86 | 86 |
|
87 |
mEffects = new DistortedEffects(1);
|
|
87 |
mEffects = new DistortedEffects(); |
|
88 | 88 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
89 | 89 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
90 | 90 |
|
... | ... | |
150 | 150 |
bmpHeight = bitmap.getHeight(); |
151 | 151 |
bmpWidth = bitmap.getWidth(); |
152 | 152 |
|
153 |
// We could have gotten here after the activity went to the background |
|
154 |
// for a brief amount of time; in this case mTexture is already created. |
|
155 |
// Do not leak memory by creating it the second time around. |
|
156 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
157 |
|
|
158 |
// likewise the Mesh |
|
153 | 159 |
// This will make the Mesh stretched by bmpWidth x bmpHeight even before any effects |
154 | 160 |
// are applied to it (the Mesh - MeshRectangles - is flat, so the third parameter does not |
155 | 161 |
// not matter). bmpWight x bmpHeight is the size of the Bitmap, thus this means that we can |
... | ... | |
158 | 164 |
// around its center has to be centered at (bmpWidth/2, bmpHeight/2, 0). |
159 | 165 |
// Without this call, the default size of the Mesh is 1x1x0 ( or 1x1x1 in case of not-flat |
160 | 166 |
// Meshes) so we would need to be rotating around (0.5,0.5,0.0). |
161 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
162 |
|
|
163 |
// We could have gotten here after the activity went to the background |
|
164 |
// for a brief amount of time; in this case mTexture is already created. |
|
165 |
// Do not leak memory by creating it the second time around. |
|
166 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
167 |
|
|
168 |
// likewise the Mesh |
|
169 |
if( mMesh==null ) mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
|
167 |
if( mMesh==null ) |
|
168 |
{ |
|
169 |
mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
|
170 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
171 |
} |
|
170 | 172 |
|
171 | 173 |
// even if mTexture wasn't null, we still need to call setTexture() on it |
172 | 174 |
// because every time activity goes to background, its OpenGL resources |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
---|---|---|
65 | 65 |
mPaint.setStyle(Style.FILL); |
66 | 66 |
|
67 | 67 |
mView = v; |
68 |
mEffects= new DistortedEffects(1);
|
|
68 |
mEffects= new DistortedEffects(); |
|
69 | 69 |
mScreen = new DistortedScreen(); |
70 | 70 |
mRefresh= true; |
71 | 71 |
} |
... | ... | |
141 | 141 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
142 | 142 |
mCanvas = new Canvas(mBitmap); |
143 | 143 |
|
144 |
mEffects.setStretch(texW,texH,0); |
|
145 |
|
|
146 | 144 |
if( mMesh!=null ) mMesh.markForDeletion(); |
147 | 145 |
mMesh = new MeshRectangles(80,80*texH/texW); |
146 |
mMesh.setStretch(texW,texH,0); |
|
148 | 147 |
|
149 | 148 |
mScreen.detachAll(); |
150 | 149 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java | ||
---|---|---|
35 | 35 |
import org.distorted.library.main.DistortedScreen; |
36 | 36 |
import org.distorted.library.main.DistortedTexture; |
37 | 37 |
import org.distorted.library.mesh.MeshBase; |
38 |
import org.distorted.library.mesh.MeshQuad; |
|
38 | 39 |
import org.distorted.library.mesh.MeshRectangles; |
39 | 40 |
import org.distorted.library.message.EffectListener; |
40 | 41 |
import org.distorted.library.type.Dynamic1D; |
... | ... | |
78 | 79 |
|
79 | 80 |
mLeaf = new DistortedTexture(); |
80 | 81 |
DistortedTexture surface = new DistortedTexture(); |
81 |
MeshBase mesh = new MeshRectangles(1,1); |
|
82 | 82 |
|
83 |
DistortedNode root = new DistortedNode(surface, new DistortedEffects(mRootW,mRootH,0), mesh); |
|
84 |
|
|
83 |
MeshQuad rootMesh = new MeshQuad(); |
|
84 |
rootMesh.setStretch(mRootW,mRootH,0); |
|
85 |
MeshQuad leafMesh = new MeshQuad(); |
|
86 |
leafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0); |
|
87 |
|
|
88 |
DistortedEffects rootEffects = new DistortedEffects(); |
|
89 |
DistortedNode root = new DistortedNode(surface, rootEffects, rootMesh); |
|
90 |
|
|
85 | 91 |
Static3D moveVector = new Static3D(0.55f*LEAF_SIZE, (mRootH-LEAF_SIZE)/2, 0); |
86 | 92 |
Static1D chromaLevel= new Static1D(0.5f); |
87 | 93 |
Static3D center = new Static3D(mRootW/2, mRootH/2, 0); |
... | ... | |
91 | 97 |
|
92 | 98 |
for(int j=0; j<NUM_LEAVES; j++) |
93 | 99 |
{ |
94 |
mLeafEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
100 |
mLeafEffects[j] = new DistortedEffects(); |
|
95 | 101 |
mLeafEffects[j].apply(leafMove); |
96 | 102 |
mLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
97 | 103 |
mLeafEffects[j].apply( new FragmentEffectChroma(chromaLevel, new Static3D(colors[3*j],colors[3*j+1], colors[3*j+2])) ); |
98 |
DistortedNode node = new DistortedNode( mLeaf, mLeafEffects[j], mesh);
|
|
104 |
DistortedNode node = new DistortedNode( mLeaf, mLeafEffects[j], leafMesh);
|
|
99 | 105 |
root.attach(node); |
100 | 106 |
} |
101 | 107 |
|
src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
---|---|---|
94 | 94 |
for(int i=0; i<NUM_OBJECTS; i++) |
95 | 95 |
{ |
96 | 96 |
mMoveVector[i] = new Static3D(0,0,0); |
97 |
effects[i] = new DistortedEffects(OBJ_SIZE,OBJ_SIZE,OBJ_SIZE);
|
|
97 |
effects[i] = new DistortedEffects(); |
|
98 | 98 |
mBlurStatus[i] = false; |
99 | 99 |
} |
100 | 100 |
|
101 | 101 |
mBlurVector = new Static1D(10); |
102 | 102 |
|
103 | 103 |
MeshCubes mesh = new MeshCubes(1,1,1); |
104 |
mesh.setStretch(OBJ_SIZE,OBJ_SIZE,OBJ_SIZE); |
|
104 | 105 |
|
105 | 106 |
mTex1 = new DistortedTexture(); |
106 | 107 |
mTex2 = new DistortedTexture(); |
src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java | ||
---|---|---|
78 | 78 |
chromaDyn.add(new Static1D(0.0f)); |
79 | 79 |
chromaDyn.add(new Static1D(0.8f)); |
80 | 80 |
|
81 |
mEffects= new DistortedEffects(1);
|
|
81 |
mEffects= new DistortedEffects(); |
|
82 | 82 |
mEffects.apply(new MatrixEffectScale(mScale)); |
83 | 83 |
mEffects.apply(new MatrixEffectMove(mMove)); |
84 | 84 |
mEffects.apply(new FragmentEffectChroma(chromaDyn, new Static3D(0,0,1))); |
... | ... | |
181 | 181 |
int gridHeight= bitmap2.getHeight(); |
182 | 182 |
int gridDepth = gridWidth/GRID; |
183 | 183 |
|
184 |
mEffects.setStretch(lisaWidth,lisaHeight,0); |
|
185 |
|
|
186 | 184 |
if( mLisaTexture==null ) mLisaTexture = new DistortedTexture(); |
187 | 185 |
if( mGridTexture==null ) mGridTexture = new DistortedTexture(); |
188 | 186 |
mLisaTexture.setTexture(bitmap1); |
189 | 187 |
mGridTexture.setTexture(bitmap2); |
190 | 188 |
|
191 |
DistortedEffects gridEffects = new DistortedEffects(gridWidth,gridHeight,gridDepth); |
|
189 |
DistortedEffects gridEffects = new DistortedEffects(); |
|
190 |
|
|
191 |
if( mMeshRectangles ==null ) |
|
192 |
{ |
|
193 |
mMeshRectangles = new MeshRectangles(1,1); |
|
194 |
mMeshRectangles.setStretch(lisaWidth,lisaHeight,0); |
|
195 |
} |
|
192 | 196 |
|
193 |
if( mMeshRectangles ==null ) mMeshRectangles = new MeshRectangles(1,1); |
|
194 |
if( mMeshCubes==null) mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
|
197 |
if( mMeshCubes==null) |
|
198 |
{ |
|
199 |
mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
|
200 |
mMeshCubes.setStretch(gridWidth,gridHeight,gridDepth); |
|
201 |
} |
|
195 | 202 |
|
196 | 203 |
mRoot = new DistortedNode(mLisaTexture, mEffects, mMeshRectangles); |
197 | 204 |
mRoot.attach(mGridTexture,gridEffects,mMeshCubes); |
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
35 | 35 |
import org.distorted.library.main.DistortedLibrary; |
36 | 36 |
import org.distorted.library.main.DistortedScreen; |
37 | 37 |
import org.distorted.library.main.DistortedNode; |
38 |
import org.distorted.library.mesh.MeshRectangles;
|
|
38 |
import org.distorted.library.mesh.MeshQuad;
|
|
39 | 39 |
import org.distorted.library.type.Dynamic1D; |
40 | 40 |
import org.distorted.library.type.Static3D; |
41 | 41 |
import org.distorted.library.type.Static1D; |
... | ... | |
57 | 57 |
private DistortedNode mRoot; |
58 | 58 |
private DistortedTexture mLeaf; |
59 | 59 |
private DistortedScreen mScreen; |
60 |
private MeshRectangles mMesh;
|
|
60 |
private MeshQuad mLeafMesh;
|
|
61 | 61 |
private int mScreenW, mScreenH; |
62 | 62 |
private int mPrevRendered, mCurrRendered; |
63 | 63 |
private Static3D mMove, mScale; |
... | ... | |
78 | 78 |
} |
79 | 79 |
else if( number>0 && number<=NUM_LEAVES ) |
80 | 80 |
{ |
81 |
if( checked ) mCircleNode[color].attach( mLeaf, mEffects[number-1], mMesh); |
|
81 |
if( checked ) mCircleNode[color].attach( mLeaf, mEffects[number-1], mLeafMesh);
|
|
82 | 82 |
else mCircleNode[color].detach(mEffects[number-1]); |
83 | 83 |
} |
84 | 84 |
} |
... | ... | |
98 | 98 |
|
99 | 99 |
mLeaf = new DistortedTexture(); |
100 | 100 |
DistortedTexture surface = new DistortedTexture(); |
101 |
mMesh = new MeshRectangles(1,1); |
|
101 |
|
|
102 |
mLeafMesh = new MeshQuad(); |
|
103 |
mLeafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0); |
|
104 |
MeshQuad circleMesh = new MeshQuad(); |
|
105 |
circleMesh.setStretch(3*LEAF_SIZE,3*LEAF_SIZE,0); |
|
106 |
MeshQuad rootMesh = new MeshQuad(); |
|
107 |
rootMesh.setStretch(mScreenW,mScreenH,0); |
|
108 |
|
|
102 | 109 |
mMove = new Static3D(0,0,0); |
103 | 110 |
mScale= new Static3D(1,1,1); |
104 | 111 |
|
105 |
DistortedEffects rootEffects = new DistortedEffects(mScreenW,mScreenH,0);
|
|
112 |
DistortedEffects rootEffects = new DistortedEffects(); |
|
106 | 113 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
107 | 114 |
rootEffects.apply(new MatrixEffectMove(mMove)); |
108 | 115 |
|
109 |
mRoot = new DistortedNode(new DistortedTexture(), rootEffects, mMesh);
|
|
116 |
mRoot = new DistortedNode(new DistortedTexture(), rootEffects, rootMesh);
|
|
110 | 117 |
|
111 | 118 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
112 | 119 |
rot.setMode(Dynamic1D.MODE_JUMP); |
... | ... | |
122 | 129 |
|
123 | 130 |
for(int j=0; j<NUM_LEAVES; j++) |
124 | 131 |
{ |
125 |
mEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
132 |
mEffects[j] = new DistortedEffects(); |
|
126 | 133 |
mEffects[j].apply(new MatrixEffectMove(moveVector)); |
127 | 134 |
mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
128 | 135 |
} |
129 | 136 |
|
130 | 137 |
for(int i=0; i<NUM_CIRCLES; i++) |
131 | 138 |
{ |
132 |
DistortedEffects effects = new DistortedEffects(3*LEAF_SIZE,3*LEAF_SIZE,0);
|
|
139 |
DistortedEffects effects = new DistortedEffects(); |
|
133 | 140 |
effects.apply( new MatrixEffectRotate(rot, axis, center) ); |
134 | 141 |
effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) ); |
135 | 142 |
effects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2])) ); |
136 | 143 |
|
137 |
mCircleNode[i] = new DistortedNode( surface, effects, mMesh);
|
|
144 |
mCircleNode[i] = new DistortedNode( surface, effects, circleMesh);
|
|
138 | 145 |
mRoot.attach(mCircleNode[i]); |
139 | 146 |
|
140 |
for(int j=0; j<NUM_LEAVES; j++) mCircleNode[i].attach(mLeaf, mEffects[j], mMesh); |
|
147 |
for(int j=0; j<NUM_LEAVES; j++) mCircleNode[i].attach(mLeaf, mEffects[j], mLeafMesh);
|
|
141 | 148 |
} |
142 | 149 |
|
143 | 150 |
mScreen = new DistortedScreen(); |
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
95 | 95 |
dRight.add( new Static3D( 0, 0, 0) ); |
96 | 96 |
dRight.add( new Static3D( 20, 10, 0) ); |
97 | 97 |
|
98 |
mEffects = new DistortedEffects(1);
|
|
98 |
mEffects = new DistortedEffects(); |
|
99 | 99 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
100 | 100 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
101 | 101 |
|
... | ... | |
262 | 262 |
bmpHeight = bmp.getHeight(); |
263 | 263 |
bmpWidth = bmp.getWidth(); |
264 | 264 |
|
265 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
266 |
|
|
267 | 265 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
268 | 266 |
mTexture.setTexture(bmp); |
269 | 267 |
|
270 |
if( mMesh==null ) mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
|
268 |
if( mMesh==null ) |
|
269 |
{ |
|
270 |
mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
|
271 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
272 |
} |
|
271 | 273 |
|
272 | 274 |
mScreen.detachAll(); |
273 | 275 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/postprocesstree/PostprocessTreeRenderer.java | ||
---|---|---|
34 | 34 |
import org.distorted.library.main.DistortedNode; |
35 | 35 |
import org.distorted.library.main.DistortedScreen; |
36 | 36 |
import org.distorted.library.main.DistortedTexture; |
37 |
import org.distorted.library.mesh.MeshQuad; |
|
37 | 38 |
import org.distorted.library.mesh.MeshRectangles; |
38 | 39 |
import org.distorted.library.type.Dynamic1D; |
39 | 40 |
import org.distorted.library.type.Static1D; |
... | ... | |
78 | 79 |
|
79 | 80 |
mLeaf = new DistortedTexture(); |
80 | 81 |
|
81 |
MeshRectangles mesh = new MeshRectangles(1,1); |
|
82 |
MeshQuad rootMesh = new MeshQuad(); |
|
83 |
rootMesh.setStretch(mScreenW,mScreenH,0); |
|
84 |
MeshQuad innerMesh = new MeshQuad(); |
|
85 |
innerMesh.setStretch(INNER*LEAF_SIZE,INNER*LEAF_SIZE,0); |
|
86 |
MeshQuad leafMesh = new MeshQuad(); |
|
87 |
leafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0); |
|
88 |
|
|
82 | 89 |
mMove = new Static3D(0,0,0); |
83 | 90 |
mScale= new Static3D(1,1,1); |
84 | 91 |
|
85 |
DistortedEffects rootEffects = new DistortedEffects(mScreenW,mScreenH,0);
|
|
86 |
DistortedEffects innerEffects = new DistortedEffects(INNER*LEAF_SIZE,INNER*LEAF_SIZE,0);
|
|
92 |
DistortedEffects rootEffects = new DistortedEffects(); |
|
93 |
DistortedEffects innerEffects = new DistortedEffects(); |
|
87 | 94 |
DistortedEffects[] innerLeafEffects= new DistortedEffects[NUM_LEAVES]; |
88 | 95 |
DistortedEffects[] outerLeafEffects= new DistortedEffects[NUM_LEAVES]; |
89 | 96 |
|
90 |
DistortedNode root = new DistortedNode(new DistortedTexture(), rootEffects, mesh);
|
|
97 |
DistortedNode root = new DistortedNode(new DistortedTexture(), rootEffects, rootMesh);
|
|
91 | 98 |
|
92 | 99 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
93 | 100 |
rootEffects.apply(new MatrixEffectMove(mMove)); |
... | ... | |
107 | 114 |
|
108 | 115 |
for(int j=0; j<NUM_LEAVES; j++) |
109 | 116 |
{ |
110 |
outerLeafEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
117 |
outerLeafEffects[j] = new DistortedEffects(); |
|
111 | 118 |
outerLeafEffects[j].apply(new MatrixEffectMove(outerMoveVector)); |
112 | 119 |
outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, outerCenter) ); |
113 | 120 |
|
114 |
root.attach(mLeaf, outerLeafEffects[j], mesh);
|
|
121 |
root.attach(mLeaf, outerLeafEffects[j], leafMesh);
|
|
115 | 122 |
} |
116 | 123 |
|
117 | 124 |
innerEffects.apply( new MatrixEffectRotate(rotate, axis, innerCenter) ); |
... | ... | |
119 | 126 |
innerEffects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0) ) ); |
120 | 127 |
innerEffects.apply(blurEffect); |
121 | 128 |
|
122 |
DistortedNode innerNode = new DistortedNode( new DistortedTexture(), innerEffects, mesh);
|
|
129 |
DistortedNode innerNode = new DistortedNode( new DistortedTexture(), innerEffects, innerMesh);
|
|
123 | 130 |
root.attach(innerNode); |
124 | 131 |
|
125 | 132 |
for(int j=0; j<NUM_LEAVES; j++) |
126 | 133 |
{ |
127 |
innerLeafEffects[j] = new DistortedEffects(LEAF_SIZE,LEAF_SIZE,0);
|
|
134 |
innerLeafEffects[j] = new DistortedEffects(); |
|
128 | 135 |
innerLeafEffects[j].apply(new MatrixEffectMove(innerMoveVector)); |
129 | 136 |
innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, innerCenter) ); |
130 | 137 |
|
131 |
innerNode.attach( mLeaf, innerLeafEffects[j], mesh );
|
|
138 |
innerNode.attach( mLeaf, innerLeafEffects[j], leafMesh );
|
|
132 | 139 |
} |
133 | 140 |
|
134 | 141 |
mScreen = new DistortedScreen(); |
src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
---|---|---|
56 | 56 |
ProjectionRenderer(GLSurfaceView view) |
57 | 57 |
{ |
58 | 58 |
mView = view; |
59 |
mEffects= new DistortedEffects(1);
|
|
59 |
mEffects= new DistortedEffects(); |
|
60 | 60 |
mScreen = new DistortedScreen(); |
61 | 61 |
|
62 | 62 |
mVector = new Static3D(0,0,0); |
... | ... | |
130 | 130 |
mPoint3.set( width/4, 3*height/4, 0); |
131 | 131 |
mPoint4.set(3*width/4, 3*height/4, 0); |
132 | 132 |
|
133 |
mEffects.setStretch(width,height,0); |
|
134 |
|
|
135 | 133 |
// Avoid memory leaks: delete old texture if it exists (it might if we |
136 | 134 |
// got here after a brief amount of time spent in the background) |
137 | 135 |
if( mTexture!=null ) mTexture.markForDeletion(); |
... | ... | |
140 | 138 |
mTexture.setTexture(bmp); |
141 | 139 |
|
142 | 140 |
// likewise with the Mesh |
143 |
if( mMesh!=null ) mMesh.markForDeletion(); |
|
144 |
|
|
141 |
if( mMesh!=null ) mMesh.markForDeletion(); |
|
145 | 142 |
mMesh = new MeshRectangles(100,100*height/width); |
143 |
mMesh.setStretch(width,height,0); |
|
146 | 144 |
|
147 | 145 |
mScreen.detachAll(); |
148 | 146 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
63 | 63 |
mView = v; |
64 | 64 |
mTexture = new DistortedTexture(); |
65 | 65 |
|
66 |
DistortedEffects effects = new DistortedEffects(1);
|
|
66 |
DistortedEffects effects = new DistortedEffects(); |
|
67 | 67 |
DynamicQuat rot = new DynamicQuat(); |
68 | 68 |
|
69 | 69 |
Random rnd = new Random(System.currentTimeMillis()); |
src/main/java/org/distorted/examples/rubik/RubikCube.java | ||
---|---|---|
130 | 130 |
tmpBottom= (y== 0 ? mapBottom:mapBlack); |
131 | 131 |
|
132 | 132 |
mCubes[x][y][z] = new MeshCubes(vertices,vertices,vertices, tmpFront, tmpBack, tmpLeft, tmpRight, tmpTop, tmpBottom); |
133 |
mCubes[x][y][z].setStretch(STRETCH_SIZE,STRETCH_SIZE,STRETCH_SIZE); |
|
134 |
|
|
133 | 135 |
cubeVectors[x][y][z] = new Static3D( STRETCH_SIZE*(x-nc), STRETCH_SIZE*(y-nc), STRETCH_SIZE*(z-nc) ); |
134 | 136 |
mRotationAngle[x][y][z] = new Dynamic1D(); |
135 | 137 |
mRotationAxis[x][y][z] = new Static3D(1,0,0); |
... | ... | |
138 | 140 |
mRotationAngle[x][y][z].add(new Static1D(0.0f)); |
139 | 141 |
mRotate[x][y][z] = new MatrixEffectRotate( mRotationAngle[x][y][z], mRotationAxis[x][y][z], center); |
140 | 142 |
|
141 |
mEffects[x][y][z] = new DistortedEffects(STRETCH_SIZE,STRETCH_SIZE,STRETCH_SIZE);
|
|
143 |
mEffects[x][y][z] = new DistortedEffects(); |
|
142 | 144 |
mEffects[x][y][z].apply( new MatrixEffectMove(cubeVectors[x][y][z]) ); |
143 | 145 |
mEffects[x][y][z].apply( mRotate[x][y][z] ); |
144 | 146 |
mEffects[x][y][z].apply(quatEffect); |
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
93 | 93 |
mMove = new Static3D(0,0,0); |
94 | 94 |
mScaleMain = new Static3D(1,1,1); |
95 | 95 |
|
96 |
mEffects = new DistortedEffects(1);
|
|
96 |
mEffects = new DistortedEffects(); |
|
97 | 97 |
mEffects.apply( new VertexEffectSink(diSink, pLeft , sinkRegion) ); |
98 | 98 |
mEffects.apply( new VertexEffectSink(diSink, pRight, sinkRegion) ); |
99 | 99 |
mEffects.apply( new MatrixEffectScale(mScaleMain)); |
... | ... | |
245 | 245 |
bmpHeight = bitmap.getHeight(); |
246 | 246 |
bmpWidth = bitmap.getWidth(); |
247 | 247 |
|
248 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
249 |
|
|
250 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
248 |
if( mMesh==null ) |
|
249 |
{ |
|
250 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
251 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
252 |
} |
|
251 | 253 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
252 | 254 |
mTexture.setTexture(bitmap); |
253 | 255 |
|
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
65 | 65 |
sink.add(new Static1D(1.0f)); |
66 | 66 |
sink.add(new Static1D(0.2f)); |
67 | 67 |
|
68 |
mEffects = new DistortedEffects(1);
|
|
68 |
mEffects = new DistortedEffects(); |
|
69 | 69 |
VertexEffectSink sinkEffect = new VertexEffectSink(sink, new Static3D(297, 280, 0), null); |
70 | 70 |
mEffects.apply(sinkEffect); |
71 | 71 |
|
... | ... | |
129 | 129 |
bmpHeight = bitmap.getHeight(); |
130 | 130 |
bmpWidth = bitmap.getWidth(); |
131 | 131 |
|
132 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
133 |
|
|
134 | 132 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
135 | 133 |
mTexture.setTexture(bitmap); |
136 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
134 |
if( mMesh==null ) |
|
135 |
{ |
|
136 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
137 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
138 |
} |
|
139 |
|
|
137 | 140 |
|
138 | 141 |
mScreen.detachAll(); |
139 | 142 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
34 | 34 |
import org.distorted.library.effect.MatrixEffectScale; |
35 | 35 |
import org.distorted.library.main.DistortedNode; |
36 | 36 |
import org.distorted.library.main.DistortedScreen; |
37 |
import org.distorted.library.mesh.MeshRectangles;
|
|
37 |
import org.distorted.library.mesh.MeshQuad;
|
|
38 | 38 |
import org.distorted.library.type.Dynamic1D; |
39 | 39 |
import org.distorted.library.type.Dynamic3D; |
40 | 40 |
import org.distorted.library.type.Static1D; |
... | ... | |
110 | 110 |
private DistortedEffects[] mStarEffects; |
111 | 111 |
private DistortedNode mBackground; |
112 | 112 |
private DistortedScreen mScreen; |
113 |
private MeshRectangles mQuad;
|
|
113 |
private MeshQuad mGFFAQuad, mCrawlQuad, mCrawlBackgroundQuad, mLogoQuad, mStarQuad;
|
|
114 | 114 |
|
115 | 115 |
private long alphaEffectID, scaleEffectID, moveEffectID; |
116 | 116 |
private Random mRnd = new Random(0); |
... | ... | |
122 | 122 |
{ |
123 | 123 |
mView = v; |
124 | 124 |
|
125 |
mQuad = new MeshRectangles(1,1); |
|
125 |
mGFFAQuad = new MeshQuad(); |
|
126 |
mStarQuad = new MeshQuad(); |
|
127 |
mCrawlQuad = new MeshQuad(); |
|
128 |
mCrawlBackgroundQuad = new MeshQuad(); |
|
129 |
mLogoQuad = new MeshQuad(); |
|
126 | 130 |
|
127 |
mGFFAEffects = new DistortedEffects(1); |
|
128 |
mLogoEffects = new DistortedEffects(1); |
|
129 |
mCrawlEffects = new DistortedEffects(1); |
|
130 |
mCrawlBackgroundEffects = new DistortedEffects(1); |
|
131 |
mGFFAQuad.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0); |
|
132 |
mCrawlQuad.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0); |
|
133 |
|
|
134 |
mGFFAEffects = new DistortedEffects(); |
|
135 |
mLogoEffects = new DistortedEffects(); |
|
136 |
mCrawlEffects = new DistortedEffects(); |
|
137 |
mCrawlBackgroundEffects = new DistortedEffects(); |
|
131 | 138 |
|
132 | 139 |
if( NUM_STARS>0 ) |
133 | 140 |
{ |
134 | 141 |
mStarEffects = new DistortedEffects[NUM_STARS]; |
135 |
mStarEffects[0] = new DistortedEffects(1);
|
|
142 |
mStarEffects[0] = new DistortedEffects(); |
|
136 | 143 |
|
137 | 144 |
for (int i = 1; i < NUM_STARS; i++) |
138 | 145 |
mStarEffects[i] = new DistortedEffects(mStarEffects[0], DistortedLibrary.CLONE_VERTEX); |
... | ... | |
207 | 214 |
if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion(); |
208 | 215 |
mCrawlBackgroundTexture = new DistortedTexture(); |
209 | 216 |
|
210 |
mCrawlBackgroundEffects.setStretch(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)),0);
|
|
217 |
mCrawlBackgroundQuad.setStretch(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)),0);
|
|
211 | 218 |
|
212 | 219 |
int randomA, randomX, randomY, randomTime; |
213 | 220 |
float randomS, randomAlpha1, randomAlpha2; |
... | ... | |
237 | 244 |
|
238 | 245 |
mStarEffects[i].apply( new FragmentEffectAlpha(di) ); |
239 | 246 |
|
240 |
mScreen.attach(mStarTexture, mStarEffects[i], mQuad); |
|
247 |
mScreen.attach(mStarTexture, mStarEffects[i], mStarQuad);
|
|
241 | 248 |
} |
242 | 249 |
|
243 |
float scale = (0.5f*w/mGFFAEffects.getStartchX());
|
|
250 |
float scale = (0.5f*w/mGFFAQuad.getStretchX());
|
|
244 | 251 |
|
245 | 252 |
Dynamic1D di = new Dynamic1D(6000,0.5f); |
246 | 253 |
di.add(new Static1D(1.0f)); |
... | ... | |
255 | 262 |
mGFFAEffects.apply( new MatrixEffectMove(new Static3D(w/5,2*h/3,0)) ); |
256 | 263 |
mGFFAEffects.apply( alpha ); |
257 | 264 |
|
258 |
mScreen.attach(mGFFATexture, mGFFAEffects, mQuad); |
|
265 |
mScreen.attach(mGFFATexture, mGFFAEffects, mGFFAQuad);
|
|
259 | 266 |
} |
260 | 267 |
|
261 | 268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
292 | 299 |
paint.setTypeface(tf); |
293 | 300 |
|
294 | 301 |
///// create GFFA /////////////////// |
295 |
mGFFAEffects.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0); |
|
296 | 302 |
if( mGFFATexture==null ) mGFFATexture = new DistortedTexture(); |
297 | 303 |
bitmapGFFA = Bitmap.createBitmap(GFFA_WIDTH,GFFA_HEIGHT,Bitmap.Config.ARGB_8888); |
298 | 304 |
bitmapGFFA.eraseColor(0x00000000); |
... | ... | |
306 | 312 |
mGFFATexture.setTexture(bitmapGFFA); |
307 | 313 |
|
308 | 314 |
///// create Logo /////////////////// |
309 |
mLogoEffects.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0);
|
|
315 |
mLogoQuad.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0);
|
|
310 | 316 |
if( mLogoTexture==null ) mLogoTexture = new DistortedTexture(); |
311 | 317 |
mLogoTexture.setTexture(bitmapLogo); |
312 | 318 |
|
313 | 319 |
///// create CRAWL ////////////////// |
314 |
mCrawlEffects.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0); |
|
315 | 320 |
if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture(); |
316 | 321 |
bitmapText = Bitmap.createBitmap(CRAWL_WIDTH,CRAWL_HEIGHT,Bitmap.Config.ARGB_8888); |
317 | 322 |
bitmapText.eraseColor(0x00000000); |
... | ... | |
326 | 331 |
mCrawlTexture.setTexture(bitmapText); |
327 | 332 |
|
328 | 333 |
///// create Stars /////////////////// |
329 |
mStarEffects[0].setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0);
|
|
334 |
mStarQuad.setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0);
|
|
330 | 335 |
if( mStarTexture==null ) mStarTexture = new DistortedTexture(); |
331 | 336 |
mStarTexture.setTexture(bitmapStar); |
332 | 337 |
} |
... | ... | |
385 | 390 |
int screenW=mScreen.getWidth(); |
386 | 391 |
int screenH=mScreen.getHeight(); |
387 | 392 |
|
388 |
int logoW = mLogoEffects.getStartchX();
|
|
389 |
int logoH = mLogoEffects.getStartchY();
|
|
393 |
float logoW = mLogoQuad.getStretchX();
|
|
394 |
float logoH = mLogoQuad.getStretchY();
|
|
390 | 395 |
|
391 | 396 |
int initSize= (int)(3.0f*screenW/logoW); |
392 | 397 |
int finaSize= (int)(0.1f*screenW/logoW); |
... | ... | |
402 | 407 |
mLogoEffects.apply( scale ); |
403 | 408 |
mLogoEffects.apply( new MatrixEffectMove(new Static3D(screenW/2,screenH/2,0)) ); |
404 | 409 |
|
405 |
mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
|
|
410 |
mScreen.attach(mLogoTexture, mLogoEffects, mLogoQuad);
|
|
406 | 411 |
} |
407 | 412 |
else if( effectID == scaleEffectID ) |
408 | 413 |
{ |
409 | 414 |
mScreen.detach(mLogoEffects); |
410 | 415 |
mLogoTexture.markForDeletion(); |
411 | 416 |
|
412 |
int crawlW = mCrawlEffects.getStartchX();
|
|
413 |
int crawlH = mCrawlEffects.getStartchY();
|
|
414 |
int screenW= mScreen.getWidth();
|
|
415 |
int backH = mCrawlBackgroundEffects.getStartchY();
|
|
416 |
float scale= (float)screenW/crawlW;
|
|
417 |
float crawlW = mCrawlQuad.getStretchX();
|
|
418 |
float crawlH = mCrawlQuad.getStretchY();
|
|
419 |
float screenW= mScreen.getWidth();
|
|
420 |
float backH = mCrawlBackgroundQuad.getStretchY();
|
|
421 |
float scale = screenW/crawlW;
|
|
417 | 422 |
|
418 | 423 |
mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) ); |
419 | 424 |
|
... | ... | |
433 | 438 |
mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) ); |
434 | 439 |
mCrawlEffects.apply( move ); |
435 | 440 |
|
436 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
|
|
437 |
mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);
|
|
441 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects, mCrawlBackgroundQuad);
|
|
442 |
mBackground.attach(mCrawlTexture, mCrawlEffects, mCrawlQuad);
|
|
438 | 443 |
mBackground.glDisable(GLES31.GL_DEPTH_TEST); |
Also available in: Unified diff
Move the Effects.setStretch to Meshbase.setStretch