public static dvektor Inverse(dvektor aa) { int total = aa.x + aa.y + aa.z; dvektor retv = aa + (-total); return(retv * -1); }
public Block blockAdjacentToNeighboringChunkCoord(ChunkIndex neighborCI, dvektor dir) // OR maybe - after all this. { ChunkIndex adjIndex; ChunkIndex unitCI = new ChunkIndex(dvektor.Abs(dir)); dvektor inverseDvek = dvektor.Inverse(dvektor.Abs(dir)); ChunkIndex inverseCI = new ChunkIndex(inverseDvek); adjIndex = inverseCI * neighborCI; // zero out direction that we want int dir_coord = dir.total() == -1 ? CHUNKLENGTH : 0; // if dir pos, this chunk is pointing to us from negative and vis-versa ChunkIndex adjSide = new ChunkIndex(dir_coord, dir_coord, dir_coord) * unitCI; adjIndex = adjIndex + adjSide; return(blockAt(adjIndex)); }
public ChunkIndex(dvektor d) { x = (int)d.x; y = (int)d.y; z = (int)d.z; }
public static dvektor Abs(dvektor aa) { return(aa * aa); }
public static dvektor OppositeDirection(dvektor d) { return(d * -1.0f); }
public dvektor(ChunkIndex ci) { this = new dvektor(ci.x, ci.y, ci.z); }