Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public static void Run()
        {
            var mesh = HeMesh3d.Factory.CreateFromOBJ(Paths.Resources + _fileIn);

            double scale  = 0.5;
            double offset = scale * Math.PI * 0.25;

            // apply texture coordinates from an implicit function
            foreach (var v in mesh.Vertices)
            {
                var p = v.Position * scale;

                v.Texture = new Vec2d(
                    ImplicitSurfaces.Gyroid(p.X, p.Y, p.Z),
                    ImplicitSurfaces.Gyroid(p.X + offset, p.Y + offset, p.Z + offset)
                    );
            }

            // compute vertex normals & write to file
            mesh.GetVertexNormals(v => v.Position, (v, n) => v.Normal = n);
            mesh.WriteToOBJ(Paths.Resources + _fileOut);

            Console.WriteLine("File written successfully. Press return to exit.");
            Console.ReadLine();
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        public override float Evaluate(Vector3 point)
        {
            // impl ref
            // http://iquilezles.org/www/articles/distfunctions/distfunctions.htm

            point = _toLocal.MultiplyPoint3x4(point);

            switch (_type)
            {
            case ImplicitSurfaceType.Diamond:
                return((float)ImplicitSurfaces.Diamond(point));

            case ImplicitSurfaceType.Gyroid:
                return((float)ImplicitSurfaces.Gyroid(point));

            case ImplicitSurfaceType.HybridPW:
                return((float)ImplicitSurfaces.HybridPW(point));

            case ImplicitSurfaceType.IWP:
                return((float)ImplicitSurfaces.IWP(point));

            case ImplicitSurfaceType.Neovius:
                return((float)ImplicitSurfaces.Neovius(point));
            }

            throw new System.NotImplementedException();
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public static void Start()
        {
            var mesh  = HeMesh3d.Factory.CreateFromOBJ(Paths.Resources + _fileIn);
            var verts = mesh.Vertices;

            var    texCoords = new Vector2d[verts.Count];
            double scale     = 0.5;
            double offset    = scale * Math.PI * 0.25;

            // create texture coordinates from implicit function
            for (int i = 0; i < verts.Count; i++)
            {
                var p = verts[i].Position * scale;
                var u = ImplicitSurfaces.Gyroid(p.X, p.Y, p.Z);
                var v = ImplicitSurfaces.Gyroid(p.X + offset, p.Y + offset, p.Z + offset);
                texCoords[i] = new Vector2d(u, v);
            }

            // compute vertex normals & write to file
            mesh.Vertices.Action(v => v.Normal = v.GetNormal(), true);
            Interop.Meshes.WriteToObj(mesh, Paths.Resources + _fileOut, v => texCoords[v]);

            Console.WriteLine("File written successfully. Press return to exit.");
            Console.ReadLine();
        }
Пример #4
0
    /// <summary>
    ///
    /// </summary>
    public bool Filter(Vector3 vector)
    {
        const float f = 2.0f * Mathf.PI;

        vector.x *= f / CountX;
        vector.y *= f / CountY;
        vector.z *= f / CountZ;

        //return ImplicitSurfaces.Gyroid(vector) > 0.5;
        return(ImplicitSurfaces.Diamond(vector) > 0.3);
    }