예제 #1
0
        protected DMesh3 MakeDebugGraphMesh()
        {
            DMesh3 graphMesh = new DMesh3();

            graphMesh.EnableVertexColors(Vector3f.One);
            foreach (int vid in Graph.VertexIndices())
            {
                if (TipVertices.Contains(vid))
                {
                    MeshEditor.AppendBox(graphMesh, Graph.GetVertex(vid), 0.3f, Colorf.Green);
                }
                else if (TipBaseVertices.Contains(vid))
                {
                    MeshEditor.AppendBox(graphMesh, Graph.GetVertex(vid), 0.225f, Colorf.Magenta);
                }
                else if (GroundVertices.Contains(vid))
                {
                    MeshEditor.AppendBox(graphMesh, Graph.GetVertex(vid), 0.35f, Colorf.Blue);
                }
                else
                {
                    MeshEditor.AppendBox(graphMesh, Graph.GetVertex(vid), 0.15f, Colorf.White);
                }
            }
            foreach (int eid in Graph.EdgeIndices())
            {
                Segment3d seg = Graph.GetEdgeSegment(eid);
                MeshEditor.AppendLine(graphMesh, seg, 0.1f);
            }
            return(graphMesh);
        }
예제 #2
0
        public static void test_levelset_basic()
        {
            //DMesh3 mesh = TestUtil.MakeCappedCylinder(false);
            //MeshTransforms.Scale(mesh, 1, 3, 1);
            DMesh3 mesh = TestUtil.LoadTestMesh(Program.TEST_FILES_PATH + "bunny_open_base.obj");

            AxisAlignedBox3d bounds   = mesh.CachedBounds;
            float            cellSize = (float)bounds.MaxDim / 32.0f;

            MeshSignedDistanceGrid levelSet = new MeshSignedDistanceGrid(mesh, cellSize);

            levelSet.Compute();

            Vector3i dims = levelSet.Dimensions;
            int      midx = dims.x / 2;
            int      midy = dims.y / 2;
            int      midz = dims.z / 2;

            //for ( int xi = 0; xi < dims.x; ++xi ) {
            //    System.Console.Write(levelSet[xi, yi, zi] + " ");
            //}
            for (int yi = 0; yi < dims.y; ++yi)
            {
                System.Console.Write(levelSet[midx, yi, midz] + " ");
            }
            System.Console.WriteLine();

            DMesh3     tmp    = new DMesh3();
            MeshEditor editor = new MeshEditor(tmp);

            for (int x = 0; x < dims.x; ++x)
            {
                for (int y = 0; y < dims.y; ++y)
                {
                    for (int z = 0; z < dims.z; ++z)
                    {
                        if (levelSet[x, y, z] < 0)
                        {
                            Vector3f c = levelSet.CellCenter(x, y, z);
                            editor.AppendBox(new Frame3f(c), cellSize);
                        }
                    }
                }
            }
            TestUtil.WriteTestOutputMesh(tmp, "LevelSetInterior.obj");
            TestUtil.WriteTestOutputMesh(mesh, "LevelSetInterior_src.obj");
        }