Project

General

Profile

« Previous | Next » 

Revision 0b732630

Added by Leszek Koltunski over 3 years ago

Convert the Ivy corner cubit to the new, 'universal' cubit creation method.

This forces deep changes to 'createRoundSolid' and the underlying 'MeshPolygon' class to make them support arbitrary Polygon 'centers of face convexity'.

Reason: the faces of this cubit are concave and such default 'center of face convexity' (which by default used to be (0,0)) turned to lie outside the face - which produces strange visual artifacts.

View differences:

src/main/java/org/distorted/library/mesh/MeshPolygon.java
218 218
 *                   outermost band (and 2 triangles of the next band, and 1 triange of the third
219 219
 *                   band) get denser - the 3 triangles become 3+2 = 5.
220 220
 * @param exVertices See above.
221
 * @param centerX    the X coordinate of the 'center' of the Polygon, i.e. point of the mesh
222
 *                   all bands go to.
223
 * @param centerY    Y coordinate of the center.
221 224
 */
222
  public MeshPolygon(float[] verticesXY, float[] bands, int exIndex, int exVertices)
225
  public MeshPolygon(float[] verticesXY, float[] bands, int exIndex, int exVertices, float centerX, float centerY)
223 226
    {
224 227
    super();
225 228

  
......
230 233
    extraIndex         = exIndex;
231 234
    extraVertices      = exVertices;
232 235

  
236
    if( centerX!=0.0f || centerY!=0.0f )
237
      {
238
      for(int v=0; v<mNumPolygonVertices; v++)
239
        {
240
        mPolygonVertices[2*v  ] -= centerX;
241
        mPolygonVertices[2*v+1] -= centerY;
242
        }
243
      }
244

  
233 245
    computeNumberOfVertices();
234 246
    computeCache();
235 247

  
......
241 253
    if( remainingVert!=0 )
242 254
      android.util.Log.d("MeshPolygon", "remainingVert " +remainingVert );
243 255

  
256
    if( centerX!=0.0f || centerY!=0.0f )
257
      {
258
      for(int v=0; v<numVertices; v++)
259
        {
260
        attribs1[VERT1_ATTRIBS*v + POS_ATTRIB  ] += centerX;
261
        attribs1[VERT1_ATTRIBS*v + POS_ATTRIB+1] += centerY;
262
        attribs2[VERT2_ATTRIBS*v + TEX_ATTRIB  ] += centerX;
263
        attribs2[VERT2_ATTRIBS*v + TEX_ATTRIB+1] += centerY;
264
        }
265
      }
266

  
244 267
    setAttribs(attribs1,attribs2);
245 268
    }
246 269

  
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271

  
272
  public MeshPolygon(float[] verticesXY, float[] bands, int exIndex, int exVertices)
273
    {
274
    this(verticesXY,bands,exIndex,exVertices,0.0f,0.0f);
275
    }
276

  
247 277
///////////////////////////////////////////////////////////////////////////////////////////////////
248 278
/**
249 279
 * Create a polygon of any shape and varying elevations from the edges towards the center.
......
251 281
 */
252 282
  public MeshPolygon(float[] verticesXY, float[] bands)
253 283
    {
254
    this(verticesXY,bands,0,0);
284
    this(verticesXY,bands,0,0,0.0f,0.0f);
255 285
    }
256 286

  
257 287
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff