/// <summary>
 /// Initializes a new instance of the <see cref="ComputeTextureColor" /> class.
 /// </summary>
 /// <param name="texture">The texture.</param>
 /// <param name="texcoordIndex">Index of the texcoord.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="offset">The offset.</param>
 protected ComputeTextureBase(Texture texture, TextureCoordinate texcoordIndex, Vector2 scale, Vector2 offset)
 {
     Enabled       = true;
     Texture       = texture;
     TexcoordIndex = texcoordIndex;
     Sampler       = new ComputeColorParameterSampler();
     Scale         = scale;
     Offset        = offset;
     Key           = null;
 }
Esempio n. 2
0
        /// <summary>
        /// Add a new generic parameter.
        /// </summary>
        /// <typeparam name="TValue">The type of the generic.</typeparam>
        /// <param name="keyName">The name of the generic.</param>
        /// <param name="generics">The target ComputeColorParameters.</param>
        public void AddKey <TValue>(string keyName, ComputeColorParameters generics)
        {
            IComputeColorParameter computeColorParameter;
            var typeT = typeof(TValue);

            if (typeT == typeof(Texture))
            {
                computeColorParameter = new ComputeColorParameterTexture();
            }
            else if (typeT == typeof(float))
            {
                computeColorParameter = new ComputeColorParameterFloat();
            }
            else if (typeT == typeof(int))
            {
                computeColorParameter = new ComputeColorParameterInt();
            }
            else if (typeT == typeof(Vector2))
            {
                computeColorParameter = new ComputeColorParameterFloat2();
            }
            else if (typeT == typeof(Vector3))
            {
                computeColorParameter = new ComputeColorParameterFloat3();
            }
            else if (typeT == typeof(Vector4))
            {
                computeColorParameter = new ComputeColorParameterFloat4();
            }
            else if (typeT == typeof(SamplerState))
            {
                computeColorParameter = new ComputeColorParameterSampler();
            }
            else
            {
                throw new Exception("Unsupported generic format");
            }

            if (Generics.ContainsKey(keyName))
            {
                var gen = Generics[keyName];
                if (gen == null || gen.GetType() != computeColorParameter.GetType())
                {
                    generics[keyName] = computeColorParameter;
                }
                else
                {
                    generics[keyName] = gen;
                }
            }
            else
            {
                generics.Add(keyName, computeColorParameter);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Add a new member.
        /// </summary>
        /// <typeparam name="TMember">The type of the member.</typeparam>
        /// <param name="linkName">The name of the parameter key.</param>
        /// <param name="members">The target parameter collection.</param>
        public void AddMember <TMember>(string linkName, Dictionary <ParameterKey, object> members)
        {
            var pk = GetTypedParameterKey <TMember>(linkName);

            if (pk != null)
            {
                Type   expectedType = null;
                object defaultValue;
                if (pk.PropertyType == typeof(Graphics.Texture))
                {
                    expectedType = typeof(ComputeColorParameterTexture);
                    defaultValue = new ComputeColorParameterTexture();
                }
                else if (pk.PropertyType == typeof(Graphics.SamplerState))
                {
                    expectedType = typeof(ComputeColorParameterSampler);
                    defaultValue = new ComputeColorParameterSampler();
                }
                else
                {
                    expectedType = pk.PropertyType;
                    defaultValue = pk.DefaultValueMetadataT.DefaultValue;
                }

                if (Members.ContainsKey(pk))
                {
                    var value = Members[pk];
                    if (value.GetType() == expectedType)
                    {
                        members.Add(pk, value);
                    }
                }
                else
                {
                    members.Add(pk, defaultValue);
                }
            }
        }