Revision 6f2d931d
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/library/mesh/MeshFlat.java | ||
---|---|---|
62 | 62 |
{ |
63 | 63 |
remainingVert--; |
64 | 64 |
|
65 |
attribs[8*vertex ] = x-0.5f;
|
|
66 |
attribs[8*vertex+1] = 0.5f-y;
|
|
67 |
attribs[8*vertex+2] = 0;
|
|
65 |
attribs[VERT_ATTRIBS*vertex + POS_ATTRIB ] = x-0.5f;
|
|
66 |
attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f-y;
|
|
67 |
attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0;
|
|
68 | 68 |
|
69 |
attribs[8*vertex+3] = 0.0f;
|
|
70 |
attribs[8*vertex+4] = 0.0f;
|
|
71 |
attribs[8*vertex+5] = 1.0f;
|
|
69 |
attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB ] = 0.0f;
|
|
70 |
attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = 0.0f;
|
|
71 |
attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = 1.0f;
|
|
72 | 72 |
|
73 |
attribs[8*vertex+6] = x; |
|
74 |
attribs[8*vertex+7] = 1.0f-y; |
|
73 |
attribs[VERT_ATTRIBS*vertex + INF_ATTRIB ] = 1.0f; // |
|
74 |
attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = 0.0f; // TODO |
|
75 |
attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.0f; // |
|
76 |
|
|
77 |
attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB ] = x; |
|
78 |
attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y; |
|
75 | 79 |
|
76 | 80 |
return vertex+1; |
77 | 81 |
} |
... | ... | |
80 | 84 |
|
81 | 85 |
private int repeatLast(int vertex, float[] attribs) |
82 | 86 |
{ |
83 |
remainingVert--; |
|
84 |
|
|
85 | 87 |
//android.util.Log.e("MeshFlat", "repeating last vertex!"); |
86 | 88 |
|
87 | 89 |
if( vertex>0 ) |
88 | 90 |
{ |
89 |
attribs[8*vertex ] = attribs[8*vertex-8]; |
|
90 |
attribs[8*vertex+1] = attribs[8*vertex-7]; |
|
91 |
attribs[8*vertex+2] = attribs[8*vertex-6]; |
|
92 |
attribs[8*vertex+3] = attribs[8*vertex-5]; |
|
93 |
attribs[8*vertex+4] = attribs[8*vertex-4]; |
|
94 |
attribs[8*vertex+5] = attribs[8*vertex-3]; |
|
95 |
attribs[8*vertex+6] = attribs[8*vertex-2]; |
|
96 |
attribs[8*vertex+7] = attribs[8*vertex-1]; |
|
91 |
remainingVert--; |
|
92 |
|
|
93 |
attribs[VERT_ATTRIBS*vertex + POS_ATTRIB ] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB ]; |
|
94 |
attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+1]; |
|
95 |
attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+2]; |
|
96 |
|
|
97 |
attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB ] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB ]; |
|
98 |
attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+1]; |
|
99 |
attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+2]; |
|
100 |
|
|
101 |
attribs[VERT_ATTRIBS*vertex + INF_ATTRIB ] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB ]; |
|
102 |
attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+1]; |
|
103 |
attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+2]; |
|
104 |
|
|
105 |
attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB ] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB ]; |
|
106 |
attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB+1]; |
|
97 | 107 |
|
98 | 108 |
vertex++; |
99 | 109 |
} |
... | ... | |
176 | 186 |
super(0.0f); |
177 | 187 |
computeNumberOfVertices(cols,rows); |
178 | 188 |
|
179 |
float[] attribs= new float[(POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*numVertices];
|
|
189 |
float[] attribs= new float[VERT_ATTRIBS*numVertices];
|
|
180 | 190 |
|
181 | 191 |
buildGrid(attribs); |
182 | 192 |
|
183 | 193 |
//android.util.Log.e("MeshFlat", "dataLen="+numVertices); |
184 |
//android.util.Log.d("MeshFlat", "attribs: "+debug(attribs,8) );
|
|
194 |
//android.util.Log.d("MeshFlat", "attribs: "+debug(attribs,VERT_ATTRIBS) );
|
|
185 | 195 |
|
186 | 196 |
if( remainingVert!=0 ) |
187 | 197 |
android.util.Log.d("MeshFlat", "remainingVert " +remainingVert ); |
Also available in: Unified diff
Added a new attribute to vertices of a MeshBase object: the vec3 'inflate' vector.
This vector describes the direction where the vertex needs to be moved when we 'inflate' the whole mesh.
If the mesh is locally smooth, this is simply the normal vector; otherwise (for example in the corners of the MeshCubes) - not.
Currently the new attribute is always set to (1,0,0) and not used yet.