Пример #1
0
        public static OpenTK.Matrix3 ToGL(this Assimp.Matrix3x3 matrix)
        {
            var m = matrix;

            m.Transpose();
            return(new OpenTK.Matrix3(m.A1, m.A2, m.A3, m.B1, m.B2, m.B3, m.C1, m.C2, m.C3));
        }
Пример #2
0
        private static Matrix toDXMat(Assimp.Matrix3x3 mat)
        {
            //scaling is
            //M11, M22, M33

            //translation is
            //M41, M42, M43


            Matrix m = new Matrix();

            m.M11 = mat.A1;
            m.M12 = mat.A2;
            m.M13 = mat.A3;
            //m.M14 = 1;// mat.A4;

            m.M21 = mat.B1;
            m.M22 = mat.B2;
            m.M23 = mat.B3;
            // m.M24 = 1;// mat.B4;

            m.M31 = mat.C1;
            m.M32 = mat.C2;
            m.M33 = mat.C3;
            // m.M34 = 1;// mat.C4;

            /// m.M41 = 1;// mat.D1;
            //m.M42 = 1;//mat.D2;
            // m.M43 = 1;//mat.D3;
            // m.M44 = 1;//mat.D4;

            if (m.M11 == 0)
            {
                m.M11 = 1;
            }
            if (m.M22 == 0)
            {
                m.M22 = 1;
            }
            if (m.M33 == 0)
            {
                m.M33 = 1;
            }

            return(m);
        }
Пример #3
0
        /// <summary>
        /// Get an Assimp matrix for the mesh of a rendermesh.
        /// This is an approximation of the logic applied by the 
        ///  game to scaling the model using the assigned node.
        /// </summary>
        public static Assimp.Matrix4x4 getMatForMesh(RenderModel model, Mesh mesh)
        {
            var rot_mat = Assimp.Matrix3x3.Identity;
            int node_idx = mesh.RigidNodeIndex;
            if (node_idx < 0) {
                node_idx = 0;
            }
            if (node_idx < model.Nodes.Count)
            {
                float s = model.Nodes[node_idx].DefaultScale;
                RenderModel.Node node = model.Nodes[node_idx];
                rot_mat = new Assimp.Matrix3x3(node.InverseForward.X *s , node.InverseForward.Y * s, node.InverseForward.Z*s,
                                                    node.InverseLeft.X*s, node.InverseLeft.Y*s, node.InverseLeft.Z*s,
                                                    node.InverseUp.X*s, node.InverseUp.Y*s, node.InverseUp.Z*s);
                //Console.WriteLine("Loaded matrix: {0}", rot_mat);

            }

            var matrix_local = new Assimp.Matrix4x4(rot_mat);
            return matrix_local;
        }
Пример #4
0
 public static LDDModder.Simple3D.Matrix3 ToLDD(this Assimp.Matrix3x3 matrix)
 {
     return(ToLDD(matrix.ToGL()));
 }