Beispiel #1
0
        private void TriangulateCellWeights_River(
            IHexCell center, IHexCell right, HexDirection direction, bool hasCenterRightRiver, IHexMesh weightsMesh
            )
        {
            var centerRightContour = CellContourCanon.GetContourForCellEdge(center, direction);

            Vector3 innerOne, innerTwo, contourOneXYZ, contourTwoXYZ;

            for (int i = 1; i < centerRightContour.Count; i++)
            {
                contourOneXYZ = centerRightContour[i - 1].ToXYZ();
                contourTwoXYZ = centerRightContour[i].ToXYZ();

                innerOne = Vector3.Lerp(center.AbsolutePosition, contourOneXYZ, RenderConfig.SolidFactor);
                innerTwo = Vector3.Lerp(center.AbsolutePosition, contourTwoXYZ, RenderConfig.SolidFactor);

                weightsMesh.AddTriangle(center.AbsolutePosition, innerOne, innerTwo);
                weightsMesh.AddTriangleColor(CenterWeights);

                weightsMesh.AddQuad(innerOne, innerTwo, contourOneXYZ, contourTwoXYZ);

                if (hasCenterRightRiver)
                {
                    weightsMesh.AddQuadColor(CenterWeights);
                }
                else
                {
                    weightsMesh.AddQuadColor(CenterWeights, CenterRightWeights);
                }
            }

            if (hasCenterRightRiver && direction <= HexDirection.SE)
            {
                ContourTriangulator.TriangulateContoursBetween(
                    center, right, direction, CenterWeights, RightWeights, weightsMesh
                    );
            }
        }
        public void TriangulateOrientation(IHexCell center, IHexMesh orientationMesh)
        {
            short indexOffset = (short)(center.Index + 1);

            foreach (var direction in EnumUtil.GetValues <HexDirection>())
            {
                byte[] rg = BitConverter.GetBytes(indexOffset);
                byte   b  = (byte)direction;

                var cellColor = new Color32(rg[0], rg[1], b, 0);

                var centerContour = CellContourCanon.GetContourForCellEdge(center, direction);

                for (int i = 1; i < centerContour.Count; i++)
                {
                    orientationMesh.AddTriangle(
                        center.AbsolutePosition, centerContour[i - 1].ToXYZ(), centerContour[i].ToXYZ()
                        );

                    orientationMesh.AddTriangleColor(cellColor);
                }

                if (direction <= HexDirection.SE && RiverCanon.HasRiverAlongEdge(center, direction))
                {
                    var right = Grid.GetNeighbor(center, direction);

                    ContourTriangulator.TriangulateContoursBetween(
                        center, right, direction, cellColor, cellColor, orientationMesh
                        );

                    if (direction <= HexDirection.E && RiverCanon.HasRiverAlongEdge(right, direction.Previous2()))
                    {
                    }
                }
            }
        }