Project

General

Profile

Download (5.13 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / bandaged / FactoryBandagedCuboid.java @ 45aedaa7

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.bandaged;
11

    
12
import org.distorted.library.type.Static3D;
13
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
14

    
15
///////////////////////////////////////////////////////////////////////////////////////////////////
16

    
17
public class FactoryBandagedCuboid extends FactoryBandaged
18
  {
19
  private static FactoryBandagedCuboid mThis;
20

    
21
///////////////////////////////////////////////////////////////////////////////////////////////////
22

    
23
  private FactoryBandagedCuboid()
24
    {
25

    
26
    }
27

    
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

    
30
  public static FactoryBandagedCuboid getInstance()
31
     {
32
     if( mThis==null ) mThis = new FactoryBandagedCuboid();
33
     return mThis;
34
     }
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
  public float[][] getVertices(int variant)
39
    {
40
    return new float[][]
41
      {
42
        { 0.5f, 0.5f, 0.5f },
43
        { 0.5f, 0.5f,-0.5f },
44
        { 0.5f,-0.5f, 0.5f },
45
        { 0.5f,-0.5f,-0.5f },
46
        {-0.5f, 0.5f, 0.5f },
47
        {-0.5f, 0.5f,-0.5f },
48
        {-0.5f,-0.5f, 0.5f },
49
        {-0.5f,-0.5f,-0.5f },
50
      };
51
    }
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public int[][] getIndices(int variant)
56
    {
57
    return new int[][]
58
      {
59
        {2,3,1,0},
60
        {7,6,4,5},
61
        {4,0,1,5},
62
        {7,3,2,6},
63
        {6,2,0,4},
64
        {3,7,5,1}
65
      };
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  public int getElementVariant(float x, float y, float z)
71
     {
72
     return 0;
73
     }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  public float[][] getCuts(int[] numLayers)
78
    {
79
    int numAxis = numLayers.length;
80
    float[][] cuts = new float[numAxis][];
81

    
82
    for(int axis=0; axis<numAxis; axis++)
83
      {
84
      int len = numLayers[axis];
85
      float start = 1-len*0.5f;
86

    
87
      if( len>=2 )
88
        {
89
        cuts[axis] = new float[len-1];
90
        for(int i=0; i<len-1; i++) cuts[axis][i] = start+i;
91
        }
92
      }
93

    
94
    return cuts;
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

    
99
  public Static3D[] getNormals()
100
    {
101
    return TouchControlHexahedron.FACE_AXIS;
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  public float[][] getRotAxis()
107
    {
108
    return new float[][] { {-1,0,0},{0,-1,0},{0,0,-1} };
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
  public float[][] getDiameterAxis()
114
     {
115
     return new float[][] { {1,0,0},{0,1,0},{0,0,1} };
116
     }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

    
120
  public int diameterMap(float diameter)
121
     {
122
     return diameter>7 ? 7 : (int)diameter;
123
     }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  public float[] getDist3D()
128
    {
129
    float dx = mNumLayers[0]/2.0f;
130
    float dy = mNumLayers[1]/2.0f;
131
    float dz = mNumLayers[2]/2.0f;
132

    
133
    return new float[] {dx,dx,dy,dy,dz,dz};
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  public float[][] getBands(boolean iconMode)
139
    {
140
    int sum = mNumLayers[0]+mNumLayers[1]+mNumLayers[2];
141

    
142
    float height= iconMode ? 0.001f : 0.05f;
143
    int[] angle = {65,54,43,35,30,26,23,21};
144
    float R     = 0.3f;
145
    float S     = 0.5f;
146
    int extraI  = sum>6 ? 0 : 2;
147
    int extraV  = sum>6 ? 0 : 2;
148
    int numVertA= sum>=19 ? 3 : (sum>=16 ? 4:5);
149
    int numVertI= sum>=13 ? 2 : 3;
150

    
151
    return new float[][] { {0.001f  ,angle[0],R,S,numVertI,extraV,extraI},
152
                           {height  ,angle[1],R,S,numVertA,extraV,extraI},
153
                           {height/2,angle[2],R,S,numVertA,extraV,extraI},
154
                           {height/3,angle[3],R,S,numVertA,extraV,extraI},
155
                           {height/4,angle[4],R,S,numVertA,extraV,extraI},
156
                           {height/5,angle[5],R,S,numVertA,extraV,extraI},
157
                           {height/6,angle[6],R,S,numVertA,extraV,extraI},
158
                           {height/7,angle[7],R,S,numVertA,extraV,extraI},
159
                         };
160
    }
161
  }
(8-8/11)