Beispiel #1
0
        /// <summary>
        /// On drop event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ConnectorDropBehavior.IDropHandler.OnDrop(object sender, DragEventArgs e)
        {
            var item = e.Data.GetData(typeof(Tuple <NodeVertex, object>)) as Tuple <NodeVertex, object>;

            NodeVertex source = item.Item1;
            NodeVertex target = Vertex as NodeVertex;

            source.AddOutgoing(target, item.Item2, (sender as FrameworkElement).DataContext);
        }
        public override void AddOutgoing(NodeVertex target, object from, object to)
        {
            var sourceSlot = from as IGraphicsCompositorSlotViewModel;
            var targetSlot = to as IGraphicsCompositorSlotViewModel;

            if (sourceSlot != null && targetSlot != null)
            {
                sourceSlot.LinkTo(targetSlot);
            }
        }
Beispiel #3
0
        public override void AddOutgoing(NodeVertex target, object from, object to)
        {
            base.AddOutgoing(target, @from, to);

            // Add link through editor view model
            ViewModel.Method.Method.AddLink(new Link
            {
                Source = ((VisualScriptSlotViewModel)@from).Slot,
                Target = ((VisualScriptSlotViewModel)to).Slot,
            });
        }
Beispiel #4
0
 private IGraphicsCompositorBlockViewModel GetBlock(NodeVertex vertex)
 {
     return(blockMapping[vertex]);
 }
Beispiel #5
0
 public ConnectionWrapperData(NodeGraphBehavior owner, ConnectionWrapper wrapper, NodeVertex vertex)
 {
     Owner   = owner;
     Wrapper = wrapper;
     Vertex  = vertex;
 }
Beispiel #6
0
 /// <summary>
 /// <para>Enable the specified flag and the specified vertex.</para>
 /// </summary>
 public void EnableVertex(NodeContent flag, NodeVertex vertex)
 {
     this.EnableVertex(flag);
     this._vertices[(int)vertex].AddReferenceTo(this);
 }
Beispiel #7
0
 /// <summary>
 /// <para>Disable the specified flag and the specified vertex.</para>
 /// </summary>
 public void DisableVertex(NodeContent flag, NodeVertex vertex)
 {
     this.DisableVertex(flag);
     this._vertices[(int)vertex].RemoveReferenceFrom(this);
 }
Beispiel #8
0
        private void FillWithVertex(NodeVertex position)
        {
            VertexPositionNormalTextureTangentBinormal vertexValue = this.Vertices[(int)position].Value;
            TerrainVertex vertex = this.Vertices[(int)position];

            if (this.ParentTree.ProcessIterationId != vertex.LastUsedIteration)
            {
                vertex.BufferIndice = this.ParentTree.Vertices.Count;
                this.ParentTree.Vertices.Add(vertexValue);
                vertex.LastUsedIteration = this.ParentTree.ProcessIterationId;
            }
            this.ParentTree.Indices.Add(vertex.BufferIndice);

            if (currentIndice == 0)
            {
                terrainPrimitive = new TerrainPrimitive(0, 0, 0);
                terrainPrimitive.Indice1 = vertex.BufferIndice;
                currentIndice++;
            }
            else if (currentIndice == 1)
            {
                terrainPrimitive.Indice2 = vertex.BufferIndice;
                currentIndice++;
            }
            else if (currentIndice == 2)
            {
                terrainPrimitive.Indice3 = vertex.BufferIndice;
                currentIndice = 0;
                terrainPrimitive.SetNormalTangentBinormal(this.ParentTree.Vertices);
            }
        }
Beispiel #9
0
 /// <summary>
 /// <para>Gets a value indicating is the spécified vertex is used by a child.</para>
 /// </summary>
 /// <returns></returns>
 private bool EdgeUsed(NodeVertex position)
 {
     return this.Vertices[(int)position].Enabled;
 }
