public Surface(Vector3i coord, Dir dir) { this.coord = coord; this.dir = dir; var vector = DirUtils.GetUnitVector(dir); normal = vector.to_f(); coordAbove = coord + vector; identifier = coord.x + "," + coord.y + "," + coord.z + "," + dir; point = new Vector3(coord.x, coord.y, coord.z) + normal * 0.5f; pointAbove = new Vector3(coordAbove.x, coordAbove.y, coordAbove.z); rotation = DirUtils.GetRotation(dir); uvVectors = DirUtils.GetUV(dir); }
public Vector3 GetGravityVector(Vector3 position, float tolerance) { var dirs = GetGravities(position, tolerance); if (dirs.Count == 0) { return(new Vector3()); } var v = new Vector3(); foreach (var dir in dirs) { v += DirUtils.GetUnitVector(dir).to_f(); } return(v); }
private void initSurfaces(Vector3i coord) { var block = map[coord]; foreach (var dir in DirUtils.Dirs) { var hasGravity = block.HasGravity(dir); // Has gravity if (!hasGravity) { continue; } // Not blocked var nextCoord = coord + DirUtils.GetUnitVector(dir); if (HasVoxel(nextCoord)) { continue; } var surface = block.AddSurface(dir); surface.isWater = block.type == TerrianBlockType.Water; surfaceLookUp [surface.identifier] = surface; } }
public static Vector3i NextCoord(this Vector3i coord, Dir dir) { return(coord + DirUtils.GetUnitVector(dir)); }