Ejemplo n.º 1
0
	public void CopyValues(FMatrix sourceMatrix)
	{
		a = sourceMatrix.a;
		b = sourceMatrix.b;
		c = sourceMatrix.c;
		d = sourceMatrix.d;
		tx = sourceMatrix.tx;
		ty = sourceMatrix.ty;
	}
Ejemplo n.º 2
0
    public FNode()
    {
        _matrix = new FMatrix();
        _concatenatedMatrix = new FMatrix();

        #if UNITY_EDITOR
            if(Futile.instance.shouldTrackNodesInRXProfiler) RXProfiler.TrackLifeCycle(this);
        #endif
    }
Ejemplo n.º 3
0
 public void ConcatAndCopyValues(FMatrix first, FMatrix second)
 {
     a = first.a*second.a + first.b*second.c;
     b = first.a*second.b + first.b*second.d;
     c = first.c*second.a + first.d*second.c;
     d = first.c*second.b + first.d*second.d;
     tx = first.tx*second.a + first.ty*second.c + second.tx;
     ty = first.tx*second.b + first.ty*second.d + second.ty;
 }
Ejemplo n.º 4
0
        public void DrawArrow(FVector2 start, FVector2 end, float length, float width, bool drawStartIndicator,
                              Color color)
        {
            // Draw connection segment between start- and end-point
            DrawSegment(start, end, color);

            // Precalculate halfwidth
            float halfWidth = width / 2;

            // Create directional reference
            FVector2 rotation = (start - end);

            rotation.Normalize();

            // Calculate angle of directional vector
            float angle = (float)Math.Atan2(rotation.X, -rotation.Y);
            // Create matrix for rotation
            FMatrix rotFMatrix = FMatrix.CreateRotationZ(angle);
            // Create translation matrix for end-point
            FMatrix endFMatrix = FMatrix.CreateTranslation(end.X, end.Y, 0);

            // Setup arrow end shape
            FVector2[] verts = new FVector2[3];
            verts[0] = new FVector2(0, 0);
            verts[1] = new FVector2(-halfWidth, -length);
            verts[2] = new FVector2(halfWidth, -length);

            // Rotate end shape
            FVector2.Transform(verts, ref rotFMatrix, verts);
            // Translate end shape
            FVector2.Transform(verts, ref endFMatrix, verts);

            // Draw arrow end shape
            DrawSolidPolygon(verts, 3, color, false);

            if (drawStartIndicator)
            {
                // Create translation matrix for start
                FMatrix startFMatrix = FMatrix.CreateTranslation(start.X, start.Y, 0);
                // Setup arrow start shape
                FVector2[] baseVerts = new FVector2[4];
                baseVerts[0] = new FVector2(-halfWidth, length / 4);
                baseVerts[1] = new FVector2(halfWidth, length / 4);
                baseVerts[2] = new FVector2(halfWidth, 0);
                baseVerts[3] = new FVector2(-halfWidth, 0);

                // Rotate start shape
                FVector2.Transform(baseVerts, ref rotFMatrix, baseVerts);
                // Translate start shape
                FVector2.Transform(baseVerts, ref startFMatrix, baseVerts);
                // Draw start shape
                DrawSolidPolygon(baseVerts, 4, color, false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Rotate the vertices with the defined value in radians.
        /// </summary>
        /// <param name="value">The amount to rotate by in radians.</param>
        public void Rotate(float value)
        {
            FMatrix rotationMatrix;

            FMatrix.CreateRotationZ(value, out rotationMatrix);

            for (int i = 0; i < Count; i++)
            {
                this[i] = FVector2.Transform(this[i], rotationMatrix);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// You can optionally pass in the matrices transpose-adjoint, which save it recalculating it.
        /// MSM: If we are going to save the transpose-adjoint we should also save the more expensive
        /// determinant.
        /// </summary>
        /// <param name="m">The Matrix to transform plane with.</param>
        /// <param name="detM">Determinant of Matrix.</param>
        /// <param name="ta">Transpose-adjoint of Matrix.</param>
        /// <returns>The result of transform.</returns>
        public FPlane TransformByUsingAdjointT(FMatrix m, float detM, FMatrix ta)
        {
            FVector newNorm = ta.TransformVector(this).GetSafeNormal();

            if (detM < 0.0f)
            {
                newNorm *= -1.0f;
            }

            return(new FPlane(m.TransformPosition(this * W), newNorm));
        }
Ejemplo n.º 7
0
    public void InvertAndCopyValues(FMatrix other)
    {
        float bottom = 1.0f / (other.a * other.d - other.b * other.c);

        a  = other.d * bottom;
        b  = -other.b * bottom;
        c  = -other.c * bottom;
        d  = other.a * bottom;
        tx = (other.c * other.ty - other.d * other.tx) * bottom;
        ty = -(other.a * other.ty - other.b * other.tx) * bottom;
    }
Ejemplo n.º 8
0
    public FMatrix Clone()
    {
        FMatrix result = new FMatrix();
        result.a = a;
        result.b = b;
        result.c = c;
        result.d = d;
        result.tx = tx;
        result.ty = ty;

        return result;
    }
Ejemplo n.º 9
0
    public FNode()
    {
        _matrix             = new FMatrix();
        _concatenatedMatrix = new FMatrix();

                #if UNITY_EDITOR
        if (Futile.instance.shouldTrackNodesInRXProfiler)
        {
            RXProfiler.TrackLifeCycle(this);
        }
                #endif
    }
Ejemplo n.º 10
0
    protected void CreateSpecialMatrices()
    {
        _needsSpecialMatrices = true;         //after now the matrices will be updated on redraw

        _inverseConcatenatedMatrix       = new FMatrix();
        _screenConcatenatedMatrix        = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();

        _inverseConcatenatedMatrix.InvertAndCopyValues(_concatenatedMatrix);
        _screenConcatenatedMatrix.ConcatAndCopyValues(_concatenatedMatrix, _stage.screenConcatenatedMatrix);
        _screenInverseConcatenatedMatrix.InvertAndCopyValues(_screenConcatenatedMatrix);
    }
Ejemplo n.º 11
0
        public void TestRank()
        {
            // 1 2 3
            // 4 5 6
            // 7 8 9
            FMatrix <int> mat    = new FMatrix <int>(3, 3, 0);
            int           number = 1;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    mat.matrix[i][j] = number;
                    number++;
                }
            }

            int?rank = FMatrix <int> .Rank(mat);

            Assert.IsTrue(rank.HasValue);
            Assert.AreEqual(rank.Value, 2);


            //1 2 3 4
            //5 6 7 8
            //9 8 7 6
            //5 4 3 2
            FMatrix <int> mat2 = new FMatrix <int>(4, 4, 0);

            number = 1;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    mat2.matrix[i][j] = number;
                    number++;
                }
            }
            number = 9;
            for (int i = 2; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    mat2.matrix[i][j] = number;
                    number--;
                }
            }
            int?rank2 = FMatrix <int> .Rank(mat2);

            Assert.IsTrue(rank2.HasValue);
            Assert.AreEqual(rank2.Value, 2);
        }
