Project

General

Profile

« Previous | Next » 

Revision 29ad5fc9

Added by Leszek Koltunski over 2 years ago

Progress with FactoryBandaged.

View differences:

src/main/java/org/distorted/objectlib/helpers/FactoryBandaged3x3Cubit.java
42 42
  private ArrayList<float[]> mVertexArray;
43 43
  private float[][][] mVertices;
44 44
  private int[][][] mIndices;
45
  private float[][] mMove;
45 46
  private final int[] mWall;
46 47
  private final int[][] mPoints;
47 48
  private final boolean[][][] mTmp;
48
  private final float[] mMove;
49 49

  
50 50
///////////////////////////////////////////////////////////////////////////////////////////////////
51 51

  
......
54 54
    mWall= new int[9];
55 55
    mPoints = new int[4][4];
56 56
    mTmp = new boolean[3][3][3];
57
    mMove = new float[3];
58 57
    }
59 58

  
60 59
///////////////////////////////////////////////////////////////////////////////////////////////////
61 60

  
62
  private float[][] getVertices(ArrayList<float[]> list, float[] move)
61
  private float[][] getVertices(ArrayList<float[]> list, float[] move, int variant)
63 62
    {
64 63
    int numMoves = move.length/3;
65
    mMove[0]=0.0f;
66
    mMove[1]=0.0f;
67
    mMove[2]=0.0f;
64
    mMove[variant][0]=0.0f;
65
    mMove[variant][1]=0.0f;
66
    mMove[variant][2]=0.0f;
68 67

  
69 68
    for(int m=0; m<numMoves; m++)
70 69
      {
71
      mMove[0] += move[3*m  ];
72
      mMove[1] += move[3*m+1];
73
      mMove[2] += move[3*m+2];
70
      mMove[variant][0] += move[3*m  ];
71
      mMove[variant][1] += move[3*m+1];
72
      mMove[variant][2] += move[3*m+2];
74 73
      }
75 74

  
76
    mMove[0]/=numMoves;
77
    mMove[1]/=numMoves;
78
    mMove[2]/=numMoves;
75
    mMove[variant][0]/=numMoves;
76
    mMove[variant][1]/=numMoves;
77
    mMove[variant][2]/=numMoves;
79 78

  
80 79
    int total  = 0;
81 80
    int length = list.size();
......
96 95

  
97 96
      for(int j=0; j<len; j++)
98 97
        {
99
        verts[pointer][0] = vertices[i][3*j  ] - mMove[0];
100
        verts[pointer][1] = vertices[i][3*j+1] - mMove[1];
101
        verts[pointer][2] = vertices[i][3*j+2] - mMove[2];
98
        verts[pointer][0] = vertices[i][3*j  ] - mMove[variant][0];
99
        verts[pointer][1] = vertices[i][3*j+1] - mMove[variant][1];
100
        verts[pointer][2] = vertices[i][3*j+2] - mMove[variant][2];
102 101
        pointer++;
103 102
        }
104 103
      }
......
782 781
// return array of:
783 782
// 0 if this is an inner face, 1 if its diameter is 1, 2 if diameter is 2, 3 if 3.
784 783

  
785
  private int[] generateBandIndices(float[][] vertices, int[][] indices)
784
  private int[] generateBandIndices(float[][] vertices, int[][] indices, float[] move)
786 785
    {
787 786
    int numCubitFaces = indices.length;
788 787
    int[] bandIndices = new int[numCubitFaces];
......
799 798
        for(int face=0; face<6; face++)
800 799
          {
801 800
          float[] vert = vertices[ indices[cubitFace][vertex] ];
802
          if( vertInFace(vert, mMove, TouchControlHexahedron.FACE_AXIS[face],1.5f) )
801
          if( vertInFace(vert, move, TouchControlHexahedron.FACE_AXIS[face],1.5f) )
803 802
            {
804 803
            vertBelongsBitmap |= (1<<face);
805 804
            }
......
865 864
    if( mVertexArray==null ) mVertexArray = new ArrayList<>();
866 865
    mVertices= new float[numVariants][][];
867 866
    mIndices = new int[numVariants][][];
867
    mMove = new float[numVariants][3];
868 868
    }
869 869

  
870 870
///////////////////////////////////////////////////////////////////////////////////////////////////
......
904 904
    createBack1(mVertexArray);
905 905
    createBack2(mVertexArray);
906 906

  
907
    mVertices[variant] = getVertices(mVertexArray,pos);
907
    mVertices[variant] = getVertices(mVertexArray,pos,variant);
908 908
    mIndices[variant]  = getIndices(mVertexArray);
909 909
/*
910 910
int lenV = mVertices[variant].length;
......
955 955
                            {defHeight/2,45,0.25f,0.5f,5,1,1},
956 956
                            {defHeight/3,45,0.25f,0.5f,5,1,1} };
957 957

  
958
    int[] bandIndices   = generateBandIndices(mVertices[variant], mIndices[variant]);
958
    int[] bandIndices   = generateBandIndices(mVertices[variant], mIndices[variant], mMove[variant]);
959 959
    float[][] centers   = generateCenters(mVertices[variant], mIndices[variant]);
960 960
    int[] cornerIndices = generateCornerIndices(mVertices[variant], mIndices[variant]);
961 961
    int[] centerIndices = generateCenterIndices(mVertices[variant], mIndices[variant]);
src/main/java/org/distorted/objectlib/objects/TwistyBandagedGeneric.java
53 53
      {
54 54
      POSITIONS = new float[][]
55 55
        {
56
/*
56

  
57 57
          {-1.0f, +1.0f, +1.0f,
58 58
           -1.0f, +1.0f, +0.0f,
59 59
           -1.0f, +1.0f, -1.0f,
......
64 64
          {-1.0f, -1.0f, +1.0f,
65 65
           -1.0f, -1.0f, +0.0f,
66 66
           -1.0f, -1.0f, -1.0f },
67
*/
67

  
68
/*
68 69
          {-1.0f, +1.0f, +1.0f},
69 70
          {-1.0f, +1.0f, +0.0f},
70 71
          {-1.0f, +1.0f, -1.0f},
......
75 76
          {-1.0f, -1.0f, +1.0f},
76 77
          {-1.0f, -1.0f, +0.0f},
77 78
          {-1.0f, -1.0f, -1.0f},
78

  
79
*/
79 80
          { 0.0f, +1.0f, +1.0f},
80 81
          { 0.0f, +1.0f, +0.0f},
81 82
          { 0.0f, +1.0f, -1.0f},

Also available in: Unified diff