Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
0
        private void render()
        {
            //fShader._Metallic = (Mathf.sin(time) + 1) / 2;

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


            Stack <Assimp.Node> nodes = new Stack <Assimp.Node>();

            nodes.Push(scene.RootNode);

            Dictionary <Assimp.Node, Assimp.Matrix4x4> dictNodeM = new Dictionary <Assimp.Node, Assimp.Matrix4x4>();

            dictNodeM.Add(scene.RootNode, scene.RootNode.Transform);

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

            while (nodes.Count > 0)
            {
                var n = nodes.Pop();
                for (int i = 0; i < n.ChildCount; i++)
                {
                    nodes.Push(n.Children[i]);
                    dictNodeM.Add(n.Children[i], dictNodeM[n] * n.Children[i].Transform);
                }

                //if (n.Name.IndexOf("LOD") > 0 && !n.Name.EndsWith("3"))
                //{

                //}
                //else
                if (n.MeshIndices.Count > 0)
                {
                    var m = dictNodeM[n];
                    renderMesh(m, n.MeshIndices);
                }
            }



            context3D.present();
        }
Exemplo n.º 4
0
        private void render()
        {
            //fShader._Metallic = (Mathf.sin(time) + 1) / 2;

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


            Stack <Assimp.Node> nodes = new Stack <Assimp.Node>();

            nodes.Push(scene.RootNode);

            Dictionary <Assimp.Node, Assimp.Matrix4x4> dictNodeM = new Dictionary <Assimp.Node, Assimp.Matrix4x4>();

            dictNodeM.Add(scene.RootNode, scene.RootNode.Transform);

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


            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    var m = Matrix3D.Identity;

                    m.appendScale(0.5f, 0.5f, 0.5f);

                    m.appendTranslation((i - 5) * 0.6f, (j - 5) * 0.6f, 0);

                    fShader.Roughness = 1 - i * 1.0f / 10;
                    fShader._Metallic = 1 - j * 1.0f / 10;

                    renderMesh(m);
                }
            }



            context3D.present();
        }