Project

General

Profile

« Previous | Next » 

Revision 69ed1eb4

Added by Leszek Koltunski over 7 years ago

Progress with getting Mesh'es bounding rectangle.

View differences:

src/main/java/org/distorted/library/MeshFlat.java
34 34
  private int mCols, mRows;
35 35
  private int remainingVert;
36 36

  
37
  private static float[] mBoundingVert = new float[] { -0.5f,-0.5f,0.0f,
38
                                                       +0.5f,-0.5f,0.0f,
39
                                                       -0.5f,+0.5f,0.0f,
40
                                                       +0.5f,+0.5f,0.0f };
41

  
37 42
///////////////////////////////////////////////////////////////////////////////////////////////////
38 43
// Create a flat, full grid.
39 44

  
......
60 65

  
61 66
///////////////////////////////////////////////////////////////////////////////////////////////////
62 67

  
63
   private int addVertex(int vertex, int col, int row, float[] position, float[] normal, float[] texture)
68
   private int addVertex(int vertex, float x, float y, float[] position, float[] normal, float[] texture)
64 69
     {
65 70
     remainingVert--;
66 71

  
67
     float x= (float)col/mCols;
68
     float y= (float)row/mRows;
69

  
70 72
     position[3*vertex  ] = x-0.5f;
71 73
     position[3*vertex+1] = 0.5f-y;
72 74
     position[3*vertex+2] = 0;
......
115 117
     boolean currentBlockIsNE;
116 118
     int vertex = 0;
117 119

  
120
     float x,y;
121
     final float X = 1.0f/mCols;
122
     final float Y = 1.0f/mRows;
123

  
118 124
     //android.util.Log.d("BITMAP", "buildGrid");
119 125

  
126
     y = 0.0f;
127

  
120 128
     for(int row=0; row<mRows; row++)
121 129
       {
130
       x = 0.0f;
131

  
122 132
       for(int col=0; col<mCols; col++)
123 133
         {
124 134
         currentBlockIsNE = (2*row<=mRows-1)^(2*col<=mCols-1);
......
126 136
         if( col==0 || (lastBlockIsNE^currentBlockIsNE) )
127 137
           {
128 138
           if( row!=0 && col==0 ) vertex = repeatLast(vertex,position,normal,texture);
129
           vertex= addVertex( vertex, col, row+(currentBlockIsNE?0:1), position, normal, texture);
139
           vertex= addVertex( vertex, x, y+(currentBlockIsNE?0:Y), position, normal, texture);
130 140
           if( row!=0 && col==0 ) vertex = repeatLast(vertex,position,normal,texture);
131 141
           if( lastBlockIsNE^currentBlockIsNE)  vertex = repeatLast(vertex,position,normal,texture);
132
           vertex= addVertex( vertex, col, row+(currentBlockIsNE?1:0), position, normal, texture);
142
           vertex= addVertex( vertex, x, y+(currentBlockIsNE?Y:0), position, normal, texture);
133 143
           }
134
         vertex= addVertex( vertex, col+1, row+(currentBlockIsNE?0:1), position, normal, texture);
135
         vertex= addVertex( vertex, col+1, row+(currentBlockIsNE?1:0), position, normal, texture);
144
         vertex= addVertex( vertex, x+X, y+(currentBlockIsNE?0:Y), position, normal, texture);
145
         vertex= addVertex( vertex, x+X, y+(currentBlockIsNE?Y:0), position, normal, texture);
136 146

  
137 147
         lastBlockIsNE = currentBlockIsNE;
148
         x+=X;
138 149
         }
150

  
151
       y+=Y;
139 152
       }
140 153

  
141 154
     //android.util.Log.d("BITMAP", "buildGrid done");
......
159 172

  
160 173
///////////////////////////////////////////////////////////////////////////////////////////////////
161 174

  
162
   boolean canUsePostprocessingShortcut()
163
      {
164
      return true;
165
      }
175
   float[] getBoundingVertices()
176
     {
177
     return mBoundingVert;
178
     }
166 179

  
167 180
///////////////////////////////////////////////////////////////////////////////////////////////////
168 181
// PUBLIC API

Also available in: Unified diff