Пример #1
0
        public override void Init()
        {
            //Modifiers para variar parametros de la pared
            Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100),
                                  new Vector3(0, 0, 0));
            Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100),
                                  new Vector3(100, 100, 100));
            Modifiers.addInterval("orientation", new[] { "XY", "XZ", "YZ" }, 0);
            Modifiers.addVertex2f("tiling", new Vector2(0, 0), new Vector2(10, 10), new Vector2(1, 1));
            Modifiers.addBoolean("autoAdjust", "autoAdjust", false);

            //Modifier de textura
            var texturePath = MediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg";

            currentTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, texturePath);
            Modifiers.addTexture("texture", currentTexture.FilePath);

            //Crear pared
            plane = new TgcPlane();
            plane.setTexture(currentTexture);

            //Actualizar segun valores cargados
            updatePlane();

            //Ajustar camara segun tamano de la pared
            Camara = new TgcRotationalCamera(plane.BoundingBox.calculateBoxCenter(),
                                             plane.BoundingBox.calculateBoxRadius() * 2, Input);
        }
Пример #2
0
        /// <summary>
        ///     Actualizar parametros de la pared segun los valores cargados
        /// </summary>
        private void updatePlane()
        {
            //Origen, dimensiones, tiling y AutoAdjust
            var origin     = (Vector3)Modifiers["origin"];
            var dimension  = (Vector3)Modifiers["dimension"];
            var tiling     = (Vector2)Modifiers["tiling"];
            var autoAdjust = (bool)Modifiers["autoAdjust"];

            //Cambiar orienacion
            var orientation = (string)Modifiers["orientation"];

            TgcPlane.Orientations or;
            if (orientation == "XY")
            {
                or = TgcPlane.Orientations.XYplane;
            }
            else if (orientation == "XZ")
            {
                or = TgcPlane.Orientations.XZplane;
            }
            else
            {
                or = TgcPlane.Orientations.YZplane;
            }

            //Cambiar textura
            var text = (string)Modifiers["texture"];

            if (text != currentTexture.FilePath)
            {
                currentTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, text);
                plane.setTexture(currentTexture);
            }

            //Aplicar valores en pared
            plane.Origin       = origin;
            plane.Size         = dimension;
            plane.Orientation  = or;
            plane.AutoAdjustUv = autoAdjust;
            plane.UTile        = tiling.X;
            plane.VTile        = tiling.Y;

            //Es necesario ejecutar updateValues() para que los cambios tomen efecto
            plane.updateValues();
        }
Пример #3
0
 public override void setTexture(TgcTexture texture, int slot)
 {
     mesh.setTexture(texture);
 }
Пример #4
0
        public override void Init()
        {
            var d3dDevice = D3DDevice.Instance.Device;

            moto = new Moto(MediaDir, new Vector3(0, 0, 0));
            moto.init();

            texturaPiso           = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SkyBoxTron\\bottom.png");
            pisoPlane             = new TgcPlane();
            pisoPlane.Origin      = new Vector3(-5000, 0, -5000);
            pisoPlane.Size        = new Vector3(10000, 0, 10000);
            pisoPlane.Orientation = TgcPlane.Orientations.XZplane;
            pisoPlane.setTexture(texturaPiso);
            pisoPlane.updateValues();

            piso = pisoPlane.toMesh("piso");
            piso.AutoTransformEnable = true;

            camaraInterna = new camara(moto);
            Camara        = camaraInterna;
            camaraInterna.rotateY(FastMath.ToRad(180));

            skyBoxTron = new SkyBox(MediaDir);
            skyBoxTron.init();

            texto          = new TgcText2D();
            texto.Color    = Color.Red;
            texto.Align    = TgcText2D.TextAlign.LEFT;
            texto.Text     = "Perdiste, toca la tecla R para reiniciar";
            texto.Size     = new Size(700, 400);
            texto.Position = new Point(550, 150);

            textoModoDios          = new TgcText2D();
            textoModoDios.Color    = Color.Red;
            textoModoDios.Text     = "Modo Dios Activado";
            textoModoDios.Position = new Point(0, 30);
            textoModoDios.Size     = new Size(500, 200);

            controladorIA = new ControladorIA();

            this.generarOponentes();

            perdido = false;

            cajas               = new List <TgcMesh>();
            cajaConLuz          = new TgcSceneLoader().loadSceneFromFile(MediaDir + Game.Default.pathCajaMetalica).Meshes[0];
            cajaConLuz.Position = new Vector3(0, 0, -200);
            cajaConLuz.Scale    = new Vector3(0.8f, 0.8f, 0.8f);
            efectoLuz           = TgcShaders.loadEffect(ShadersDir + "MultiDiffuseLights.fx");

            this.generarCajas(100);

            controladorIA.setObstaculosEscenario(cajas);

            gestorPowerUps = new GestorPowerUps();

            mp3Player = new TgcMp3Player();
            mp3Player.closeFile();
            mp3Player.FileName = MediaDir + Game.Default.pathMusica;
            mp3Player.play(true);
        }