Project

General

Profile

« Previous | Next » 

Revision 65270124

Added by Leszek Koltunski almost 8 years ago

Fragment3D should be pretty much finished.

View differences:

src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
27 27
import org.distorted.examples.R;
28 28
import org.distorted.library.Distorted;
29 29
import org.distorted.library.DistortedBitmap;
30
import org.distorted.library.DistortedCubes;
31 30
import org.distorted.library.DistortedObject;
32
import org.distorted.library.EffectNames;
33 31
import org.distorted.library.EffectTypes;
34
import org.distorted.library.type.Dynamic1D;
35
import org.distorted.library.type.Dynamic2D;
36
import org.distorted.library.type.Dynamic3D;
37 32
import org.distorted.library.type.DynamicQuat;
38
import org.distorted.library.type.Static1D;
39
import org.distorted.library.type.Static2D;
40 33
import org.distorted.library.type.Static3D;
41 34
import org.distorted.library.type.Static4D;
42 35

  
......
50 43

  
51 44
class Fragment3DRenderer implements GLSurfaceView.Renderer
52 45
{
53
    private static final int SIZE = 100;
54

  
55 46
    private GLSurfaceView mView;
56 47
    private DistortedObject mObject;
57 48
    private DistortedBitmap mBackground;
58
    private float mFactorObj;
59

  
60 49
    private int mObjWidth, mObjHeight;
61

  
62 50
    private DynamicQuat mQuatInt1, mQuatInt2;
63

  
64 51
    Static4D mQuat1, mQuat2;
65 52
    int mScreenMin;
66 53

  
......
71 58
      mView = v;
72 59

  
73 60
      mObject     = ((Fragment3DActivity)v.getContext()).getObject();
74
      mBackground = new DistortedBitmap(SIZE, SIZE, 1);
61
      mBackground = new DistortedBitmap(100, 100, 1);
75 62

  
76 63
      mObjWidth = mObject.getWidth();
77 64
      mObjHeight= mObject.getHeight();
......
107 94

  
108 95
      mObject.abortEffects(EffectTypes.MATRIX);
109 96
      mBackground.abortEffects(EffectTypes.MATRIX);
97
      float factorObj;
110 98

  
111 99
      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
112 100
        {
113
        mFactorObj = (0.70f*height)/mObjHeight;
101
        factorObj = (0.80f*height)/mObjHeight;
114 102
        }
115 103
      else
116 104
        {
117
        mFactorObj = (0.70f*width)/mObjWidth;
105
        factorObj = (0.80f*width)/mObjWidth;
118 106
        }
119 107

  
120 108
      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
121 109

  
122
      mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
123
      mObject.scale(mFactorObj);
110
      mObject.move( new Static3D( (width-factorObj*mObjWidth)/2 , (height-factorObj*mObjHeight)/2 , 0) );
111
      mObject.scale(factorObj);
124 112
      mObject.quaternion(mQuatInt1, rotateObj);
125 113
      mObject.quaternion(mQuatInt2, rotateObj);
126 114

  
......
128 116
      float factorBackX = ((float)width)/backgroundSize;
129 117
      float factorBackY = ((float)height)/backgroundSize;
130 118

  
131
      mBackground.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
119
      mBackground.move(new Static3D( -width/2, -height/2,-factorObj*(mObjWidth+mObjHeight)/2) );
132 120
      mBackground.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
133 121

  
134 122
      Distorted.onSurfaceChanged(width, height); 

Also available in: Unified diff