private void pickTextureButton_Click(object sender, EventArgs e)
        {
            //get the parameter type
            String            text      = parameterComboBox1.Text;
            uint              paramName = GodzUtil.GetHashCode(text);
            MaterialParameter mp        = mMaterial.getParameter(paramName);

            if (mp != null)
            {
                MaterialParameterType ty = mp.getType();
                if (ty == MaterialParameterType.MaterialParameter_Texture)
                {
                    textureOpenFileDialog.ShowDialog();
                }
                else
                {
                    mp.clearValues();
                    String value = parameterTextBox.Text;

                    // Split string on comma - tokenize
                    string[] words = value.Split(',');
                    foreach (string word in words)
                    {
                        float v = float.Parse(word);
                        mp.addValue(v);
                    }

                    mp.submitValues();
                }
            }
        }
Example #2
0
        private static Type ToType(MaterialParameterType type)
        {
            switch (type)
            {
            case MaterialParameterType.Bool: return(typeof(bool));

            case MaterialParameterType.Integer: return(typeof(int));

            case MaterialParameterType.Float: return(typeof(float));

            case MaterialParameterType.Vector2: return(typeof(Vector2));

            case MaterialParameterType.Vector3: return(typeof(Vector3));

            case MaterialParameterType.Vector4: return(typeof(Vector4));

            case MaterialParameterType.Color: return(typeof(Color));

            case MaterialParameterType.Texture: return(typeof(Texture));

            case MaterialParameterType.CubeTexture: return(typeof(CubeTexture));

            case MaterialParameterType.NormalMap: return(typeof(Texture));

            case MaterialParameterType.SceneTexture: return(typeof(MaterialSceneTextures));

            case MaterialParameterType.GPUTexture: return(typeof(GPUTexture));

            case MaterialParameterType.Matrix: return(typeof(Matrix));

            case MaterialParameterType.ChannelMask: return(typeof(ChannelMask));

            default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Example #3
0
        public void SetParam(MaterialParameterType type, string key, System.Object value)
        {
            switch (type)
            {
            case MaterialParameterType.Color:
                this.SetColor(key, (Color)value);
                break;

            case MaterialParameterType.Number:
                this.SetFloat(key, (float)value);
                break;

            case MaterialParameterType.Texture:
                this.SetTexture(key, (Texture)value);
                break;

            case MaterialParameterType.Vector2:
                this.SetVector2(key, (Vector2)value);
                break;

            case MaterialParameterType.Vector3:
                this.SetVector3(key, (Vector3)value);
                break;

            case MaterialParameterType.Vector4:
                this.SetVector4(key, (Vector4)value);
                break;

            case MaterialParameterType.Boolean:
                this.SetBoolean(key, (bool)value);
                break;
            }
        }
Example #4
0
 internal MaterialParameter(int hash, MaterialBase material, int index, MaterialParameterType type, bool isPublic)
 {
     _hash     = hash;
     _material = material;
     _index    = index;
     _type     = type;
     _isPublic = isPublic;
 }
Example #5
0
 public MaterialParameter(IEffectParameter param, String name, bool isSemantic, Matrix value) {
     _type = MaterialParameterType.Matrix;
     _cachedParameter = param;
     _isSemantic = isSemantic;
     _name = name;
     _singleValue = 0;
     _intValue = 0;
     _boolValue = false;
     _vector2Value = Vector2.Zero;
     _vector3Value = Vector3.Zero;
     _vector4Value = Vector4.Zero;
     _textureValue = null;
     _matrixValue = value;
 }
Example #6
0
 public MaterialParameter(MaterialParameter param, IEffectParameter replacement) {
     _type = param.ParameterType;
     _cachedParameter = replacement;
     _name = param.Name;
     _isSemantic = param.IsSemantic;
     _singleValue = param.SingleValue;
     _intValue = param.IntValue;
     _boolValue = param.BoolValue;
     _vector2Value = param.Vector2Value;
     _vector3Value = param.Vector3Value;
     _vector4Value = param.Vector4Value;
     _textureValue = param.TextureValue;
     _matrixValue = param.MatrixValue;
 }
        private void parameterComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //get the parameter type
            String            text      = parameterComboBox1.Text;
            uint              paramName = GodzUtil.GetHashCode(text);
            MaterialParameter mp        = mMaterial.getParameter(paramName);

            if (mp != null)
            {
                parameterTextBox.Text = "";

                //select the type
                MaterialParameterType ty = mp.getType();
                if (ty == MaterialParameterType.MaterialParameter_Texture)
                {
                    parameterTypeComboBox.SelectedIndex = 0;
                }
                else
                {
                    parameterTypeComboBox.SelectedIndex = 1;

                    //set float value....
                    String text2 = "";
                    uint   num   = mp.getNumFloats();
                    for (uint i = 0; i < num; i++)
                    {
                        text2 += mp.getFloat(i).ToString();
                        if (i < num - 1)
                        {
                            text2 += ",";
                        }
                    }

                    parameterTextBox.Text = text2;
                }
            }
        }
Example #8
0
 public MaterialParameter(MaterialParameterType type, object value, object defaultValue)
 {
     ParamType    = type;
     Value        = value;
     DefaultValue = defaultValue;
 }
            private static ConnectionType GetConnectionType(MaterialParameterType parameter)
            {
                if (parameter == MaterialParameterType.Invalid)
                {
                    return(ConnectionType.Invalid);
                }

                if (parameter == MaterialParameterType.Bool)
                {
                    return(ConnectionType.Bool);
                }

                if (parameter == MaterialParameterType.Integer)
                {
                    return(ConnectionType.Integer);
                }

                if (parameter == MaterialParameterType.Float)
                {
                    return(ConnectionType.Float);
                }

                if (parameter == MaterialParameterType.Vector2)
                {
                    return(ConnectionType.Vector2);
                }

                if (parameter == MaterialParameterType.Vector3)
                {
                    return(ConnectionType.Vector3);
                }

                if (parameter == MaterialParameterType.Vector4)
                {
                    return(ConnectionType.Vector4);
                }

                if (parameter == MaterialParameterType.Color)
                {
                    return(ConnectionType.Vector4);
                }

                // TODO: Automatically cast between GPUTexture and Texture
                if (parameter == MaterialParameterType.Texture || parameter == MaterialParameterType.CubeTexture ||
                    parameter == MaterialParameterType.NormalMap || parameter == MaterialParameterType.SceneTexture ||
                    parameter == MaterialParameterType.GPUTexture ||
                    parameter == MaterialParameterType.GPUTextureArray ||
                    parameter == MaterialParameterType.GPUTextureVolume ||
                    parameter == MaterialParameterType.GPUTextureCube)
                {
                    return(ConnectionType.Object);
                }

                if (parameter == MaterialParameterType.Matrix)
                {
                    return(ConnectionType.Object);
                }

                if (parameter == MaterialParameterType.ChannelMask)
                {
                    return(ConnectionType.Object);
                }

                return(ConnectionType.Invalid);
            }