// // Helper functions // internal static T CreateExpressionNode <T>() where T : class { T newNode; if (typeof(T) == typeof(BooleanNode)) { newNode = new BooleanNode() as T; } else if (typeof(T) == typeof(ScalarNode)) { newNode = new ScalarNode() as T; } else if (typeof(T) == typeof(Vector2Node)) { newNode = new Vector2Node() as T; } else if (typeof(T) == typeof(Vector3Node)) { newNode = new Vector3Node() as T; } else if (typeof(T) == typeof(Vector4Node)) { newNode = new Vector4Node() as T; } else if (typeof(T) == typeof(ColorNode)) { newNode = new Vector4Node() as T; } else if (typeof(T) == typeof(QuaternionNode)) { newNode = new Vector4Node() as T; } else if (typeof(T) == typeof(Matrix3x2Node)) { newNode = new Matrix4x4Node() as T; } else if (typeof(T) == typeof(Matrix4x4Node)) { newNode = new Matrix4x4Node() as T; } else { throw new Exception("unexpected type"); } return(newNode); }
public static Vector2Node Conditional(BooleanNode condition, Vector2Node trueCase, Vector2Node falseCase) { return(Function <Vector2Node>(ExpressionNodeType.Conditional, condition, trueCase, falseCase)); }
/// <summary> Creates a skew matrix from the specified angles in radians. </summary> /// <param name="xAngle">X angle, in radians.</param> /// <param name="yAngle">Y angle, in radians.</param> /// <param name="centerPoint">The centerpoint for the operation.</param> public static Matrix3x2Node CreateSkew(ScalarNode xAngle, ScalarNode yAngle, Vector2Node centerPoint) { return(Function <Matrix3x2Node>(ExpressionNodeType.Matrix3x2FromSkew, xAngle, yAngle, centerPoint)); }
/// <summary> Creates a scale matrix from the specified vector scale. </summary> /// <param name="val">Source scaling vector.</param> public static Matrix3x2Node CreateScale(Vector2Node val) { return(Function <Matrix3x2Node>(ExpressionNodeType.Matrix3x2FromScale, val)); }
/// <summary> Creates a translation matrix from the specified vector.</summary> /// <param name="val">Source translation vector.</param> public static Matrix3x2Node CreateTranslation(Vector2Node val) { return(Function <Matrix3x2Node>(ExpressionNodeType.Matrix3x2FromTranslation, val)); }
/// <summary> Transforms a vector by the specified matrix. </summary> /// <param name="val1">Vector to be transformed.</param> /// <param name="val2">The transformation matrix.</param> public static Vector2Node Transform(Vector2Node val1, Matrix3x2Node val2) { return(Function <Vector2Node>(ExpressionNodeType.Transform, val1, val2)); }
public static Vector2Node Scale(Vector2Node val1, ScalarNode val2) { return(Function <Vector2Node>(ExpressionNodeType.Scale, val1, val2)); }
/// <summary> Returns the normalized version of a vector. </summary> /// <param name="val">Vector value to normalize.</param> public static Vector2Node Normalize(Vector2Node val) { return(Function <Vector2Node>(ExpressionNodeType.Normalize, val)); }
public static Vector2Node Mod(Vector2Node val1, Vector2Node val2) { return(Function <Vector2Node>(ExpressionNodeType.Modulus, val1, val2)); }
public static Vector2Node Lerp(Vector2Node val1, Vector2Node val2, ScalarNode progress) { return(Function <Vector2Node>(ExpressionNodeType.Lerp, val1, val2, progress)); }
public static ScalarNode LengthSquared(Vector2Node val) { return(Function <ScalarNode>(ExpressionNodeType.LengthSquared, val)); }
public static ScalarNode DistanceSquared(Vector2Node val1, Vector2Node val2) { return(Function <ScalarNode>(ExpressionNodeType.DistanceSquared, val1, val2)); }
public static Vector2Node Clamp(Vector2Node val, Vector2Node min, Vector2Node max) { return(Function <Vector2Node>(ExpressionNodeType.Clamp, val, min, max)); }
public static Vector2Node Abs(Vector2Node val) { return(Function <Vector2Node>(ExpressionNodeType.Absolute, val)); }