Revision e83350b4
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 float D = (float)Math.sqrt(2.0)/2.0f; |
|
65 |
private static final int SIZE = 500; |
|
66 |
private static final int RADIUS = 30; |
|
67 |
private static final int LEVEL = 32; |
|
68 |
private static final float FOV = 30.0f; |
|
69 |
private static final float NEAR = 0.1f; |
|
70 |
private static final int MAX_EFF = 20; |
|
66 | 71 |
|
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; |
|
72 | 72 |
|
73 | 73 |
private GLSurfaceView mView; |
74 | 74 |
private DistortedTexture mTexture; |
... | ... | |
91 | 91 |
{ |
92 | 92 |
mView = v; |
93 | 93 |
|
94 |
DistortedEffects.setMax(EffectType.VERTEX , MAX_EFF); |
|
95 |
DistortedEffects.setMax(EffectType.FRAGMENT, MAX_EFF); |
|
96 |
|
|
94 | 97 |
mStrength = new Static1D(0.5f); |
95 | 98 |
mColor = new Static3D(255,0,0); |
96 | 99 |
mRegionF = new Static3D(RADIUS,RADIUS,RADIUS); |
... | ... | |
120 | 123 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
121 | 124 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
122 | 125 |
|
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 |
|
|
127 | 126 |
mScreen = new DistortedScreen(); |
128 | 127 |
mScreen.setProjection(FOV, NEAR); |
129 | 128 |
} |
... | ... | |
139 | 138 |
|
140 | 139 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
141 | 140 |
{ |
142 |
final float SCALE = 0.75f;
|
|
141 |
final float SCALE = 1.10f;
|
|
143 | 142 |
|
144 | 143 |
mScreenMin = width<height ? width:height; |
145 | 144 |
float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight : (SCALE*width)/mObjWidth; |
... | ... | |
168 | 167 |
double sinLAT = Math.sin(latitude); |
169 | 168 |
double cosLAT = Math.cos(latitude); |
170 | 169 |
|
171 |
float x = 0.7071f*(float)(sinLON*cosLAT);
|
|
172 |
float y = 0.7071f*(float)(cosLON*cosLAT);
|
|
173 |
float z = 0.7071f*(float) sinLAT ;
|
|
170 |
float x = (float)(sinLON*cosLAT)/2.0f;
|
|
171 |
float y = (float) sinLAT /2.0f;
|
|
172 |
float z = (float)(cosLON*cosLAT)/2.0f;
|
|
174 | 173 |
|
175 |
Static3D center = new Static3D(x*mObjWidth,y*mObjHeight,z*mObjDepth);
|
|
174 |
Static3D center = new Static3D( (0.5f+x)*mObjWidth, (0.5f+y)*mObjHeight, (0.5f-z)*mObjDepth);
|
|
176 | 175 |
|
177 |
android.util.Log.e("earth", "center "+(x*mObjWidth)+" "+(y*mObjHeight)+" "+(z*mObjDepth)); |
|
178 |
android.util.Log.e("earth", "longitude: "+longitude+" latitude:"+latitude); |
|
176 |
//android.util.Log.e("earth", "center "+(x*mObjWidth)+" "+(y*mObjHeight)+" "+(z*mObjDepth));
|
|
177 |
//android.util.Log.e("earth", "longitude: "+longitude+" latitude:"+latitude);
|
|
179 | 178 |
|
180 | 179 |
switch(name) |
181 | 180 |
{ |
Also available in: Unified diff
Progress with the Earth app.