1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2023 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 static org.distorted.objectlib.main.TwistyObject.SQ3;
|
13
|
import static org.distorted.objectlib.main.TwistyObject.SQ6;
|
14
|
|
15
|
import org.distorted.library.main.DistortedScreen;
|
16
|
import org.distorted.library.mesh.MeshBase;
|
17
|
import org.distorted.library.type.Static3D;
|
18
|
import org.distorted.objectlib.main.InitData;
|
19
|
import org.distorted.objectlib.main.TwistyObject;
|
20
|
import org.distorted.objectlib.objects.TwistyBandagedPyraminx;
|
21
|
import org.distorted.objectlib.shape.ShapeTetrahedron;
|
22
|
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
|
23
|
|
24
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25
|
|
26
|
public class BandagedObjectPyraminx extends BandagedObject
|
27
|
{
|
28
|
private boolean isFaceInverted(int face)
|
29
|
{
|
30
|
return face>1;
|
31
|
}
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
float getDist2D()
|
36
|
{
|
37
|
return SQ3/6;
|
38
|
}
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
|
42
|
int[] getColors()
|
43
|
{
|
44
|
return ShapeTetrahedron.FACE_COLORS;
|
45
|
}
|
46
|
|
47
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
48
|
|
49
|
boolean isAdjacent(float dx, float dy, float dz)
|
50
|
{
|
51
|
return dx*dx + dy*dy + dz*dz < (SQ3/4)*1.01f;
|
52
|
}
|
53
|
|
54
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55
|
|
56
|
float[][][] getPositions()
|
57
|
{
|
58
|
FactoryBandagedPyraminx factory = FactoryBandagedPyraminx.getInstance();
|
59
|
return factory.getPositions(mSize);
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
MeshBase createMesh(float[] pos, boolean round)
|
65
|
{
|
66
|
FactoryBandagedPyraminx factory = FactoryBandagedPyraminx.getInstance();
|
67
|
return factory.createMesh(pos,mSize,false,round);
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
// PUBLIC API
|
72
|
|
73
|
public BandagedObjectPyraminx(DistortedScreen screen)
|
74
|
{
|
75
|
super(screen,4);
|
76
|
}
|
77
|
|
78
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79
|
|
80
|
public float getScreenRatio()
|
81
|
{
|
82
|
return 0.8f;
|
83
|
}
|
84
|
|
85
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
|
|
87
|
public float[] getDist3D()
|
88
|
{
|
89
|
float d = SQ6/12;
|
90
|
return new float[] {d,d,d,d};
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
public Static3D[] getFaceAxis()
|
96
|
{
|
97
|
return TouchControlTetrahedron.FACE_AXIS;
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
public boolean tryChangeObject(int x, int y, int z)
|
103
|
{
|
104
|
if( mSize[0]!=x )
|
105
|
{
|
106
|
mSize[0] = x;
|
107
|
mSize[1] = x;
|
108
|
mSize[2] = x;
|
109
|
mSize[3] = x;
|
110
|
|
111
|
mMax = x;
|
112
|
int numOcta = FactoryBandagedPyraminx.numEntriesInEmptyLattice(x-1);
|
113
|
int numTetra= FactoryBandagedPyraminx.numEntriesInEmptyLattice(x);
|
114
|
mNumCubits = numOcta + numTetra;
|
115
|
return true;
|
116
|
}
|
117
|
|
118
|
return false;
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
public int computeProjectionAngle()
|
124
|
{
|
125
|
return 120;
|
126
|
}
|
127
|
|
128
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129
|
|
130
|
public boolean isInsideFace(int face, float[] p)
|
131
|
{
|
132
|
float y = (isFaceInverted(face) ? p[1] : -p[1]);
|
133
|
float x = p[0];
|
134
|
return (y >= -mDist2D) && (y <= mDist2D*(2-6*x)) && (y <= mDist2D*(2+6*x));
|
135
|
}
|
136
|
|
137
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
138
|
|
139
|
public TwistyObject createObject(int mode, float size)
|
140
|
{
|
141
|
float[][] pos = getCubitPositions();
|
142
|
InitData data = new InitData( mSize,pos);
|
143
|
return new TwistyBandagedPyraminx( TwistyObject.MESH_NICE, mode, ShapeTetrahedron.DEFAULT_ROT, new Static3D(0,0,0), size, data, null );
|
144
|
}
|
145
|
}
|