Project

General

Profile

« Previous | Next » 

Revision f8c52090

Added by Leszek Koltunski 12 months ago

generalize FactoryBandagedCuboid: start removing 'cuboidal' assumptions from it.

View differences:

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
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff