Exemple #1
0
        private void Render()
        {
            if (!loaded)
            {
                return;
            }

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            /*
             * GL.Color3(Color.Yellow);
             * GL.Begin(BeginMode.Triangles);
             * GL.Vertex2(10, 20);
             * GL.Vertex2(100, 20);
             * GL.Vertex2(100, 50);
             * GL.End();
             */
            OverheadCamera();
            if (playertexture == -1)
            {
                LoadPlayerTexture(MyStream.ReadAllBytes(getfile.GetFile("mineplayer.png")));
            }
            DrawGrass();
            DrawAxisLine(new Vector3(), HeadingDeg(), PitchDeg());
            GL.Enable(EnableCap.Texture2D);
            bool  exception   = false;
            byte  headingbyte = (byte)(HeadingDeg() / 360 * 256);
            byte  pitchbyte   = (byte)(PitchDeg() / 360 * 256);
            float speed       = 1.0f;

            //d.SetAnimPeriod(1.0f / (trackBar3.Value * 0.1f));
            //progressBar1.Value = (int)((animstate.GetInterp() % (d.GetAnimPeriod())) / d.GetAnimPeriod() * 100);

            try
            {
                game.GLMatrixModeModelView();
                game.GLLoadMatrix(m);
                GL.BindTexture(TextureTarget.Texture2D, playertexture);
                d.Render(dt, PitchDeg(), true, true, 1);
            }
            catch (Exception ee)
            {
                if (richTextBox2Text != ee.ToString())
                {
                    richTextBox2Text  = ee.ToString();
                    richTextBox2.Text = ee.ToString();
                }
                exception = true;
            }
            if (!exception)
            {
                richTextBox2.Text = "";
                richTextBox2Text  = "";
            }

            glControl1.SwapBuffers();
        }
Exemple #2
0
        private void Render()
        {
            if (!loaded || !modelLoaded)
            {
                // Do not update if no model is currently loaded
                return;
            }

            // Clear buffers for new frame
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // Initialize camera
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            OverheadCamera();

            // Load model texture
            if (playertexture == -1)
            {
                LoadPlayerTexture(MyStream.ReadAllBytes(getfile.GetFile("mineplayer.png")));
            }

            // Draw grass and axis lines
            DrawGrass();
            DrawAxisLine(new Vector3(), HeadingDeg(), PitchDeg());

            // Try to render the model and display errors
            GL.Enable(EnableCap.Texture2D);
            bool exception = false;

            try
            {
                game.GLMatrixModeModelView();
                game.GLLoadMatrix(m);
                GL.BindTexture(TextureTarget.Texture2D, playertexture);
                game.GLRotate(HeadingDeg(), 0, 1, 0);
                d.Render(dt, PitchDeg(), 1);
            }
            catch (Exception ee)
            {
                if (richTextBox2Text != ee.ToString())
                {
                    richTextBox2Text  = ee.ToString();
                    richTextBox2.Text = ee.ToString();
                }
                exception = true;
            }
            if (!exception)
            {
                richTextBox2.Text  = "";
                richTextBox2Text   = "";
                progressBar1.Value = (int)((d.GetAnimationFrame() / d.GetAnimationLength()) * progressBar1.Maximum);
            }

            // Swap buffers to draw changes
            glControl1.SwapBuffers();
        }
Exemple #3
0
        private void Render()
        {
            if (!loaded)
            {
                return;
            }

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            /*
             * GL.Color3(Color.Yellow);
             * GL.Begin(BeginMode.Triangles);
             * GL.Vertex2(10, 20);
             * GL.Vertex2(100, 20);
             * GL.Vertex2(100, 50);
             * GL.End();
             */
            OverheadCamera();
            if (playertexture == -1)
            {
                LoadPlayerTexture(MyStream.ReadAllBytes(getfile.GetFile("mineplayer.png")));
            }
            DrawGrass();
            DrawAxisLine(new Vector3(), HeadingDeg(), PitchDeg());
            GL.Enable(EnableCap.Texture2D);
            bool exception   = false;
            byte headingbyte = (byte)(HeadingDeg() / 360 * 256);
            byte pitchbyte   = (byte)(PitchDeg() / 360 * 256);

            d.AnimPeriod       = 1.0 / (trackBar3.Value * 0.1);
            progressBar1.Value = (int)((animstate.interp % (d.AnimPeriod)) / d.AnimPeriod * 100);
            try
            {
                d.DrawCharacter(animstate, new OpenTK.Vector3(0, 0, 0),
                                headingbyte, pitchbyte, true, dt, playertexture, new AnimationHint());
            }
            catch (Exception ee)
            {
                if (richTextBox2Text != ee.ToString())
                {
                    richTextBox2Text  = ee.ToString();
                    richTextBox2.Text = ee.ToString();
                }
                exception = true;
            }
            if (!exception)
            {
                richTextBox2.Text = "";
                richTextBox2Text  = "";
            }

            glControl1.SwapBuffers();
        }