Revision afd7e804
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
|---|---|---|
| 429 | 429 |
|
| 430 | 430 |
private void rescaleObject() |
| 431 | 431 |
{
|
| 432 |
float size = mObject.getSize(); |
|
| 432 |
float size = mObject.getMaxSize();
|
|
| 433 | 433 |
final float Q = mObjectScreenRatio/size; |
| 434 | 434 |
mScaleValue = mWidth<mHeight ? Q*mWidth : Q*mHeight; |
| 435 | 435 |
mScale.set( mScaleValue,mScaleValue,mScaleValue ); |
| src/main/java/org/distorted/bandaged/BandagedCubit.java | ||
|---|---|---|
| 26 | 26 |
import org.distorted.library.type.Static1D; |
| 27 | 27 |
import org.distorted.library.type.Static3D; |
| 28 | 28 |
import org.distorted.library.type.Static4D; |
| 29 |
import org.distorted.objectlib.helpers.FactoryBandagedCubit; |
|
| 30 | 29 |
import org.distorted.objectlib.helpers.FactoryCubit; |
| 31 | 30 |
|
| 32 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_BLUE; |
|
| 33 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_GREEN; |
|
| 34 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_ORANGE; |
|
| 35 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_RED; |
|
| 36 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_WHITE; |
|
| 37 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_YELLOW; |
|
| 38 |
|
|
| 39 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 | 32 |
|
| 41 | 33 |
public class BandagedCubit |
| ... | ... | |
| 46 | 38 |
private static Bitmap mBitmap; |
| 47 | 39 |
private static Static4D[] mTextureMaps; |
| 48 | 40 |
|
| 41 |
private final BandagedObject mObject; |
|
| 49 | 42 |
private final DistortedNode mNode; |
| 50 | 43 |
private final DistortedEffects mEffects; |
| 51 | 44 |
private final DistortedTexture mTexture; |
| 52 | 45 |
private final Static3D mMove; |
| 53 | 46 |
private final boolean mRoundCorners; |
| 54 |
private final int mX, mY, mZ; |
|
| 55 | 47 |
|
| 56 | 48 |
private float mUnscaledX, mUnscaledY, mUnscaledZ; |
| 57 | 49 |
private float[] mPosition; |
| ... | ... | |
| 60 | 52 |
|
| 61 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 62 | 54 |
|
| 63 |
private static void createBitmap() |
|
| 55 |
private static void createBitmap(int[] colors)
|
|
| 64 | 56 |
{
|
| 65 |
final int[] FACE_COLORS = new int[] |
|
| 66 |
{
|
|
| 67 |
COLOR_YELLOW, COLOR_WHITE, |
|
| 68 |
COLOR_BLUE , COLOR_GREEN, |
|
| 69 |
COLOR_RED , COLOR_ORANGE |
|
| 70 |
}; |
|
| 71 |
final int NUM = FACE_COLORS.length; |
|
| 57 |
final int NUM = colors.length; |
|
| 72 | 58 |
final int SIZE= 32; |
| 73 | 59 |
|
| 74 | 60 |
mTextureMaps = new Static4D[NUM]; |
| ... | ... | |
| 80 | 66 |
|
| 81 | 67 |
for(int color=0; color<NUM; color++) |
| 82 | 68 |
{
|
| 83 |
paint.setColor(FACE_COLORS[color]);
|
|
| 69 |
paint.setColor(colors[color]);
|
|
| 84 | 70 |
canvas.drawRect(color*SIZE, 0, (color+1)*SIZE, SIZE, paint); |
| 85 | 71 |
mTextureMaps[color] = new Static4D( ((float)color)/NUM, 0.0f, 1.0f/NUM, 1.0f ); |
| 86 | 72 |
} |
| 87 | 73 |
} |
| 88 | 74 |
|
| 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 90 |
// (x,y,z) == |
|
| 91 |
// |
|
| 92 |
// ( 1,0,0) --> 0 |
|
| 93 |
// (-1,0,0) --> 1 |
|
| 94 |
// (0, 1,0) --> 2 |
|
| 95 |
// (0,-1,0) --> 3 |
|
| 96 |
// (0,0, 1) --> 4 |
|
| 97 |
// (0,0,-1) --> 5 |
|
| 98 |
|
|
| 99 |
private int computeMapsIndex(float x, float y, float z) |
|
| 100 |
{
|
|
| 101 |
int ix = x>0 ? (int)(x+0.5f) : (int)(x-0.5f); |
|
| 102 |
int iy = y>0 ? (int)(y+0.5f) : (int)(y-0.5f); |
|
| 103 |
int iz = z>0 ? (int)(z+0.5f) : (int)(z-0.5f); |
|
| 104 |
|
|
| 105 |
if( ix== 1 ) return 0; |
|
| 106 |
if( ix==-1 ) return 1; |
|
| 107 |
if( iy== 1 ) return 2; |
|
| 108 |
if( iy==-1 ) return 3; |
|
| 109 |
if( iz== 1 ) return 4; |
|
| 110 |
if( iz==-1 ) return 5; |
|
| 111 |
|
|
| 112 |
return 0; |
|
| 113 |
} |
|
| 114 |
|
|
| 115 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 116 | 76 |
|
| 117 | 77 |
private void resetTextureMaps(MeshBase mesh) |
| ... | ... | |
| 124 | 84 |
{
|
| 125 | 85 |
Static4D q = fact.getQuaternion(i); |
| 126 | 86 |
QuatHelper.rotateVectorByQuat(mTmp,0,0,1,0,q); |
| 127 |
int index = computeMapsIndex(mTmp[0], mTmp[1], mTmp[2]);
|
|
| 87 |
int index = mObject.computeMapsIndex(mTmp);
|
|
| 128 | 88 |
maps[i] = mTextureMaps[index]; |
| 129 | 89 |
} |
| 130 | 90 |
|
| ... | ... | |
| 156 | 116 |
// PUBLIC API |
| 157 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 158 | 118 |
|
| 159 |
public BandagedCubit(float[] position, int x, int y, int z, Static4D quat1,
|
|
| 119 |
public BandagedCubit(BandagedObject object, float[] position, Static4D quat1,
|
|
| 160 | 120 |
Static4D quat2, Static3D scale, boolean roundCorners) |
| 161 | 121 |
{
|
| 162 |
mX = x; |
|
| 163 |
mY = y; |
|
| 164 |
mZ = z; |
|
| 122 |
mObject = object; |
|
| 165 | 123 |
mRoundCorners = roundCorners; |
| 166 | 124 |
mPosition = position; |
| 167 | 125 |
mIsAttached = true; |
| ... | ... | |
| 169 | 127 |
|
| 170 | 128 |
computeMove(mPosition); |
| 171 | 129 |
mMove = new Static3D(0,0,0); |
| 172 |
|
|
| 173 |
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance(); |
|
| 174 |
MeshBase mesh = factory.createMesh(mPosition,mX,mY,mZ,false,mRoundCorners); |
|
| 130 |
MeshBase mesh = mObject.createMesh(mPosition,mRoundCorners); |
|
| 175 | 131 |
|
| 176 | 132 |
mTexture = new DistortedTexture(); |
| 177 |
if( mBitmap==null ) createBitmap(); |
|
| 133 |
if( mBitmap==null ) createBitmap(mObject.getColors());
|
|
| 178 | 134 |
mTexture.setTextureAlreadyInverted(mBitmap); |
| 179 | 135 |
|
| 180 | 136 |
resetTextureMaps(mesh); |
| ... | ... | |
| 207 | 163 |
|
| 208 | 164 |
computeMove(tmpPosition); |
| 209 | 165 |
mPosition = tmpPosition; |
| 210 |
|
|
| 211 |
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance(); |
|
| 212 |
MeshBase mesh = factory.createMesh(mPosition,mX,mY,mZ,false,mRoundCorners); |
|
| 166 |
MeshBase mesh = mObject.createMesh(mPosition,mRoundCorners); |
|
| 213 | 167 |
resetTextureMaps(mesh); |
| 214 | 168 |
mNode.setMesh(mesh); |
| 215 | 169 |
mMove.set( scale*mUnscaledX, scale*mUnscaledY, scale*mUnscaledZ); |
| ... | ... | |
| 229 | 183 |
mPosition[2] = z; |
| 230 | 184 |
|
| 231 | 185 |
computeMove(mPosition); |
| 232 |
|
|
| 233 |
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance(); |
|
| 234 |
MeshBase mesh = factory.createMesh(mPosition,mX,mY,mZ,false,mRoundCorners); |
|
| 186 |
MeshBase mesh = mObject.createMesh(mPosition,mRoundCorners); |
|
| 235 | 187 |
resetTextureMaps(mesh); |
| 236 | 188 |
mNode.setMesh(mesh); |
| 237 | 189 |
mMove.set( scale*mUnscaledX, scale*mUnscaledY, scale*mUnscaledZ); |
| ... | ... | |
| 241 | 193 |
|
| 242 | 194 |
public void recreateBitmap() |
| 243 | 195 |
{
|
| 244 |
if( mBitmap==null ) createBitmap(); |
|
| 196 |
if( mBitmap==null ) createBitmap(mObject.getColors());
|
|
| 245 | 197 |
mTexture.setTextureAlreadyInverted(mBitmap); |
| 246 | 198 |
} |
| 247 | 199 |
|
| src/main/java/org/distorted/bandaged/BandagedObject.java | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
package org.distorted.bandaged; |
| 11 | 11 |
|
| 12 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_BLUE; |
|
| 13 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_GREEN; |
|
| 14 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_ORANGE; |
|
| 15 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_RED; |
|
| 16 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_WHITE; |
|
| 17 |
import static org.distorted.objectlib.main.TwistyObject.COLOR_YELLOW; |
|
| 18 |
|
|
| 12 | 19 |
import org.distorted.library.main.DistortedNode; |
| 13 | 20 |
import org.distorted.library.main.DistortedScreen; |
| 21 |
import org.distorted.library.mesh.MeshBase; |
|
| 14 | 22 |
import org.distorted.library.type.Static3D; |
| 15 | 23 |
import org.distorted.library.type.Static4D; |
| 24 |
import org.distorted.objectlib.helpers.FactoryBandagedCubit; |
|
| 16 | 25 |
import org.distorted.objectlib.main.InitData; |
| 17 | 26 |
import org.distorted.objectlib.main.TwistyObject; |
| 18 | 27 |
import org.distorted.objectlib.objects.TwistyBandagedCuboid; |
| ... | ... | |
| 23 | 32 |
|
| 24 | 33 |
public class BandagedObject |
| 25 | 34 |
{
|
| 26 |
private static final float DIST2D = 0.5f; |
|
| 27 |
|
|
| 28 | 35 |
private final DistortedScreen mScreen; |
| 29 | 36 |
private final float[] mPos; |
| 37 |
private final int[] mSize; |
|
| 38 |
private final float mDist2D; |
|
| 30 | 39 |
|
| 31 | 40 |
private BandagedCubit[] mCubits; |
| 32 |
private int mX, mY, mZ;
|
|
| 41 |
private int mMax;
|
|
| 33 | 42 |
private int mNumCubits; |
| 34 | 43 |
|
| 35 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 38 | 47 |
{
|
| 39 | 48 |
mScreen = screen; |
| 40 | 49 |
mPos = new float[3]; |
| 50 |
mSize = new int[3]; |
|
| 51 |
mDist2D = getDist2D(); |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 55 |
|
|
| 56 |
int[] getSize() |
|
| 57 |
{
|
|
| 58 |
return mSize; |
|
| 41 | 59 |
} |
| 42 | 60 |
|
| 43 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 88 | 106 |
|
| 89 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 90 | 108 |
|
| 91 |
float getSize() |
|
| 109 |
float getMaxSize()
|
|
| 92 | 110 |
{
|
| 93 |
return mX>mY ? Math.max(mX, mZ) : Math.max(mY, mZ);
|
|
| 111 |
return mMax;
|
|
| 94 | 112 |
} |
| 95 | 113 |
|
| 96 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 119 | 137 |
TwistyObject createObject(int mode, float size) |
| 120 | 138 |
{
|
| 121 | 139 |
float[][] pos = getCubitPositions(); |
| 122 |
InitData data = new InitData( new int[] {mX,mY,mZ},pos);
|
|
| 140 |
InitData data = new InitData( mSize,pos);
|
|
| 123 | 141 |
return new TwistyBandagedCuboid( TwistyObject.MESH_NICE, mode, ShapeHexahedron.DEFAULT_ROT, new Static3D(0,0,0), size, data, null ); |
| 124 | 142 |
} |
| 125 | 143 |
|
| ... | ... | |
| 174 | 192 |
|
| 175 | 193 |
boolean tryChangeObject(int x, int y, int z) |
| 176 | 194 |
{
|
| 177 |
if( mX!=x || mY!=y || mZ!=z )
|
|
| 195 |
if( mSize[0]!=x || mSize[1]!=y || mSize[2]!=z )
|
|
| 178 | 196 |
{
|
| 179 |
mX = x; |
|
| 180 |
mY = y; |
|
| 181 |
mZ = z; |
|
| 182 |
mNumCubits = computeNumCubits(mX,mY,mZ); |
|
| 197 |
mSize[0] = x; |
|
| 198 |
mSize[1] = y; |
|
| 199 |
mSize[2] = z; |
|
| 200 |
mMax = x>y ? Math.max(x,z) : Math.max(y,z); |
|
| 201 |
mNumCubits = computeNumCubits(x,y,z); |
|
| 183 | 202 |
return true; |
| 184 | 203 |
} |
| 185 | 204 |
|
| ... | ... | |
| 190 | 209 |
|
| 191 | 210 |
int computeProjectionAngle() |
| 192 | 211 |
{
|
| 193 |
float quot1 = mZ/ (float)mX;
|
|
| 194 |
float quot2 = mZ/ (float)mY;
|
|
| 195 |
float quot3 = mX/ (float)mZ;
|
|
| 196 |
float quot4 = mX/ (float)mY;
|
|
| 212 |
float quot1 = mSize[2]/ (float)mSize[0];
|
|
| 213 |
float quot2 = mSize[2]/ (float)mSize[1];
|
|
| 214 |
float quot3 = mSize[0]/ (float)mSize[2];
|
|
| 215 |
float quot4 = mSize[0]/ (float)mSize[1];
|
|
| 197 | 216 |
|
| 198 | 217 |
float quot5 = Math.max(quot1,quot2); |
| 199 | 218 |
float quot6 = Math.max(quot3,quot4); |
| ... | ... | |
| 230 | 249 |
|
| 231 | 250 |
float[] getDist3D() |
| 232 | 251 |
{
|
| 233 |
float max = getSize(); |
|
| 252 |
float max = getMaxSize();
|
|
| 234 | 253 |
|
| 235 |
float x = 0.5f*(mX/max);
|
|
| 236 |
float y = 0.5f*(mY/max);
|
|
| 237 |
float z = 0.5f*(mZ/max);
|
|
| 254 |
float x = 0.5f*(mSize[0]/max);
|
|
| 255 |
float y = 0.5f*(mSize[1]/max);
|
|
| 256 |
float z = 0.5f*(mSize[2]/max);
|
|
| 238 | 257 |
|
| 239 | 258 |
return new float[] {x,x,y,y,z,z};
|
| 240 | 259 |
} |
| 241 | 260 |
|
| 261 |
|
|
| 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 263 |
|
|
| 264 |
float getDist2D() |
|
| 265 |
{
|
|
| 266 |
return 0.5f; |
|
| 267 |
} |
|
| 268 |
|
|
| 269 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 270 |
// (x,y,z) == |
|
| 271 |
// |
|
| 272 |
// ( 1,0,0) --> 0 |
|
| 273 |
// (-1,0,0) --> 1 |
|
| 274 |
// (0, 1,0) --> 2 |
|
| 275 |
// (0,-1,0) --> 3 |
|
| 276 |
// (0,0, 1) --> 4 |
|
| 277 |
// (0,0,-1) --> 5 |
|
| 278 |
|
|
| 279 |
int computeMapsIndex(float[] faceAxis) |
|
| 280 |
{
|
|
| 281 |
float x = faceAxis[0]; |
|
| 282 |
float y = faceAxis[1]; |
|
| 283 |
float z = faceAxis[2]; |
|
| 284 |
|
|
| 285 |
int ix = x>0 ? (int)(x+0.5f) : (int)(x-0.5f); |
|
| 286 |
int iy = y>0 ? (int)(y+0.5f) : (int)(y-0.5f); |
|
| 287 |
int iz = z>0 ? (int)(z+0.5f) : (int)(z-0.5f); |
|
| 288 |
|
|
| 289 |
if( ix== 1 ) return 0; |
|
| 290 |
if( ix==-1 ) return 1; |
|
| 291 |
if( iy== 1 ) return 2; |
|
| 292 |
if( iy==-1 ) return 3; |
|
| 293 |
if( iz== 1 ) return 4; |
|
| 294 |
if( iz==-1 ) return 5; |
|
| 295 |
|
|
| 296 |
return 0; |
|
| 297 |
} |
|
| 298 |
|
|
| 299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 300 |
|
|
| 301 |
MeshBase createMesh(float[] pos, boolean round) |
|
| 302 |
{
|
|
| 303 |
FactoryBandagedCubit factory = FactoryBandagedCubit.getInstance(); |
|
| 304 |
int[] size = getSize(); |
|
| 305 |
return factory.createMesh(pos,size[0],size[1],size[2],false,round); |
|
| 306 |
} |
|
| 307 |
|
|
| 308 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 309 |
|
|
| 310 |
int[] getColors() |
|
| 311 |
{
|
|
| 312 |
return new int[] |
|
| 313 |
{
|
|
| 314 |
COLOR_YELLOW, COLOR_WHITE, |
|
| 315 |
COLOR_BLUE , COLOR_GREEN, |
|
| 316 |
COLOR_RED , COLOR_ORANGE |
|
| 317 |
}; |
|
| 318 |
} |
|
| 319 |
|
|
| 242 | 320 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 243 | 321 |
|
| 244 | 322 |
void createCubits(Static4D quatT, Static4D quatA, Static3D scale) |
| 245 | 323 |
{
|
| 246 | 324 |
mCubits = new BandagedCubit[mNumCubits]; |
| 247 | 325 |
int c=0; |
| 248 |
|
|
| 249 |
float begX = 0.5f*(1-mX); |
|
| 250 |
float begY = 0.5f*(1-mY); |
|
| 251 |
float begZ = 0.5f*(1-mZ); |
|
| 252 |
|
|
| 253 |
for(int x=0; x<mX; x++) |
|
| 254 |
for(int y=0; y<mY; y++) |
|
| 255 |
for(int z=0; z<mZ; z++) |
|
| 256 |
if( x==0 || x==mX-1 || y==0 || y==mY-1 || z==0 || z==mZ-1 ) |
|
| 326 |
int sx = mSize[0]; |
|
| 327 |
int sy = mSize[1]; |
|
| 328 |
int sz = mSize[2]; |
|
| 329 |
|
|
| 330 |
float begX = 0.5f*(1-sx); |
|
| 331 |
float begY = 0.5f*(1-sy); |
|
| 332 |
float begZ = 0.5f*(1-sz); |
|
| 333 |
|
|
| 334 |
for(int x=0; x<sx; x++) |
|
| 335 |
for(int y=0; y<sy; y++) |
|
| 336 |
for(int z=0; z<sz; z++) |
|
| 337 |
if( x==0 || x==sx-1 || y==0 || y==sy-1 || z==0 || z==sz-1 ) |
|
| 257 | 338 |
{
|
| 258 | 339 |
float[] pos = new float[] { begX+x,begY+y,begZ+z };
|
| 259 |
mCubits[c] = new BandagedCubit(pos,mX,mY,mZ,quatT,quatA,scale,false);
|
|
| 340 |
mCubits[c] = new BandagedCubit(this,pos,quatT,quatA,scale,false);
|
|
| 260 | 341 |
c++; |
| 261 | 342 |
} |
| 262 | 343 |
} |
| ... | ... | |
| 286 | 367 |
|
| 287 | 368 |
void stretchPoint(int face, float[] output) |
| 288 | 369 |
{
|
| 289 |
float max = getSize(); |
|
| 370 |
float max = getMaxSize();
|
|
| 290 | 371 |
|
| 291 | 372 |
switch(face/2) |
| 292 | 373 |
{
|
| 293 |
case 0: output[0] *= (max/mZ); output[1] *= (max/mY); break;
|
|
| 294 |
case 1: output[0] *= (max/mX); output[1] *= (max/mZ); break;
|
|
| 295 |
case 2: output[0] *= (max/mX); output[1] *= (max/mY); break;
|
|
| 374 |
case 0: output[0] *= (max/mSize[2]); output[1] *= (max/mSize[1]); break;
|
|
| 375 |
case 1: output[0] *= (max/mSize[0]); output[1] *= (max/mSize[2]); break;
|
|
| 376 |
case 2: output[0] *= (max/mSize[0]); output[1] *= (max/mSize[1]); break;
|
|
| 296 | 377 |
} |
| 297 | 378 |
} |
| 298 | 379 |
|
| ... | ... | |
| 300 | 381 |
|
| 301 | 382 |
int whichCubitTouched(int face, float pointX, float pointY) |
| 302 | 383 |
{
|
| 384 |
float x = mSize[0]; |
|
| 385 |
float y = mSize[1]; |
|
| 386 |
float z = mSize[2]; |
|
| 387 |
|
|
| 303 | 388 |
switch(face) |
| 304 | 389 |
{
|
| 305 |
case 0: mPos[0] = (mX-1)/2.0f;
|
|
| 306 |
mPos[1] = (int)( mY*pointY+mY/2.0f)-(mY-1)/2.0f;
|
|
| 307 |
mPos[2] = (int)(-mZ*pointX-mZ/2.0f)+(mZ-1)/2.0f;
|
|
| 390 |
case 0: mPos[0] = (x-1)/2;
|
|
| 391 |
mPos[1] = (int)( y*pointY+y/2)-(y-1)/2;
|
|
| 392 |
mPos[2] = (int)(-z*pointX-z/2)+(z-1)/2;
|
|
| 308 | 393 |
break; |
| 309 |
case 1: mPos[0] =-(mX-1)/2.0f;
|
|
| 310 |
mPos[1] = (int)( mY*pointY+mY/2.0f)-(mY-1)/2.0f;
|
|
| 311 |
mPos[2] = (int)( mZ*pointX+mZ/2.0f)-(mZ-1)/2.0f;
|
|
| 394 |
case 1: mPos[0] =-(x-1)/2;
|
|
| 395 |
mPos[1] = (int)( y*pointY+y/2)-(y-1)/2;
|
|
| 396 |
mPos[2] = (int)( z*pointX+z/2)-(z-1)/2;
|
|
| 312 | 397 |
break; |
| 313 |
case 2: mPos[0] = (int)( mX*pointX+mX/2.0f)-(mX-1)/2.0f;
|
|
| 314 |
mPos[1] = (mY-1)/2.0f;
|
|
| 315 |
mPos[2] = (int)(-mZ*pointY-mZ/2.0f)+(mZ-1)/2.0f;
|
|
| 398 |
case 2: mPos[0] = (int)( x*pointX+x/2)-(x-1)/2;
|
|
| 399 |
mPos[1] = (y-1)/2;
|
|
| 400 |
mPos[2] = (int)(-z*pointY-z/2)+(z-1)/2;
|
|
| 316 | 401 |
break; |
| 317 |
case 3: mPos[0] = (int)( mX*pointX+mX/2.0f)-(mX-1)/2.0f;
|
|
| 318 |
mPos[1] =-(mY-1)/2.0f;
|
|
| 319 |
mPos[2] = (int)( mZ*pointY+mZ/2.0f)-(mZ-1)/2.0f;
|
|
| 402 |
case 3: mPos[0] = (int)( x*pointX+x/2)-(x-1)/2;
|
|
| 403 |
mPos[1] =-(y-1)/2;
|
|
| 404 |
mPos[2] = (int)( z*pointY+z/2)-(z-1)/2;
|
|
| 320 | 405 |
break; |
| 321 |
case 4: mPos[0] = (int)( mX*pointX+mX/2.0f)-(mX-1)/2.0f;
|
|
| 322 |
mPos[1] = (int)( mY*pointY+mY/2.0f)-(mY-1)/2.0f;
|
|
| 323 |
mPos[2] = (mZ-1)/2.0f;
|
|
| 406 |
case 4: mPos[0] = (int)( x*pointX+x/2)-(x-1)/2;
|
|
| 407 |
mPos[1] = (int)( y*pointY+y/2)-(y-1)/2;
|
|
| 408 |
mPos[2] = (z-1)/2;
|
|
| 324 | 409 |
break; |
| 325 |
case 5: mPos[0] = (int)(-mX*pointX-mX/2.0f)+(mX-1)/2.0f;
|
|
| 326 |
mPos[1] = (int)( mY*pointY+mY/2.0f)-(mY-1)/2.0f;
|
|
| 327 |
mPos[2] =-(mZ-1)/2.0f;
|
|
| 410 |
case 5: mPos[0] = (int)(-x*pointX-x/2)+(x-1)/2;
|
|
| 411 |
mPos[1] = (int)( y*pointY+y/2)-(y-1)/2;
|
|
| 412 |
mPos[2] =-(z-1)/2;
|
|
| 328 | 413 |
break; |
| 329 | 414 |
} |
| 330 | 415 |
|
| ... | ... | |
| 346 | 431 |
|
| 347 | 432 |
boolean isInsideFace(int face, float[] p) |
| 348 | 433 |
{
|
| 349 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D );
|
|
| 434 |
return ( p[0]<=mDist2D && p[0]>=-mDist2D && p[1]<=mDist2D && p[1]>=-mDist2D );
|
|
| 350 | 435 |
} |
| 351 | 436 |
} |
Also available in: Unified diff
Everything about the nature of an object being bandaged should now hopefully be abstracted out in the single class - 'BandagedObject'