Project

General

Profile

« Previous | Next » 

Revision d40cfeb2

Added by Leszek Koltunski almost 8 years ago

Progress with Vertex3D

View differences:

src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java
48 48
class Vertex3DRenderer implements GLSurfaceView.Renderer
49 49
{
50 50
    private static final int SIZE = 100;
51
	  private static final int NUM  =   3;
52 51

  
53 52
    private GLSurfaceView mView;
54 53
    private static DistortedCubes mCube;
54
    private int mCols, mRows;
55 55

  
56 56
    private static EffectNames[] order;
57 57
    
......
121 121
    public Vertex3DRenderer(GLSurfaceView v)
122 122
      {
123 123
      mView = v;
124
      mCube = new DistortedCubes( NUM, "111101111", SIZE);
124

  
125
      String shape = Vertex3DActivity.getShape();
126

  
127
      mCols = Vertex3DActivity.getCols();
128
      mRows = shape.length() / mCols;
129

  
130
      mCube = new DistortedCubes( mCols, shape, SIZE);
125 131
      
126 132
      mCenterPoint = new Static2D(0,0);
127 133
      mDeformPoint = new Static3D(0,0,0);
......
155 161
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
156 162
      {
157 163
      mCube.abortEffects(EffectTypes.MATRIX);
158
      float factor = (width>height ? height:width)/((NUM+2)*SIZE);
164
      float factor;
165

  
166
      if( width*mRows > height*mCols ) // screen is more 'horizontal' than the shape
167
        {
168
        factor = height/((mRows+2)*SIZE);
169
        }
170
      else
171
        {
172
        factor = width/((mCols+2)*SIZE);
173
        }
174

  
159 175
      mCube.scale(factor);
160
      mCube.move( new Static3D( (width-factor*NUM*SIZE)/2,(height-factor*NUM*SIZE)/2,0) );
176
      mCube.move( new Static3D( (width-factor*mCols*SIZE)/2 , (height-factor*mRows*SIZE)/2 , 0) );
161 177

  
162 178
      setVertexEffects();
163 179

  

Also available in: Unified diff