Project

General

Profile

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

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

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[] elementVertices(int ax, boolean left, int element)
39
    {
40
    float[] pos = mElements[element].getPos();
41
    float[] ret = new float[12];
42

    
43
    switch(ax)
44
      {
45
      case 0: if( left )
46
                {
47
                ret[ 0] = pos[0]-0.5f;
48
                ret[ 1] = pos[1]+0.5f;
49
                ret[ 2] = pos[2]-0.5f;
50
                ret[ 3] = pos[0]-0.5f;
51
                ret[ 4] = pos[1]-0.5f;
52
                ret[ 5] = pos[2]-0.5f;
53
                ret[ 6] = pos[0]-0.5f;
54
                ret[ 7] = pos[1]-0.5f;
55
                ret[ 8] = pos[2]+0.5f;
56
                ret[ 9] = pos[0]-0.5f;
57
                ret[10] = pos[1]+0.5f;
58
                ret[11] = pos[2]+0.5f;
59
                }
60
              else
61
                {
62
                ret[ 0] = pos[0]+0.5f;
63
                ret[ 1] = pos[1]+0.5f;
64
                ret[ 2] = pos[2]+0.5f;
65
                ret[ 3] = pos[0]+0.5f;
66
                ret[ 4] = pos[1]-0.5f;
67
                ret[ 5] = pos[2]+0.5f;
68
                ret[ 6] = pos[0]+0.5f;
69
                ret[ 7] = pos[1]-0.5f;
70
                ret[ 8] = pos[2]-0.5f;
71
                ret[ 9] = pos[0]+0.5f;
72
                ret[10] = pos[1]+0.5f;
73
                ret[11] = pos[2]-0.5f;
74
                }
75
              break;
76
      case 1: if( left )
77
                {
78
                ret[ 0] = pos[0]-0.5f;
79
                ret[ 1] = pos[1]-0.5f;
80
                ret[ 2] = pos[2]+0.5f;
81
                ret[ 3] = pos[0]-0.5f;
82
                ret[ 4] = pos[1]-0.5f;
83
                ret[ 5] = pos[2]-0.5f;
84
                ret[ 6] = pos[0]+0.5f;
85
                ret[ 7] = pos[1]-0.5f;
86
                ret[ 8] = pos[2]-0.5f;
87
                ret[ 9] = pos[0]+0.5f;
88
                ret[10] = pos[1]-0.5f;
89
                ret[11] = pos[2]+0.5f;
90
                }
91
              else
92
                {
93
                ret[ 0] = pos[0]-0.5f;
94
                ret[ 1] = pos[1]+0.5f;
95
                ret[ 2] = pos[2]-0.5f;
96
                ret[ 3] = pos[0]-0.5f;
97
                ret[ 4] = pos[1]+0.5f;
98
                ret[ 5] = pos[2]+0.5f;
99
                ret[ 6] = pos[0]+0.5f;
100
                ret[ 7] = pos[1]+0.5f;
101
                ret[ 8] = pos[2]+0.5f;
102
                ret[ 9] = pos[0]+0.5f;
103
                ret[10] = pos[1]+0.5f;
104
                ret[11] = pos[2]-0.5f;
105
                }
106
              break;
107
      case 2: if( left )
108
                {
109
                ret[ 0] = pos[0]+0.5f;
110
                ret[ 1] = pos[1]+0.5f;
111
                ret[ 2] = pos[2]-0.5f;
112
                ret[ 3] = pos[0]+0.5f;
113
                ret[ 4] = pos[1]-0.5f;
114
                ret[ 5] = pos[2]-0.5f;
115
                ret[ 6] = pos[0]-0.5f;
116
                ret[ 7] = pos[1]-0.5f;
117
                ret[ 8] = pos[2]-0.5f;
118
                ret[ 9] = pos[0]-0.5f;
119
                ret[10] = pos[1]+0.5f;
120
                ret[11] = pos[2]-0.5f;
121
                }
122
              else
123
                {
124
                ret[ 0] = pos[0]-0.5f;
125
                ret[ 1] = pos[1]+0.5f;
126
                ret[ 2] = pos[2]+0.5f;
127
                ret[ 3] = pos[0]-0.5f;
128
                ret[ 4] = pos[1]-0.5f;
129
                ret[ 5] = pos[2]+0.5f;
130
                ret[ 6] = pos[0]+0.5f;
131
                ret[ 7] = pos[1]-0.5f;
132
                ret[ 8] = pos[2]+0.5f;
133
                ret[ 9] = pos[0]+0.5f;
134
                ret[10] = pos[1]+0.5f;
135
                ret[11] = pos[2]+0.5f;
136
                }
137
              break;
138
      }
139

    
140
    return ret;
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

    
145
  public boolean elementFaceNotNull(int ax, boolean left, int element)
146
     {
147
     return true;
148
     }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  public int getElementVariant(float x, float y, float z)
153
     {
154
     return 0;
155
     }
156

    
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158

    
159
  public float[][] getCuts(int[] numLayers)
160
    {
161
    int numAxis = numLayers.length;
162
    float[][] cuts = new float[numAxis][];
163

    
164
    for(int axis=0; axis<numAxis; axis++)
165
      {
166
      int len = numLayers[axis];
167
      float start = 1-len*0.5f;
168

    
169
      if( len>=2 )
170
        {
171
        cuts[axis] = new float[len-1];
172
        for(int i=0; i<len-1; i++) cuts[axis][i] = start+i;
173
        }
174
      }
175

    
176
    return cuts;
177
    }
178

    
179
///////////////////////////////////////////////////////////////////////////////////////////////////
180

    
181
  public Static3D[] getNormals()
182
    {
183
    return TouchControlHexahedron.FACE_AXIS;
184
    }
185

    
186
///////////////////////////////////////////////////////////////////////////////////////////////////
187

    
188
  public float[][] getRotAxis()
189
    {
190
    return new float[][] { {-1,0,0},{0,-1,0},{0,0,-1} };
191
    }
192

    
193
///////////////////////////////////////////////////////////////////////////////////////////////////
194

    
195
  public float[][] getDiameterAxis()
196
     {
197
     return new float[][] { {1,0,0},{0,1,0},{0,0,1} };
198
     }
199

    
200
///////////////////////////////////////////////////////////////////////////////////////////////////
201

    
202
  public float[] getDist3D()
203
    {
204
    float dx = mNumLayers[0]/2.0f;
205
    float dy = mNumLayers[1]/2.0f;
206
    float dz = mNumLayers[2]/2.0f;
207

    
208
    return new float[] {dx,dx,dy,dy,dz,dz};
209
    }
210

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

    
213
  public float[][] getBands(boolean iconMode)
214
    {
215
    float height= iconMode ? 0.001f : 0.05f;
216
    int[] angle = {65,54,43,35,30,26};
217
    float R     = 0.3f;
218
    float S     = 0.5f;
219
    int extraI  = 0;
220
    int extraV  = 0;
221

    
222
    int sum = mNumLayers[0]+mNumLayers[1]+mNumLayers[2];
223
    int numVertA= sum>=19 ? 3 : (sum>=16 ? 4:5);
224
    int numVertI= sum>=13 ? 2 : 3;
225

    
226
    return new float[][] { {  0.001f,angle[0],R,S,numVertI,extraV,extraI},
227
                           {height  ,angle[1],R,S,numVertA,extraV,extraI},
228
                           {height/2,angle[2],R,S,numVertA,extraV,extraI},
229
                           {height/3,angle[3],R,S,numVertA,extraV,extraI},
230
                           {height/4,angle[4],R,S,numVertA,extraV,extraI},
231
                           {height/5,angle[5],R,S,numVertA,extraV,extraI} };
232
    }
233
  }
(7-7/8)