Exemplo n.º 1
0
        public void Save()
        {
            B = new VAO(Vertexes.Count);
            P = new Vector3[Vertexes.Count];
            N = new Vector3[Vertexes.Count];
            C = new Color4[Vertexes.Count];
            T = new Vector2[Vertexes.Count];
            for (int i = 0; i < Vertexes.Count; i++)
            {
                P[i] = Vertexes[i].Position;
                N[i] = Vertexes[i].Normal;

                C[i].R = Vertexes[i].Color.R * Defuse.R;
                C[i].G = Vertexes[i].Color.G * Defuse.G;
                C[i].B = Vertexes[i].Color.B * Defuse.B;
                C[i].A = Vertexes[i].Color.A * Defuse.A;

                T[i] = Vertexes[i].TextureCoords;
            }
            if (AutoNormal)
            {
                for (int i = 0; i < Vertexes.Count; i = i + 3)
                {
                    Vector3 n = EG.GetTriangleNormal(P[i], P[i + 1], P[i + 2]);
                    n.Normalize();
                    N[i]     = n;
                    N[i + 1] = n;
                    N[i + 2] = n;
                }
            }



            BP = new VBO();
            BP.SetData(P);
            B.AttachVBO(0, BP, 3, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);

            BN = new VBO();
            BN.SetData(N);
            B.AttachVBO(1, BN, 3, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);

            BC = new VBO();
            BC.SetData(C);
            B.AttachVBO(2, BC, 4, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);

            BT = new VBO();
            BT.SetData(T);
            B.AttachVBO(3, BT, 2, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);
        }
Exemplo n.º 2
0
        public static void Init()
        {
            NotDefultProgram = null;
            BaseShader       = ShaderProgram.FromSrcDir("basic");
            ViewLoc          = BaseShader.GetUniformLocation("View");
            BiasLoc          = BaseShader.GetUniformLocation("Bias");
            ModelLoc         = BaseShader.GetUniformLocation("Model");
            ProjectionLoc    = BaseShader.GetUniformLocation("Projection");
            TextureLoc       = BaseShader.GetUniformLocation("Texture");
            CAmbientLoc      = BaseShader.GetUniformLocation("CAmbient");
            CSpecularLoc     = BaseShader.GetUniformLocation("CSpecular");
            LPosLoc          = BaseShader.GetUniformLocation("LPos");
            LEnableLoc       = BaseShader.GetUniformLocation("LEnable");

            ShadowMapLoc = BaseShader.GetUniformLocation("ShadowMap");

            LPos      = new Vector3(0f, 5f, 0f);
            CAmbient  = new Vector4(0.1f, 0.1f, 0.1f, 1f);
            CSpecular = new Vector4(1f, 1f, 1f, 1f);



            B  = new VAO(4);
            BP = new VBO();
            BP.SetData(P);
            B.AttachVBO(0, BP, 3, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);

            BN = new VBO();
            BN.SetData(N);
            B.AttachVBO(1, BN, 3, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);

            BC = new VBO();
            BC.SetData(C);
            B.AttachVBO(2, BC, 4, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);

            BT = new VBO();
            BT.SetData(T);
            B.AttachVBO(3, BT, 2, OpenTK.Graphics.OpenGL4.VertexAttribPointerType.Float, 0);
        }