Revision e83350b4
Added by Leszek Koltunski almost 7 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 |         {
 | 
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
|---|---|---|
| 36 | 36 | import org.distorted.library.main.DistortedTexture; | 
| 37 | 37 | import org.distorted.library.mesh.MeshBase; | 
| 38 | 38 | import org.distorted.library.mesh.MeshFlat; | 
| 39 | import org.distorted.library.mesh.MeshSphere; | |
| 39 | 40 | import org.distorted.library.type.Static3D; | 
| 40 | 41 | import org.distorted.library.type.Static4D; | 
| 41 | 42 |  | 
| ... | ... | |
| 63 | 64 | private boolean mShowingRegion=false; | 
| 64 | 65 | private float mFactorObj, mFactorReg; | 
| 65 | 66 | private int mWidth; | 
| 67 | private float mFactor; | |
| 66 | 68 |  | 
| 67 | 69 | Static4D mQuat1, mQuat2; | 
| 68 | 70 | int mScreenMin; | 
| ... | ... | |
| 97 | 99 | MeshBase mesh = act.getMesh(); | 
| 98 | 100 | MeshFlat quad = new MeshFlat(1,1); | 
| 99 | 101 |  | 
| 102 | mFactor = mesh instanceof MeshSphere ? 1.0f : 0.7f; | |
| 103 |  | |
| 100 | 104 | mObjWidth = mObjectTexture.getWidth(); | 
| 101 | 105 | mObjHeight= mObjectTexture.getHeight(); | 
| 102 | 106 | mObjDepth = mObjectTexture.getDepth(mesh); | 
| ... | ... | |
| 235 | 239 |  | 
| 236 | 240 | if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object | 
| 237 | 241 |         {
 | 
| 238 |         mFactorObj = (0.70f*height)/mObjHeight;
 | |
| 239 | factorCen = (0.08f*height)/centerSize; | |
| 242 |         mFactorObj = (mFactor*height)/mObjHeight;
 | |
| 243 |         factorCen  = (0.08f  *height)/centerSize;
 | |
| 240 | 244 | } | 
| 241 | 245 | else | 
| 242 | 246 |         {
 | 
| 243 |         mFactorObj = (0.70f*width)/mObjWidth;
 | |
| 244 | factorCen = (0.08f*width)/centerSize; | |
| 247 |         mFactorObj = (mFactor*width)/mObjWidth;
 | |
| 248 |         factorCen  = (0.08f  *width)/centerSize;
 | |
| 245 | 249 | } | 
| 246 | 250 |  | 
| 247 | 251 | Effects3DActivity2 act = (Effects3DActivity2)mView.getContext(); | 
Also available in: Unified diff
Progress with the Earth app.