Project

General

Profile

« Previous | Next » 

Revision 3c4a326c

Added by Leszek Koltunski about 4 years ago

More work on making new types of RubikObjects easily creatable.

View differences:

src/main/java/org/distorted/object/RubikCube.java
30 30
import org.distorted.library.type.Static3D;
31 31
import org.distorted.library.type.Static4D;
32 32

  
33
import static org.distorted.object.RubikObjectList.VECTX;
34
import static org.distorted.object.RubikObjectList.VECTY;
35
import static org.distorted.object.RubikObjectList.VECTZ;
36

  
37 33
///////////////////////////////////////////////////////////////////////////////////////////////////
38 34

  
39 35
class RubikCube extends RubikObject
......
64 60
    }
65 61

  
66 62
///////////////////////////////////////////////////////////////////////////////////////////////////
67
// i.e. size^3 - (size-2)^3 - number of cubits in the outside wall of the Cube (we dont create or
68
// render the inside0
63
// i.e. size^3 - (size-2)^3 - number of cubits in the outside wall of the Cube (we don't create or
64
// render the inside)
69 65

  
70 66
  int getNumCubits(int size)
71 67
    {
72
    return 6*size*size - 12*size + 8;
68
    return size>1 ? 6*size*size - 12*size + 8 : 1;
73 69
    }
74 70

  
75 71
///////////////////////////////////////////////////////////////////////////////////////////////////
......
109 105

  
110 106
///////////////////////////////////////////////////////////////////////////////////////////////////
111 107

  
112
  boolean belongsToRotation( Static3D currentPosition, int vector, int row)
108
  boolean belongsToRotation( Static3D currentPosition, Static3D axis, int row)
113 109
    {
114
    switch(vector)
115
      {
116
      case VECTX: return currentPosition.get0()==row;
117
      case VECTY: return currentPosition.get1()==row;
118
      case VECTZ: return currentPosition.get2()==row;
119
      }
110
    if( axis.get0()!=0 ) return currentPosition.get0()==row;
111
    if( axis.get1()!=0 ) return currentPosition.get1()==row;
112
    if( axis.get2()!=0 ) return currentPosition.get2()==row;
120 113

  
121 114
    return false;
122 115
    }

Also available in: Unified diff