public override void OnPointerEnter(Vector2 pointerPosition, CompositionImage image) { _propertySet = _compositor.CreatePropertySet(); _propertySet.InsertScalar("Scale", 1.25f); _propertySet.InsertScalar("Rotation", 0f); _propertySet.InsertVector2("Translate", new Vector2(0f, 0f)); _propertySet.InsertVector2("CenterPointOffset", new Vector2((float)_lightMap.Size.Width / 2f, 0f)); _transformExpressionNode.SetReferenceParameter("props", _propertySet); image.Brush.StartAnimation("LightMapTransform.TransformMatrix", _transformExpressionNode); _propertySet.StartAnimation("Rotation", _enterAnimation); }
public override void OnPointerEnter(Vector2 pointerPosition, CompositionImage image) { _propertySet = _compositor.CreatePropertySet(); _propertySet.InsertScalar("Scale", 1f); Vector2 positionNormalized = new Vector2((pointerPosition.X / (float)image.Width) - .5f, (pointerPosition.Y / (float)image.Height) - .5f); _propertySet.InsertVector2("Translate", positionNormalized); _propertySet.InsertVector2("CenterPointOffset", new Vector2(128, 128)); _transformExpression.SetReferenceParameter("props", _propertySet); image.Brush.StartAnimation("LightMapTransform.TransformMatrix", _transformExpression); _propertySet.StartAnimation("Scale", _enterAnimation); }
public static void InsertValue <T>(CompositionPropertySet prop, string name, T value) where T : struct { { if (value is float v) { prop.InsertScalar(name, v); } } { if (value is Vector2 v) { prop.InsertVector2(name, v); } } { if (value is Vector3 v) { prop.InsertVector3(name, v); } } { if (value is Vector4 v) { prop.InsertVector4(name, v); } } { if (value is Quaternion v) { prop.InsertQuaternion(name, v); } } }
/// <summary> /// Starts spying on the vector2 property of the provided object. /// </summary> /// <param name="sourceObject"></param> /// <param name="propertyName"></param> /// <param name="originalValue"></param> public static void StartSpyingVector2Property(CompositionObject sourceObject, string propertyName, Vector2 originalValue) { CompositionPropertySet propertySet = null; ExpressionAnimation expressionAnimation = null; string propertySetPropertyName = null; StartSpyingProperty(sourceObject, ref propertyName, out propertySet, out expressionAnimation, out propertySetPropertyName); propertySet.InsertVector2(propertySetPropertyName, originalValue); propertySet.StartAnimation(propertySetPropertyName, expressionAnimation); }
/// <summary> /// Creates a Viewport with default properties. /// Offset = Vector3.Zero /// Size = Vector2(100, 100) /// Stretch = Uniform /// StretchMatrix = Matrix4x4.Identity /// </summary> /// <param name="compositor"></param> /// <exception cref="System.ArgumentException">Thrown when constructor is passed a null value.</exception> public Viewport(Compositor compositor) { if (compositor == null) { throw new System.ArgumentException("Compositor cannot be null"); } _compositor = compositor; _propertySet = _compositor.CreatePropertySet(); // Create properties of viewport _propertySet.InsertVector3("Offset", Vector3.Zero); _propertySet.InsertVector2("Size", new Vector2(100, 100)); _propertySet.InsertScalar("Stretch", (int)Stretch.Uniform); _propertySet.InsertMatrix4x4("StretchMatrix", Matrix4x4.Identity); Camera = new OrbitalCamera(_compositor); StartAnimationsOnStretchMatrix(); }
public override void OnPointerMoved(Vector2 pointerPosition, CompositionImage image) { Vector2 positionNormalized = new Vector2((pointerPosition.X / (float)image.Width) - .5f, (pointerPosition.Y / (float)image.Height) - .5f); _propertySet.InsertVector2("Translate", positionNormalized); }
public static CompositionPropertySet SetValue(this CompositionPropertySet set, string name, Vector2 value) { set.InsertVector2(name, value); return set; }
public override void OnPointerEnter(Vector2 pointerPosition, CompositionImage image) { _propertySet = _compositor.CreatePropertySet(); _propertySet.InsertScalar("Scale", 1.25f); _propertySet.InsertScalar("Rotation", 0f); _propertySet.InsertVector2("Translate", new Vector2(0f, 0f)); _propertySet.InsertVector2("CenterPointOffset", new Vector2((float)_lightMap.Size.Width / 2f, 0f)); _transformExpression.SetReferenceParameter("props", _propertySet); image.Brush.StartAnimation("LightMapTransform.TransformMatrix", _transformExpression); _propertySet.StartAnimation("Rotation", _enterAnimation); }