private void SetInitialParameterValue(MaterialParameter materialParameter)
        {
            materialParameter.ParamType = MaterialParameterType.GetMaterialParameterType(materialTypeComboBox.SelectedValue.ToString());
            Type paramType = materialParameter.ParamType.ParameterType;

            if (materialParameter.ParamType.UsesArrays)
            {
                if (materialParameter.ParamType.UsesAttributes)
                {
                    materialParameter.ParamValue = new List <string[]>();
                }
                else
                {
                    materialParameter.ParamValue = new List <string>();
                }
            }
            else
            {
                if (materialParameter.ParamType.ParameterType.Name == "String")
                {
                    materialParameter.ParamValue = string.Empty;
                }
                else
                {
                    materialParameter.ParamValue = Activator.CreateInstance(paramType).ToString();
                }

                materialParameterValue.Text = materialParameter.ParamValue.ToString();
            }
        }
Example #2
0
        /// <summary>
        /// Refreshes the list of parameters and reads the XML file, updating the parameter lists in memory.
        /// </summary>
        /// <param name="completeUserDataPath">The directory where parameterStorage.xml is stored.</param>
        static public void ReadXmlParameters(string completeUserDataPath)
        {
            MaterialParametersArrayList.Clear();
            XDocument xDoc;

            xDoc = XDocument.Load(completeUserDataPath + "\\parameterStorage.xml");
            MaterialParametersArrayList.Clear();
            IEnumerable <XElement> materialParamList = xDoc.Elements("parameterSettings").Elements("materialParameterList").Elements("materialParameter");

            foreach (XElement param in materialParamList) //We need to ignore proxies until they're ready too..
            {
                string parameterName = param.Element("paramName").Value;
                string parameter     = param.Element("parameter").Value;
                MaterialParameterType parameterType = MaterialParameterType.GetMaterialParameterType(param.Element("paramType").Value);
                dynamic parameterValue;
                int     parameterForce        = ParseParameterType <int>(param.Element("paramForce").Value);
                int     parameterRandomChance = ParseParameterType <int>(param.Element("randomChance").Value);
                float   parameterRandomOffset = ParseParameterType <float>(param.Element("randomOffset").Value);

                if (parameterType.UsesArrays)
                {
                    if (parameterType.UsesAttributes)
                    {
                        parameterValue = ReadParameterValueChildren(param.Element("paramValue"), parameterType.ArrayElementKeys, parameterType.AttributeKeys);
                    }
                    else
                    {
                        parameterValue = ReadParameterValueChildren(param.Element("paramValue"), parameterType.ArrayElementKeys);
                    }
                    if (parameterType.Delimiter)
                    {
                        parameterValue = string.Join(",", ReadParameterValueChildren(param.Element("paramValue"), parameterType.ArrayElementKeys).ToArray());
                    }
                }
                else
                {
                    parameterValue = param.Element("paramValue").Value;
                }

                List <string> parameterShaderFilters    = ReadParameterValueChildren(param.Element("shaderFilterArray"), "filter");
                int           parameterShaderFilterMode = ParseParameterType <int>(param.Element("shaderFilterArray").Attribute("shaderFilterMode").Value);

                List <string> parameterProxyFilters    = ReadParameterValueChildren(param.Element("proxyFilterArray"), "filter");
                int           parameterProxyFilterMode = ParseParameterType <int>(param.Element("proxyFilterArray").Attribute("proxyFilterMode").Value);

                MaterialParametersArrayList.Add(new MaterialParameter(parameterName,
                                                                      parameter,
                                                                      parameterType,
                                                                      parameterValue,
                                                                      parameterForce,
                                                                      parameterRandomChance,
                                                                      parameterRandomOffset,
                                                                      parameterShaderFilters,
                                                                      parameterShaderFilterMode,
                                                                      parameterProxyFilters,
                                                                      parameterProxyFilterMode));
            }
        }
Example #3
0
 public MaterialParameter(string name,
                          string parameter,
                          MaterialParameterType type,
                          dynamic value,
                          int force    = 0,
                          int chance   = 100,
                          float offset = 0.0f,
                          List <string> shaderFilters = null,
                          int shaderFilterMode        = 0,
                          List <string> proxyFilters  = null,
                          int proxyFilterMode         = 0)
 {
     ParamName        = name;
     Parameter        = parameter;
     ParamType        = type;
     ParamValue       = value;
     ParamForce       = force;
     RandomizerChance = chance;
     RandomizerOffset = offset;
     if (shaderFilters == null)
     {
         ShaderFilterArray = new List <string>();
     }
     else
     {
         ShaderFilterArray = shaderFilters;
     }
     ShaderFilterMode = shaderFilterMode;
     if (proxyFilters == null)
     {
         ProxyFilterArray = new List <string>();
     }
     else
     {
         ProxyFilterArray = proxyFilters;
     }
     ProxyFilterMode = proxyFilterMode;
 }
Example #4
0
 /// <summary>
 /// Adds default parameters to the ArrayList of MaterialParameters.
 /// </summary>
 static async public Task InsertDefaultParameters()
 {
     MaterialParametersArrayList.Add(new MaterialParameter("Solid Color", "$color", MaterialParameterType.GetMaterialParameterType("vector3"), "255,255,255"));
     //MaterialParametersArrayList.Add(new MaterialParameter("Pulsing Rainbow", "Sine", MaterialParameterType.GetMaterialParameterType("proxy"), "add"));
     MaterialParametersArrayList.Add(new MaterialParameter("No Phong Shading", "$phong", MaterialParameterType.GetMaterialParameterType("boolean"), "0"));
     MaterialParametersArrayList.Add(new MaterialParameter("All Phong Shading", "$phong", MaterialParameterType.GetMaterialParameterType("boolean"), "1"));
     MaterialParametersArrayList.Add(new MaterialParameter("Extreme Phong Boost", "$phongboost", MaterialParameterType.GetMaterialParameterType("integer"), "500"));
     await WriteXmlParameters(MainWindow.completeUserDataPath);
 }
        private async void ConfirmButton_Click(object sender, EventArgs e)
        {
            XMLInteraction.MaterialParametersArrayList.Add(new MaterialParameter(ParameterName.Text, "", MaterialParameterType.GetMaterialParameterType("integer"), "0"));
            await XMLInteraction.WriteXmlParameters(MainWindow.completeUserDataPath);

            Parent.RefreshMaterialParameterList();
            Close();
        }