public MeshBuilderConnectionPoint(VoxelCell cellA, VoxelCell cellB, Vector3 position) { bool cellAFirst = GetIsCellAFirst(cellA, cellB); CellA = cellAFirst ? cellA : cellB; CellB = cellAFirst ? cellB : cellA; Key = GetKey(); Position = position; Uv = Vector2.one; }
private bool GetIsCellAFirst(VoxelCell cellA, VoxelCell cellB) { if (cellA.GroundPoint.Index == cellB.GroundPoint.Index) { if (cellA.Height == cellB.Height) { throw new Exception("Cannot make MeshBuilderPoint from two cells at the same voxel location."); } return(cellA.Height < cellB.Height); } return(cellA.GroundPoint.Index < cellB.GroundPoint.Index); }
public VoxelVisualComponent(VoxelCell coreCell, GroundQuad quad, bool onTopHalf) { Core = coreCell; Quad = quad; OnTopHalf = onTopHalf; VoxelCell bottomCell = onTopHalf ? coreCell : (coreCell.CellBelow ?? coreCell); VoxelCell topCell = onTopHalf ? (coreCell.CellAbove ?? coreCell) : coreCell; bottomLayer = new VoxelVisualsLayer(bottomCell, quad); topLayer = new VoxelVisualsLayer(topCell, quad); ContentPosition = coreCell.CellPosition + (onTopHalf ? new Vector3(0, .5f, 0) : Vector3.zero); }
public VoxelVisualsLayer(VoxelCell basisCell, GroundQuad basisQuad) { BasisCell = basisCell; BasisQuad = basisQuad; Center = new Vector3(basisQuad.Center.x, basisCell.Height, basisQuad.Center.y); GroundPoint diagonalPoint = basisQuad.GetDiagonalPoint(basisCell.GroundPoint); DiagonalCell = diagonalPoint.Voxels[basisCell.Height]; GroundPoint[] otherPoints = basisQuad.Points.Where(item => item != basisCell.GroundPoint && item != diagonalPoint).ToArray(); AdjacentCellA = otherPoints[0].Voxels[basisCell.Height]; AdjacentCellB = otherPoints[1].Voxels[basisCell.Height]; }