Revision 2e96ee72
Added by Leszek Koltunski over 8 years ago
src/main/java/org/distorted/library/DistortedCubesGrid.java | ||
---|---|---|
161 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
162 | 162 |
// desc is guaranteed to be padded with 0s in the end (DistortedCubes constructor does it) |
163 | 163 |
|
164 |
private void buildGrid(int cols, String desc, boolean frontOnly)
|
|
164 |
private void prepareDataStructures(int cols, String desc, boolean frontOnly)
|
|
165 | 165 |
{ |
166 | 166 |
mRows =0; |
167 | 167 |
mCols =0; |
... | ... | |
191 | 191 |
// Water on the edges of the grid is also considered connected to itself! |
192 | 192 |
// |
193 | 193 |
// This function also creates a list of 'Edges'. Each Edge is a data structure from which later on we |
194 |
// will start building the side walls of each connected black of land (and sides of holes of water
|
|
194 |
// will start building the side walls of each connected block of land (and sides of holes of water
|
|
195 | 195 |
// inside) |
196 | 196 |
|
197 | 197 |
private void markRegions() |
... | ... | |
291 | 291 |
{ |
292 | 292 |
int td,lr; |
293 | 293 |
|
294 |
int nw = (col>0 && row>0 ) ? (mCubes[row-1][col-1]%2) : 0;
|
|
295 |
int w = (col>0 ) ? (mCubes[row ][col-1]%2) : 0;
|
|
296 |
int n = ( row>0 ) ? (mCubes[row-1][col ]%2) : 0;
|
|
297 |
int c = (mCubes[row ][col ]%2);
|
|
298 |
int sw = (col>0 && row<mRows-1) ? (mCubes[row+1][col-1]%2) : 0;
|
|
294 |
int nw = (col>0 && row>0 ) ? (mCubes[row-1][col-1]%2) : 0;
|
|
295 |
int w = (col>0 ) ? (mCubes[row ][col-1]%2) : 0;
|
|
296 |
int n = ( row>0 ) ? (mCubes[row-1][col ]%2) : 0;
|
|
297 |
int c = (mCubes[row ][col ]%2);
|
|
298 |
int sw = (col>0 && row<mRows-1) ? (mCubes[row+1][col-1]%2) : 0;
|
|
299 | 299 |
int s = ( row<mRows-1) ? (mCubes[row+1][col ]%2) : 0; |
300 | 300 |
int ne = (col<mCols-1 && row>0 ) ? (mCubes[row-1][col+1]%2) : 0; |
301 | 301 |
int e = (col<mCols-1 ) ? (mCubes[row ][col+1]%2) : 0; |
... | ... | |
337 | 337 |
mNormalX[3] = lr*R; |
338 | 338 |
mNormalY[3] = td*R; |
339 | 339 |
/* |
340 |
android.util.Log.d("CUBES", "row="+row+" col="+col);
|
|
341 |
android.util.Log.d("CUBES", mNormalX[0]+" "+mNormalY[0]);
|
|
342 |
android.util.Log.d("CUBES", mNormalX[1]+" "+mNormalY[1]);
|
|
343 |
android.util.Log.d("CUBES", mNormalX[2]+" "+mNormalY[2]);
|
|
344 |
android.util.Log.d("CUBES", mNormalX[3]+" "+mNormalY[3]);
|
|
340 |
android.util.Log.d("CUBES", "row="+row+" col="+col);
|
|
341 |
android.util.Log.d("CUBES", mNormalX[0]+" "+mNormalY[0]);
|
|
342 |
android.util.Log.d("CUBES", mNormalX[1]+" "+mNormalY[1]);
|
|
343 |
android.util.Log.d("CUBES", mNormalX[2]+" "+mNormalY[2]);
|
|
344 |
android.util.Log.d("CUBES", mNormalX[3]+" "+mNormalY[3]);
|
|
345 | 345 |
*/ |
346 | 346 |
} |
347 | 347 |
|
... | ... | |
699 | 699 |
*/ |
700 | 700 |
public DistortedCubesGrid(int cols, String desc, boolean frontOnly) |
701 | 701 |
{ |
702 |
buildGrid(cols,desc,frontOnly);
|
|
702 |
prepareDataStructures(cols,desc,frontOnly);
|
|
703 | 703 |
|
704 | 704 |
int numVertices=0; |
705 | 705 |
float[] positionData= new float[POSITION_DATA_SIZE*dataLength]; |
Also available in: Unified diff
minor formatting stuff