Project

General

Profile

« Previous | Next » 

Revision 64558e4e

Added by Leszek Koltunski over 5 years ago

Rename the old 'Cubes' app to 'Inflate' - this now combines the testing functionality of former 'Cubes' and 'Inflate' apps.
The old 'Inflate' in turn renamed to 'Earth' - here we are going to show an Earth rotating in space.

View differences:

src/main/java/org/distorted/examples/inflate/InflateRenderer.java
19 19

  
20 20
package org.distorted.examples.inflate;
21 21

  
22
import android.opengl.GLSurfaceView;
22
import javax.microedition.khronos.egl.EGLConfig;
23
import javax.microedition.khronos.opengles.GL10;
23 24

  
25
import org.distorted.library.effect.FragmentEffectAlpha;
24 26
import org.distorted.library.effect.MatrixEffectMove;
25 27
import org.distorted.library.effect.MatrixEffectQuaternion;
26 28
import org.distorted.library.effect.MatrixEffectScale;
27
import org.distorted.library.main.Distorted;
28 29
import org.distorted.library.main.DistortedEffects;
29 30
import org.distorted.library.main.DistortedScreen;
30 31
import org.distorted.library.main.DistortedTexture;
31 32
import org.distorted.library.mesh.MeshBase;
32 33
import org.distorted.library.type.DynamicQuat;
33
import org.distorted.library.type.Static3D;
34
import org.distorted.library.type.Static1D;
34 35
import org.distorted.library.type.Static4D;
36
import org.distorted.library.type.Static3D;
37
import org.distorted.library.main.Distorted;
35 38

  
36
import javax.microedition.khronos.egl.EGLConfig;
37
import javax.microedition.khronos.opengles.GL10;
39
import android.opengl.GLSurfaceView;
38 40

  
39 41
///////////////////////////////////////////////////////////////////////////////////////////////////
40 42

  
......
50 52
    private DistortedScreen mScreen;
51 53
    private int mObjWidth, mObjHeight, mObjDepth;
52 54
    private Static3D mMove, mScale, mCenter;
55
    private Static1D mAlpha;
53 56

  
54 57
    Static4D mQuat1, mQuat2;
55 58
    int mScreenMin;
......
60 63
      {
61 64
      mView = v;
62 65

  
66
      mAlpha = new Static1D(1.0f);
67

  
63 68
      mMove = new Static3D(0,0,0);
64 69
      mScale= new Static3D(1,1,1);
65 70
      mCenter=new Static3D(0,0,0);
......
67 72
      InflateActivity2 act = (InflateActivity2)v.getContext();
68 73

  
69 74
      mTexture = act.getTexture();
70
      mMesh    = act.getMesh();
75
      mMesh = act.getMesh();
71 76

  
72 77
      mObjWidth = mTexture.getWidth();
73 78
      mObjHeight= mTexture.getHeight();
......
87 92
      mEffects.apply( new MatrixEffectScale(mScale));
88 93
      mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) );
89 94
      mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) );
95
      mEffects.apply( new FragmentEffectAlpha(mAlpha));
90 96

  
91 97
      mScreen = new DistortedScreen();
92 98
      mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f);
......
104 110
    
105 111
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
106 112
      {
107
      final float SCALE = 0.75f;
108

  
109 113
      mScreenMin = width<height ? width:height;
110
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight :  (SCALE*width)/mObjWidth;
114
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (0.75f*height)/mObjHeight :  (0.75f*width)/mObjWidth;
111 115
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
112 116
      mScale.set(factor,factor,factor);
113 117
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
114 118
      mScreen.resize(width, height);
115 119
      }
116 120

  
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122

  
123
    void setRenderModeToOIT(boolean oit)
124
      {
125
      mScreen.setOrderIndependentTransparency(oit);
126
      }
127

  
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

  
130
    void setTransparency(int level)
131
      {
132
      mAlpha.set((float)level/100.0f);
133
      }
134

  
117 135
///////////////////////////////////////////////////////////////////////////////////////////////////
118 136

  
119 137
    float setLevel(int level)
......
131 149
      InflateActivity2 act = (InflateActivity2)mView.getContext();
132 150

  
133 151
      mTexture.setTexture( act.getBitmap() );
134

  
135 152
      mScreen.detachAll();
136 153
      mScreen.attach(mTexture,mEffects,mMesh);
137 154

  
155
      FragmentEffectAlpha.enable();
156

  
138 157
      try
139 158
        {
140
        Distorted.onCreate(mView.getContext());
159
        Distorted.onCreate(act);
141 160
        }
142 161
      catch(Exception ex)
143 162
        {

Also available in: Unified diff