コード例 #1
0
        //
        // 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);
        }
コード例 #2
0
 public static Vector2Node    Conditional(BooleanNode condition, Vector2Node trueCase, Vector2Node falseCase)
 {
     return(Function <Vector2Node>(ExpressionNodeType.Conditional, condition, trueCase, falseCase));
 }
コード例 #3
0
 /// <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));
 }
コード例 #4
0
 /// <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));
 }
コード例 #5
0
 /// <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));
 }
コード例 #6
0
 /// <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));
 }
コード例 #7
0
 public static Vector2Node   Scale(Vector2Node val1, ScalarNode val2)
 {
     return(Function <Vector2Node>(ExpressionNodeType.Scale, val1, val2));
 }
コード例 #8
0
 /// <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));
 }
コード例 #9
0
 public static Vector2Node Mod(Vector2Node val1, Vector2Node val2)
 {
     return(Function <Vector2Node>(ExpressionNodeType.Modulus, val1, val2));
 }
コード例 #10
0
 public static Vector2Node Lerp(Vector2Node val1, Vector2Node val2, ScalarNode progress)
 {
     return(Function <Vector2Node>(ExpressionNodeType.Lerp, val1, val2, progress));
 }
コード例 #11
0
 public static ScalarNode LengthSquared(Vector2Node val)
 {
     return(Function <ScalarNode>(ExpressionNodeType.LengthSquared, val));
 }
コード例 #12
0
 public static ScalarNode DistanceSquared(Vector2Node val1, Vector2Node val2)
 {
     return(Function <ScalarNode>(ExpressionNodeType.DistanceSquared, val1, val2));
 }
コード例 #13
0
 public static Vector2Node Clamp(Vector2Node val, Vector2Node min, Vector2Node max)
 {
     return(Function <Vector2Node>(ExpressionNodeType.Clamp, val, min, max));
 }
コード例 #14
0
 public static Vector2Node Abs(Vector2Node val)
 {
     return(Function <Vector2Node>(ExpressionNodeType.Absolute, val));
 }