Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContextHandle"/> struct.
        /// </summary>
        /// <param name="context">The context.</param>
        public ContextHandle(VisjectSurfaceContext context)
        {
            int count  = 0;
            var parent = context.Parent;

            while (parent != null)
            {
                count++;
                parent = parent.Parent;
            }
            if (count == 0)
            {
                // Root context
                _path = null;
            }
            else
            {
                _path = new string[count];
                for (int i = 0; i < count; i++)
                {
                    _path[i] = context.Context.SurfaceName;
                    context  = context.Parent;
                }
            }
        }
Beispiel #2
0
 public MoveNodesAction(VisjectSurfaceContext context, uint[] nodeIds, Vector2 locationDelta)
 {
     _surface       = context.Surface;
     _context       = new ContextHandle(context);
     _nodeIds       = nodeIds;
     _locationDelta = locationDelta;
 }
 public MaterialNodeParamsSet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch,
                              GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
     _baseSize     = Archetype.Size;
     _inputCount   = Archetype.Elements.Count(e => e.Type == NodeElementType.Input);
     _highestBoxId = Archetype.Elements.Max(e => e.BoxID);
 }
Beispiel #4
0
 /// <inheritdoc />
 public ParticleEmitterNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
     Headers[0] = new ModulesHeader(this, ParticleModules.ModuleType.Spawn);
     Headers[1] = new ModulesHeader(this, ParticleModules.ModuleType.Initialize);
     Headers[2] = new ModulesHeader(this, ParticleModules.ModuleType.Update);
     Headers[3] = new ModulesHeader(this, ParticleModules.ModuleType.Render);
 }
Beispiel #5
0
        public EditNodeConnections(VisjectSurfaceContext context, SurfaceNode node)
        {
            _surface = context.Surface;
            _context = new ContextHandle(context);
            _nodeId  = node.ID;

            CaptureConnections(node, out _before);
        }
Beispiel #6
0
            /// <inheritdoc />
            public MultiBlend(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
                : base(id, context, nodeArch, groupArch)
            {
                var layoutOffsetY = FlaxEditor.Surface.Constants.LayoutOffsetY;

                _selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY)
                {
                    HorizontalAlignment = TextAlignment.Near,
                    Text   = "Selected Animation:",
                    Parent = this
                };

                _selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width)
                {
                    Parent = this
                };

                _selectedAnimation.PopupShowing         += OnSelectedAnimationPopupShowing;
                _selectedAnimation.SelectedIndexChanged += OnSelectedAnimationChanged;

                var items = new List <string>(MaxAnimationsCount);

                while (items.Count < MaxAnimationsCount)
                {
                    items.Add(string.Empty);
                }
                _selectedAnimation.Items = items;

                _animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4))
                {
                    Parent = this
                };
                _animationPicker.SelectedItemChanged += OnAnimationPickerItemChanged;

                _animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight)
                {
                    HorizontalAlignment = TextAlignment.Near,
                    Text   = "Speed:",
                    Parent = this
                };

                _animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4)
                {
                    SlideSpeed = 0.01f,
                    Parent     = this
                };
                _animationSpeed.ValueChanged += OnAnimationSpeedValueChanged;
            }
Beispiel #7
0
        /// <summary>
        /// Gets the box.
        /// </summary>
        /// <param name="context">The Surface context.</param>
        /// <returns>The restored box.</returns>
        public Box Get(VisjectSurfaceContext context)
        {
            var node = context.FindNode(_nodeId);

            if (node == null)
            {
                throw new Exception("Missing node.");
            }
            var box = node.GetBox(_boxId);

            if (box == null)
            {
                throw new Exception("Missing box.");
            }
            return(box);
        }
        /// <summary>
        /// Tries to load surface graph from the asset.
        /// </summary>
        /// <param name="createDefaultIfMissing">True if create default surface if missing, otherwise won't load anything.</param>
        /// <returns>Loaded surface bytes or null if cannot load it or it's missing.</returns>
        public static byte[] LoadSurface(JsonAsset asset, ExpressionGraph assetInstance, bool createDefaultIfMissing)
        {
            if (!asset)
            {
                throw new ArgumentNullException(nameof(asset));
            }
            if (assetInstance == null)
            {
                throw new ArgumentNullException(nameof(assetInstance));
            }

            // Return its data
            if (assetInstance.VisjectSurface?.Length > 0)
            {
                return(assetInstance.VisjectSurface);
            }

            // Create it if it's missing
            if (createDefaultIfMissing)
            {
                // A bit of a hack
                // Create a Visject Graph with a main node and serialize it!
                var surfaceContext = new VisjectSurfaceContext(null, null, new FakeSurfaceContext());

                // Add the main node
                var node = NodeFactory.CreateNode(ExpressionGraphGroups, 1, surfaceContext, MainNodeGroupId, MainNodeTypeId);
                if (node == null)
                {
                    Debug.LogWarning("Failed to create main node.");
                    return(null);
                }
                surfaceContext.Nodes.Add(node);
                // Initialize
                node.Location = Vector2.Zero;

                surfaceContext.Save();

                return(surfaceContext.Context.SurfaceData);
            }
            else
            {
                return(null);
            }
        }
