/// <summary> /// Initializes a new instance of the <see cref="GorgonTrackUInt32{T}" /> class. /// </summary> /// <param name="property">Property information.</param> internal GorgonTrackUInt32(GorgonAnimatedProperty property) : base(property) { _setProperty = BuildSetAccessor <UInt32>(); InterpolationMode = TrackInterpolationMode.Linear; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonTrackTexture2D{T}" /> class. /// </summary> /// <param name="textureProperty">Property to alter the texture.</param> /// <param name="regionProperty">Property to alter the region.</param> internal GorgonTrackTexture2D(GorgonAnimatedProperty textureProperty, GorgonAnimatedProperty regionProperty) : base(textureProperty) { _getTextureProperty = BuildGetAccessor <GorgonTexture2D>(); _setTextureProperty = BuildSetAccessor <GorgonTexture2D>(); _setTextureRegionProperty = BuildSetAccessor <RectangleF>(regionProperty.Property.GetSetMethod()); InterpolationMode = TrackInterpolationMode.None; }
/// <summary> /// Initializes a new instance of the <see cref="GorgonAnimationTrack{T}" /> class. /// </summary> /// <param name="property">The property to animate.</param> protected GorgonAnimationTrack(GorgonAnimatedProperty property) : base(property.DisplayName) { Animation = null; DataType = property.DataType; // We use this to set/return the property values. Unlike the previous version of Gorgon, // which used reflection to set/return the values, we're using an expression tree to do the work. // Profiling in a tight loop of 1,000,000 iterations: The reflection took between 415ms - 469ms // to set and return values, while the expression tree took 39 ms, a little over 10-12x the speed. // The animation controller in the previous version of Gorgon was horrifically slow, hopefully // this will remedy that. AnimatedProperty = property; KeyFrames = new GorgonAnimationKeyFrameCollection <T>(this); Spline = new GorgonSpline(); }
/// <summary> /// Function to build the track list for the animated object. /// </summary> internal void EnumerateTracks() { if (_animation.AnimationController == null) { return; } // Enumerate tracks from the owner object animated properties list. foreach (var item in _animation.AnimationController.AnimatedProperties) { if (Contains(item.Value.DisplayName)) // Don't add tracks that are already here. { continue; } switch (item.Value.DataType.FullName.ToUpperInvariant()) { case "SYSTEM.BYTE": Add(new GorgonTrackByte <T>(item.Value)); break; case "SYSTEM.SBYTE": Add(new GorgonTrackSByte <T>(item.Value)); break; case "SYSTEM.INT16": Add(new GorgonTrackInt16 <T>(item.Value)); break; case "SYSTEM.UINT16": Add(new GorgonTrackUInt16 <T>(item.Value)); break; case "SYSTEM.INT32": Add(new GorgonTrackInt32 <T>(item.Value)); break; case "SYSTEM.UINT32": Add(new GorgonTrackUInt32 <T>(item.Value)); break; case "SYSTEM.INT64": Add(new GorgonTrackInt64 <T>(item.Value)); break; case "SYSTEM.UINT64": Add(new GorgonTrackUInt64 <T>(item.Value)); break; case "SYSTEM.SINGLE": Add(new GorgonTrackSingle <T>(item.Value)); break; case "SLIMMATH.VECTOR2": Add(new GorgonTrackVector2 <T>(item.Value)); break; case "SLIMMATH.VECTOR3": Add(new GorgonTrackVector3 <T>(item.Value)); break; case "SLIMMATH.VECTOR4": Add(new GorgonTrackVector4 <T>(item.Value)); break; case "GORGONLIBRARY.GRAPHICS.GORGONTEXTURE2D": // We need grab an additional property for texture animation. var property = new GorgonAnimatedProperty(_animation.AnimationController.AnimatedObjectType.GetProperty("TextureRegion")); Add(new GorgonTrackTexture2D <T>(item.Value, property)); break; case "GORGONLIBRARY.GRAPHICS.GORGONCOLOR": Add(new GorgonTrackGorgonColor <T>(item.Value)); break; } } }