private void ParameterSet(object instance, object value, GraphParameter parameter, object tag)
 {
     if (instance is ParticleEffect particleEffect && particleEffect && parameter && tag is ParticleEffectParameter effectParameter && effectParameter)
     {
         particleEffect.SetParameterValue(effectParameter.TrackName, parameter.Name, value);
     }
 }
 private object ParameterDefaultValue(object instance, GraphParameter parameter, object tag)
 {
     if (tag is ParticleEffectParameter effectParameter)
     {
         return(effectParameter.DefaultValue);
     }
     return(null);
 }
 private object ParameterGet(object instance, GraphParameter parameter, object tag)
 {
     if (instance is ParticleEffect particleEffect && particleEffect && parameter && tag is ParticleEffectParameter effectParameter && effectParameter)
     {
         return(particleEffect.GetParameterValue(effectParameter.TrackName, parameter.Name));
     }
     return(null);
 }
Exemple #4
0
 public GraphParameterData(GraphParameter parameter, string name, bool isPublic, Type type, Attribute[] attributes, object tag)
 {
     Parameter   = parameter;
     IsPublic    = isPublic;
     Type        = type;
     Tag         = tag;
     Attributes  = attributes;
     Order       = (EditorOrderAttribute)Attributes.FirstOrDefault(x => x is EditorOrderAttribute);
     Display     = (EditorDisplayAttribute)Attributes.FirstOrDefault(x => x is EditorDisplayAttribute);
     Tooltip     = (TooltipAttribute)Attributes.FirstOrDefault(x => x is TooltipAttribute);
     Space       = (SpaceAttribute)Attributes.FirstOrDefault(x => x is SpaceAttribute);
     Header      = (HeaderAttribute)Attributes.FirstOrDefault(x => x is HeaderAttribute);
     DisplayName = Display?.Name ?? name ?? parameter.Name;
 }
 public EditParameterOverrideAction(ParticleSystemWindow window, ParticleEmitterTrack track, GraphParameter parameter, object newValue)
 {
     _window         = window;
     _trackName      = track.Name;
     _paramId        = parameter.Identifier;
     _beforeOverride = true;
     _afterOverride  = true;
     _beforeValue    = parameter.Value;
     _afterValue     = newValue;
 }
Exemple #6
0
        /// <summary>
        /// Gets the attributes collection from the graph parameter.
        /// </summary>
        /// <param name="parameter">The graph parameter.</param>
        /// <returns>The attributes collection.</returns>
        public static Attribute[] GetAttributes(GraphParameter parameter)
        {
            var data = parameter.GetMetaData(AttributeMetaTypeID);

            return(GetAttributes(data));
        }
Exemple #7
0
 /// <summary>
 /// Determines whether the specified attribute was defined for this member.
 /// </summary>
 /// <param name="parameter">The graph parameter.</param>
 /// <param name="attributeType">The attribute type.</param>
 /// <returns><c>true</c> if the specified member has attribute; otherwise, <c>false</c>.</returns>
 public static bool HasAttribute(GraphParameter parameter, Type attributeType)
 {
     return(GetAttributes(parameter).Any(x => x.GetType() == attributeType));
 }
Exemple #8
0
 public GraphParameterData(GraphParameter parameter, object tag = null)
     : this(parameter, null, parameter.IsPublic, parameter.Type, SurfaceMeta.GetAttributes(parameter), tag)
 {
 }
        public void CompileSurface(RenderingGraph graph)
        {
            // We're mapping every output box to an index
            // So we can store the node outputs in an array
            var variableIndexGetter = new GraphVariables();

            // Get the parameters
            GetParameterGetterNodeArchetype(out ushort paramNodeGroupId);

            var graphParams = new Dictionary <Guid, GraphParameter>();
            var parameters  = new GraphParameter[Parameters.Count];

            for (int i = 0; i < Parameters.Count; i++)
            {
                var param          = Parameters[i];
                var graphParameter = new GraphParameter(param.Name, param.Value, variableIndexGetter.RegisterVariable());
                graphParams.Add(param.ID, graphParameter);
                parameters[i] = graphParameter;
            }

            var nodes = FindNode(MainNodeGroupId, MainNodeTypeId)
                        .DepthFirstTraversal()
                        .Select <SurfaceNode, RenderingNode>((surfaceNode, index) =>
            {
                int[] inputIndices = surfaceNode.Elements
                                     .OfType <InputBox>()
                                     .Select(inputBox => inputBox.HasAnyConnection ? variableIndexGetter.UseVariable(inputBox) : -1)
                                     .ToArray();
                int[] outputIndices = surfaceNode.Elements
                                      .OfType <OutputBox>()
                                      .Select(outputBox => variableIndexGetter.RegisterVariable(outputBox))
                                      .ToArray();

                int groupId = surfaceNode.GroupArchetype.GroupID;
                int typeId  = surfaceNode.Archetype.TypeID;

                if (groupId == paramNodeGroupId)
                {
                    var graphParam = graphParams[(Guid)surfaceNode.Values[0]];
                    inputIndices   = new int[1] {
                        graphParam.OutputIndex
                    };
                }

                var nodeDefinition = new NodeDefinition()
                {
                    GroupId       = groupId,
                    TypeId        = typeId,
                    Index         = index,
                    Values        = surfaceNode.Values,
                    InputIndices  = inputIndices,
                    OutputIndices = outputIndices
                };

                var nodeFactory = GetNodeFactoryGroup(groupId).GetNodeFactory(typeId);
                return(nodeFactory.Create(nodeDefinition));
            })
                        .ToArray();

            graph.Parameters = parameters;
            graph.Nodes      = nodes;
        }