Beispiel #9
0
            public AssetNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, Guid assetId)
                : base(id, context, nodeArch, groupArch)
            {
                AssetId = assetId;

                // Init node UI
                var picker = new AssetPicker
                {
                    Location = new Vector2(40, 2 * Constants.LayoutOffsetY),
                    Width    = 100.0f,
                    CanEdit  = false,
                    Parent   = this,
                };
                // TODO: display some asset info like disk size, memory usage, etc.
                var asset = FlaxEngine.Content.LoadAsync <Asset>(AssetId);

                if (asset != null)
                {
                    var path = asset.Path;
                    picker.SelectedAsset = asset;
                    Title       = System.IO.Path.GetFileNameWithoutExtension(path);
                    TooltipText = asset.TypeName + '\n' + path;
                }
                else
                {
                    picker.SelectedID = AssetId;
                    var assetItem = picker.SelectedItem;
                    if (assetItem != null)
                    {
                        Title       = assetItem.ShortName;
                        TooltipText = assetItem.TypeName + '\n' + assetItem.Path;
                    }
                    else
                    {
                        Title = AssetId.ToString();
                    }
                }
                ResizeAuto();
                LayoutHeight = Height;
            }
Beispiel #10
0
 /// <inheritdoc />
 public DummyCustomNode(uint id, VisjectSurfaceContext context)
     : base(id, context, new NodeArchetype(), new GroupArchetype())
 {
 }
 private void OnSurfaceContextChanged(VisjectSurfaceContext context)
 {
     _surface.UpdateNavigationBar(_navigationBar, _toolstrip);
 }
Beispiel #12
0
 /// <inheritdoc />
 public ParticleEmitterFunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Creates the get node.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="context">The surface.</param>
 /// <param name="arch">The node archetype.</param>
 /// <param name="groupArch">The group archetype.</param>
 /// <returns>The created node.</returns>
 public static SurfaceNode CreateGetNode(uint id, VisjectSurfaceContext context, NodeArchetype arch, GroupArchetype groupArch)
 {
     return(new SurfaceNodeParamsGet(id, context, arch, groupArch));
 }
Beispiel #14
0
 /// <inheritdoc />
 public void OnContextCreated(VisjectSurfaceContext context)
 {
 }
Beispiel #15
0
 /// <inheritdoc />
 public AppendNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #16
0
 public SwitchOnEnumNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #17
0
 /// <inheritdoc />
 protected StructureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, bool isUnpacking)
     : base(id, context, nodeArch, groupArch)
 {
     _isUnpacking = isUnpacking;
 }
Beispiel #18
0
 /// <inheritdoc />
 public SurfaceNodeParamsGet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
     // Force first layout init for every param type
     _layoutType = (ParameterType)int.MaxValue;
 }
Beispiel #19
0
 /// <inheritdoc />
 public SurfaceNodeParamsGetVisualScript(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
     Prototypes = null;
 }
Beispiel #20
0
 public SampleTextureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #21
0
 /// <inheritdoc />
 public MaterialFunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #22
0
 /// <inheritdoc />
 public ParticleAttributeNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #23
0
 /// <inheritdoc />
 public UnpackStructureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch, true)
 {
 }
Beispiel #24
0
 /// <inheritdoc />
 public SurfaceNodeMaterial(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #25
0
 protected FunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #26
0
 /// <inheritdoc />
 public SurfaceNodeParamsGetParticleEmitter(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
     Prototypes = DefaultPrototypesParticleEmitter;
 }
Beispiel #27
0
 /// <inheritdoc />
 public ColorGradientNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #28
0
 /// <inheritdoc />
 public SurfaceNodeParamsSet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }
Beispiel #29
0
 /// <inheritdoc />
 public GetGameplayGlobalNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
     : base(id, context, nodeArch, groupArch)
 {
 }