Project

General

Profile

« Previous | Next » 

Revision 2617d26b

Added by Leszek Koltunski over 2 years ago

Progress

View differences:

src/main/java/org/distorted/objectlib/helpers/FactoryCubit.java
53 53
  private static class StickerCoords
54 54
    {
55 55
    float[] vertices;
56
    boolean outer;
56 57
    }
57 58

  
58 59
  private static class FaceTransform
......
222 223

  
223 224
///////////////////////////////////////////////////////////////////////////////////////////////////
224 225

  
225
  private void fitInSquare(FaceTransform info, float[][] vert3D)
226
  private void fitInSquare(FaceTransform info, float[][] vert3D, boolean isOuter)
226 227
    {
227 228
    float minX = Float.MAX_VALUE;
228 229
    float maxX =-Float.MAX_VALUE;
......
253 254

  
254 255
    int len = vert3D.length;
255 256
    StickerCoords sInfo = new StickerCoords();
257
    sInfo.outer = isOuter;
256 258
    sInfo.vertices = new float[2*len];
257 259

  
258 260
    for( int vertex=0; vertex<len; vertex++ )
......
269 271

  
270 272
///////////////////////////////////////////////////////////////////////////////////////////////////
271 273

  
272
  private FaceTransform constructNewTransform(final float[][] vert3D)
274
  private FaceTransform constructNewTransform(final float[][] vert3D, boolean isOuter)
273 275
    {
274 276
    FaceTransform ft = new FaceTransform();
275 277

  
......
361 363
      }
362 364

  
363 365
    // fit the whole thing in a square and remember the scale & 2D vertices
364
    fitInSquare(ft, vert3D);
366
    fitInSquare(ft, vert3D, isOuter);
365 367

  
366 368
    // remember the rotation
367 369
    ft.qx =-mQuat1[0];
......
603 605

  
604 606
    for(int v=0; v<lenV; v++)
605 607
      {
606
      staticVert[0] = new Static3D( (float)vertices[v][0], (float)vertices[v][1], (float)vertices[v][2]);
608
      staticVert[0] = new Static3D( vertices[v][0],vertices[v][1],vertices[v][2] );
607 609

  
608 610
      int cent = centerIndexes[v];
609 611

  
......
717 719

  
718 720
///////////////////////////////////////////////////////////////////////////////////////////////////
719 721

  
720
  public void printStickerCoords()
722
  public void printStickerCoords(boolean all)
721 723
    {
722 724
    int stickers = mStickerCoords.size();
723 725

  
......
725 727

  
726 728
    for(int s=0; s<stickers; s++)
727 729
      {
728
      String ver = "{ ";
729 730
      StickerCoords info = mStickerCoords.get(s);
730
      int len = info.vertices.length/2;
731 731

  
732
      for(int i =0; i<len; i++)
732
      if( all || info.outer )
733 733
        {
734
        if( i!=0 ) ver += ", ";
735
        ver += ( (float)info.vertices[2*i]+"f, "+(float)info.vertices[2*i+1]+"f");
736
        }
734
        String ver = "{ ";
735
        int len = info.vertices.length/2;
737 736

  
738
      ver += " }";
739
      android.util.Log.d("D", ver);
737
        for(int i =0; i<len; i++)
738
          {
739
          if( i!=0 ) ver += ", ";
740
          ver += ( info.vertices[2*i]+"f, "+info.vertices[2*i+1]+"f");
741
          }
742

  
743
        ver += " }";
744
        android.util.Log.d("D", ver);
745
        }
740 746
      }
741 747

  
742 748
    android.util.Log.d("D", "---- END STICKER COORDS ----");
......
776 782

  
777 783
///////////////////////////////////////////////////////////////////////////////////////////////////
778 784

  
779
  public void createNewFaceTransform( final float[][] vertices, final int[][] indexes)
785
  public void createNewFaceTransform( final float[][] vertices, final int[][] indexes, int outer)
780 786
    {
781 787
    FaceTransform ft;
782 788
    int numNew = mNewFaceTransf.size();
......
793 799
    for (int face=0; face<numFaces; face++)
794 800
      {
795 801
      boolean collapsed = false;
802
      boolean isOuter = face<outer;
796 803

  
797 804
      float[][] vert = constructVert(vertices, indexes[face]);
798
      FaceTransform newT = constructNewTransform(vert);
805
      FaceTransform newT = constructNewTransform(vert,isOuter);
799 806

  
800 807
      for (int old=0; !collapsed && old<numOld; old++)
801 808
        {
......
820 827
    {
821 828
    float[][] vertices = shape.getVertices();
822 829
    int[][] indices = shape.getVertIndices();
823
    createNewFaceTransform(vertices,indices);
830
    int outer = shape.getNumOutside();
831
    createNewFaceTransform(vertices,indices,outer);
824 832
    }
825 833

  
826 834
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff