Exemplo n.º 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 ColorNode() as T;
            }
            else if (typeof(T) == typeof(QuaternionNode))
            {
                newNode = new QuaternionNode() as T;
            }
            else if (typeof(T) == typeof(Matrix3x2Node))
            {
                newNode = new Matrix3x2Node() as T;
            }
            else if (typeof(T) == typeof(Matrix4x4Node))
            {
                newNode = new Matrix4x4Node() as T;
            }
            else
            {
                throw new Exception("unexpected type");
            }

            return(newNode);
        }
 /// <summary> Creates a quaternion that rotates around an arbitrary vector. </summary>
 /// <param name="axis">Rotation axis</param>
 /// <param name="angle">Angle, in radians.</param>
 public static QuaternionNode CreateQuaternionFromAxisAngle(Vector3Node axis, ScalarNode angle)
 {
     return(Function <QuaternionNode>(ExpressionNodeType.QuaternionFromAxisAngle, axis, angle));
 }
 public static Vector3Node    Conditional(BooleanNode condition, Vector3Node trueCase, Vector3Node falseCase)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Conditional, condition, trueCase, falseCase));
 }
 public static Matrix4x4Node CreateScale(Vector3Node val)
 {
     return(Function <Matrix4x4Node>(ExpressionNodeType.Matrix4x4FromScale, val));
 }
 /// <summary> Creates a matrix that rotates around an arbitrary vector. </summary>
 /// <param name="axis">Rotation axis</param>
 /// <param name="angle">Angle, in radians.</param>
 public static Matrix4x4Node CreateMatrix4x4FromAxisAngle(Vector3Node axis, ScalarNode angle)
 {
     return(Function <Matrix4x4Node>(ExpressionNodeType.Matrix4x4FromAxisAngle, axis, angle));
 }
 public static Vector3Node   Scale(Vector3Node val1, ScalarNode val2)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Scale, val1, val2));
 }
 public static Matrix4x4Node CreateTranslation(Vector3Node val)
 {
     return(Function <Matrix4x4Node>(ExpressionNodeType.Matrix4x4FromTranslation, val));
 }
 public static Vector3Node Mod(Vector3Node val1, Vector3Node val2)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Modulus, val1, val2));
 }
 public static Vector3Node    Normalize(Vector3Node val)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Normalize, val));
 }
 public static Vector3Node Lerp(Vector3Node val1, Vector3Node val2, ScalarNode progress)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Lerp, val1, val2, progress));
 }
 public static ScalarNode LengthSquared(Vector3Node val)
 {
     return(Function <ScalarNode>(ExpressionNodeType.LengthSquared, val));
 }
 public static ScalarNode DistanceSquared(Vector3Node val1, Vector3Node val2)
 {
     return(Function <ScalarNode>(ExpressionNodeType.DistanceSquared, val1, val2));
 }
 public static Vector3Node Clamp(Vector3Node val, Vector3Node min, Vector3Node max)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Clamp, val, min, max));
 }
 public static Vector3Node Abs(Vector3Node val)
 {
     return(Function <Vector3Node>(ExpressionNodeType.Absolute, val));
 }