Пример #1
0
        private void render()
        {
            //fShader._Metallic = (Mathf.sin(time) + 1) / 2;

            context3D.setCulling(Context3DTriangleFace.BACK);
            context3D.setDepthTest(true, Context3DCompareMode.LESS);
            context3D.clear(49 / 255f, 77 / 255f, 121 / 255f);


            Matrix3D _ObjectToWorld;
            Matrix3D _WorldToObject;
            Matrix3D _MatrixV;
            Matrix3D _matrix_projection;
            Matrix3D _MatrixVP;
            Matrix3D _MatrixInvV;



            Matrix3D m = Matrix3D.Identity;

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

            Vector4 camerpos = new Vector4(0, 0, 0.5f, 1);


            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(-0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 50f);

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

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

            context3D.bindVertexBuffer(lst_vertexes[0]);
            context3D.drawTriangles(lst_indexList[0]);

            context3D.present();
        }
Пример #2
0
        private void render()
        {
            Matrix3D _ObjectToWorld;
            Matrix3D _WorldToObject;
            Matrix3D _MatrixV;
            Matrix3D _matrix_projection;
            Matrix3D _MatrixVP;
            Matrix3D _MatrixInvV;

            context3D.bindVertexBuffer(vertexes);

            context3D.setCulling(Context3DTriangleFace.NONE);
            context3D.setDepthTest(true, Context3DCompareMode.LESS);

            Matrix3D mv = new Matrix3D();

            mv.identity();


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

            float angle  = time * 3.14f / 2;
            var   camera = Matrix3D.lookAtLH(Mathf.sin(angle) * -5f + 0.5f, 2f, Mathf.cos(angle) * -5f + 0.5f,
                                             0.5f, 0.5f, 0,
                                             0, 1, 0);

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

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

            mv.append(perspective);

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

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


            context3D.clear(49 / 255f, 77 / 255f, 121 / 255f);
            context3D.drawTriangles(indexList);

            context3D.present();
        }
Пример #3
0
        private void renderMesh(Matrix3D modelmatrix)
        {
            Matrix3D _ObjectToWorld;
            Matrix3D _WorldToObject;
            Matrix3D _MatrixV;
            Matrix3D _matrix_projection;
            Matrix3D _MatrixVP;
            Matrix3D _MatrixInvV;



            Matrix3D m = Matrix3D.Identity;


            m.append(modelmatrix);

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

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

            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);



            context3D.bindVertexBuffer(lst_vertexes[0]);
            context3D.drawTriangles(lst_indexList[0]);
        }
Пример #4
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]]);
            }
        }