Revision b88ec561
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
class EarthRenderer implements GLSurfaceView.Renderer |
64 | 64 |
{ |
65 |
private static final int SIZE = 500; |
|
66 |
private static final int LEVEL= 32; |
|
67 |
private static final float FOV = 30.0f; |
|
68 |
private static final float NEAR = 0.1f; |
|
65 |
private static final float D = (float)Math.sqrt(2.0)/2.0f; |
|
66 |
|
|
67 |
private static final int SIZE = 500; |
|
68 |
private static final int RADIUS = (int)(SIZE*D); |
|
69 |
private static final int LEVEL = 32; |
|
70 |
private static final float FOV = 30.0f; |
|
71 |
private static final float NEAR = 0.1f; |
|
69 | 72 |
|
70 | 73 |
private GLSurfaceView mView; |
71 | 74 |
private DistortedTexture mTexture; |
... | ... | |
79 | 82 |
int mScreenMin; |
80 | 83 |
|
81 | 84 |
private Static3D mColor; |
85 |
private Static3D mRegionF; |
|
82 | 86 |
private Static1D mStrength; |
83 | 87 |
|
84 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
88 | 92 |
mView = v; |
89 | 93 |
|
90 | 94 |
mStrength = new Static1D(0.5f); |
91 |
mColor= new Static3D(255,0,0); |
|
92 |
mMove = new Static3D(0,0,0); |
|
93 |
mScale= new Static3D(1,1,1); |
|
94 |
mCenter=new Static3D(0,0,0); |
|
95 |
mColor = new Static3D(255,0,0); |
|
96 |
mRegionF = new Static3D(RADIUS,RADIUS,RADIUS); |
|
97 |
mMove = new Static3D(0,0,0); |
|
98 |
mScale = new Static3D(1,1,1); |
|
99 |
mCenter = new Static3D(0,0,0); |
|
95 | 100 |
|
96 |
mMesh = new MeshSphere(LEVEL); |
|
97 |
mTexture= new DistortedTexture(SIZE,SIZE); |
|
101 |
mMesh = new MeshSphere(LEVEL);
|
|
102 |
mTexture = new DistortedTexture(SIZE,SIZE);
|
|
98 | 103 |
|
99 | 104 |
mObjWidth = mTexture.getWidth(); |
100 | 105 |
mObjHeight= mTexture.getHeight(); |
... | ... | |
115 | 120 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
116 | 121 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
117 | 122 |
|
123 |
|
|
124 |
Static3D center = new Static3D(0.5f*mObjWidth,0.5f*mObjHeight,0.5f*mObjDepth); |
|
125 |
mEffects.apply( new FragmentEffectChroma(mStrength, mColor,center, mRegionF, false) ); |
|
126 |
|
|
118 | 127 |
mScreen = new DistortedScreen(); |
119 | 128 |
mScreen.setProjection(FOV, NEAR); |
120 | 129 |
} |
... | ... | |
163 | 172 |
float y = 0.7071f*(float)(cosLON*cosLAT); |
164 | 173 |
float z = 0.7071f*(float) sinLAT ; |
165 | 174 |
|
166 |
float radius = SIZE/10; |
|
167 |
Static4D region = new Static4D(x*mObjWidth,y*mObjHeight,radius,radius); |
|
175 |
Static3D center = new Static3D(x*mObjWidth,y*mObjHeight,z*mObjDepth); |
|
176 |
|
|
177 |
android.util.Log.e("earth", "center "+(x*mObjWidth)+" "+(y*mObjHeight)+" "+(z*mObjDepth)); |
|
178 |
android.util.Log.e("earth", "longitude: "+longitude+" latitude:"+latitude); |
|
168 | 179 |
|
169 | 180 |
switch(name) |
170 | 181 |
{ |
... | ... | |
175 | 186 |
case PINCH : effect = new VertexEffectPinch (mDyn2, center, mRegionV); break; |
176 | 187 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, center, mRegionV); break; |
177 | 188 |
case WAVE : effect = new VertexEffectWave (mDyn5, center, mRegionV); break; |
178 |
|
|
179 |
case ALPHA : effect = new FragmentEffectAlpha (mStrength, region, false); break; |
|
180 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mStrength, region, true ); break; |
|
181 |
case CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,region, false); break; |
|
182 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,region, true ); break; |
|
183 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mStrength, region, false); break; |
|
184 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mStrength, region, true ); break; |
|
185 |
case SATURATION : effect = new FragmentEffectSaturation(mStrength, region, false); break; |
|
186 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mStrength, region, true ); break; |
|
187 |
case CONTRAST : effect = new FragmentEffectContrast (mStrength, region, false); break; |
|
188 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mStrength, region, true ); break; |
|
189 | 189 |
*/ |
190 |
case ALPHA : effect = new FragmentEffectAlpha (mStrength, center, mRegionF, false); break; |
|
191 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mStrength, center, mRegionF, true ); break; |
|
192 |
case CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,center, mRegionF, false); break; |
|
193 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,center, mRegionF, true ); break; |
|
194 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mStrength, center, mRegionF, false); break; |
|
195 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mStrength, center, mRegionF, true ); break; |
|
196 |
case SATURATION : effect = new FragmentEffectSaturation(mStrength, center, mRegionF, false); break; |
|
197 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mStrength, center, mRegionF, true ); break; |
|
198 |
case CONTRAST : effect = new FragmentEffectContrast (mStrength, center, mRegionF, false); break; |
|
199 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mStrength, center, mRegionF, true ); break; |
|
200 |
|
|
201 |
default : android.util.Log.e("EarthRenderer", "unexpected effect: "+name.toString() ); |
|
190 | 202 |
} |
191 | 203 |
|
192 | 204 |
if( effect!=null ) |
193 | 205 |
{ |
194 |
android.util.Log.e("renderer", "adding fragment effect"); |
|
195 | 206 |
mEffects.apply(effect); |
196 | 207 |
} |
197 | 208 |
} |
... | ... | |
229 | 240 |
mScreen.detachAll(); |
230 | 241 |
mScreen.attach(mTexture,mEffects,mMesh); |
231 | 242 |
|
243 |
Effect.enableEffects(EffectType.FRAGMENT); |
|
244 |
Effect.enableEffects(EffectType.VERTEX); |
|
245 |
|
|
232 | 246 |
try |
233 | 247 |
{ |
234 | 248 |
Distorted.onCreate(mView.getContext()); |
Also available in: Unified diff
Progress with the Earth app.