Пример #1
0
        internal static Mesh NewSDFMesh(SDF sdf, Box box, double step)
        {
            var             min       = box.Min;
            var             size      = box.Size();
            var             nx        = (int)Math.Ceiling(size.X / step);
            var             ny        = (int)Math.Ceiling(size.Y / step);
            var             nz        = (int)Math.Ceiling(size.Z / step);
            var             sx        = size.X / nx;
            var             sy        = size.Y / ny;
            var             sz        = size.Z / nz;
            List <Triangle> triangles = new List <Triangle>();

            for (int x = 0; x < nx - 1; x++)
            {
                for (int y = 0; y < ny - 1; y++)
                {
                    for (int z = 0; z < nz - 1; z++)
                    {
                        (var x0, var y0, var z0) = ((double)x * sx + min.X, (double)y * sy + min.Y, (double)z * sz + min.Z);
                        (var x1, var y1, var z1) = (x0 + sx, y0 + sy, z0 + sz);

                        var p = new Vector[8] {
                            new Vector(x0, y0, z0),
                            new Vector(x1, y0, z0),
                            new Vector(x1, y1, z0),
                            new Vector(x0, y1, z0),
                            new Vector(x0, y0, z1),
                            new Vector(x1, y0, z1),
                            new Vector(x1, y1, z1),
                            new Vector(x0, y1, z1)
                        };

                        double[] v = new double[8];

                        for (int i = 0; i < 8; i++)
                        {
                            v[i] = sdf.Evaluate(p[i]);
                        }

                        if (mcPolygonize(p, v, 0) == null)
                        {
                            continue;
                        }
                        else
                        {
                            triangles.AddRange(mcPolygonize(p, v, 0));
                        }
                    }
                }
            }
            return(Mesh.NewMesh(triangles.ToArray()));
        }
Пример #2
0
        double SDF.Evaluate(Vector p)
        {
            Vector q = p.Mod(Step).Sub(Step.DivScalar(2));

            return(SDF.Evaluate(q));
        }
Пример #3
0
 double SDF.Evaluate(Vector p)
 {
     return(SDF.Evaluate(p.DivScalar(Factor)) * Factor);
 }
Пример #4
0
        double SDF.Evaluate(Vector p)
        {
            var q = Inverse.MulPosition(p);

            return(SDF.Evaluate(q));
        }
Пример #5
0
 public double Evaluate(Vector p)
 {
     return(SDF.Evaluate(p));
 }