示例#1
0
    private void OnDrawGizmos()
    {
        HashSet <Triangle2> grid = GenerateMesh.GenerateGrid(width, cells);

        if (grid != null)
        {
            //But this will not display each triangle, so we don't know if the mesh is correct
            //Gizmos.DrawMesh(grid, Vector3.zero, Quaternion.identity);

            //Convert the triangles to a mesh

            //2d to 3d
            HashSet <Triangle3> grid_3d = new HashSet <Triangle3>();

            foreach (Triangle2 t in grid)
            {
                Triangle3 t_3d = new Triangle3(t.p1.ToMyVector3(), t.p2.ToMyVector3(), t.p3.ToMyVector3());

                grid_3d.Add(t_3d);
            }

            //Triangle to mesh
            //Will also test that the triangle->mesh is working
            //Mesh meshGrid = TransformBetweenDataStructures.Triangle3ToCompressedMesh(grid_3d);

            Mesh meshGrid = _TransformBetweenDataStructures.Triangle3ToMesh(grid_3d);

            TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(meshGrid, 0);
        }
    }
    private void OnDrawGizmos()
    {
        if (triangulatedMesh != null)
        {
            //Display the triangles with a random color
            TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(triangulatedMesh, seed);

            //Display the points
            TestAlgorithmsHelpMethods.DisplayPoints(points, 0.1f, Color.black);

            //Display the points on the hull
            if (pointsOnHull != null && pointsOnHull.Count > 0)
            {
                HashSet <Vector3> pointsOnHull_3d = new HashSet <Vector3>();

                foreach (MyVector2 p in pointsOnHull)
                {
                    pointsOnHull_3d.Add(p.ToVector3());
                }

                TestAlgorithmsHelpMethods.DisplayPoints(pointsOnHull_3d, 0.3f, Color.black);
            }
        }

        if (testTriangles != null)
        {
            List <Triangle2> test = new List <Triangle2>(testTriangles);

            testTriangleNumber = Mathf.Clamp(testTriangleNumber, 0, testTriangles.Count - 1);

            Triangle2 t = test[testTriangleNumber];

            TestAlgorithmsHelpMethods.DisplayTriangle(t.p1.ToVector3(), t.p2.ToVector3(), t.p3.ToVector3(), Color.white);
        }
    }
    private void LineSegmemt(MyVector2 pA, MyVector2 pB)
    {
        HashSet <Triangle2> triangles = _GenerateMesh.LineSegment(pA, pB, 0.2f);

        Mesh mesh = _TransformBetweenDataStructures.Triangles2ToMesh(triangles, useCompressedMesh: false);

        //Display
        TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(mesh, 0);
    }
    //The mesh we generate with the Marching Squares algorithm
    private void DisplayGeneratedMesh()
    {
        if (grid == null)
        {
            return;
        }


        Mesh mesh = grid.GenerateUnityMesh(0f);

        TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(mesh, 0);
    }
示例#5
0
    private void OnDrawGizmos()
    {
        if (triangulatedMesh != null)
        {
            TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(triangulatedMesh, seed);
        }


        //Display the obstacles
        if (constraints != null)
        {
            //DebugResults.DisplayConnectedPoints(obstacle, Color.black);
        }
    }
示例#6
0
    private void DisplayTriangles()
    {
        if (triangulation == null)
        {
            return;
        }


        //Convert from triangle to mesh
        Mesh mesh = _TransformBetweenDataStructures.Triangles2ToMesh(triangulation, false);

        TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(mesh, 0);
        //TestAlgorithmsHelpMethods.DisplayMesh(mesh, Color.gray);
    }
    private void OnDrawGizmos()
    {
        if (triangulatedMesh != null)
        {
            //Display the triangles with a random color
            TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(triangulatedMesh, seed);

            //Display the points
            TestAlgorithmsHelpMethods.DisplayPoints(points, 0.1f, Color.black);

            //Display the points on the hull
            if (pointsOnHull != null && pointsOnHull.Count > 0)
            {
                HashSet <Vector3> pointsOnHull_3d = new HashSet <Vector3>();

                foreach (MyVector2 p in pointsOnHull)
                {
                    pointsOnHull_3d.Add(p.ToVector3());
                }

                TestAlgorithmsHelpMethods.DisplayPoints(pointsOnHull_3d, 0.3f, Color.black);
            }
        }
    }
    //Debug
    private void OnDrawGizmos()
    {
        //DIsplay the map
        //if (map != null)
        //{
        //    for (int x = 0; x < mapSize; x++)
        //    {
        //        for (int z = 0; z < mapSize; z++)
        //        {
        //            Gizmos.color = (map[x, z] == 1) ? Color.black : Color.white;

        //            Vector3 pos = new Vector3(-mapSize * 0.5f + x + 0.5f, 0f, -mapSize * 0.5f + z + 0.5f);

        //            Gizmos.DrawCube(pos, Vector3.one);
        //        }
        //    }
        //}

        //Display the marching squares
        if (grid != null)
        {
            int xLength = grid.squares.GetLength(0);
            int zLength = grid.squares.GetLength(1);

            for (int x = 0; x < xLength; x++)
            {
                for (int z = 0; z < zLength; z++)
                {
                    MarchingSquares.Square square = grid.squares[x, z];

                    Gizmos.color = square.TL.isActive ? Color.blue : Color.red;
                    Gizmos.DrawSphere(square.TL.pos, 0.2f);

                    Gizmos.color = square.TR.isActive ? Color.blue : Color.red;
                    Gizmos.DrawSphere(square.TR.pos, 0.2f);

                    Gizmos.color = square.BL.isActive ? Color.blue : Color.red;
                    Gizmos.DrawSphere(square.BL.pos, 0.2f);

                    Gizmos.color = square.BR.isActive ? Color.blue : Color.red;
                    Gizmos.DrawSphere(square.BR.pos, 0.2f);


                    //Gizmos.color = Color.green;

                    //Gizmos.DrawSphere(square.T.pos, 0.1f);
                    //Gizmos.DrawSphere(square.L.pos, 0.1f);
                    //Gizmos.DrawSphere(square.B.pos, 0.1f);
                    //Gizmos.DrawSphere(square.R.pos, 0.1f);
                }
            }
        }



        //Display the mesh
        if (grid != null)
        {
            Mesh mesh = new Mesh();

            mesh.vertices = grid.vertices.ToArray();

            mesh.triangles = grid.triangles.ToArray();

            mesh.RecalculateNormals();

            TestAlgorithmsHelpMethods.DisplayMeshWithRandomColors(mesh, 0);
        }
    }