/// <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; } } }
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); }
/// <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); }
public EditNodeConnections(VisjectSurfaceContext context, SurfaceNode node) { _surface = context.Surface; _context = new ContextHandle(context); _nodeId = node.ID; CaptureConnections(node, out _before); }
/// <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; }
/// <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); } }
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; }
/// <inheritdoc /> public DummyCustomNode(uint id, VisjectSurfaceContext context) : base(id, context, new NodeArchetype(), new GroupArchetype()) { }
private void OnSurfaceContextChanged(VisjectSurfaceContext context) { _surface.UpdateNavigationBar(_navigationBar, _toolstrip); }
/// <inheritdoc /> public ParticleEmitterFunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <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)); }
/// <inheritdoc /> public void OnContextCreated(VisjectSurfaceContext context) { }
/// <inheritdoc /> public AppendNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
public SwitchOnEnumNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> protected StructureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, bool isUnpacking) : base(id, context, nodeArch, groupArch) { _isUnpacking = isUnpacking; }
/// <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; }
/// <inheritdoc /> public SurfaceNodeParamsGetVisualScript(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { Prototypes = null; }
public SampleTextureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public MaterialFunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public ParticleAttributeNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public UnpackStructureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch, true) { }
/// <inheritdoc /> public SurfaceNodeMaterial(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
protected FunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public SurfaceNodeParamsGetParticleEmitter(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { Prototypes = DefaultPrototypesParticleEmitter; }
/// <inheritdoc /> public ColorGradientNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public SurfaceNodeParamsSet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public GetGameplayGlobalNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }