Revision 823f63f7
Added by Leszek Koltunski almost 7 years ago
| src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
|---|---|---|
| 63 | 63 |
|
| 64 | 64 |
class EarthRenderer implements GLSurfaceView.Renderer |
| 65 | 65 |
{
|
| 66 |
private static final int SIZE = 500; |
|
| 67 |
private static final int RADIUS = 30; |
|
| 68 |
private static final int LEVEL = 32; |
|
| 69 |
private static final float FOV = 30.0f; |
|
| 70 |
private static final float NEAR = 0.1f; |
|
| 71 |
private static final int MAX_EFF = 20; |
|
| 72 |
private static final float SCALE = 1.10f; |
|
| 66 |
private static final int SIZE = 500; |
|
| 67 |
private static final int RADIUS_V= SIZE/10; |
|
| 68 |
private static final int RADIUS_F= SIZE/15; |
|
| 69 |
private static final int LEVEL = 32; |
|
| 70 |
private static final float FOV = 30.0f; |
|
| 71 |
private static final float NEAR = 0.1f; |
|
| 72 |
private static final int MAX_EFF = 20; |
|
| 73 |
private static final float SCALE = 1.10f; |
|
| 73 | 74 |
|
| 74 | 75 |
private GLSurfaceView mView; |
| 75 | 76 |
private DistortedTexture mTexture; |
| ... | ... | |
| 78 | 79 |
private DistortedScreen mScreen; |
| 79 | 80 |
private int mObjWidth, mObjHeight, mObjDepth; |
| 80 | 81 |
private Static3D mMove, mScaleFactor, mCenter; |
| 81 |
private Dynamic3D mScale; |
|
| 82 | 82 |
|
| 83 | 83 |
private int mScrWidth, mScrHeight; |
| 84 | 84 |
private float mLevel; |
| 85 | 85 |
|
| 86 | 86 |
private Static3D mColor; |
| 87 | 87 |
private Static3D mRegionF; |
| 88 |
private Static4D mRegionV; |
|
| 88 | 89 |
private Static1D mStrength; |
| 89 | 90 |
|
| 90 | 91 |
Static4D mQuat1, mQuat2; |
| ... | ... | |
| 101 | 102 |
DistortedEffects.setMax(EffectType.VERTEX , MAX_EFF); |
| 102 | 103 |
DistortedEffects.setMax(EffectType.FRAGMENT, MAX_EFF); |
| 103 | 104 |
|
| 104 |
mScale = new Dynamic3D(0,0.5f); |
|
| 105 | 105 |
mStrength = new Static1D(0.5f); |
| 106 | 106 |
mColor = new Static3D(255,0,0); |
| 107 |
mRegionF = new Static3D(RADIUS,RADIUS,RADIUS); |
|
| 107 |
mRegionF = new Static3D(RADIUS_F,RADIUS_F,RADIUS_F); |
|
| 108 |
mRegionV = new Static4D(0,0,0,RADIUS_V); |
|
| 108 | 109 |
mMove = new Static3D(0,0,0); |
| 109 | 110 |
mScaleFactor= new Static3D(1,1,1); |
| 110 | 111 |
mCenter = new Static3D(0,0,0); |
| 111 | 112 |
|
| 112 |
mScale.add(mScaleFactor); |
|
| 113 |
Dynamic3D scale = new Dynamic3D(0,0.5f); |
|
| 114 |
scale.add(mScaleFactor); |
|
| 113 | 115 |
|
| 114 | 116 |
mMesh = new MeshSphere(LEVEL); |
| 115 | 117 |
mTexture = new DistortedTexture(SIZE,SIZE); |
| ... | ... | |
| 129 | 131 |
|
| 130 | 132 |
mEffects = new DistortedEffects(); |
| 131 | 133 |
mEffects.apply( new MatrixEffectMove(mMove) ); |
| 132 |
mEffects.apply( new MatrixEffectScale(mScale));
|
|
| 134 |
mEffects.apply( new MatrixEffectScale(scale));
|
|
| 133 | 135 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
| 134 | 136 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
| 135 | 137 |
|
| ... | ... | |
| 187 | 189 |
|
| 188 | 190 |
void addNewPoint(float longitude, float latitude, EffectName name) |
| 189 | 191 |
{
|
| 192 |
final float CORR = 10.0F; |
|
| 193 |
Static3D vector; |
|
| 190 | 194 |
Effect effect =null; |
| 191 | 195 |
|
| 192 | 196 |
double sinLON = Math.sin(longitude); |
| ... | ... | |
| 198 | 202 |
float y = (float) sinLAT /2.0f; |
| 199 | 203 |
float z = (float)(cosLON*cosLAT)/2.0f; |
| 200 | 204 |
|
| 201 |
Static3D center = new Static3D( (0.5f+x)*mObjWidth, (0.5f+y)*mObjHeight, (0.5f-z)*mObjDepth);
|
|
| 205 |
Static3D center = new Static3D( (0.5f+x)*mObjWidth, (0.5f+y)*mObjHeight, (0.5f+z)*mObjDepth);
|
|
| 202 | 206 |
|
| 203 | 207 |
//android.util.Log.e("earth", "center "+(x*mObjWidth)+" "+(y*mObjHeight)+" "+(z*mObjDepth));
|
| 204 | 208 |
//android.util.Log.e("earth", "longitude: "+longitude+" latitude:"+latitude);
|
| 205 | 209 |
|
| 206 | 210 |
switch(name) |
| 207 | 211 |
{
|
| 212 |
case DISTORT : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR); |
|
| 213 |
effect = new VertexEffectDistort( vector, center, mRegionV); break; |
|
| 214 |
case DEFORM : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR); |
|
| 215 |
effect = new VertexEffectDeform ( vector, center, mRegionV); break; |
|
| 208 | 216 |
/* |
| 209 |
case DISTORT : effect = new VertexEffectDistort(mDyn3, center, mRegionV); break; |
|
| 210 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, center, mRegionV); break; |
|
| 211 | 217 |
case SINK : effect = new VertexEffectSink (mDyn1, center, mRegionV); break; |
| 212 | 218 |
case PINCH : effect = new VertexEffectPinch (mDyn2, center, mRegionV); break; |
| 213 | 219 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, center, mRegionV); break; |
Also available in: Unified diff
Correct the z-axis of the center of fragment effects (it was inverted)