Revision 1585ba24
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
---|---|---|
24 | 24 |
import android.opengl.GLSurfaceView; |
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 |
import org.distorted.library.effect.Effect; |
|
27 | 28 |
import org.distorted.library.effect.EffectName; |
28 | 29 |
import org.distorted.library.effect.EffectType; |
30 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
31 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
32 |
import org.distorted.library.effect.FragmentEffectChroma; |
|
33 |
import org.distorted.library.effect.FragmentEffectContrast; |
|
34 |
import org.distorted.library.effect.FragmentEffectSaturation; |
|
29 | 35 |
import org.distorted.library.effect.MatrixEffectMove; |
30 | 36 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
31 | 37 |
import org.distorted.library.effect.MatrixEffectScale; |
38 |
import org.distorted.library.effect.VertexEffectDeform; |
|
39 |
import org.distorted.library.effect.VertexEffectDistort; |
|
40 |
import org.distorted.library.effect.VertexEffectPinch; |
|
41 |
import org.distorted.library.effect.VertexEffectSink; |
|
42 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
43 |
import org.distorted.library.effect.VertexEffectWave; |
|
32 | 44 |
import org.distorted.library.main.Distorted; |
33 | 45 |
import org.distorted.library.main.DistortedEffects; |
34 | 46 |
import org.distorted.library.main.DistortedScreen; |
... | ... | |
36 | 48 |
import org.distorted.library.mesh.MeshBase; |
37 | 49 |
import org.distorted.library.mesh.MeshSphere; |
38 | 50 |
import org.distorted.library.type.DynamicQuat; |
51 |
import org.distorted.library.type.Static1D; |
|
39 | 52 |
import org.distorted.library.type.Static3D; |
40 | 53 |
import org.distorted.library.type.Static4D; |
41 | 54 |
|
... | ... | |
49 | 62 |
|
50 | 63 |
class EarthRenderer implements GLSurfaceView.Renderer |
51 | 64 |
{ |
52 |
private static final int SIZE = 100;
|
|
65 |
private static final int SIZE = 500;
|
|
53 | 66 |
private static final int LEVEL= 32; |
54 | 67 |
private static final float FOV = 30.0f; |
55 | 68 |
private static final float NEAR = 0.1f; |
... | ... | |
65 | 78 |
Static4D mQuat1, mQuat2; |
66 | 79 |
int mScreenMin; |
67 | 80 |
|
81 |
private Static3D mColor; |
|
82 |
private Static1D mStrength; |
|
83 |
|
|
68 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
69 | 85 |
|
70 | 86 |
EarthRenderer(GLSurfaceView v) |
71 | 87 |
{ |
72 | 88 |
mView = v; |
73 | 89 |
|
90 |
mStrength = new Static1D(0.5f); |
|
91 |
mColor= new Static3D(255,0,0); |
|
74 | 92 |
mMove = new Static3D(0,0,0); |
75 | 93 |
mScale= new Static3D(1,1,1); |
76 | 94 |
mCenter=new Static3D(0,0,0); |
... | ... | |
132 | 150 |
|
133 | 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 152 |
|
135 |
void addNewPoint(float x, float y, EffectName effect)
|
|
153 |
void addNewPoint(float longitude, float latitude, EffectName name)
|
|
136 | 154 |
{ |
155 |
Effect effect =null; |
|
156 |
|
|
157 |
double sinLON = Math.sin(longitude); |
|
158 |
double cosLON = Math.cos(longitude); |
|
159 |
double sinLAT = Math.sin(latitude); |
|
160 |
double cosLAT = Math.cos(latitude); |
|
161 |
|
|
162 |
float x = 0.7071f*(float)(sinLON*cosLAT); |
|
163 |
float y = 0.7071f*(float)(cosLON*cosLAT); |
|
164 |
float z = 0.7071f*(float) sinLAT ; |
|
137 | 165 |
|
166 |
float radius = SIZE/10; |
|
167 |
Static4D region = new Static4D(x*mObjWidth,y*mObjHeight,radius,radius); |
|
168 |
|
|
169 |
switch(name) |
|
170 |
{ |
|
171 |
/* |
|
172 |
case DISTORT : effect = new VertexEffectDistort(mDyn3, center, mRegionV); break; |
|
173 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, center, mRegionV); break; |
|
174 |
case SINK : effect = new VertexEffectSink (mDyn1, center, mRegionV); break; |
|
175 |
case PINCH : effect = new VertexEffectPinch (mDyn2, center, mRegionV); break; |
|
176 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, center, mRegionV); break; |
|
177 |
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 |
*/ |
|
190 |
} |
|
191 |
|
|
192 |
if( effect!=null ) |
|
193 |
{ |
|
194 |
android.util.Log.e("renderer", "adding fragment effect"); |
|
195 |
mEffects.apply(effect); |
|
196 |
} |
|
138 | 197 |
} |
139 | 198 |
|
140 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Make the Fragment effects truly 3D: change their 4D 'region' into a 3D 'center' (a point in 3D) and 3D 'region' (which is now a set of 3 radii defining an ellipsoid around the center)
Also corresponding changes to the applications.