public void alterBox(Vector3i min, Vector3i size, sbyte value) { for (int x = min.getX(); x < (min + size).getX(); x++) for (int y = min.getY(); y <= (min + size).getY(); y++) for (int z = min.getZ(); z <= (min + size).getZ(); z++) { alterPoint(x, y, z, value); } }
public sbyte average(Vector3i min, int size) { size++; int sum = 0; int i=0; for (int x = 0; x < size; x++) for (int y = 0; y < size; y++) for (int z = 0; z < size; z++) { sum += getPoint(x+min.getX(), y+min.getY(), z+min.getZ()); i++; } //Console.WriteLine("SUM: "+sum+" AVG: "+(sum/i)+" @"+i); return (sbyte)(sum / i); }
public byte getPoint(Vector3i i) { return getPoint(i.getX(), i.getY(), i.getZ()); }
public void setPoint(Vector3i v, byte c) { setPoint(v.getX(), v.getY(), v.getZ(), c); }
public byte getPoint(Vector3i i) { return(getPoint(i.getX(), i.getY(), i.getZ())); }
public Cell(VoxelMap data, Vector3i pos) { this.data = data; this.pos = pos; }
private void EliminateLodPositionShift(int lod, ref byte d0, ref byte d1, ref long t, ref Vector3i iP0, ref Vector3f P0, ref Vector3i iP1, ref Vector3f P1) { for (int k = 0; k < lod - 1; k++) { Vector3f vm = (P0 + P1) / 2.0f; Vector3i pm = (iP0 + iP1) / 2; byte sm = data.getPoint(pm); if (Math.Sign(d0) != Math.Sign(sm)) { P1 = vm; iP1 = pm; d1 = sm; } else { P0 = vm; iP0 = pm; d0 = sm; } } t = (d1 << 8) / (d1 - d0); // recalc }
private static Cell getReuseCell(Cell[, ,] cells, int lod, byte rDir,Vector3i pos) { int rx = rDir & 0x01; int rz = (rDir >> 1) & 0x01; int ry = (rDir >> 2) & 0x01; int dx = pos.getX() / lod - rx; int dy = pos.getY() / lod - ry; int dz = pos.getZ() / lod - rz; Cell ccc = cells[dx, dy, dz]; return ccc; }