Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            ColladaXML daeReader = new ColladaXML("collada_schema_1_4.xsd");
            Console.WriteLine("Parsing File...");
            daeReader.Parse(Paths.ModelPath + "face.dae");
            mesh = daeReader.Mesh.Elements[2];
            mesh.CreateGPUBuffers();
            GL.ClearColor(Color4.Wheat);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Lequal);
            GL.CullFace(CullFaceMode.Back);
            shader = new Shader("hello-gl.v.glsl", "hello-gl.f.glsl");

            GL.GenBuffers(1, out buf);
            GL.BindBuffer(BufferTarget.ArrayBuffer, buf);
            GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(mesh.VertexBuffer.Length * sizeof(float)), mesh.VertexBuffer, BufferUsageHint.StaticDraw);
            GL.GenBuffers(2, out buf2);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf2);
            GL.BufferData(BufferTarget.ElementArrayBuffer, new IntPtr(mesh.IndexBuffer.Length * sizeof(ushort)), mesh.IndexBuffer, BufferUsageHint.StaticDraw);

            CreateShaders();
            mouseX = X + (Width / 2);
            mouseY = Y + (Height / 2);

            CursorVisible = false;

            OpenTK.Input.Mouse.SetPosition((double)mouseX, (double)mouseY);
            lastState = OpenTK.Input.Mouse.GetState();

            CursorVisible = false;
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
            base.OnLoad (e);
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            ColladaXML daeReader = new ColladaXML("collada_schema_1_4.xsd");
            Console.WriteLine("Parsing File...");
            daeReader.Parse(Paths.ModelPath + "texobj.dae");
            mesh = daeReader.Mesh.Elements[0];
            mesh.Optimise(new NormalSmoother());
            mesh.CreateGPUBuffers();
            GL.ClearColor(OpenTK.Graphics.Color4.Wheat);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Lequal);
            GL.CullFace(CullFaceMode.Back);
            shader = new Shader("test.v.glsl", "test.f.glsl");
            lineDrawer = new Shader("linedrawer.v.glsl", "linedrawer.f.glsl");

            /*
            GL.GenBuffers(1, out buf);
            GL.BindBuffer(BufferTarget.ArrayBuffer, buf);
            GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(mesh.VertexBuffer.Length * sizeof(float)), mesh.VertexBuffer, BufferUsageHint.StaticDraw);
            GL.GenBuffers(2, out buf2);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf2);
            GL.BufferData(BufferTarget.ElementArrayBuffer, new IntPtr(mesh.IndexBuffer.Length * sizeof(ushort)), mesh.IndexBuffer, BufferUsageHint.StaticDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
            */
            CreateShaders();
            mouseX = X + (Width / 2);
            mouseY = Y + (Height / 2);

            CursorVisible = false;

            OpenTK.Input.Mouse.SetPosition((double)mouseX, (double)mouseY);
            lastState = OpenTK.Input.Mouse.GetState();

            CursorVisible = false;
            GenerateDebugBuffer("NORMAL");
            cubetex = new Texture("test.png");
            cubenorm = new Texture("testN.png");
            megamanTex = new Texture("megamansheet.png");
            animator = new Animator();
            Animation animation = new Animation();
            animation.speed = 10.0d;

            animation.Add(20, 60, 40, 50);
            animation.Add(60, 60, 40, 50);
            animation.Add(100, 60, 40, 50);
            animation.Add(140, 60, 40, 50);
            animation.Add(180, 60, 40, 50);
            animation.Add(220, 60, 40, 50);

            animator.AddAnimation("default", animation);

            base.OnLoad (e);
        }