Ejemplo n.º 12
0
    public FMatrix Clone()
    {
        FMatrix result = new FMatrix();

        result.a  = a;
        result.b  = b;
        result.c  = c;
        result.d  = d;
        result.tx = tx;
        result.ty = ty;

        return(result);
    }
Ejemplo n.º 13
0
        public virtual void set(Matrix original)
        {
            if (original.getNumCols() != 2 || original.getNumRows() != 2)
            {
                throw new ArgumentException("Rows and/or columns do not match");
            }
            FMatrix m = (FMatrix)original;

            a11 = m.get(0, 0);
            a12 = m.get(0, 1);
            a21 = m.get(1, 0);
            a22 = m.get(1, 1);
        }
Ejemplo n.º 14
0
        public static void copy(FMatrix from, FMatrix to)
        {
            int numCols = from.getNumCols();
            int numRows = from.getNumRows();

            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numCols; j++)
                {
                    to.set(i, j, from.get(i, j));
                }
            }
        }
Ejemplo n.º 15
0
    public FStage() : base()
    {
        _stage = this;

        _renderer = new FRenderer(this);

        _identityMatrix = new FMatrix();
        _identityMatrix.ResetToIdentity();

        _inverseConcatenatedMatrix       = new FMatrix();
        _screenConcatenatedMatrix        = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();
    }
