コード例 #1
0
        private void GenerateConfigurationNumberDebug()
        {
            SquareGrid squareGrid = meshGenerator.GetSquareGrid();

            for (int y = 0; y < squareGrid.height; y++)
            {
                for (int x = 0; x < squareGrid.width; x++)
                {
                    int     configuration = squareGrid.GetSquare(x, y).GetConfiguration();
                    Vector3 position      = squareGrid.GetSquare(x, y).GetPosition();

                    GameObject go = Instantiate(DebugNumberPrefab, position, Quaternion.Euler(new Vector3(90, 0, 0)));
                    go.GetComponent <TextMesh> ().text = configuration.ToString();
                }
            }
        }
コード例 #2
0
        public Mesh GenerateMeshRounded(int roundSteps)
        {
            this.roundSteps = roundSteps;

            mesh      = new Mesh();
            vertices  = new List <Vector3> ();
            uvs       = new List <Vector2> ();
            triangles = new List <int> ();

            for (int y = 0; y < squareGrid.height; y++)
            {
                for (int x = 0; x < squareGrid.width; x++)
                {
                    TriangulateQuadRounded(mesh, squareGrid.GetSquare(x, y));
                }
            }

            mesh.vertices  = vertices.ToArray();
            mesh.uv        = uvs.ToArray();
            mesh.triangles = triangles.ToArray();

            mesh.RecalculateNormals();
            mesh.RecalculateBounds();

            return(mesh);
        }
コード例 #3
0
        private void OnDrawGizmos()
        {
            if (map == null || meshGenerator == null)
            {
                return;
            }

            SquareGrid squareGrid = meshGenerator.GetSquareGrid();

            for (int y = 0; y < squareGrid.height; y++)
            {
                for (int x = 0; x < squareGrid.width; x++)
                {
                    int configuration = squareGrid.GetSquare(x, y).GetConfiguration();

                    if (squaresDebug)
                    {
                        Gizmos.color = Color.black;
                        if (configuration == configurationNumber)
                        {
                            Gizmos.color = Color.red;
                        }

                        Gizmos.DrawSphere(squareGrid.GetSquare(x, y).GetPosition(), 0.1f);
                    }

                    if (controlNodesDebug)
                    {
                        Gizmos.color = squareGrid.GetSquare(x, y).TopLeft.value == 0 ? Color.white : Color.black;
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).TopLeft.GetPosition(), Vector3.one * 0.4f);

                        Gizmos.color = squareGrid.GetSquare(x, y).TopRight.value == 0 ? Color.white : Color.black;
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).TopRight.GetPosition(), Vector3.one * 0.4f);

                        Gizmos.color = squareGrid.GetSquare(x, y).BottomRight.value == 0 ? Color.white : Color.black;
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).BottomRight.GetPosition(), Vector3.one * 0.4f);

                        Gizmos.color = squareGrid.GetSquare(x, y).BottomLeft.value == 0 ? Color.white : Color.black;
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).BottomLeft.GetPosition(), Vector3.one * 0.4f);
                    }

                    if (sideNodesDebug)
                    {
                        Gizmos.color = Color.green;
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).TopCenter.GetPosition(), Vector3.one * 0.1f);
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).RightCenter.GetPosition(), Vector3.one * 0.1f);
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).BottomCenter.GetPosition(), Vector3.one * 0.1f);
                        Gizmos.DrawCube(squareGrid.GetSquare(x, y).LeftCenter.GetPosition(), Vector3.one * 0.1f);
                    }
                }
            }
        }