Revision edc4a0e4
Added by Leszek Koltunski almost 7 years ago
| src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
|---|---|---|
| 50 | 50 | 
    import org.distorted.library.type.Dynamic3D;  | 
| 51 | 51 | 
    import org.distorted.library.type.DynamicQuat;  | 
| 52 | 52 | 
    import org.distorted.library.type.Static1D;  | 
| 53 | 
    import org.distorted.library.type.Static2D;  | 
|
| 53 | 54 | 
    import org.distorted.library.type.Static3D;  | 
| 54 | 55 | 
    import org.distorted.library.type.Static4D;  | 
| 56 | 
    import org.distorted.library.type.Static5D;  | 
|
| 55 | 57 | 
     | 
| 56 | 58 | 
    import java.io.IOException;  | 
| 57 | 59 | 
    import java.io.InputStream;  | 
| ... | ... | |
| 64 | 66 | 
    class EarthRenderer implements GLSurfaceView.Renderer  | 
| 65 | 67 | 
    {
   | 
| 66 | 68 | 
    private static final int SIZE = 500;  | 
| 67 | 
        private static final int   RADIUS_V= SIZE/10;
   | 
|
| 69 | 
        private static final int   RADIUS_V= SIZE/ 8;
   | 
|
| 68 | 70 | 
    private static final int RADIUS_F= SIZE/15;  | 
| 69 | 71 | 
    private static final int LEVEL = 32;  | 
| 70 | 72 | 
    private static final float FOV = 30.0f;  | 
| ... | ... | |
| 87 | 89 | 
    private Static3D mRegionF;  | 
| 88 | 90 | 
    private Static4D mRegionV;  | 
| 89 | 91 | 
    private Static1D mStrength;  | 
| 92 | 
    private Static2D mPinch;  | 
|
| 93 | 
    private Static1D mSwirl;  | 
|
| 90 | 94 | 
     | 
| 91 | 95 | 
    Static4D mQuat1, mQuat2;  | 
| 92 | 96 | 
    int mScreenMin;  | 
| ... | ... | |
| 109 | 113 | 
    mMove = new Static3D(0,0,0);  | 
| 110 | 114 | 
    mScaleFactor= new Static3D(1,1,1);  | 
| 111 | 115 | 
    mCenter = new Static3D(0,0,0);  | 
| 116 | 
    mPinch = new Static2D(0.5f,0.0f);  | 
|
| 117 | 
    mSwirl = new Static1D(45.0f);  | 
|
| 112 | 118 | 
     | 
| 113 | 119 | 
    Dynamic3D scale = new Dynamic3D(0,0.5f);  | 
| 114 | 120 | 
    scale.add(mScaleFactor);  | 
| ... | ... | |
| 204 | 210 | 
     | 
| 205 | 211 | 
    Static3D center = new Static3D( (0.5f+x)*mObjWidth, (0.5f+y)*mObjHeight, (0.5f+z)*mObjDepth);  | 
| 206 | 212 | 
     | 
| 207 | 
          //android.util.Log.e("earth", "center "+(x*mObjWidth)+" "+(y*mObjHeight)+" "+(z*mObjDepth));
   | 
|
| 208 | 
          //android.util.Log.e("earth", "longitude: "+longitude+" latitude:"+latitude);
   | 
|
| 209 | 
     | 
|
| 210 | 213 | 
    switch(name)  | 
| 211 | 214 | 
            {
   | 
| 212 | 215 | 
    case DISTORT : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR);  | 
| 213 | 
    effect = new VertexEffectDistort( vector, center, mRegionV); break;  | 
|
| 216 | 
                                    effect = new VertexEffectDistort(   vector, center, mRegionV); break;
   | 
|
| 214 | 217 | 
    case DEFORM : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR);  | 
| 215 | 
    effect = new VertexEffectDeform ( vector, center, mRegionV); break;  | 
|
| 216 | 
            /*
   | 
|
| 217 | 
            case SINK             : effect = new VertexEffectSink   (mDyn1, center, mRegionV); break;
   | 
|
| 218 | 
            case PINCH            : effect = new VertexEffectPinch  (mDyn2, center, mRegionV); break;
   | 
|
| 219 | 
            case SWIRL            : effect = new VertexEffectSwirl  (mDyn1, center, mRegionV); break;
   | 
|
| 220 | 
            case WAVE             : effect = new VertexEffectWave   (mDyn5, center, mRegionV); break;
   | 
|
| 221 | 
    */  | 
|
| 218 | 
                                    effect = new VertexEffectDeform (   vector, center, mRegionV); break;
   | 
|
| 219 | 
            case SINK             : effect = new VertexEffectSink   (mStrength, center, mRegionV); break;
   | 
|
| 220 | 
            case PINCH            : effect = new VertexEffectPinch  (mPinch   , center, mRegionV); break;      // Those 3 are not really
   | 
|
| 221 | 
            case SWIRL            : effect = new VertexEffectSwirl  (mSwirl   , center, mRegionV); break;      // fully 3D effects. They
   | 
|
| 222 | 
            case WAVE             : Static5D wave = new Static5D( RADIUS_V/2, RADIUS_V/2, 0, 90-latitude, 90); // will not look good
   | 
|
| 223 | 
                                    effect = new VertexEffectWave   (wave     , center, mRegionV); break;      // everywhere on the sphere.
   | 
|
| 224 | 
     | 
|
| 222 | 225 | 
    case ALPHA : effect = new FragmentEffectAlpha (mStrength, center, mRegionF, false); break;  | 
| 223 | 226 | 
    case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mStrength, center, mRegionF, true ); break;  | 
| 224 | 227 | 
    case CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,center, mRegionF, false); break;  | 
Also available in: Unified diff
Make the Sink effect fully 3D.