Ejemplo n.º 16
0
    public FStage()
        : base()
    {
        _stage = this;

        _renderer = new FRenderer(this);

        _identityMatrix = new FMatrix();
        _identityMatrix.ResetToIdentity();

        _inverseConcatenatedMatrix = new FMatrix();
        _screenConcatenatedMatrix = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();
    }
Ejemplo n.º 17
0
        public FMatrix ToMatrixWithScale()
        {
            var outMatrix = new FMatrix();

            outMatrix.M30 = Translation.X;
            outMatrix.M31 = Translation.Y;
            outMatrix.M32 = Translation.Z;

            var x2 = Rotation.X + Rotation.X;
            var y2 = Rotation.Y + Rotation.Y;
            var z2 = Rotation.Z + Rotation.Z;

            {
                var xx2 = Rotation.X * x2;
                var yy2 = Rotation.Y * y2;
                var zz2 = Rotation.Z * z2;

                outMatrix.M00 = (1.0f - (yy2 + zz2)) * Scale3D.X;
                outMatrix.M11 = (1.0f - (xx2 + zz2)) * Scale3D.Y;
                outMatrix.M22 = (1.0f - (xx2 + yy2)) * Scale3D.Z;
            }
            {
                var yz2 = Rotation.Y * z2;
                var wx2 = Rotation.W * x2;

                outMatrix.M21 = (yz2 - wx2) * Scale3D.Z;
                outMatrix.M12 = (yz2 + wx2) * Scale3D.Y;
            }
            {
                var xy2 = Rotation.X * y2;
                var wz2 = Rotation.W * z2;

                outMatrix.M10 = (xy2 - wz2) * Scale3D.Y;
                outMatrix.M01 = (xy2 + wz2) * Scale3D.X;
            }
            {
                var xz2 = Rotation.X * z2;
                var wy2 = Rotation.W * y2;

                outMatrix.M20 = (xz2 + wy2) * Scale3D.Z;
                outMatrix.M02 = (xz2 - wy2) * Scale3D.X;
            }

            outMatrix.M03 = 0.0f;
            outMatrix.M13 = 0.0f;
            outMatrix.M23 = 0.0f;
            outMatrix.M33 = 1.0f;

            return(outMatrix);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Get result of Transforming sphere by Matrix.
        /// </summary>
        /// <param name="m">Matrix to transform by.</param>
        /// <returns>Result of transformation.</returns>
        public FSphere TransformBy(FMatrix m)
        {
            FSphere result;

            result.Center = m.TransformPosition(Center);

            FVector XAxis = new FVector(m[0, 0], m[0, 1], m[0, 2]);
            FVector YAxis = new FVector(m[1, 0], m[1, 1], m[1, 2]);
            FVector ZAxis = new FVector(m[2, 0], m[2, 1], m[2, 2]);

            result.W = FMath.Sqrt(FMath.Max(XAxis | XAxis, FMath.Max(YAxis | YAxis, ZAxis | ZAxis))) * W;

            return(result);
        }
Ejemplo n.º 19
0
    public FStage(string name) : base()
    {
        _name = name;

        _stage = this;

        _renderer = new FRenderer(this);

        _identityMatrix = new FMatrix();
        _identityMatrix.Identity();

        _inverseConcatenatedMatrix       = new FMatrix();
        _screenConcatenatedMatrix        = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();
    }
Ejemplo n.º 20
0
 public static void extract(FMatrix src,
                            int srcY0, int srcX0,
                            FMatrix dst,
                            int dstY0, int dstX0,
                            int numRows, int numCols)
 {
     for (int y = 0; y < numRows; y++)
     {
         for (int x = 0; x < numCols; x++)
         {
             float v = src.get(y + srcY0, x + srcX0);
             dst.set(dstY0 + y, dstX0 + x, v);
         }
     }
 }
Ejemplo n.º 21
0
        public void TestMatrixConstructionFunction()
        {
            //public FMatrix(int row, int column, T initializeNumber)
            FMatrix <int> mat = new FMatrix <int>(3, 4, -1);  //row 3 column 4 初始化成 -1

            Assert.IsTrue(mat.row == 3);
            Assert.IsTrue(mat.column == 4);
            Assert.IsTrue(mat.matrix[2][3] == -1);

            FMatrix <int> mat2 = new FMatrix <int>(mat);          //复制构造函数

            Assert.IsTrue(mat2.row == 3);
            Assert.IsTrue(mat2.column == 4);
            Assert.IsTrue(mat2.matrix[2][3] == -1);
        }
Ejemplo n.º 22
0
    public FStage(string name)
        : base()
    {
        _name = name;

        _stage = this;

        _renderer = new FRenderer(this);

        _identityMatrix = new FMatrix();
        _identityMatrix.Identity();

        _inverseConcatenatedMatrix = new FMatrix();
        _screenConcatenatedMatrix = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();
    }
Ejemplo n.º 23
0
    public void Concat(FMatrix other)
    {
        float oldA = a;
        float oldB = b;
        float oldC = c;
        float oldD = d;
        float oldTX = tx;
        float oldTY = ty;

        a = oldA*other.a + oldB*other.c;
        b = oldA*other.b + oldB*other.d;
        c = oldC*other.a + oldD*other.c;
        d = oldC*other.b + oldD*other.d;
        tx = oldTX*other.a + oldTY*other.c + other.tx;
        ty = oldTX*other.b + oldTY*other.d + other.ty;
    }
Ejemplo n.º 24
0
        public void TestInitialize()
        {
            FMatrix <int> mat = new FMatrix <int>();

            Assert.IsNull(mat.matrix);                      //未初始化

            Assert.IsTrue(mat.Initialize(4, 5, -2));        //初始化
            Assert.IsTrue(mat.row == 4);
            Assert.IsTrue(mat.column == 5);
            Assert.IsTrue(mat.matrix[3][4] == -2);

            Assert.IsFalse(mat.Initialize(3, 4, -3));       //二次初始化
            Assert.IsTrue(mat.row == 4);
            Assert.IsTrue(mat.column == 5);
            Assert.IsTrue(mat.matrix[3][4] == -2);
        }
Ejemplo n.º 25
0
    public void ConcatOther(FMatrix other)     //the opposite order of Concat
    {
        float oldA  = a;
        float oldB  = b;
        float oldC  = c;
        float oldD  = d;
        float oldTX = tx;
        float oldTY = ty;

        a  = other.a * oldA + other.b * oldC;
        b  = other.a * oldB + other.b * oldD;
        c  = other.c * oldA + other.d * oldC;
        d  = other.c * oldB + other.d * oldD;
        tx = other.tx * oldA + other.ty * oldC + oldTX;
        ty = other.tx * oldB + other.ty * oldD + oldTY;
    }
Ejemplo n.º 26
0
    public void Concat(FMatrix other)
    {
        float oldA  = a;
        float oldB  = b;
        float oldC  = c;
        float oldD  = d;
        float oldTX = tx;
        float oldTY = ty;

        a  = oldA * other.a + oldB * other.c;
        b  = oldA * other.b + oldB * other.d;
        c  = oldC * other.a + oldD * other.c;
        d  = oldC * other.b + oldD * other.d;
        tx = oldTX * other.a + oldTY * other.c + other.tx;
        ty = oldTX * other.b + oldTY * other.d + other.ty;
    }
Ejemplo n.º 27
0
    //use node.LocalToLocal to use a point from a different coordinate space
    public void ScaleAroundPointRelative(Vector2 localPoint, float relativeScaleX, float relativeScaleY)
    {
        FMatrix tempMatrix = FMatrix.tempMatrix;

        tempMatrix.ResetToIdentity();
        tempMatrix.SetScaleThenRotate(0, 0, (relativeScaleX - 1.0f), (relativeScaleY - 1.0f), _rotation * -RXMath.DTOR);
        Vector2 moveVector = tempMatrix.GetNewTransformedVector(new Vector2(localPoint.x * _scaleX, localPoint.y * _scaleY));

        _x += -moveVector.x;
        _y += -moveVector.y;

        _scaleX *= relativeScaleX;
        _scaleY *= relativeScaleY;

        _isMatrixDirty = true;
    }
Ejemplo n.º 28
0
        public static void print(Stream output, FMatrix mat, string format,
                                 int row0, int row1, int col0, int col1)
        {
            Console.WriteLine("Type = submatrix , rows " + row0 + " to " + row1 + "  columns " + col0 + " to " + col1);

            format += " ";

            for (int y = row0; y < row1; y++)
            {
                for (int x = col0; x < col1; x++)
                {
                    Console.Write(format, mat.get(y, x));
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 29
0
    //the opposite order of Concat
    public void ConcatOther(FMatrix other)
    {
        float oldA = a;
        float oldB = b;
        float oldC = c;
        float oldD = d;
        float oldTX = tx;
        float oldTY = ty;

        a = other.a*oldA + other.b*oldC;
        b = other.a*oldB + other.b*oldD;
        c = other.c*oldA + other.d*oldC;
        d = other.c*oldB + other.d*oldD;
        tx = other.tx*oldA + other.ty*oldC + oldTX;
        ty = other.tx*oldB + other.ty*oldD + oldTY;
    }
Ejemplo n.º 30
0
        public virtual void set(Matrix original)
        {
            if (original.getNumCols() != 6 || original.getNumRows() != 6)
            {
                throw new ArgumentException("Rows and/or columns do not match");
            }
            FMatrix m = (FMatrix)original;

            a11 = m.get(0, 0);
            a12 = m.get(0, 1);
            a13 = m.get(0, 2);
            a14 = m.get(0, 3);
            a15 = m.get(0, 4);
            a16 = m.get(0, 5);
            a21 = m.get(1, 0);
            a22 = m.get(1, 1);
            a23 = m.get(1, 2);
            a24 = m.get(1, 3);
            a25 = m.get(1, 4);
            a26 = m.get(1, 5);
            a31 = m.get(2, 0);
            a32 = m.get(2, 1);
            a33 = m.get(2, 2);
            a34 = m.get(2, 3);
            a35 = m.get(2, 4);
            a36 = m.get(2, 5);
            a41 = m.get(3, 0);
            a42 = m.get(3, 1);
            a43 = m.get(3, 2);
            a44 = m.get(3, 3);
            a45 = m.get(3, 4);
            a46 = m.get(3, 5);
            a51 = m.get(4, 0);
            a52 = m.get(4, 1);
            a53 = m.get(4, 2);
            a54 = m.get(4, 3);
            a55 = m.get(4, 4);
            a56 = m.get(4, 5);
            a61 = m.get(5, 0);
            a62 = m.get(5, 1);
            a63 = m.get(5, 2);
            a64 = m.get(5, 3);
            a65 = m.get(5, 4);
            a66 = m.get(5, 5);
        }
Ejemplo n.º 31
0
        public static void print(Stream output, FMatrix mat, string format)
        {
            string type = mat.GetType().Name;

            Console.WriteLine(
                "Type = " + type + " , numRows = " + mat.getNumRows() + " , numCols = " + mat.getNumCols());

            format += " ";

            for (int y = 0; y < mat.getNumRows(); y++)
            {
                for (int x = 0; x < mat.getNumCols(); x++)
                {
                    Console.Write(format, mat.get(y, x));
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Multiply the quaternion by a matrix.
        /// This matrix conversion came from
        /// http://www.m-hikari.com/ija/ija-password-2008/ija-password17-20-2008/aristidouIJA17-20-2008.pdf
        /// used for non-uniform scaling transform.
        /// </summary>
        /// <param name="q">The quaternion.</param>
        /// <param name="m">Matrix to multiply by.</param>
        /// <returns>Matrix result after multiplication.</returns>
        /// <see cref="RotateVector"/>
        public static FMatrix operator *(FQuat q, FMatrix m)
        {
            FMatrix result = default(FMatrix);
            FQuat   vt, vr;
            FQuat   inv = q.Inverse();

            for (int i = 0; i < 4; ++i)
            {
                FQuat vq = new FQuat(m[i, 0], m[i, 1], m[i, 2], m[i, 3]);
                vt           = q * vq;
                vr           = vt * inv;
                result[i, 0] = vr.X;
                result[i, 1] = vr.Y;
                result[i, 2] = vr.Z;
                result[i, 3] = vr.W;
            }
            return(result);
        }
Ejemplo n.º 33
0
        public virtual void set(Matrix original)
        {
            FMatrix m = (FMatrix)original;

            if (m.getNumCols() == 1 && m.getNumRows() == 2)
            {
                a1 = m.get(0, 0);
                a2 = m.get(1, 0);
            }
            else if (m.getNumRows() == 1 && m.getNumCols() == 2)
            {
                a1 = m.get(0, 0);
                a2 = m.get(0, 1);
            }
            else
            {
                throw new ArgumentException("Incompatible shape");
            }
        }
Ejemplo n.º 34
0
    //use node.LocalToLocal to use a point from a different coordinate space
    public void RotateAroundPointRelative(Vector2 localPoint, float relativeDegrees)
    {
        FMatrix tempMatrix = FMatrix.tempMatrix;

        tempMatrix.ResetToIdentity();
        tempMatrix.SetScaleThenRotate(0, 0, _scaleX, _scaleY, _rotation * -RXMath.DTOR);
        Vector2 firstVector = tempMatrix.GetNewTransformedVector(new Vector2(-localPoint.x, -localPoint.y));

        _rotation += relativeDegrees;

        tempMatrix.ResetToIdentity();
        tempMatrix.SetScaleThenRotate(0, 0, _scaleX, _scaleY, _rotation * -RXMath.DTOR);
        Vector2 secondVector = tempMatrix.GetNewTransformedVector(new Vector2(-localPoint.x, -localPoint.y));

        _x += secondVector.x - firstVector.x;
        _y += secondVector.y - firstVector.y;

        _isMatrixDirty = true;
    }
Ejemplo n.º 35
0
        public static void assertEquals(FMatrix A, FMatrix B, float tol)
        {
            assertShape(A, B);

            for (int i = 0; i < A.getNumRows(); i++)
            {
                for (int j = 0; j < A.getNumCols(); j++)
                {
                    float valA = A.get(i, j);
                    float valB = B.get(i, j);

                    assertTrue(!float.IsNaN(valA) && !float.IsNaN(valB),
                               "At (" + i + "," + j + ") A = " + valA + " B = " + valB);
                    assertTrue(!float.IsInfinity(valA) && !float.IsInfinity(valB),
                               "At (" + i + "," + j + ") A = " + valA + " B = " + valB);
                    assertTrue(Math.Abs(valA - valB) <= tol, "At (" + i + "," + j + ") A = " + valA + " B = " + valB);
                }
            }
        }
Ejemplo n.º 36
0
        /**
         * Generic, but slow, conversion function.
         *
         * @param input Input matrix.
         * @param output Output matrix.
         */
        public static void convert(FMatrix input, FMatrix output)
        {
            if (input.getNumRows() != output.getNumRows())
            {
                throw new ArgumentException("Number of rows do not match");
            }
            if (input.getNumCols() != output.getNumCols())
            {
                throw new ArgumentException("Number of columns do not match");
            }

            for (int i = 0; i < input.getNumRows(); i++)
            {
                for (int j = 0; j < input.getNumCols(); j++)
                {
                    output.unsafe_set(i, j, input.unsafe_get(i, j));
                }
            }
        }
Ejemplo n.º 37
0
    protected void CreateSpecialMatrices()
    {
        _needsSpecialMatrices = true;         //after now the matrices will be updated on redraw

        _inverseConcatenatedMatrix       = new FMatrix();
        _screenConcatenatedMatrix        = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();

        if (_isOnStage)
        {
            _inverseConcatenatedMatrix.InvertAndCopyValues(_concatenatedMatrix);
            _screenConcatenatedMatrix.ConcatAndCopyValues(_concatenatedMatrix, _stage.screenConcatenatedMatrix);
            _screenInverseConcatenatedMatrix.InvertAndCopyValues(_screenConcatenatedMatrix);
        }
        else
        {
            Debug.LogWarning("Futile: Warning! You're probably trying to use GlobalToLocal/LocalToLocal with an object that isn't currently part of the display list");
        }
    }
Ejemplo n.º 38
0
        public void Transform(FMatrix transform)
        {
            // Transform main polygon
            for (int i = 0; i < this.Count; i++)
                this[i] = FVector2.Transform(this[i], transform);

            // Transform holes
            FVector2[] temp = null;
            if (_holes != null && _holes.Count > 0)
            {
                for (int i = 0; i < _holes.Count; i++)
                {
                    temp = _holes[i].ToArray();
                    FVector2.Transform(temp, ref transform, temp);

                    _holes[i] = new Vertices(temp);
                }
            }
        }
Ejemplo n.º 39
0
        public override void set(Matrix original)
        {
            if (original is FMatrixRBlock)
            {
                set((FMatrixRBlock)original);
            }
            else
            {
                FMatrix m = (FMatrix)original;

                for (int i = 0; i < numRows; i++)
                {
                    for (int j = 0; j < numCols; j++)
                    {
                        set(i, j, m.get(i, j));
                    }
                }
            }
        }
Ejemplo n.º 40
0
    public FNode()
    {
        _depth = 0;

        _x = 0;
        _y = 0;
        _scaleX = 1;
        _scaleY = 1;
        _rotation = 0;

        _sortZ = 0;

        _alpha = 1.0f;
        _concatenatedAlpha = 1.0f;
        _isAlphaDirty = false;

        _matrix = new FMatrix();
        _concatenatedMatrix = new FMatrix();
        _isMatrixDirty = false;
    }
Ejemplo n.º 41
0
 public TextureConverter(uint[] data, int width, byte? alphaTolerance,
     float? hullTolerance, bool? holeDetection, bool? multipartDetection,
     bool? pixelOffsetOptimization, FMatrix? transform)
 {
     Initialize(data, width, alphaTolerance, hullTolerance, holeDetection,
         multipartDetection, pixelOffsetOptimization, transform);
 }
Ejemplo n.º 42
0
    protected void CreateSpecialMatrices()
    {
        _needsSpecialMatrices = true; //after now the matrices will be updated on redraw

        _inverseConcatenatedMatrix = new FMatrix();
        _screenConcatenatedMatrix = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();

        if(_isOnStage)
        {
            _inverseConcatenatedMatrix.InvertAndCopyValues(_concatenatedMatrix);
            _screenConcatenatedMatrix.ConcatAndCopyValues(_concatenatedMatrix,_stage.screenConcatenatedMatrix);
            _screenInverseConcatenatedMatrix.InvertAndCopyValues(_screenConcatenatedMatrix);
        }
        else
        {
            Debug.LogWarning("Futile: Warning! You're probably trying to use GlobalToLocal/LocalToLocal with an object that isn't currently part of the display list");
        }
    }
Ejemplo n.º 43
0
        private void Initialize(uint[] data, int? width, byte? alphaTolerance,
            float? hullTolerance, bool? holeDetection, bool? multipartDetection,
            bool? pixelOffsetOptimization, FMatrix? transform)
        {
            if (data != null && !width.HasValue)
                throw new ArgumentNullException("width", "'width' can't be null if 'data' is set.");

            if (data == null && width.HasValue)
                throw new ArgumentNullException("data", "'data' can't be null if 'width' is set.");

            if (data != null && width.HasValue)
                SetTextureData(data, width.Value);

            if (alphaTolerance.HasValue)
                AlphaTolerance = alphaTolerance.Value;
            else
                AlphaTolerance = 20;

            if (hullTolerance.HasValue)
                HullTolerance = hullTolerance.Value;
            else
                HullTolerance = 1.5f;

            if (holeDetection.HasValue)
                HoleDetection = holeDetection.Value;
            else
                HoleDetection = false;

            if (multipartDetection.HasValue)
                MultipartDetection = multipartDetection.Value;
            else
                MultipartDetection = false;

            if (pixelOffsetOptimization.HasValue)
                PixelOffsetOptimization = pixelOffsetOptimization.Value;
            else
                PixelOffsetOptimization = false;

            if (transform.HasValue)
                Transform = transform.Value;
            else
                Transform = FMatrix.Identity;
        }
Ejemplo n.º 44
0
    public void InvertAndCopyValues(FMatrix other)
    {
        float bottom = 1.0f/(other.a*other.d-other.b*other.c);

        a = other.d*bottom;
        b = -other.b*bottom;
        c = -other.c*bottom;
        d = other.a*bottom;
        tx = (other.c*other.ty-other.d*other.tx)*bottom;
        ty = -(other.a*other.ty-other.b*other.tx)*bottom;
    }
Ejemplo n.º 45
0
    protected void CreateSpecialMatrices()
    {
        _needsSpecialMatrices = true; //after now the matrices will be updated on redraw

        _inverseConcatenatedMatrix = new FMatrix();
        _screenConcatenatedMatrix = new FMatrix();
        _screenInverseConcatenatedMatrix = new FMatrix();

        _inverseConcatenatedMatrix.InvertAndCopyValues(_concatenatedMatrix);
        _screenConcatenatedMatrix.ConcatAndCopyValues(_concatenatedMatrix, _stage.screenConcatenatedMatrix);
        _screenInverseConcatenatedMatrix.InvertAndCopyValues(_screenConcatenatedMatrix);
    }