コード例 #1
0
        public override void init()
        {
            //Device de DirectX para crear primitivas
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Carpeta de archivos Media del alumno
            string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosMediaDir;
            //Creacion de una esfera
            string         sphere = GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml";
            TgcSceneLoader loader = new TgcSceneLoader();

            Universo = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Universo\\Universo-TgcScene.xml");

            //Cargado texturas para nave

            //TgcScene modeloNaveEnemiga = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-Speeder\\StarWars-Speeder-TgcScene.xml");
            TgcScene modeloNaveEnemiga = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\AvionCaza\\AvionCaza-TgcScene.xml");
            TgcScene modelosDeNaves    = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\AvionCaza\\AvionCaza-TgcScene.xml");

            nave.Iniciar(modelosDeNaves);

            NaveEnemiga1.Iniciar(modeloNaveEnemiga, nave.Modelo.Position);
            //Cargado de textura para el sol
            sol = loader.loadSceneFromFile(sphere).Meshes[0];
            sol.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\SunTexture.jpg") });


            //Deshabilitamos el manejo automático de Transformaciones de TgcMesh, para poder manipularlas en forma customizada
            sol.AutoTransformEnable = false;


            GuiController.Instance.UserVars.addVar("variablePrueba");

            GuiController.Instance.UserVars.setValue("variablePrueba", 5451);



            ///////////////MODIFIERS//////////////////

            //Crear un modifier para un valor FLOAT
            GuiController.Instance.Modifiers.addFloat("camaraY", 0f, 1500f, 400f);
            GuiController.Instance.Modifiers.addFloat("camaraZ", 0f, 1500f, 1000f);
            float camaraY = (float)GuiController.Instance.Modifiers["camaraY"];
            float camaraZ = (float)GuiController.Instance.Modifiers["camaraZ"];

            //Crear un modifier para un ComboBox con opciones
            string[] opciones = new string[] { "opcion1", "opcion2", "opcion3" };
            GuiController.Instance.Modifiers.addInterval("valorIntervalo", opciones, 0);

            //Crear un modifier para modificar un vértice
            GuiController.Instance.Modifiers.addVertex3f("valorVertice", new Vector3(-100, -100, -100), new Vector3(50, 50, 50), new Vector3(0, 0, 0));

            camaraTerceraPersona.Iniciar(nave.Modelo.Position, camaraY, camaraZ);

            List <string> lista = new List <string>();

            lista.Add("elemento1");
            lista.Add("elemento2");

            string elemento1 = lista[0];

            foreach (string elemento in lista)
            {
                //Loggear por consola del Framework
                GuiController.Instance.Logger.log(elemento);
            }


            for (int i = 0; i < lista.Count; i++)
            {
                string element = lista[i];
            }

            //GuiController.Instance.BackgroundColor = Color.Black;
            currentFile = null;
            GuiController.Instance.Modifiers.addFile("MP3-File", GuiController.Instance.ExamplesMediaDir + "Music\\I am The Money.mp3", "MP3s|*.mp3");

            //obstaculos.Add(sol);

            //foreach (TgcMesh mesh in Universo.Meshes)
            //{
            //    obstaculos.Add(mesh);
            //}

            GuiController.Instance.CustomRenderEnabled = true;
            CustomVertex.PositionTextured[] screenQuadVertices = new CustomVertex.PositionTextured[]
            {
                new CustomVertex.PositionTextured(-1, 1, 1, 0, 0),
                new CustomVertex.PositionTextured(1, 1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1, -1, 1, 1, 1)
            };
            screenQuadVB = new VertexBuffer(typeof(CustomVertex.PositionTextured),
                                            4, d3dDevice, Usage.Dynamic | Usage.WriteOnly,
                                            CustomVertex.PositionTextured.Format, Pool.Default);
            screenQuadVB.SetData(screenQuadVertices, 0, LockFlags.None);

            renderTarget2D = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth
                                         , d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget,
                                         Format.X8R8G8B8, Pool.Default);
            //Cargar shader con efectos de Post-Procesado
            effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\PostProcess.fx");

            //Configurar Technique dentro del shader
            effect.Technique = "BlurTechnique";
        }