Example #1
0
        private void renderMesh(Assimp.Matrix4x4 matrix, List <int> meshindices)
        {
            Matrix3D _ObjectToWorld;
            Matrix3D _WorldToObject;
            Matrix3D _MatrixV;
            Matrix3D _matrix_projection;
            Matrix3D _MatrixVP;
            Matrix3D _MatrixInvV;



            Matrix3D m = Matrix3D.Identity;

            Matrix3D mt = new Matrix3D(

                matrix[1, 1], matrix[1, 2], matrix[1, 3], matrix[1, 4],
                matrix[2, 1], matrix[2, 2], matrix[2, 3], matrix[2, 4],
                matrix[3, 1], matrix[3, 2], matrix[3, 3], matrix[3, 4],
                matrix[4, 1], matrix[4, 2], matrix[4, 3], matrix[4, 4]
                );

            //mt.transpose();
            //m.append(mt);


            //time = 0.096f;

            float angle = time * 3.14f / 2;

            //angle = 0.32656005f;

            //m.appendRotation(angle, Vector3.X_AXIS);
            m.appendRotation(angle, Vector3.Y_AXIS);
            //m.appendScale(Mathf.sin(1), 1, 2);


            _ObjectToWorld = m;
            _WorldToObject = m.getInvert();

            Vector4 camerpos = new Vector4(0, 0, -3.3f, 1);

            Matrix3D mcamera = Matrix3D.Identity.appendRotation(angle, Vector3.Y_AXIS);
            //camerpos = camerpos * mcamera;


            var camera = Matrix3D.lookAtLH(camerpos.x, camerpos.y, camerpos.z,
                                           0f, 0f, 0,
                                           0, 1, 0);

            _MatrixV    = camera;
            _MatrixInvV = _MatrixV.getInvert();

            var perspective = Matrix3D.perspectiveOffCenterLH(-1, 1, -1.0f * 600 / 800, 1.0f * 600 / 800, 2f, 50f);

            _matrix_projection = perspective;
            _MatrixVP          = _MatrixV.append(perspective);

            context3D.setProgramConstants_Matrices(_ObjectToWorld, _WorldToObject, camera, _matrix_projection, _MatrixVP, _MatrixInvV, true);
            context3D.setProgramVariables(camerpos);



            for (int i = 0; i < meshindices.Count; i++)
            {
                context3D.bindVertexBuffer(lst_vertexes[meshindices[i]]);
                context3D.drawTriangles(lst_indexList[meshindices[i]]);
            }
        }