Exemplo n.º 1
0
        /// <summary>
        /// Arranca a ejecutar un ejemplo.
        /// Para el ejemplo anterior, si hay alguno.
        /// </summary>
        /// <param name="example"></param>
        internal void executeExample(TgcExample example)
        {
            stopCurrentExample();
            userVars.clearVars();
            modifiers.clear();
            resetDefaultConfig();
            fpsCamera.resetValues();
            rotCamera.resetValues();
            thirdPersonCamera.resetValues();

            //Ejecutar init
            try
            {
                example.init();

                //Ver si abrimos una ventana para modo FullScreen
                if (FullScreenEnable)
                {
                    mainForm.removePanel3dFromMainForm();
                    fullScreenPanel.Controls.Add(panel3d);
                    fullScreenPanel.Show(mainForm);
                }

                this.currentExample = example;
                panel3d.Focus();
                mainForm.setCurrentExampleStatus("Ejemplo actual: " + example.getName());
                Logger.log("Ejecutando ejemplo: " + example.getName(), Color.Blue);
            }
            catch (Exception e)
            {
                Logger.logError("Error en init() de ejemplo: " + example.getName(), e);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Termina y vuelve a empezar el ejemplo actual, si hay alguno ejecutando.
 /// </summary>
 internal void resetCurrentExample()
 {
     if (currentExample != null)
     {
         TgcExample exampleBackup = currentExample;
         stopCurrentExample();
         executeExample(exampleBackup);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Crea todos los modulos necesarios de la aplicacion
        /// </summary>
        internal void initGraphics(MainForm mainForm, Control panel3d)
        {
            this.mainForm        = mainForm;
            this.panel3d         = panel3d;
            this.fullScreenPanel = new FullScreenPanel();
            panel3d.Focus();

            //Iniciar graficos
            this.tgcD3dDevice    = new TgcD3dDevice(panel3d);
            this.texturesManager = new TgcTexture.Manager();
            this.tgcD3dDevice.OnResetDevice(tgcD3dDevice.D3dDevice, null);

            //Iniciar otras herramientas
            this.texturesPool      = new TgcTexture.Pool();
            this.logger            = new Logger(mainForm.LogConsole);
            this.text3d            = new TgcDrawText(tgcD3dDevice.D3dDevice);
            this.tgcD3dInput       = new TgcD3dInput(mainForm, panel3d);
            this.fpsCamera         = new TgcFpsCamera();
            this.rotCamera         = new TgcRotationalCamera();
            this.thirdPersonCamera = new TgcThirdPersonCamera();
            this.axisLines         = new TgcAxisLines(tgcD3dDevice.D3dDevice);
            this.userVars          = new TgcUserVars(mainForm.getDataGridUserVars());
            this.modifiers         = new TgcModifiers(mainForm.getModifiersPanel());
            this.elapsedTime       = -1;
            this.frustum           = new TgcFrustum();
            this.mp3Player         = new TgcMp3Player();
            this.directSound       = new TgcDirectSound();
            this.fog                 = new TgcFog();
            this.currentCamera       = this.rotCamera;
            this.customRenderEnabled = false;
            this.drawer2D            = new TgcDrawer2D();
            this.shaders             = new TgcShaders();

            //toogles
            this.rotCamera.Enable         = true;
            this.fpsCamera.Enable         = false;
            this.thirdPersonCamera.Enable = false;
            this.fpsCounterEnable         = true;
            this.axisLines.Enable         = true;

            //Cargar algoritmos
            exampleLoader          = new ExampleLoader();
            examplesDir            = System.Environment.CurrentDirectory + "\\" + ExampleLoader.EXAMPLES_DIR + "\\";
            examplesMediaDir       = examplesDir + "Media" + "\\";
            alumnoEjemplosDir      = System.Environment.CurrentDirectory + "\\" + "AlumnoEjemplos" + "\\";
            alumnoEjemplosMediaDir = alumnoEjemplosDir + "AlumnoMedia" + "\\";
            exampleLoader.loadExamplesInGui(mainForm.TreeViewExamples, new string[] { examplesDir, alumnoEjemplosDir });

            //Cargar shaders del framework
            this.shaders.loadCommonShaders();

            //Cargar ejemplo default
            TgcExample defaultExample = exampleLoader.getExampleByName(mainForm.Config.defaultExampleName, mainForm.Config.defaultExampleCategory);

            executeExample(defaultExample);
        }
Exemplo n.º 4
0
        private void ExecuteExample(TgcExample example)
        {
            Modelo.ExecuteExample(example);
            ContadorFPS();
            AxisLines();
            Wireframe();

            toolStripStatusCurrentExample.Text = "Ejemplo actual: " + example.Name;
            panel3D.Focus();
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Arranca a ejecutar un ejemplo.
        ///  Para el ejemplo anterior, si hay alguno.
        /// </summary>
        /// <param name="example"></param>
        public void ExecuteExample(TgcExample example)
        {
            StopCurrentExample();

            //Ejecutar Init
            ExampleLoader.CurrentExample = example;
            //TODO esto no me cierra mucho OnResetDevice
            OnResetDevice(D3DDevice.Instance.Device, null);
            example.ResetDefaultConfig();
            example.DirectSound = DirectSound;
            example.Input       = Input;
            example.Init();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Cuando el Direct3D Device se resetea.
        /// Se reinica el ejemplo actual, si hay alguno.
        /// </summary>
        internal void onResetDevice()
        {
            TgcExample exampleBackup = currentExample;

            if (exampleBackup != null)
            {
                stopCurrentExample();
            }
            tgcD3dDevice.doResetDevice();
            if (exampleBackup != null)
            {
                executeExample(exampleBackup);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Deja de ejecutar el ejemplo actual
        /// </summary>
        internal void stopCurrentExample()
        {
            if (currentExample != null)
            {
                currentExample.close();
                tgcD3dDevice.resetWorldTransofrm();
                Logger.log("Ejemplo " + currentExample.getName() + " terminado");
                currentExample = null;
                elapsedTime    = -1;

                if (FullScreenEnable && fullScreenPanel.Visible)
                {
                    closeFullScreenPanel();
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Arranca a ejecutar un ejemplo.
        ///     Para el ejemplo anterior, si hay alguno.
        /// </summary>
        /// <param name="example"></param>
        public void ExecuteExample(TgcExample example)
        {
            StopCurrentExample();

            //Ejecutar Init
            try
            {
                example.ResetDefaultConfig();
                example.Init();
                ExampleLoader.CurrentExample = example;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error en Init() de ejemplo: " + example.Name, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Ejecuta un ejemplo particular.
        /// </summary>
        /// <param name="example">Ejemplo a ejecutar.</param>
        private void ExecuteExample(TgcExample example)
        {
            try
            {
                Model.ExecuteExample(example);
                ContadorFPS();
                AxisLines();
                Wireframe();

                toolStripStatusCurrentExample.Text = "Ejemplo actual: " + example.Name;
                panel3D.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "No se pudo cargar el ejemplo " + example.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);

                Model.ClearCurrentExample();
            }
        }
Exemplo n.º 10
0
        private void ExecuteExample(TgcExample example)
        {
            try
            {
                Modelo.ExecuteExample(example);
                ContadorFPS();
                AxisLines();
                Wireframe();

                toolStripStatusCurrentExample.Text = "Ejemplo actual: " + example.Name;
                panel3D.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "No se pudo cargar el ejemplo " + example.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);

                //TODO mejorar esta llamada con un metodo de model
                Modelo.ExampleLoader.CurrentExample = null;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Cuando se selecciona un ejemplo para ejecutar del TreeNode
        /// </summary>
        internal void executeSelectedExample(TreeNode treeNode, bool fullScreenEnable)
        {
            TgcExample example = exampleLoader.getExampleByTreeNode(treeNode);

            executeExample(example);
        }