示例#1
0
        public static dynamic TryGetPathProperty(Track track, string propertyName, float time)
        {
            Property pathProperty = null;

            track?.PathProperties.TryGetValue(propertyName, out pathProperty);
            if (pathProperty == null)
            {
                return(null);
            }

            PointDefinitionInterpolation pointDataInterpolation = (PointDefinitionInterpolation)pathProperty.Value;

            switch (pathProperty.PropertyType)
            {
            case PropertyType.Linear:
                return(pointDataInterpolation.InterpolateLinear(time));

            case PropertyType.Quaternion:
                return(pointDataInterpolation.InterpolateQuaternion(time));

            case PropertyType.Vector3:
                return(pointDataInterpolation.Interpolate(time));

            case PropertyType.Vector4:
                return(pointDataInterpolation.InterpolateVector4(time));

            default:
                return(null);
            }
        }
        /*public static dynamic TryGetPathProperty(Track track, string propertyName, float time)
         * {
         *  Property pathProperty = null;
         *  track?.PathProperties.TryGetValue(propertyName, out pathProperty);
         *  if (pathProperty == null)
         *  {
         *      return null;
         *  }
         *
         *  PointDefinitionInterpolation pointDataInterpolation = (PointDefinitionInterpolation)pathProperty.Value;
         *
         *  switch (pathProperty.PropertyType)
         *  {
         *      case PropertyType.Linear:
         *          return pointDataInterpolation.InterpolateLinear(time);
         *
         *      case PropertyType.Quaternion:
         *          return pointDataInterpolation.InterpolateQuaternion(time);
         *
         *      case PropertyType.Vector3:
         *          return pointDataInterpolation.Interpolate(time);
         *
         *      case PropertyType.Vector4:
         *          return pointDataInterpolation.InterpolateVector4(time);
         *
         *      default:
         *          return null;
         *  }
         * }*/

        public static float?TryGetLinearPathProperty(Track track, string propertyName, float time)
        {
            PointDefinitionInterpolation pointDataInterpolation = GetPathInterpolation(track, propertyName, PropertyType.Linear);

            if (pointDataInterpolation != null)
            {
                return(pointDataInterpolation.InterpolateLinear(time));
            }

            return(null);
        }