示例#1
0
        private void UpdateMesh(NetBuilder.Shape shape)
        {
            var nMesh = NetBuilder.Build(shape, 0.01f, Allocator.Temp);

            for (int i = 0; i < shape.paths.Length; ++i)
            {
                var path   = shape.paths[i];
                int length = path.end - path.begin + 1;
                var points = new NativeArray <Vector2>(length, Allocator.Temp);
                points.Slice(0, length).CopyFrom(shape.points.Slice(path.begin, length));

                var pMesh = PathBuilder.BuildClosedPath(points, 0.03f, path.isClockWise, Allocator.Temp);

                points.Dispose();

                var temp = new NativePlainMesh(nMesh, pMesh, Allocator.Temp);

                pMesh.Dispose();
                nMesh.Dispose();

                nMesh = temp;
            }


            this.mesh.Clear();
            this.mesh.vertices  = nMesh.vertices.ToArray();
            this.mesh.triangles = nMesh.triangles.ToArray();

            nMesh.Dispose();
        }
示例#2
0
    private void Awake()
    {
        Application.runInBackground = true;
        _rng = new Rng(1234);

        DataManager.Load();

        _tex            = new Texture2D(DataManager.Train.Rows, DataManager.Train.Cols, TextureFormat.ARGB32, false, true); // Lol
        _tex.filterMode = FilterMode.Point;

        var def = new NetDefinition(
            DataManager.Train.ImgDims,
            new LayerDefinition(30, LayerType.Deterministic, ActivationType.Sigmoid),
            new LayerDefinition(10, LayerType.Deterministic, ActivationType.Sigmoid));

        _net            = NetBuilder.Build(def);
        _gradientBucket = NetBuilder.Build(def);

        NetUtils.RandomGaussian(_net, ref _rng);

        _renderer.SetTarget(_net);

        // const int testImg = 7291;
        // _label = Mnist.Test.Labels[testImg];
        // Mnist.ToTexture(Mnist.Test, testImg, _tex);
    }
示例#3
0
        /// <summary>
        /// Activate the object that is being hovered over in the polygon wheel
        /// This involves running storyboards for the newly deactivated object as well as the newly activated one
        /// It also involves updating the information displayed to reflect the new polyhedron
        /// Finally a graph corresponding to the new polyhedron is loaded and an animation frame is triggered
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        private bool activateObject(FrameworkElement obj)
        {
            if (!this.triggerStoryboard(obj, "MouseEnter"))
            {
                return(false);
            }

            if (this._activeObject != null)
            {
                this.triggerStoryboard(this._activeObject, "MouseLeave");
            }
            this._activeObject = obj;
            Graph graph = new Graph(this.CurrentPolyhedronId);

            _net = NetBuilder.Build(graph);
            this.updateInfo();
            this.animationTimer.Begin();
            return(true);
        }