Revision f8c52090
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/bandaged/BandagedCubit.java | ||
---|---|---|
129 | 129 |
|
130 | 130 |
computeMove(mPosition); |
131 | 131 |
mMove = new Static3D(0,0,0); |
132 |
MeshBase mesh = mObject.createMesh(mVariant,mPosition,mRoundCorners); |
|
132 |
|
|
133 |
MeshBase mesh = mObject.createMesh(mPosition,mRoundCorners); |
|
133 | 134 |
|
134 | 135 |
mTexture = new DistortedTexture(); |
135 | 136 |
if( mBitmap==null ) createBitmap(mObject.getColors()); |
... | ... | |
163 | 164 |
mPosition = tmpPosition; |
164 | 165 |
|
165 | 166 |
computeMove(mPosition); |
166 |
MeshBase mesh = mObject.createMesh(mVariant,mPosition,mRoundCorners);
|
|
167 |
MeshBase mesh = mObject.createMesh(mPosition,mRoundCorners); |
|
167 | 168 |
resetTextureMaps(mesh); |
168 | 169 |
mNode.setMesh(mesh); |
169 | 170 |
mMove.set( scale*mUnscaledX, scale*mUnscaledY, scale*mUnscaledZ); |
... | ... | |
183 | 184 |
mPosition[2] = z; |
184 | 185 |
|
185 | 186 |
computeMove(mPosition); |
186 |
MeshBase mesh = mObject.createMesh(mVariant,mPosition,mRoundCorners);
|
|
187 |
MeshBase mesh = mObject.createMesh(mPosition,mRoundCorners); |
|
187 | 188 |
resetTextureMaps(mesh); |
188 | 189 |
mNode.setMesh(mesh); |
189 | 190 |
mMove.set( scale*mUnscaledX, scale*mUnscaledY, scale*mUnscaledZ); |
src/main/java/org/distorted/bandaged/BandagedObject.java | ||
---|---|---|
55 | 55 |
abstract boolean tryChangeObject(int x, int y, int z); |
56 | 56 |
abstract boolean isInsideFace(int face, float[] p); |
57 | 57 |
abstract TwistyObject createObject(int mode, float scale ); |
58 |
abstract MeshBase createMesh(int variant, float[] pos, boolean round);
|
|
58 |
abstract MeshBase createMesh(float[] pos, boolean round); |
|
59 | 59 |
|
60 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 61 |
|
src/main/java/org/distorted/bandaged/BandagedObjectCuboid.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
boolean isAdjacent(float dx, float dy, float dz) |
68 | 68 |
{ |
69 |
return dx*dx + dy*dy + dz*dz == 1;
|
|
69 |
return dx*dx + dy*dy + dz*dz <= 1;
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
94 | 94 |
return pos; |
95 | 95 |
} |
96 | 96 |
|
97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
98 |
|
|
99 |
void getTouchedPosition(float[] output, int face, float pointX, float pointY) |
|
100 |
{ |
|
101 |
float x = mSize[0]; |
|
102 |
float y = mSize[1]; |
|
103 |
float z = mSize[2]; |
|
104 |
|
|
105 |
switch(face) |
|
106 |
{ |
|
107 |
case 0: output[0] = (x-1)/2; |
|
108 |
output[1] = (int)( y*pointY+y/2)-(y-1)/2; |
|
109 |
output[2] = (int)(-z*pointX-z/2)+(z-1)/2; |
|
110 |
break; |
|
111 |
case 1: output[0] =-(x-1)/2; |
|
112 |
output[1] = (int)( y*pointY+y/2)-(y-1)/2; |
|
113 |
output[2] = (int)( z*pointX+z/2)-(z-1)/2; |
|
114 |
break; |
|
115 |
case 2: output[0] = (int)( x*pointX+x/2)-(x-1)/2; |
|
116 |
output[1] = (y-1)/2; |
|
117 |
output[2] = (int)(-z*pointY-z/2)+(z-1)/2; |
|
118 |
break; |
|
119 |
case 3: output[0] = (int)( x*pointX+x/2)-(x-1)/2; |
|
120 |
output[1] =-(y-1)/2; |
|
121 |
output[2] = (int)( z*pointY+z/2)-(z-1)/2; |
|
122 |
break; |
|
123 |
case 4: output[0] = (int)( x*pointX+x/2)-(x-1)/2; |
|
124 |
output[1] = (int)( y*pointY+y/2)-(y-1)/2; |
|
125 |
output[2] = (z-1)/2; |
|
126 |
break; |
|
127 |
case 5: output[0] = (int)(-x*pointX-x/2)+(x-1)/2; |
|
128 |
output[1] = (int)( y*pointY+y/2)-(y-1)/2; |
|
129 |
output[2] =-(z-1)/2; |
|
130 |
break; |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
135 | 98 |
|
136 | 99 |
boolean tryChangeObject(int x, int y, int z) |
... | ... | |
185 | 148 |
|
186 | 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
187 | 150 |
|
188 |
MeshBase createMesh(int variant, float[] pos, boolean round)
|
|
151 |
MeshBase createMesh(float[] pos, boolean round) |
|
189 | 152 |
{ |
190 | 153 |
FactoryBandagedCuboid factory = FactoryBandagedCuboid.getInstance(); |
191 |
return factory.createMesh(pos,mSize[0],mSize[1],mSize[2],false,round);
|
|
154 |
return factory.createMesh(pos,mSize,false,round); |
|
192 | 155 |
} |
193 | 156 |
|
194 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/bandaged/BandagedObjectPyraminx.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
public class BandagedObjectPyraminx extends BandagedObject |
29 | 29 |
{ |
30 |
BandagedObjectPyraminx(DistortedScreen screen)
|
|
31 |
{
|
|
32 |
super(screen);
|
|
33 |
}
|
|
30 |
BandagedObjectPyraminx(DistortedScreen screen) |
|
31 |
{ |
|
32 |
super(screen); |
|
33 |
} |
|
34 | 34 |
|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
|
... | ... | |
80 | 80 |
|
81 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
82 | 82 |
|
83 |
float[] getDist3D()
|
|
84 |
{
|
|
85 |
float d = mSize[0]*SQ6/12;
|
|
86 |
return new float[] {d,d,d,d};
|
|
87 |
}
|
|
83 |
float[] getDist3D() |
|
84 |
{ |
|
85 |
float d = mSize[0]*SQ6/12; |
|
86 |
return new float[] {d,d,d,d}; |
|
87 |
} |
|
88 | 88 |
|
89 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
90 | 90 |
|
91 |
float getDist2D()
|
|
92 |
{
|
|
93 |
return SQ3/6;
|
|
94 |
}
|
|
91 |
float getDist2D() |
|
92 |
{ |
|
93 |
return SQ3/6; |
|
94 |
} |
|
95 | 95 |
|
96 | 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
97 | 97 |
|
98 |
int[] getColors()
|
|
99 |
{
|
|
100 |
return ShapeTetrahedron.FACE_COLORS;
|
|
101 |
}
|
|
98 |
int[] getColors() |
|
99 |
{ |
|
100 |
return ShapeTetrahedron.FACE_COLORS; |
|
101 |
} |
|
102 | 102 |
|
103 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
104 | 104 |
|
... | ... | |
110 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
111 | 111 |
|
112 | 112 |
boolean tryChangeObject(int x, int y, int z) |
113 |
{
|
|
114 |
if( mSize[0]!=x )
|
|
115 |
{
|
|
116 |
mSize[0] = x;
|
|
117 |
mMax = mSize[0];
|
|
118 |
int numOcta = (x-1)*x*(x+1)/6;
|
|
119 |
int numTetra= x*(x+1)*(x+2)/6;
|
|
120 |
mNumCubits = numOcta + numTetra;
|
|
121 |
return true;
|
|
122 |
}
|
|
113 |
{ |
|
114 |
if( mSize[0]!=x ) |
|
115 |
{ |
|
116 |
mSize[0] = x; |
|
117 |
mMax = mSize[0]; |
|
118 |
int numOcta = (x-1)*x*(x+1)/6; |
|
119 |
int numTetra= x*(x+1)*(x+2)/6; |
|
120 |
mNumCubits = numOcta + numTetra; |
|
121 |
return true; |
|
122 |
} |
|
123 | 123 |
|
124 |
return false;
|
|
125 |
}
|
|
124 |
return false; |
|
125 |
} |
|
126 | 126 |
|
127 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
128 | 128 |
|
129 | 129 |
int computeProjectionAngle() |
130 |
{
|
|
131 |
return 120;
|
|
132 |
}
|
|
130 |
{ |
|
131 |
return 120; |
|
132 |
} |
|
133 | 133 |
|
134 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
135 | 135 |
|
... | ... | |
166 | 166 |
|
167 | 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
168 | 168 |
|
169 |
MeshBase createMesh(int variant, float[] pos, boolean round)
|
|
170 |
{
|
|
171 |
FactoryBandagedPyraminx factory = FactoryBandagedPyraminx.getInstance();
|
|
172 |
return factory.createMesh(variant,pos,mSize[0],false,round);
|
|
173 |
}
|
|
169 |
MeshBase createMesh(float[] pos, boolean round) |
|
170 |
{ |
|
171 |
FactoryBandagedPyraminx factory = FactoryBandagedPyraminx.getInstance(); |
|
172 |
return factory.createMesh(pos,mSize[0],false,round);
|
|
173 |
} |
|
174 | 174 |
|
175 | 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
176 | 176 |
|
177 | 177 |
TwistyObject createObject(int mode, float size) |
178 |
{
|
|
179 |
float[][] pos = getCubitPositions();
|
|
180 |
InitData data = new InitData( mSize,pos);
|
|
181 |
return new TwistyBandagedPyraminx( TwistyObject.MESH_NICE, mode, ShapeTetrahedron.DEFAULT_ROT, new Static3D(0,0,0), size, data, null );
|
|
182 |
}
|
|
178 |
{ |
|
179 |
float[][] pos = getCubitPositions(); |
|
180 |
InitData data = new InitData( mSize,pos); |
|
181 |
return new TwistyBandagedPyraminx( TwistyObject.MESH_NICE, mode, ShapeTetrahedron.DEFAULT_ROT, new Static3D(0,0,0), size, data, null ); |
|
182 |
} |
|
183 | 183 |
} |
Also available in: Unified diff
generalize FactoryBandagedCuboid: start removing 'cuboidal' assumptions from it.