Revision 041f83a3
Added by Leszek Koltunski about 6 years ago
src/main/java/org/distorted/library/mesh/MeshSphere.java | ||
---|---|---|
41 | 41 |
// longitude of V3 is simply midpoint of V1 and V2 so we don't have to specify it here. |
42 | 42 |
|
43 | 43 |
private static final double FACES[][] = { |
44 |
{ 0.0 , 0.4*P, A, 0.5*P },
|
|
44 |
{ 0.0*P, 0.4*P, A, 0.5*P },
|
|
45 | 45 |
{ 0.4*P, 0.8*P, A, 0.5*P }, |
46 | 46 |
{ 0.8*P, 1.2*P, A, 0.5*P }, // 5 'top' faces with |
47 | 47 |
{ 1.2*P, 1.6*P, A, 0.5*P }, // the North Pole |
48 | 48 |
{ 1.6*P, 2.0*P, A, 0.5*P }, |
49 | 49 |
|
50 |
{ 0.0 , 0.4*P, A, -A },
|
|
50 |
{ 0.0*P, 0.4*P, A, -A },
|
|
51 | 51 |
{ 0.4*P, 0.8*P, A, -A }, |
52 | 52 |
{ 0.8*P, 1.2*P, A, -A }, // 5 faces mostly above |
53 | 53 |
{ 1.2*P, 1.6*P, A, -A }, // the equator |
54 | 54 |
{ 1.6*P, 2.0*P, A, -A }, |
55 | 55 |
|
56 |
{ 0.2 , 0.6*P, -A, A },
|
|
56 |
{ 0.2*P, 0.6*P, -A, A },
|
|
57 | 57 |
{ 0.6*P, 1.0*P, -A, A }, |
58 | 58 |
{ 1.0*P, 1.4*P, -A, A }, // 5 faces mostly below |
59 | 59 |
{ 1.4*P, 1.8*P, -A, A }, // the equator |
60 | 60 |
{ 1.8*P, 0.2*P, -A, A }, |
61 | 61 |
|
62 |
{ 0.2 , 0.6*P, -A,-0.5*P },
|
|
62 |
{ 0.2*P, 0.6*P, -A,-0.5*P },
|
|
63 | 63 |
{ 0.6*P, 1.0*P, -A,-0.5*P }, |
64 | 64 |
{ 1.0*P, 1.4*P, -A,-0.5*P }, // 5 'bottom' faces with |
65 | 65 |
{ 1.4*P, 1.8*P, -A,-0.5*P }, // the South Pole |
66 |
{ 1.8*P, 0.2*P, -A,-0.5*P } |
|
66 |
{ 1.8*P, 0.2*P, -A,-0.5*P },
|
|
67 | 67 |
}; |
68 | 68 |
private int currentVert; |
69 | 69 |
private int numVertices; |
... | ... | |
78 | 78 |
|
79 | 79 |
private void computeNumberOfVertices(int level) |
80 | 80 |
{ |
81 |
numVertices = 20*level*(level+4) -2;
|
|
81 |
numVertices = NUMFACES*level*(level+4) -2;
|
|
82 | 82 |
currentVert = 0; |
83 | 83 |
} |
84 | 84 |
|
... | ... | |
120 | 120 |
|
121 | 121 |
private void repeatLast(float[] attribs) |
122 | 122 |
{ |
123 |
//android.util.Log.e("sphere", "repeat last!"); |
|
124 |
|
|
123 | 125 |
if( currentVert>0 ) |
124 | 126 |
{ |
125 | 127 |
attribs[VERT_ATTRIBS*currentVert + POS_ATTRIB ] = attribs[VERT_ATTRIBS*(currentVert-1) + POS_ATTRIB ]; |
... | ... | |
195 | 197 |
private void newVertex(float[] attribs, int column, int row, int level, |
196 | 198 |
double lonV1, double lonV2, double latV12, double latV3) |
197 | 199 |
{ |
198 |
double quotX = (double)column/(level-1);
|
|
199 |
double quotY = (double)row /(level-1);
|
|
200 |
double quotX = (double)column/level;
|
|
201 |
double quotY = (double)row /level;
|
|
200 | 202 |
|
201 | 203 |
double lonPoint = midLongitude(lonV1,lonV2, (quotX+0.5*quotY) ); |
202 | 204 |
double latPoint = midLatitude(latV12,latV3, quotY); |
203 | 205 |
|
206 |
//android.util.Log.e("sphere", "newVertex: long:"+lonPoint+" lat:"+latPoint+" column="+column+" row="+row); |
|
207 |
|
|
204 | 208 |
addVertex(lonPoint,latPoint,attribs); |
205 | 209 |
} |
206 | 210 |
|
Also available in: Unified diff
Some fixes for Sphere; still not completely ok though.