30 |
30 |
private int remainingVert;
|
31 |
31 |
|
32 |
32 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
// create a flat, full grid
|
|
33 |
// Create a flat, full grid. cols and rows is guaranteed (by DistortedBitmap constructor)
|
|
34 |
// to be in 1,2,...,256.
|
34 |
35 |
|
35 |
36 |
private void computeNumberOfVertices(int cols, int rows)
|
36 |
37 |
{
|
37 |
|
//android.util.Log.e("BITMAP","preparing data structures, cols="+cols+" rows="+rows);
|
|
38 |
mRows=rows;
|
|
39 |
mCols=cols;
|
38 |
40 |
|
39 |
|
mRows =0;
|
40 |
|
mCols =0;
|
41 |
|
dataLength=0;
|
42 |
|
|
43 |
|
if( cols>0 )
|
|
41 |
if( cols==1 && rows==1 )
|
|
42 |
{
|
|
43 |
dataLength = 4;
|
|
44 |
}
|
|
45 |
else
|
44 |
46 |
{
|
45 |
|
mCols = cols;
|
46 |
|
mRows = rows;
|
47 |
|
|
48 |
47 |
dataLength = 2*( mRows*mCols +2*mRows - 1) +2*(mCols>=2 ? mRows:0) +
|
49 |
48 |
(mCols>=2 && mRows>=2 ? 2*mRows-2 : 1);
|
|
49 |
}
|
50 |
50 |
|
51 |
|
//android.util.Log.e("BITMAP","vertices="+dataLength);
|
|
51 |
//android.util.Log.e("BITMAP","vertices="+dataLength+" rows="+mRows+" cols="+mCols);
|
52 |
52 |
|
53 |
|
remainingVert = dataLength;
|
54 |
|
}
|
|
53 |
remainingVert = dataLength;
|
55 |
54 |
}
|
56 |
55 |
|
57 |
56 |
|
... | ... | |
139 |
138 |
}
|
140 |
139 |
|
141 |
140 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
141 |
/*
|
|
142 |
private static String debug(float[] val, int stop)
|
|
143 |
{
|
|
144 |
String ret="";
|
|
145 |
|
|
146 |
for(int i=0; i<val.length; i++)
|
|
147 |
{
|
|
148 |
if( i%stop==0 ) ret+="\n";
|
|
149 |
ret+=(" "+val[i]);
|
|
150 |
}
|
|
151 |
|
|
152 |
return ret;
|
|
153 |
}
|
|
154 |
*/
|
|
155 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
156 |
|
143 |
157 |
/**
|
144 |
158 |
* Creates the underlying grid of vertices, normals and texture coords.
|
... | ... | |
156 |
170 |
|
157 |
171 |
buildGrid(positionData,normalData,textureData);
|
158 |
172 |
|
159 |
|
/*
|
160 |
|
android.util.Log.e("CUBES","dataLen="+dataLength+" vertex="+numVertices);
|
161 |
|
android.util.Log.d("CUBES", "position: "+debug(positionData,3) );
|
162 |
|
android.util.Log.d("CUBES", "normal: " +debug( normalData,3) );
|
163 |
|
android.util.Log.d("CUBES", "texture: " +debug( textureData,2) );
|
164 |
|
*/
|
|
173 |
//android.util.Log.e("CUBES","dataLen="+dataLength);
|
|
174 |
//android.util.Log.d("CUBES", "position: "+debug(positionData,3) );
|
|
175 |
//android.util.Log.d("CUBES", "normal: " +debug( normalData,3) );
|
|
176 |
//android.util.Log.d("CUBES", "texture: " +debug( textureData,2) );
|
165 |
177 |
|
166 |
178 |
android.util.Log.d("BITMAP", "remainingVert " +remainingVert );
|
167 |
179 |
|
Fix the 1x1 case! Before it used to be impossible to create a DistortedBitmap just with 2 triangles!