Beispiel #1
0
        /// <summary>
        /// For the ground plane
        /// </summary>
        public HorizontalMeshContributor(GroundPoint groundPoint)
        {
            List <IMeshBuilderPoint>   points    = new List <IMeshBuilderPoint>();
            List <MeshBuilderTriangle> triangles = new List <MeshBuilderTriangle>();
            VoxelCell         baseCell           = groundPoint.Voxels[0];
            Vector3           lookTarget         = Vector3.up;
            IMeshBuilderPoint corePoint          = new MeshBuilderCellPoint(baseCell);

            points.Add(corePoint);
            foreach (GroundQuad quad in groundPoint.PolyConnections)
            {
                GroundPoint       diagonal      = quad.GetDiagonalPoint(groundPoint);
                Vector3           quadPos       = new Vector3(quad.Center.x, 0, quad.Center.y);
                IMeshBuilderPoint diagonalPoint = new MeshBuilderConnectionPoint(baseCell, diagonal.Voxels[0], quadPos);
                GroundPoint[]     otherPoints   = quad.Points.Where(item => item != baseCell.GroundPoint && item != diagonal).ToArray();
                IMeshBuilderPoint otherPointA   = new MeshBuilderConnectionPoint(baseCell, otherPoints[0].Voxels[0]);
                IMeshBuilderPoint otherPointB   = new MeshBuilderConnectionPoint(baseCell, otherPoints[1].Voxels[0]);

                MeshBuilderTriangle triangleA = new MeshBuilderTriangle(baseCell, null, corePoint, diagonalPoint, otherPointA, lookTarget);
                MeshBuilderTriangle triangleB = new MeshBuilderTriangle(baseCell, null, diagonalPoint, corePoint, otherPointB, lookTarget);

                points.Add(diagonalPoint);
                points.Add(otherPointA);
                points.Add(otherPointB);
                triangles.Add(triangleA);
                triangles.Add(triangleB);
            }

            Points    = points.ToArray();
            Triangles = triangles.ToArray();
        }
Beispiel #2
0
        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];
        }
Beispiel #3
0
    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));
    }
Beispiel #4
0
        public HorizontalMeshContributor(VoxelCell sourceCell, bool upwardFacing)
        {
            VoxelCell targetCell    = upwardFacing ? sourceCell.CellAbove : sourceCell.CellBelow;
            VoxelCell alignmentCell = upwardFacing ? sourceCell.CellAbove : sourceCell;

            Vector3 lookTarget = upwardFacing ? Vector3.up : Vector3.down;

            List <IMeshBuilderPoint>   points    = new List <IMeshBuilderPoint>();
            List <MeshBuilderTriangle> triangles = new List <MeshBuilderTriangle>();

            IMeshBuilderPoint corePoint = new MeshBuilderCellPoint(alignmentCell);

            points.Add(corePoint);
            foreach (GroundQuad quad in targetCell.GroundPoint.PolyConnections)
            {
                GroundPoint diagonal = quad.GetDiagonalPoint(targetCell.GroundPoint);
                Vector3     quadPos  = new Vector3(quad.Center.x, alignmentCell.Height, quad.Center.y);

                IMeshBuilderPoint diagonalPoint = new MeshBuilderConnectionPoint(alignmentCell, diagonal.Voxels[alignmentCell.Height], quadPos);
                GroundPoint[]     otherPoints   = quad.Points.Where(item => item != targetCell.GroundPoint && item != diagonal).ToArray();
                IMeshBuilderPoint otherPointA   = new MeshBuilderConnectionPoint(alignmentCell, otherPoints[0].Voxels[alignmentCell.Height]);
                IMeshBuilderPoint otherPointB   = new MeshBuilderConnectionPoint(alignmentCell, otherPoints[1].Voxels[alignmentCell.Height]);

                MeshBuilderTriangle triangleA = new MeshBuilderTriangle(targetCell, sourceCell, corePoint, diagonalPoint, otherPointA, lookTarget);
                MeshBuilderTriangle triangleB = new MeshBuilderTriangle(targetCell, sourceCell, diagonalPoint, corePoint, otherPointB, lookTarget);

                points.Add(diagonalPoint);
                points.Add(otherPointA);
                points.Add(otherPointB);
                triangles.Add(triangleA);
                triangles.Add(triangleB);
            }

            Points    = points.ToArray();
            Triangles = triangles.ToArray();
        }
Beispiel #5
0
 public VoxelCell(MainGrid grid, GroundPoint groundPoint, int height)
 {
     this.grid   = grid;
     GroundPoint = groundPoint;
     Height      = height;
 }