public VerticalMeshContributor(VoxelCell sourceCell, GroundEdge edge, VoxelCell connectedCell) { VoxelCell baseAbove = sourceCell.CellAbove; VoxelCell connectedAbove = connectedCell.CellAbove; MeshBuilderConnectionPoint edgePoint = new MeshBuilderConnectionPoint(sourceCell, connectedCell); MeshBuilderConnectionPoint edgeAbovePoint = new MeshBuilderConnectionPoint(baseAbove, connectedAbove); if (!connectedCell.Filled || edge.IsBorder) { points.Add(edgePoint); points.Add(edgeAbovePoint); } if (!connectedCell.Filled) { foreach (GroundQuad quad in edge.Quads) { Vector3 quadPos = new Vector3(quad.Center.x, sourceCell.Height, quad.Center.y); VoxelCell diagonalCell = quad.GetDiagonalPoint(sourceCell.GroundPoint).Voxels[sourceCell.Height]; MeshBuilderConnectionPoint diagonalPoint = new MeshBuilderConnectionPoint(diagonalCell, sourceCell, quadPos); VoxelCell diagonalAbove = diagonalCell.CellAbove; Vector3 quadAbove = new Vector3(quad.Center.x, sourceCell.Height + 1, quad.Center.y); MeshBuilderConnectionPoint diagonalAbovePoint = new MeshBuilderConnectionPoint(diagonalAbove, baseAbove, quadAbove); points.Add(diagonalPoint); points.Add(diagonalAbovePoint); MeshBuilderTriangle triA = new MeshBuilderTriangle(connectedCell, sourceCell, edgePoint, diagonalPoint, diagonalAbovePoint); MeshBuilderTriangle triB = new MeshBuilderTriangle(connectedCell, sourceCell, edgePoint, diagonalAbovePoint, edgeAbovePoint); triangles.Add(triA); triangles.Add(triB); } } if (edge.IsBorder) { MeshBuilderCellPoint basePoint = new MeshBuilderCellPoint(sourceCell); MeshBuilderCellPoint abovePoint = new MeshBuilderCellPoint(baseAbove); points.Add(basePoint); points.Add(abovePoint); Vector2 quadCenter = edge.Quads.First().Center; Vector3 quadPos = new Vector3(quadCenter.x, sourceCell.Height, quadCenter.y); Vector3 lookTarget = edgePoint.Position - quadPos; MeshBuilderTriangle borderA = new MeshBuilderTriangle(null, sourceCell, basePoint, abovePoint, edgePoint, lookTarget); MeshBuilderTriangle borderB = new MeshBuilderTriangle(null, sourceCell, abovePoint, edgeAbovePoint, edgePoint, lookTarget); triangles.Add(borderA); triangles.Add(borderB); } }
private VoxelVisualComponent GetHorizontalNeighbor(GroundPoint parallelPoint, GroundPoint perpendicularPoint) { GroundPoint basePoint = Core.GroundPoint; GroundEdge dividingEdge = Quad.GetEdge(basePoint, perpendicularPoint); if (dividingEdge.IsBorder) { return(null); } GroundQuad neighborQuad = dividingEdge.Quads.First(quad => quad != Quad); GroundPoint neighborDiagonal = neighborQuad.GetDiagonalPoint(basePoint); GroundPoint moneyPoint = neighborQuad.Points.First(point => point != perpendicularPoint && point != neighborDiagonal); return(moneyPoint.Voxels[Core.Height].Visuals.GetComponent(neighborQuad, OnTopHalf)); }