Example #1
0
        public override void OnRenderFrame(OpenTK.RenderFrameEventArgs e)
        {
            foreach (Camara camara in Component.AllComponentsOfType(typeof(Camara)))
            {
                if (camara.Enabled)
                {
                    Matrix4 matCamara = Matrix4.Invert(camara.Transformation.GlobalMatrix);
                    render.SetCamara(matCamara);
                    break;
                }
            }

            render.BeginDraw();

            render.ResetAllLights();

            scene.Render(render);

            render.EndDraw();

            SwapBuffers();
        }
Example #2
0
        private void VistaEscena_Paint(object sender, PaintEventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            if (IsDisposed)
            {
                return;
            }

            insidePaint++;

            try
            {
                MakeCurrent();

                scene.MakeCurrent();

                long ahora = DateTime.Now.Ticks;

                if (selectedEntity != null && selectedEntity.Destroyed)
                {
                    SelectedEntity = null;
                }

                if (ticksUltimoPaint != 0)
                {
                    deltaTime = (float)((double)(ahora - ticksUltimoPaint) / (double)10000000);

                    if (!editMode)
                    {
                        foreach (Camara camara in Component.AllComponentsOfType(typeof(Camara)))
                        {
                            if (camara.Enabled)
                            {
                                render.SetCamara(Matrix4.Invert(camara.Transformation.GlobalMatrix));
                                break;
                            }
                        }
                    }

                    render.BeginDraw();

                    try
                    {
                        try
                        {
                            RenderComponentes();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteError("Render Error: " + ex.ToString());
                        }

                        RenderHelpers(false);
                    }
                    finally
                    {
                        render.EndDraw();

                        SwapBuffers();
                    }

                    if (insidePaint == 1 && editMode == false && pausa == false)
                    {
                        try
                        {
                            scene.Update(deltaTime);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteError("Update Error: " + ex.ToString());
                        }
                    }
                }

                ticksUltimoPaint = ahora;

                MoverCamara();

                MoverObjeto();

                if (insidePaint == 1)
                {
                    EsperaFrame();
                }
            }
            finally
            {
                insidePaint--;
            }
        }