Beispiel #10
0
 /// <summary>
 /// <para>Check the specified vertex of the current <see cref="QuadNode"/>.</para>
 /// </summary>
 /// <param name="position">Position of the vertex.</param>
 /// <param name="flag">Flag to enable/disable.</param>
 private void CheckVertexAt(NodeVertex position, NodeContent flag, NodeSideVertex side)
 {
     if (this.IsDisabled(flag)//if the flag is not enabled
         && VertexTest(this.Vertices[(int)position].Value.Position, side, Camera.Camera.DefaultCamera.Transform.Translation))//and the vertex can be enabled...
         this.EnableVertex(flag, position);
     else if (this.IsEnabled(flag)//if the flag is enabled
         && !VertexTest(this.Vertices[(int)position].Value.Position, side, Camera.Camera.DefaultCamera.Transform.Translation))//and the vertex have to be disabled...
         this.DisableVertex(flag, position);
 }
Beispiel #11
0
        public void InitializeNodes(Api api, User[] users)
        {
            _users     = users;
            _usersById = users.ToDictionary(i => i.Model.Id);

            var nodes = new NodeVertex[_users.Length];

            for (var i = 0; i < _users.Length; i++)
            {
                var angle    = 3.2 * Math.Sqrt(i + 1);
                var position = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * (float)angle * 0.25f;

                nodes[i] = new NodeVertex(position, i, 1, 0, 0);
            }

            _nodesBuffer?.Dispose();
            _newNodesBuffer?.Dispose();

            _nodesBuffer    = Buffer.Structured.New(GraphicsDevice, nodes, true);
            _newNodesBuffer = Buffer.Structured.New(GraphicsDevice, nodes, true);

            _edgesBuffer?.Dispose();
            _edgesBuffer = null;
            _selectedEdgesBuffer?.Dispose();
            _selectedEdgesBuffer = null;
            _edgeIndicesBuffer?.Dispose();
            _edgeIndicesBuffer = null;

            _shader.Parameters["Edges"].SetResource(_edgesBuffer);
            _shader.Parameters["EdgeIndices"].SetResource(_edgeIndicesBuffer);

            if (_photoAtlases != null)
            {
                foreach (var atlas in _photoAtlases)
                {
                    atlas.Dispose();
                }
            }
            _photoAtlases = new Texture2D[(_users.Length + (PhotoAtlasSize - 1)) / PhotoAtlasSize];
            for (var i = 0; i < _photoAtlases.Length; i++)
            {
                var size = Math.Min(PhotoAtlasSize, _users.Length - i * PhotoAtlasSize);
                _photoAtlases[i] = Texture2D.New(GraphicsDevice, PhotoAtlasWidth, PhotoAtlasWidth, PixelFormat.R8G8B8A8.UNorm, arraySize: size);
                for (var j = 0; j < size; j++)
                {
                    GraphicsDevice.Copy(_defaultPhoto, 0, _photoAtlases[i], j);
                }
            }

            _scale    = 1 / nodes.Last().Position.Length();
            _position = Vector2.Zero;
            _rotation = 0;

            _dimx = (_users.Length + (BlockSize - 1)) / BlockSize;
            _shader.Parameters["numParticles"].SetValue(_users.Length);
            _shader.Parameters["dimx"].SetValue(_dimx);

            _loadedPhotosQueue  = new ConcurrentQueue <Tuple <int, byte[]> >();
            _loadedFriendsQueue = new ConcurrentQueue <Tuple <int, int[]> >();

            if (_userLoadingCts != null)
            {
                _userLoadingCts.Cancel();
                _userLoadingCts.Dispose();
            }

            _userLoadingCts = new CancellationTokenSource();
            Task.Factory.StartNew(() => StartPhotoLoadingTask(_userLoadingCts.Token), _userLoadingCts.Token);
            Task.Factory.StartNew(() => StartFriendsLoadingTask(api, _userLoadingCts.Token), _userLoadingCts.Token);
        }