Exemple #1
0
        public Matrix4 Copy()
        {
            Matrix4 m = new Matrix4();
            m.M11 = this.M11;
            m.M12 = this.M12;
            m.M13 = this.M13;
            m.M14 = this.M14;

            m.M21 = this.M21;
            m.M22 = this.M22;
            m.M23 = this.M23;
            m.M24 = this.M24;

            m.M31 = this.M31;
            m.M32 = this.M32;
            m.M33 = this.M33;
            m.M34 = this.M34;

            m.M41 = this.M41;
            m.M42 = this.M42;
            m.M43 = this.M43;
            m.M44 = this.M44;

            return m;
        }
Exemple #2
0
        public Matrix4 GetInverse()
        {
            /// Calculates the inverse of this Matrix
            /// The inverse is calculated using Cramers rule.
            /// If no inverse exists then 'false' is returned.
            float d = (M11 * M22 - M21 * M12) * (M33 * M44 - M43 * M34)	- (M11 * M32 - M31 * M12) * (M23 * M44 - M43 * M24)
                + (M11 * M42 - M41 * M12) * (M23 * M34 - M33 * M24)	+ (M21 * M32 - M31 * M22) * (M13 * M44 - M43 * M14)
                - (M21 * M42 - M41 * M22) * (M13 * M34 - M33 * M14)	+ (M31 * M42 - M41 * M32) * (M13 * M24 - M23 * M14);

            if (d == 0)
                return null;

            Matrix4 mNew = new Matrix4();
            d = 1f / d;

            mNew.M11 = d * (M22 * (M33 * M44 - M43 * M34) + M32 * (M43 * M24 - M23 * M44) + M42 * (M23 * M34 - M33 * M24));
            mNew.M21 = d * (M23 * (M31 * M44 - M41 * M34) + M33 * (M41 * M24 - M21 * M44) + M43 * (M21 * M34 - M31 * M24));
            mNew.M31 = d * (M24 * (M31 * M42 - M41 * M32) + M34 * (M41 * M22 - M21 * M42) + M44 * (M21 * M32 - M31 * M22));
            mNew.M41 = d * (M21 * (M42 * M33 - M32 * M43) + M31 * (M22 * M43 - M42 * M23) + M41 * (M32 * M23 - M22 * M33));
            mNew.M12 = d * (M32 * (M13 * M44 - M43 * M14) + M42 * (M33 * M14 - M13 * M34) + M12 * (M43 * M34 - M33 * M44));
            mNew.M22 = d * (M33 * (M11 * M44 - M41 * M14) + M43 * (M31 * M14 - M11 * M34) + M13 * (M41 * M34 - M31 * M44));
            mNew.M32 = d * (M34 * (M11 * M42 - M41 * M12) + M44 * (M31 * M12 - M11 * M32) + M14 * (M41 * M32 - M31 * M42));
            mNew.M42 = d * (M31 * (M42 * M13 - M12 * M43) + M41 * (M12 * M33 - M32 * M13) + M11 * (M32 * M43 - M42 * M33));
            mNew.M13 = d * (M42 * (M13 * M24 - M23 * M14) + M12 * (M23 * M44 - M43 * M24) + M22 * (M43 * M14 - M13 * M44));
            mNew.M23 = d * (M43 * (M11 * M24 - M21 * M14) + M13 * (M21 * M44 - M41 * M24) + M23 * (M41 * M14 - M11 * M44));
            mNew.M33 = d * (M44 * (M11 * M22 - M21 * M12) + M14 * (M21 * M42 - M41 * M22) + M24 * (M41 * M12 - M11 * M42));
            mNew.M43 = d * (M41 * (M22 * M13 - M12 * M23) + M11 * (M42 * M23 - M22 * M43) + M21 * (M12 * M43 - M42 * M13));
            mNew.M14 = d * (M12 * (M33 * M24 - M23 * M34) + M22 * (M13 * M34 - M33 * M14) + M32 * (M23 * M14 - M13 * M24));
            mNew.M24 = d * (M13 * (M31 * M24 - M21 * M34) + M23 * (M11 * M34 - M31 * M14) + M33 * (M21 * M14 - M11 * M24));
            mNew.M34 = d * (M14 * (M31 * M22 - M21 * M32) + M24 * (M11 * M32 - M31 * M12) + M34 * (M21 * M12 - M11 * M22));
            mNew.M44 = d * (M11 * (M22 * M33 - M32 * M23) + M21 * (M32 * M13 - M12 * M33) + M31 * (M12 * M23 - M22 * M13));

            return mNew;
        }
Exemple #3
0
        public static Matrix4 FromString(string val)
        {
            string[] vals = val.Split(';');
            Matrix4 m = new Matrix4();
            m.M11 = Convert.ToSingle(vals[0]);
            m.M12 = Convert.ToSingle(vals[1]);
            m.M13 = Convert.ToSingle(vals[2]);
            m.M14 = Convert.ToSingle(vals[3]);

            m.M21 = Convert.ToSingle(vals[4]);
            m.M22 = Convert.ToSingle(vals[5]);
            m.M23 = Convert.ToSingle(vals[6]);
            m.M24 = Convert.ToSingle(vals[7]);

            m.M31 = Convert.ToSingle(vals[8]);
            m.M32 = Convert.ToSingle(vals[9]);
            m.M33 = Convert.ToSingle(vals[10]);
            m.M34 = Convert.ToSingle(vals[11]);

            m.M41 = Convert.ToSingle(vals[12]);
            m.M42 = Convert.ToSingle(vals[13]);
            m.M43 = Convert.ToSingle(vals[14]);
            m.M44 = Convert.ToSingle(vals[15]);

            return m;
        }
