Пример #1
0
 /// <summary>
 /// Creates a dynamic parameter key for texel size updated from the texture size.
 /// </summary>
 /// <param name="textureKey">Key of the texture to take the size from</param>
 /// <returns>A dynamic TexelSize parameter key updated according to the specified texture</returns>
 public static ParameterKey <Vector2> CreateDynamicTexelSizeParameterKey(ParameterKey <Texture> textureKey)
 {
     if (textureKey == null)
     {
         throw new ArgumentNullException("textureKey");
     }
     return(ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector2, Texture>(textureKey, UpdateTexelSize)));
 }
Пример #2
0
 static TransformationKeys()
 {
     View                = ParameterKeys.New(Matrix.Identity);
     Projection          = ParameterKeys.New(Matrix.Identity);
     World               = ParameterKeys.New(Matrix.Identity);
     WorldView           = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix, Matrix>(World, View, Matrix.MultiplyRef));
     WorldViewProjection = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix, Matrix>(World, ViewProjection, Matrix.MultiplyRef));
     ProjScreenRay       = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector2, Matrix>(Projection, ExtractProjScreenRay));
     Eye                   = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector4, Matrix>(View, ViewToEye));
     EyeMS                 = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector4, Matrix>(WorldView, WorldViewToEyeMS));
     WorldInverse          = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix>(World, InvertMatrix));
     WorldInverseTranspose = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix>(WorldInverse, TransposeMatrix));
     ViewInverse           = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix>(View, InvertMatrix));
     ProjectionInverse     = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix>(Projection, InvertMatrix));
     WorldViewInverse      = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Matrix, Matrix>(WorldView, InvertMatrix));
     WorldScale            = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector3, Matrix>(World, ExtractScale));
 }
Пример #3
0
        public override void Serialize(ref ParameterKey <T> obj, ArchiveMode mode, SerializationStream stream)
        {
            if (mode == ArchiveMode.Serialize)
            {
                stream.Write(obj.Name);
                stream.Write(obj.Length);
            }
            else
            {
                var parameterName   = stream.ReadString();
                var parameterLength = stream.ReadInt32();
                obj = (ParameterKey <T>)ParameterKeys.FindByName(parameterName);

                // If parameter could not be found, create one matching this type.
                if (obj == null)
                {
                    var metadata = new ParameterKeyValueMetadata <T>();
                    obj = new ParameterKey <T>(parameterName, parameterLength, metadata);
                    ParameterKeys.Merge(obj, null, parameterName);
                }
            }
        }
Пример #4
0
 static CameraKeys()
 {
     ZProjection = ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector2, float, float>(NearClipPlane, FarClipPlane, ZProjectionACalculate));
 }
Пример #5
0
 static SpriteBaseKeys()
 {
     MatrixTransform = ParameterKeys.New(Matrix.Identity);
 }