Project

General

Profile

« Previous | Next » 

Revision 462b983d

Added by Leszek Koltunski 12 months ago

Introduce BandagedObjectPyraminx.

View differences:

src/main/java/org/distorted/bandaged/BandagedObjectCuboid.java
12 12
import org.distorted.library.main.DistortedScreen;
13 13
import org.distorted.library.mesh.MeshBase;
14 14
import org.distorted.library.type.Static3D;
15
import org.distorted.objectlib.helpers.FactoryBandagedCubit;
15
import org.distorted.objectlib.helpers.FactoryBandagedCuboid;
16 16
import org.distorted.objectlib.main.InitData;
17 17
import org.distorted.objectlib.main.TwistyObject;
18 18
import org.distorted.objectlib.objects.TwistyBandagedCuboid;
......
69 69
    return dx*dx + dy*dy + dz*dz == 1;
70 70
    }
71 71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
  boolean tryChangeObject(int x, int y, int z)
75
     {
76
     if( mSize[0]!=x || mSize[1]!=y || mSize[2]!=z )
77
       {
78
       mSize[0] = x;
79
       mSize[1] = y;
80
       mSize[2] = z;
81
       mMax = x>y ? Math.max(x,z) : Math.max(y,z);
82
       mNumCubits = ( x<=1 || y<=1 || z<=1 ) ? x*y*z : x*y*z-(x-2)*(y-2)*(z-2);
83
       return true;
84
       }
85

  
86
     return false;
87
     }
88

  
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

  
91
  int computeProjectionAngle()
92
     {
93
     float quot1 = mSize[2]/ (float)mSize[0];
94
     float quot2 = mSize[2]/ (float)mSize[1];
95
     float quot3 = mSize[0]/ (float)mSize[2];
96
     float quot4 = mSize[0]/ (float)mSize[1];
97

  
98
     float quot5 = Math.max(quot1,quot2);
99
     float quot6 = Math.max(quot3,quot4);
100
     float quot7 = Math.max(quot5,quot6);
101

  
102
          if( quot7<=1.0f ) return 120;
103
     else if( quot7<=1.5f ) return 90;
104
     else if( quot7<=2.0f ) return 60;
105
     else                   return 30;
106
     }
107

  
108 72
///////////////////////////////////////////////////////////////////////////////////////////////////
109 73

  
110 74
  float[][] getPositions()
......
167 131
      }
168 132
    }
169 133

  
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135

  
136
  boolean tryChangeObject(int x, int y, int z)
137
     {
138
     if( mSize[0]!=x || mSize[1]!=y || mSize[2]!=z )
139
       {
140
       mSize[0] = x;
141
       mSize[1] = y;
142
       mSize[2] = z;
143
       mMax = x>y ? Math.max(x,z) : Math.max(y,z);
144
       mNumCubits = ( x<=1 || y<=1 || z<=1 ) ? x*y*z : x*y*z-(x-2)*(y-2)*(z-2);
145
       return true;
146
       }
147

  
148
     return false;
149
     }
150

  
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

  
153
  int computeProjectionAngle()
154
     {
155
     float quot1 = mSize[2]/ (float)mSize[0];
156
     float quot2 = mSize[2]/ (float)mSize[1];
157
     float quot3 = mSize[0]/ (float)mSize[2];
158
     float quot4 = mSize[0]/ (float)mSize[1];
159

  
160
     float quot5 = Math.max(quot1,quot2);
161
     float quot6 = Math.max(quot3,quot4);
162
     float quot7 = Math.max(quot5,quot6);
163

  
164
          if( quot7<=1.0f ) return 120;
165
     else if( quot7<=1.5f ) return 90;
166
     else if( quot7<=2.0f ) return 60;
167
     else                   return 30;
168
     }
169

  
170 170
///////////////////////////////////////////////////////////////////////////////////////////////////
171 171

  
172 172
  boolean isInsideFace(int face, float[] p)
......
187 187

  
188 188
  MeshBase createMesh(float[] pos, boolean round)
189 189
     {
190
     FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance();
191
     int[] size = getSize();
192
     return factory.createMesh(pos,size[0],size[1],size[2],false,round);
190
     FactoryBandagedCuboid factory = FactoryBandagedCuboid.getInstance();
191
     return factory.createMesh(pos,mSize[0],mSize[1],mSize[2],false,round);
193 192
     }
194 193

  
195 194
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/bandaged/BandagedObjectPyraminx.java
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.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.helpers.FactoryBandagedPyraminx;
19
import org.distorted.objectlib.main.InitData;
20
import org.distorted.objectlib.main.TwistyObject;
21
import org.distorted.objectlib.objects.TwistyBandagedPyraminx;
22
import org.distorted.objectlib.shape.ShapeTetrahedron;
23
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
24

  
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

  
27
public class BandagedObjectPyraminx extends BandagedObject
28
{
29
   BandagedObjectPyraminx(DistortedScreen screen)
30
     {
31
     super(screen);
32
     }
33

  
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

  
36
   float[] getDist3D()
37
     {
38
     float d = mSize[0]*SQ6/12;
39
     return new float[] {d,d,d,d};
40
     }
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
   float getDist2D()
45
     {
46
     return SQ3/6;
47
     }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

  
51
   int[] getColors()
52
     {
53
     return ShapeTetrahedron.FACE_COLORS;
54
     }
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  Static3D[] getFaceAxis()
59
    {
60
    return TouchControlTetrahedron.FACE_AXIS;
61
    }
62

  
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

  
65
  boolean tryChangeObject(int x, int y, int z)
66
     {
67
     if( mSize[0]!=x )
68
       {
69
       mSize[0] = x;
70
       mMax = mSize[0];
71
       int numOcta = (x-1)*x*(x+1)/6;
72
       int numTetra= x*(x+1)*(x+2)/6;
73
       mNumCubits = numOcta + numTetra;
74
       return true;
75
       }
76

  
77
     return false;
78
     }
79

  
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

  
82
  int computeProjectionAngle()
83
     {
84
     return 120;
85
     }
86

  
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88
// TODO
89

  
90
  boolean isAdjacent(float dx, float dy, float dz)
91
    {
92
    return false;
93
    }
94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
// TODO
97

  
98
  float[][] getPositions()
99
    {
100
    return null;
101
    }
102

  
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104
// TODO
105

  
106
  void getTouchedPosition(float[] output, int face, float pointX, float pointY)
107
    {
108

  
109
    }
110

  
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
// TODO
113

  
114
  boolean isInsideFace(int face, float[] p)
115
    {
116
    return false;
117
    }
118

  
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

  
121
  MeshBase createMesh(float[] pos, boolean round)
122
     {
123
     FactoryBandagedPyraminx factory = FactoryBandagedPyraminx.getInstance();
124
     return factory.createMesh(pos,mSize[0],false,round);
125
     }
126

  
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

  
129
  TwistyObject createObject(int mode, float size)
130
     {
131
     float[][] pos = getCubitPositions();
132
     InitData data = new InitData( mSize,pos);
133
     return new TwistyBandagedPyraminx( TwistyObject.MESH_NICE, mode, ShapeTetrahedron.DEFAULT_ROT, new Static3D(0,0,0), size, data, null );
134
     }
135
}

Also available in: Unified diff