Exemple #4
0
 public static Matrix4 operator +(Matrix4 m1, Matrix4 m2)
 {
     Matrix4 mNew = new Matrix4();
     mNew.M11 = m1.M11 + m2.M11;
     mNew.M12 = m1.M12 + m2.M12;
     mNew.M13 = m1.M13 + m2.M13;
     mNew.M14 = m1.M14 + m2.M14;
     mNew.M21 = m1.M21 + m2.M21;
     mNew.M22 = m1.M22 + m2.M22;
     mNew.M23 = m1.M23 + m2.M23;
     mNew.M24 = m1.M24 + m2.M24;
     mNew.M31 = m1.M31 + m2.M31;
     mNew.M32 = m1.M32 + m2.M32;
     mNew.M33 = m1.M33 + m2.M33;
     mNew.M34 = m1.M34 + m2.M34;
     mNew.M41 = m1.M41 + m2.M41;
     mNew.M42 = m1.M42 + m2.M42;
     mNew.M43 = m1.M43 + m2.M43;
     mNew.M44 = m1.M44 + m2.M44;
     return mNew;
 }
Exemple #5
0
        public static Matrix4 operator *(Matrix4 m1, Matrix4 m2)
        {
            Matrix4 mNew = new Matrix4();

            mNew.M11 = m1.M11*m2.M11 + m1.M21*m2.M12 + m1.M31*m2.M13 + m1.M41*m2.M14;
            mNew.M12 = m1.M12*m2.M11 + m1.M22*m2.M12 + m1.M32*m2.M13 + m1.M42*m2.M14;
            mNew.M13 = m1.M13*m2.M11 + m1.M23*m2.M12 + m1.M33*m2.M13 + m1.M43*m2.M14;
            mNew.M14 = m1.M14*m2.M11 + m1.M24*m2.M12 + m1.M34*m2.M13 + m1.M44*m2.M14;

            mNew.M21 = m1.M11*m2.M21 + m1.M21*m2.M22 + m1.M31*m2.M23 + m1.M41*m2.M24;
            mNew.M22 = m1.M12*m2.M21 + m1.M22*m2.M22 + m1.M32*m2.M23 + m1.M42*m2.M24;
            mNew.M23 = m1.M13*m2.M21 + m1.M23*m2.M22 + m1.M33*m2.M23 + m1.M43*m2.M24;
            mNew.M24 = m1.M14*m2.M21 + m1.M24*m2.M22 + m1.M34*m2.M23 + m1.M44*m2.M24;

            mNew.M31 = m1.M11*m2.M31 + m1.M21*m2.M32 + m1.M31*m2.M33 + m1.M41*m2.M34;
            mNew.M32 = m1.M12*m2.M31 + m1.M22*m2.M32 + m1.M32*m2.M33 + m1.M42*m2.M34;
            mNew.M33 = m1.M13*m2.M31 + m1.M23*m2.M32 + m1.M33*m2.M33 + m1.M43*m2.M34;
            mNew.M34 = m1.M14*m2.M31 + m1.M24*m2.M32 + m1.M34*m2.M33 + m1.M44*m2.M34;

            mNew.M41 = m1.M11*m2.M41 + m1.M21*m2.M42 + m1.M31*m2.M43 + m1.M41*m2.M44;
            mNew.M42 = m1.M12*m2.M41 + m1.M22*m2.M42 + m1.M32*m2.M43 + m1.M42*m2.M44;
            mNew.M43 = m1.M13*m2.M41 + m1.M23*m2.M42 + m1.M33*m2.M43 + m1.M43*m2.M44;
            mNew.M44 = m1.M14*m2.M41 + m1.M24*m2.M42 + m1.M34*m2.M43 + m1.M44*m2.M44;

            return mNew;
        }
Exemple #6
0
 public void Unproject(object viewport, Matrix4 projection, Matrix4 view, Matrix4 world)
 {
 }
Exemple #7
0
        private void Init(bool bAutoSetParent)
        {
            m_aChildrenToRemove = new ArrayList();
            m_plChildrenByHash = new Hashtable();
            this._slChildrenLocZSorted = new SortedFloatList();

            m_sID = "";
            m_nInk = (int)RasterOps.ROPs.Copy;
            m_nBlend = 255;

            m_matrix = new Matrix4();
            m_vPivot = new Vector3();

            m_fLocZ = 0.0f;
            m_pntLoc = new EPointF(0.0f, 0.0f);
            m_pntScale = new EPointF(1.0f, 1.0f);
            m_pntRegPoint = new EPoint(0,0);

            m_rctSrcClip = new ERectangle(0,0,1,1);
            m_clr = Color.White;
            m_rctDstParent = new ERectangleF(0,0,0,0);

            m_aBehaviors = new ArrayList();

            m_nMemberAnimFrame = 0;

            m_dtChildren = new DataTable();
            m_dtChildren.Columns.Add("Name", typeof(System.String));
            m_dtChildren.Columns.Add("LocZ", typeof(System.Double));
            m_dtChildren.Columns.Add("Hash", typeof(System.Int32));

            m_pntMouseDown = new EPoint();
            m_pntMouseLast = new EPoint();
            _pntMouse = new EPoint();

            if (bAutoSetParent && m_endogine!=null && m_endogine.Stage != null)
                Parent = m_endogine.Stage.DefaultParent;

            m_renderStrategy = m_endogine.Stage.CreateRenderStrategy();

            m_renderStrategy.SetEndogine(m_endogine);
            m_renderStrategy.SetSprite(this);
            m_renderStrategy.Init();

            //TODO: make this optional (takes some resources)
            Sprite[] lcs = new Sprite[1];
            lcs[0] = this;
            EH.Instance.LatestCreatedSprites = lcs;
        }