Project

General

Profile

« Previous | Next » 

Revision e3302253

Added by Leszek Koltunski over 3 years ago

Progress with FactoryBandaged.

View differences:

src/main/java/org/distorted/objectlib/helpers/FactoryBandaged3x3Cubit.java
45 45
  private final int[] mWall;
46 46
  private final int[][] mPoints;
47 47
  private final boolean[][][] mTmp;
48
  private final float[] mMove;
48 49

  
49 50
///////////////////////////////////////////////////////////////////////////////////////////////////
50 51

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

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

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

  
72
    moveX/=numMoves;
73
    moveY/=numMoves;
74
    moveZ/=numMoves;
76
    mMove[0]/=numMoves;
77
    mMove[1]/=numMoves;
78
    mMove[2]/=numMoves;
75 79

  
76 80
    int total  = 0;
77 81
    int length = list.size();
......
92 96

  
93 97
      for(int j=0; j<len; j++)
94 98
        {
95
        verts[pointer][0] = vertices[i][3*j  ] - moveX;
96
        verts[pointer][1] = vertices[i][3*j+1] - moveY;
97
        verts[pointer][2] = vertices[i][3*j+2] - moveZ;
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 102
        pointer++;
99 103
        }
100 104
      }
......
726 730

  
727 731
///////////////////////////////////////////////////////////////////////////////////////////////////
728 732

  
729
  private static boolean vertInFace(float[] vertex, Static3D faceAxis, float dist)
733
  private static boolean vertInFace(float[] vertex, float[] move, Static3D faceAxis, float dist)
730 734
    {
731 735
    final float MAX_ERROR = 0.01f;
732 736

  
......
734 738
    float y= faceAxis.get1();
735 739
    float z= faceAxis.get2();
736 740

  
737
    float a = vertex[0]*x + vertex[1]*y + vertex[2]*z;
741
    float a = (vertex[0]+move[0])*x + (vertex[1]+move[1])*y + (vertex[2]+move[2])*z;
738 742
    float diff = a - dist;
739 743

  
740 744
    return diff>-MAX_ERROR && diff<MAX_ERROR;
......
786 790
    for(int cubitFace=0; cubitFace<numCubitFaces; cubitFace++)
787 791
      {
788 792
      bandIndices[cubitFace] = 0xffffffff;
789

  
790 793
      int numVertices = indices[cubitFace].length;
791
      int vertBelongsBitmap = 0x00000000;
792 794

  
793 795
      for(int vertex=0; vertex<numVertices; vertex++)
794 796
        {
797
        int vertBelongsBitmap = 0x00000000;
798

  
795 799
        for(int face=0; face<6; face++)
796 800
          {
797 801
          float[] vert = vertices[ indices[cubitFace][vertex] ];
798
          if( vertInFace(vert, TouchControlHexahedron.FACE_AXIS[face],1.5f) )
802
          if( vertInFace(vert, mMove, TouchControlHexahedron.FACE_AXIS[face],1.5f) )
799 803
            {
800 804
            vertBelongsBitmap |= (1<<face);
801 805
            }
......
808 812
        {
809 813
        bandIndices[cubitFace] = faceDiameter(vertices, indices[cubitFace]);
810 814
        }
815

  
816
      //android.util.Log.e("D", "cubit face "+cubitFace+" : "+bandIndices[cubitFace]);
811 817
      }
812 818

  
813 819
    return bandIndices;
......
945 951
    float defHeight     = 0.048f;
946 952
    float[][] corners   = { {0.04f,0.15f} };
947 953
    float[][] bands     = { {     0.001f,45,0.25f,0.5f,5,1,1},
948
                            {defHeight/3,45,0.25f,0.5f,5,1,1},
954
                            {defHeight/1,45,0.25f,0.5f,5,1,1},
949 955
                            {defHeight/2,45,0.25f,0.5f,5,1,1},
950
                            {defHeight/1,45,0.25f,0.5f,5,1,1} };
956
                            {defHeight/3,45,0.25f,0.5f,5,1,1} };
951 957

  
952 958
    int[] bandIndices   = generateBandIndices(mVertices[variant], mIndices[variant]);
953 959
    float[][] centers   = generateCenters(mVertices[variant], mIndices[variant]);
src/main/java/org/distorted/objectlib/objects/TwistyBandagedGeneric.java
21 21

  
22 22
import org.distorted.library.type.Static3D;
23 23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.scrambling.ScrambleState;
25
import org.distorted.objectlib.scrambling.ScrambleStateBandaged3x3;
26 24

  
27 25
import java.io.InputStream;
28 26

  

Also available in: Unified diff