Example #1
0
        protected void CheckJumpStatus(GameModel gameModel)
        {
            if (rigidBody.InterpolationLinearVelocity.Y < -0.88f)
            {
                falling    = true;
                onTheFloor = false;
                canJump    = false;
            }

            if (falling)
            {
                if (rigidBody.InterpolationLinearVelocity.Y > -0.05f)
                {
                    falling    = false;
                    onTheFloor = true;
                    var sound = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "afterJump.wav", this.mesh.Transform.Origin, gameModel.DirectSound.DsDevice);
                    sound.MinDistance = 50f;
                    sound.play(false);
                }
            }

            if (onTheFloor && !falling)
            {
                canJump = true;
            }
        }
Example #2
0
 public override void Dispose(Device dsDevice)
 {
     sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "machinegunDestroy.wav", mesh.Transform.Origin, dsDevice);
     sound.MinDistance = 34f;
     sound.play(false);
     mesh.Dispose();
     rigidBody.Dispose();
 }
        public void playSound(String fileName, Vector3 position)
        {
            Tgc3dSound sound = new Tgc3dSound(fileName, position, DirectSound.DsDevice);

            sound.MinDistance = 500f;
            theSound          = sound;
            contadorDeCiclos  = 0;
        }
Example #4
0
        public override void fire(Device dsDevice)
        {
            rigidBody.WorldTransform = Matrix.Translation(0, 0.5f, -shooter.meshAxisRadius.Z - shooter.currentSpeed * 0.01f - 1.8f) * Matrix.RotationY(shooter.yawPitchRoll.Y) * Matrix.Translation(shooter.Mesh.Transform.Origin.ToBsVector);
            rigidBody.ApplyCentralImpulse(new Vector3(shooter.frontVector.X, 0, shooter.frontVector.Z) * (30 + (FastMath.Sqrt(FastMath.Abs(shooter.currentSpeed)) / 2)));

            sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "power.wav", shooter.Mesh.Transform.Origin, dsDevice);
            sound.MinDistance = 48f;
            sound.play(false);
        }
Example #5
0
        public void fire(int opposite, Device dsDevice)
        {
            rigidBody.WorldTransform = Matrix.Translation(opposite * shooter.meshAxisRadius.X * 0.8f, 0.265f, -shooter.meshAxisRadius.Z - shooter.currentSpeed * 0.01f - 0.47f) * Matrix.RotationY(shooter.yawPitchRoll.Y) * Matrix.Translation(shooter.Mesh.Transform.Origin.ToBsVector);
            rigidBody.ApplyCentralImpulse(new Vector3(shooter.frontVector.X, 0, shooter.frontVector.Z) * (25 + (FastMath.Sqrt(FastMath.Abs(shooter.currentSpeed)) / 2)));

            sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "machinegun.wav", shooter.Mesh.Transform.Origin, dsDevice);
            sound.MinDistance = 50f;
            sound.play(false);
        }
Example #6
0
 public override void Dispose(Device dsDevice)
 {
     sound.stop();
     sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "explosionStrong.wav", mesh.Transform.Origin, dsDevice);
     sound.MinDistance = 43f;
     sound.play(false);
     mesh.Dispose();
     rigidBody.Dispose();
 }
        public void SuenaEncendido(Auto auto)
        {
            Tgc3dSound sonar;

            sonar = new Tgc3dSound(MediaDir + "Musica\\Encendido.wav", auto.Mayas[0].Position, SonidoDevice)
            {
                MinDistance = 80f
            };

            sonar.play();
        }
        public SoundsManagerLegacy(String minVelWAV, String maxVelWAV, String acceleratingWAV, String desacceleratingWAV, TGCVector3 position)
        {
            var bufferDescription = new BufferDescription();

            bufferDescription.ControlFrequency = true;
            this.minVelSound             = new Tgc3dSound(minVelWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio());
            this.maxVelSound             = new Tgc3dSound(maxVelWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio());
            this.acceleratingVelSound    = new Tgc3dSound(acceleratingWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio(), bufferDescription);
            this.desacceleratingVelSound = new Tgc3dSound(desacceleratingWAV, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio(), bufferDescription);
            this.desacceleratingVelSound.SoundBuffer.SetCurrentPosition(LAST_BUFFER_POSITION);
            this.PlayMinVel();
        }
Example #9
0
        public void Init()
        {
            //seteamos atributos particulares de las naves
            health       = 50;
            score        = 2;
            tiempoMuerte = 5f;
            Device d3dDevice = GuiController.Instance.D3dDevice;

            MESH_SCALE     = 0.5f;
            attackDamage   = 50;
            MOVEMENT_SPEED = 225f;
            //cargamos el mesh
            //las naves no tienen skeletalMesh
            this.mesh = GameManager.Instance.ModeloNave.clone("Nave");


            SPAWN_HEIGHT = 1000f;
            giroInicial  = Matrix.RotationY(0);

            //realizamos el init() comun a todos los enemigos
            base.Init();

            mesh.Effect    = GameManager.Instance.envMap;
            mesh.Technique = "SimpleEnvironmentMapTechnique";
            mesh.Effect.SetValue("lightColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("lightPosition", TgcParserUtils.vector3ToFloat4Array(new Vector3(0, 1400, 0)));
            mesh.Effect.SetValue("eyePosition", TgcParserUtils.vector3ToFloat4Array(CustomFpsCamera.Instance.getPosition()));
            mesh.Effect.SetValue("lightIntensity", 0.3f);
            mesh.Effect.SetValue("lightAttenuation", 1.0f);
            mesh.Effect.SetValue("reflection", 0.65f);

            //Cargar variables de shader de Material. El Material en realidad deberia ser propio de cada mesh. Pero en este ejemplo se simplifica con uno comun para todos
            mesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
            mesh.Effect.SetValue("materialAmbientColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("materialSpecularColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("materialSpecularExp", 9);

            mesh.Effect.SetValue("texCubeMap", GameManager.Instance.cubeMap);

            //creamos las boundingbox
            //a pesar de que las naves no tienen legs ni head, le seteamos boxes "vacias" para no tener problemas con Excepciones de null
            HEADSHOT_BOUNDINGBOX = new TgcBoundingBox();
            CHEST_BOUNDINGBOX    = this.mesh.BoundingBox.clone();
            LEGS_BOUNDINGBOX     = new TgcBoundingBox();
            //carga de sonido
            SonidoMovimiento             = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio\\Robot\\ufoHum.wav", getPosicionActual());
            SonidoMovimiento.MinDistance = 130f;
            SonidoMovimiento.play(true);
        }
Example #10
0
 public void Dissapear(Device dsDevice)
 {
     if (IsPresent)
     {
         IsPresent = false;
         Mesh.Dispose();
         timer = respawnTime;
     }
     if (dsDevice != null)
     {
         sound             = new Tgc3dSound(SoundPath, Position, dsDevice);
         sound.MinDistance = 150f;
         sound.play(false);
     }
 }
Example #11
0
        public Enemigo()
        {
            //Paths para archivo XML de la malla
            pathMesh = alumnoMediaFolder + "CucarachaJugosita\\Media\\SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";

            //Path para carpeta de texturas de la malla
            mediaPath = alumnoMediaFolder + "CucarachaJugosita\\Media\\SkeletalAnimations\\Robot\\";

            //Lista de animaciones disponibles
            animationList = new string[] {
                "Parado",
                "Caminando",
                "Correr",
                "PasoDerecho",
                "PasoIzquierdo",
                "Empujar",
                "Patear",
                "Pegar",
                "Arrojar",
            };

            //Crear rutas con cada animacion
            animationsPath = new string[animationList.Length];
            for (int i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcSkeletalAnim.xml";
            }

            //Cargar mesh y animaciones
            TgcSkeletalLoader loader2 = new TgcSkeletalLoader();

            mesh = loader2.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animationsPath);
            //mesh.Position = new Vector3(105, 5.06f, 660);
            mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f);
            //Crear esqueleto a modo Debug
            mesh.buildSkletonMesh();
            //Elegir animacion Caminando
            // mesh.BoundingBox.move(new Vector3(15,0,-170));
            //mesh.BoundingBox.scaleTranslate(mesh.BoundingBox.Position, new Vector3(4f,0.8f,4f)); // este sera el rango de vision
            bounding = new TgcBox();
            bounding = TgcBox.fromSize(mesh.Position, new Vector3(100f, 100f, 300f));
            bounding.move(new Vector3(15, 0, -170));
            sonidoCaminar               = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosDir + "CucarachaJugosita\\Media\\pasos_16.wav", mesh.Position);
            sonidoCaminar.MinDistance   = 30f;
            sonidoPerseguir             = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosDir + "CucarachaJugosita\\Media\\monstruoMuyEnojado.wav", mesh.Position);
            sonidoPerseguir.MinDistance = 300f;
        }
Example #12
0
        public Mostro()
        {
            mesh = Map.GetMeshFromScene("Esqueleto2-TgcScene.xml");

            musica             = new Tgc3dSound(g.game.MediaDir + "tambo_tambo-la_cumbita.wav", pos, g.game.DirectSound.DsDevice);
            musica.MinDistance = 60f;

            g.game.DirectSound.Listener3d.Position = g.camera.eyePosition;

            musica.play(true);

            g.mostro = this;

            lookAt = new TGCVector3(0.5f, 0, 0.5f);
            lookin = new TGCVector3(0, 0, -1);
            mode   = -1;
        }
Example #13
0
 public Disparo(TGCVector3 startPosition, TGCVector3 targetPosition, TGCVector3 size, Color color, string soundPath, Microsoft.DirectX.DirectSound.Device device)
 {
     vida                 = Stopwatch.StartNew();
     ShouldDie            = false;
     modelo               = TGCBox.fromSize(size, color);
     modelo.AutoTransform = true;
     modelo.Position      = startPosition;
     MovementDirection    = TGCVector3.Normalize(targetPosition - startPosition);
     modelo.Rotation      = new TGCVector3(ObtenerRotacionX(new TGCVector3(0, 0, 1), MovementDirection), ObtenerRotacionY(new TGCVector3(0, 0, 1), MovementDirection), 0);
     this.OOB             = TgcBoundingOrientedBox.computeFromAABB(modelo.BoundingBox);
     //this.OOB.move(this.MovementDirection);
     this.OOB.rotate(modelo.Rotation);
     this.sonido        = new Tgc3dSound(soundPath, modelo.Position, device);
     sonido.Position    = modelo.Position;
     sonido.MinDistance = 50f;
     sonido.play();
     //modelo.BoundingBox.transform(TGCMatrix.RotationYawPitchRoll(modelo.Rotation.Y,modelo.Rotation.X,0));
 }
Example #14
0
        public void init(Vector3 posP)
        {
            //sonidoAbrir = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosDir + "CucarachaJugosita\\Media\\puerta ruidosa, abrir.wav", meshP.Position);

            /*sonidoAbrir = new Tgc3dSound();
             * sonidoAbrir.loadSound(GuiController.Instance.AlumnoEjemplosDir + "CucarachaJugosita\\Media\\puerta ruidosa, abrir.wav");
             * sonidoAbrir.Position = meshP.Position;*/

            text2       = new TgcText2d();
            text2.Text  = "";
            text2.Color = Color.DarkRed;
            text2.Align = TgcText2d.TextAlign.CENTER;
            //text2.Position = new Point(500, 500);
            text2.Size = new Size(300, 100);
            // text2.Size = new Size(GuiController.Instance.D3dDevice.PresentationParameters.BackBufferWidth/13000, GuiController.Instance.D3dDevice.PresentationParameters.BackBufferHeight/13000);
            Size screenSize = GuiController.Instance.Panel3d.Size;

            // text2.Position = new Point(screenSize.Width/ 2 - text2.Size.Width / 2, screenSize.Height - text2.Size.Height*3);
            text2.Position = new Point(screenSize.Width / 2 - text2.Size.Width / 2, screenSize.Height * 6 / 10);
            text2.changeFont(new System.Drawing.Font("Chiller", /*30*/ GuiController.Instance.D3dDevice.PresentationParameters.BackBufferWidth / 45, FontStyle.Regular));
            var    loader            = new TgcSceneLoader();
            string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosDir;

            puerta1                 = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\Component_1-TgcScene.xml");
            meshP                   = puerta1.Meshes[0];
            meshP.Position          = posP;
            cobertura1              = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\cobertura1-TgcScene.xml");
            cobertura2              = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\cobertura2-TgcScene.xml");
            cobertura3              = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\cobertura3-TgcScene.xml");
            meshC1                  = cobertura1.Meshes[0];
            meshC1.Position         = posP;
            meshC2                  = cobertura2.Meshes[0];
            meshC2.Position         = posP;
            meshC3                  = cobertura3.Meshes[0];
            meshC3.Position         = posP;
            estado                  = Estado.Cerrado;
            contadorAbierta         = 500f;
            sonidoAbrir             = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosDir + "CucarachaJugosita\\Media\\puerta ruidosa, abrir.wav", meshP.Position);
            sonidoAbrir.MinDistance = 10f;
        }
Example #15
0
        public void AddSound(TGCVector3 position, float minDistance, int volume, string sound, string apodo, bool isSoundWithFrecuency)
        {
            if (this.sounds.Exists(s => sound.Equals(apodo)))
            {
                throw new Exception("Ya existe un sonido con ese nombre");
            }
            BufferDescription bufferDescription = new BufferDescription();

            bufferDescription.ControlVolume = true;
            if (isSoundWithFrecuency)
            {
                bufferDescription.ControlFrequency = true;
            }
            Tgc3dSound newSound = new Tgc3dSound(GlobalConcepts.GetInstance().GetMediaDir() + "Sound\\" + sound, position, GlobalConcepts.GetInstance().GetDispositivoDeAudio(), bufferDescription);

            newSound.SoundBuffer.Volume = volume;
            newSound.MinDistance        = minDistance;
            if (isSoundWithFrecuency)
            {
                this.initialFreq        = newSound.SoundBuffer.Frequency;
                this.soundWithFrecuency = newSound;
            }
            this.sounds.Add(new Sound(newSound, apodo));
        }
Example #16
0
 public Sound(Tgc3dSound sound, string name)
 {
     this.sound = sound;
     this.name  = name;
 }
Example #17
0
        /// <summary>
        ///     Se llama una sola vez, al principio cuando se ejecuta el ejemplo.
        ///     Escribir aquí todo el código de inicialización: cargar modelos, texturas, estructuras de optimización, todo
        ///     procesamiento que podemos pre calcular para nuestro juego.
        ///     Borrar el codigo ejemplo no utilizado.
        /// </summary>
        public override void Init()
        {
            //Device de DirectX para crear primitivas.
            var d3dDevice = D3DDevice.Instance.Device;

            timestamp = DateTime.Now;

            //Utilizando esta propiedad puedo activar el update/render a intervalos constantes.
            FixedTickEnable = true;
            //Se puede configurar el tiempo en estas propiedades TimeBetweenUpdates y TimeBetweenRenders, por defecto esta puedo en 1F / FPS_60 es a lo minimo que deberia correr el TP.
            //De no estar a gusto como se ejecuta el metodo Tick (el que maneja el GameLoop) el mismo es virtual con lo cual pueden sobrescribirlo.

            //Esconder cursor
            focusWindows  = d3dDevice.CreationParameters.FocusWindow;
            mousePosition = focusWindows.PointToScreen(new Point(focusWindows.Width / 2, focusWindows.Height / 2));
            //Cursor.Hide();

            Sounds.SoundsManager.Instance().sound    = DirectSound.DsDevice;
            Sounds.SoundsManager.Instance().mediaDir = MediaDir;

            //Burbujas
            D3DDevice.Instance.ParticlesEnabled = true;
            D3DDevice.Instance.EnableParticles();
            Particulas.Init(MediaDir, 20);

            //Oceano
            Oceano.Init(TGCVector3.Up * nivelDelAgua * 0.8f, 100, 100, ShadersDir);

            //Settear jugador y camara
            FPSCamara = new FPSCamara(Camera, Input);

            Player = Player.Instance();
            Player.SetInput(Input);
            Player.Init(FPSCamara);



            //Inicializar camara
            var cameraPosition = new TGCVector3(0, 100, -250);
            var lookAt         = new TGCVector3(0, nivelDelAgua, 0);

            Camera.SetCamera(cameraPosition, lookAt);

            sonidoUnderwater = new TgcStaticSound();
            sonidoUnderwater.loadSound(MediaDir + "Sounds\\mar.wav", DirectSound.DsDevice);

            effect         = TGCShaders.Instance.LoadEffect(ShadersDir + "e_fog.fx");
            efectoInterior = TGCShaders.Instance.LoadEffect(ShadersDir + "interior.fx");


            //Iniciar HUD
            Hud.Init(MediaDir);
            Hud.ChangeStatus(Hud.Status.MainMenu);

            //Cargar enviroment
            oceano = new Fondo(MediaDir, ShadersDir);
            oceano.Init();
            oceano.Camera = Camera;

            heightmap = new TgcSimpleTerrain();
            heightmap.loadHeightmap(MediaDir + marBnwDir, marScaleXZ, marScaleY, new TGCVector3(0, marOffsetY, 0));
            heightmap.loadTexture(MediaDir + marTexDir);

            //Cargar entidades
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "yellow_fish-TgcScene.xml");
            var mesh   = scene.Meshes[0];

            peces   = new List <Fish>();
            corales = new List <Coral>();
            metales = new List <Metal>();
            piedras = new List <Metal>();

            int i = 0;

            while (i < 20)
            {
                Fish   fish;
                string meshName = i.ToString();
                fish = new Fish(mesh.clone(meshName));
                fish = (Fish)setearMeshParaLista(fish, i);
                peces.Add(fish);

                fish.Effect(effect);
                fish.Technique("RenderScene");
                i++;
            }

            scene = loader.loadSceneFromFile(MediaDir + "shark-TgcScene.xml");
            mesh  = scene.Meshes[0];

            shark = new Shark(mesh);
            shark.Init();
            sharkSound = new Tgc3dSound(MediaDir + "Sounds\\shark.wav", shark.GetMesh().Position, DirectSound.DsDevice);
            shark.setearSonido(sharkSound);
            shark.setearAlturaMaxima(nivelDelAgua - 19f);

            efectoDesaparecer = TGCShaders.Instance.LoadEffect(ShadersDir + "perlin.fx");

            shark.setearEfectoPerlin(efectoDesaparecer);
            perlinTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Textures\\perlin.png");
            shark.setearPerlin(perlinTexture);

            scene = loader.loadSceneFromFile(MediaDir + "coral-TgcScene.xml");
            mesh  = scene.Meshes[0];


            i = 0;
            while (i < 25)
            {
                Coral  coral;
                string meshName = i.ToString();
                coral = new Coral(mesh.createMeshInstance(meshName));
                coral = (Coral)setearMeshParaLista(coral, i * 4, -17);
                corales.Add(coral);

                coral.Effect(effect);
                coral.Technique("RenderScene");
                i++;
            }

            scene = loader.loadSceneFromFile(MediaDir + "Oro-TgcScene.xml");
            mesh  = scene.Meshes[0];
            i     = 0;
            while (i < 15)
            {
                Metal  oro;
                string meshName = i.ToString();
                oro      = new Metal(mesh.createMeshInstance(meshName));
                oro      = (Metal)setearMeshParaLista(oro, i * 8, -17);
                oro.Tipo = ElementoRecolectable.oro;
                metales.Add(oro);

                oro.Effect(effect);
                oro.Technique("RenderSceneLight");
                i++;
            }

            scene = loader.loadSceneFromFile(MediaDir + "Hierro-TgcScene.xml");
            mesh  = scene.Meshes[0];
            i     = 0;
            while (i < 15)
            {
                Metal  hierro;
                string meshName = i.ToString() + i.ToString();
                hierro      = new Metal(mesh.createMeshInstance(meshName));
                hierro      = (Metal)setearMeshParaLista(hierro, (i + 10) * 8, -17);
                hierro.Tipo = ElementoRecolectable.hierro;
                metales.Add(hierro);

                hierro.Effect(effect);
                hierro.Technique("RenderScene");
                i++;
            }

            scene = loader.loadSceneFromFile(MediaDir + "Roca-TgcScene.xml");
            mesh  = scene.Meshes[0];
            i     = 0;
            while (i < 15)
            {
                Metal  roca;
                string meshName = i.ToString() + i.ToString() + i.ToString();
                roca      = new Metal(mesh.createMeshInstance(meshName));
                roca      = (Metal)setearMeshParaLista(roca, (i + 10) * 8, -17);
                roca.Tipo = ElementoRecolectable.madera;
                roca.escalar(new TGCVector3(0.3f, 0.3f, 0.3f));
                piedras.Add(roca);

                roca.Effect(effect);
                roca.Technique("RenderScene");
                i++;
            }

            scene = loader.loadSceneFromFile(MediaDir + "ship-TgcScene.xml");
            nave  = Nave.Instance();
            nave.Init(scene, nivelDelAgua);

            scene = loader.loadSceneFromFile(MediaDir + "EspadaDoble-TgcScene.xml");
            mesh  = scene.Meshes[0];
            arma  = new Arma(mesh);

            scene    = loader.loadSceneFromFile(MediaDir + "Mesa-TgcScene.xml");
            mesaNave = MesaNave.Instance();
            mesaNave.Init(scene);
            mesaNave.Effect(efectoInterior);
            mesaNave.Technique("RenderScene");

            scene        = loader.loadSceneFromFile(MediaDir + "SogaEnrollada-TgcScene.xml");
            mesh         = scene.Meshes[0];
            sogaInterior = SogaInterior.Instance();
            sogaInterior.Init(mesh);
            sogaInterior.Effect(efectoInterior);
            sogaInterior.Technique("RenderScene");

            scene         = loader.loadSceneFromFile(MediaDir + "silla-TgcScene.xml");
            sillaInterior = SillaInterior.Instance();
            sillaInterior.Init(scene);
            sillaInterior.Effect(efectoInterior);
            sillaInterior.Technique("RenderScene");

            scene         = loader.loadSceneFromFile(MediaDir + "Timon-TgcScene.xml");
            timonInterior = TimonInterior.Instance();
            timonInterior.Init(scene);
            timonInterior.Effect(efectoInterior);
            timonInterior.Technique("RenderScene");

            scene       = loader.loadSceneFromFile(MediaDir + "LamparaTecho-TgcScene.xml");
            lamparaNave = new LamparaNave(scene.Meshes[0]);
            lamparaNave.Effect(efectoInterior);
            lamparaNave.Technique("RenderScene");


            //Cargar shaders
            fog               = new TgcFog();
            fog.Color         = Color.FromArgb(30, 144, 255);
            fog.Density       = 1;
            fog.EndDistance   = 1000;
            fog.StartDistance = 1;
            fog.Enabled       = true;

            effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);

            //Fog + Lights
            effect.SetValue("nivelAgua", nivelDelAgua);

            interiorNave = InteriorNave.Instance();
            interiorNave.Init(MediaDir);

            DirectSound.ListenerTracking = Player.Instance().mesh;

            //Mascara post process
            maskTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Textures\\mascara.png");
            effect.SetValue("textura_mascara", maskTexture.D3dTexture);

            // seteamos los efectos aca porque son fijos
            oceano.Effect(effect);
            oceano.Technique("RenderScene");

            heightmap.Effect    = effect;
            heightmap.Technique = "RenderScene";

            shark.Effect(effect);
            shark.Technique("RenderScene");

            nave.Effect(effect);
            nave.Technique("RenderSceneLight");

            effect.SetValue("ambientColor", Color.FromArgb(255, 255, 255).ToArgb());
            effect.SetValue("diffuseColor", Color.FromArgb(255, 255, 255).ToArgb());
            effect.SetValue("specularColor", Color.FromArgb(255, 255, 255).ToArgb());

            efectoInterior.SetValue("ambientColor", Color.FromArgb(255, 255, 255).ToArgb());
            efectoInterior.SetValue("diffuseColor", Color.FromArgb(255, 255, 255).ToArgb());
            efectoInterior.SetValue("specularColor", Color.FromArgb(255, 255, 255).ToArgb());

            // dibujo el full screen quad
            CustomVertex.PositionTextured[] vertices =
            {
                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)
            };

            // Vertex buffer de los triangulos
            fullScreenQuad = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);
            fullScreenQuad.SetData(vertices, 0, LockFlags.None);

            // dibujo render target

            depthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true);

            renderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            // inicializo los FB que uso para el Bloom
            coralesBrillantes = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            FBHorizontalBool = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            FBVerticalBloom = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
        }
Example #18
0
        public override void init()
        {
            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear piso
            TgcTexture pisoTexture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\tierra.jpg");

            piso = TgcBox.fromSize(new Vector3(0, -60, 0), new Vector3(5000, 5, 5000), pisoTexture);


            //Cargar obstaculos y posicionarlos. Los obstáculos se crean con TgcBox en lugar de cargar un modelo.
            obstaculos = new List <TgcBox>();
            sonidos    = new List <Tgc3dSound>();
            TgcBox     obstaculo;
            Tgc3dSound sound;


            //Obstaculo 1
            obstaculo = TgcBox.fromSize(
                new Vector3(-200, 0, 0),
                new Vector3(80, 150, 80),
                TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack3\\goo2.jpg"));
            obstaculos.Add(obstaculo);

            //Sondio obstaculo 1
            //OJO, solo funcionan sonidos WAV Mono (No stereo). Hacer boton der => Propiedades sobre el archivo
            //y tiene que decir "1 Channel".
            sound = new Tgc3dSound(GuiController.Instance.ExamplesMediaDir + "Sound\\armonía, continuo.wav", obstaculo.Position);
            //Hay que configurar la mínima distancia a partir de la cual se empieza a atenuar el sonido 3D
            sound.MinDistance = 50f;
            sonidos.Add(sound);

            //Obstaculo 2
            obstaculo = TgcBox.fromSize(
                new Vector3(200, 0, 800),
                new Vector3(80, 300, 80),
                TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack3\\lun_dirt.jpg"));
            obstaculos.Add(obstaculo);

            //Sondio obstaculo 2
            sound             = new Tgc3dSound(GuiController.Instance.ExamplesMediaDir + "Sound\\viento helado.wav", obstaculo.Position);
            sound.MinDistance = 50f;
            sonidos.Add(sound);

            //Obstaculo 3
            obstaculo = TgcBox.fromSize(
                new Vector3(600, 0, 400),
                new Vector3(80, 100, 150),
                TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack3\\Metal2_1.jpg"));
            obstaculos.Add(obstaculo);

            //Sondio obstaculo 3
            sound             = new Tgc3dSound(GuiController.Instance.ExamplesMediaDir + "Sound\\risa de maníaco.wav", obstaculo.Position);
            sound.MinDistance = 50f;
            sonidos.Add(sound);


            //Cargar personaje principal
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\Hummer\\Hummer-TgcScene.xml");

            personaje          = scene.Meshes[0];
            personaje.Position = new Vector3(0, -50, 0);


            //Hacer que el Listener del sonido 3D siga al personaje
            GuiController.Instance.DirectSound.ListenerTracking = personaje;

            //Configurar camara en Tercer Persona
            GuiController.Instance.ThirdPersonCamera.Enable = true;
            GuiController.Instance.ThirdPersonCamera.setCamera(personaje.Position, 200, 300);
            GuiController.Instance.ThirdPersonCamera.TargetDisplacement = new Vector3(0, 100, 0);

            //Ejecutar en loop los sonidos
            foreach (Tgc3dSound s in sonidos)
            {
                s.play(true);
            }
        }
Example #19
0
 public Fuego(float peso, float resistencia, TgcMesh mesh, Efecto efecto, Tgc3dSound sonidoFuego)
     : base(peso, resistencia, mesh, efecto)
 {
     sonido = sonidoFuego;
 }
Example #20
0
        public override void Init()
        {
            //Crear piso
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\tierra.jpg");

            piso           = TGCBox.fromSize(new TGCVector3(5000, 5, 5000), pisoTexture);
            piso.Transform = TGCMatrix.Scaling(piso.Scale)
                             * TGCMatrix.RotationYawPitchRoll(piso.Rotation.Y, piso.Rotation.X, piso.Rotation.Z)
                             * TGCMatrix.Translation(piso.Position);
            piso.Position = new TGCVector3(0, -60, 0);

            //Cargar obstaculos y posicionarlos. Los obstaculos se crean con TgcBox en lugar de cargar un modelo.
            obstaculos = new List <TGCBox>();
            sonidos    = new List <Tgc3dSound>();
            TGCBox     obstaculo;
            Tgc3dSound sound;

            //Obstaculo 1
            obstaculo = TGCBox.fromSize(new TGCVector3(80, 150, 80),
                                        TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\Quake\\TexturePack3\\goo2.jpg"));
            obstaculo.Position  = new TGCVector3(-250, 0, 0);
            obstaculo.Transform = TGCMatrix.Scaling(obstaculo.Scale)
                                  * TGCMatrix.RotationYawPitchRoll(obstaculo.Rotation.Y, obstaculo.Rotation.X, obstaculo.Rotation.Z)
                                  * TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Sondio obstaculo 1
            //OJO, solo funcionan sonidos WAV Mono (No stereo). Hacer boton der => Propiedades sobre el archivo
            //y tiene que decir "1 Channel".
            sound = new Tgc3dSound(MediaDir + "Sound\\armonía, continuo.wav", obstaculo.Position, DirectSound.DsDevice);
            //Hay que configurar la mínima distancia a partir de la cual se empieza a atenuar el sonido 3D
            sound.MinDistance = 50f;
            sonidos.Add(sound);

            //Obstaculo 2
            obstaculo = TGCBox.fromSize(new TGCVector3(80, 300, 80),
                                        TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                                 MediaDir + "Texturas\\Quake\\TexturePack3\\lun_dirt.jpg"));
            obstaculo.Position  = new TGCVector3(250, 0, 800);
            obstaculo.Transform = TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Sondio obstaculo 2
            sound             = new Tgc3dSound(MediaDir + "Sound\\viento helado.wav", obstaculo.Position, DirectSound.DsDevice);
            sound.MinDistance = 50f;
            sonidos.Add(sound);

            //Obstaculo 3
            obstaculo = TGCBox.fromSize(new TGCVector3(80, 100, 150),
                                        TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                                 MediaDir + "Texturas\\Quake\\TexturePack3\\Metal2_1.jpg"));
            obstaculo.Position  = new TGCVector3(500, 0, -400);
            obstaculo.Transform = TGCMatrix.Scaling(obstaculo.Scale)
                                  * TGCMatrix.RotationYawPitchRoll(obstaculo.Rotation.Y, obstaculo.Rotation.X, obstaculo.Rotation.Z)
                                  * TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Sondio obstaculo 3
            sound             = new Tgc3dSound(MediaDir + "Sound\\risa de maníaco.wav", obstaculo.Position, DirectSound.DsDevice);
            sound.MinDistance = 50f;
            sonidos.Add(sound);

            //Cargar personaje principal
            var loader = new TgcSceneLoader();
            var scene  =
                loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Hummer\\Hummer-TgcScene.xml");

            personaje           = scene.Meshes[0];
            personaje.Position  = new TGCVector3(0, 0, 0);
            personaje.Transform = TGCMatrix.Scaling(personaje.Scale)
                                  * TGCMatrix.RotationYawPitchRoll(personaje.Rotation.Y, personaje.Rotation.X, personaje.Rotation.Z)
                                  * TGCMatrix.Translation(personaje.Position);

            //Hacer que el Listener del sonido 3D siga al personaje
            DirectSound.ListenerTracking = personaje;

            //Configurar camara en Tercer Persona
            camaraInterna = new TgcThirdPersonCamera(personaje.Position, 250, 500);
            Camara        = camaraInterna;

            //Ejecutar en loop los sonidos
            foreach (var s in sonidos)
            {
                s.play(true);
            }
        }
Example #21
0
 public void setearSonido(Tgc3dSound _sound)
 {
     sound             = _sound;
     sound.MinDistance = 20f;
 }
        public void Init()
        {
            //seteamos atributos particulares del robot
            health = 100;
            score  = 1;
            Device d3dDevice = GuiController.Instance.D3dDevice;

            MESH_SCALE   = 0.5f;
            tiempoMuerte = 5f;
            attackDamage = 25;
            //cargamos el mesh
            //Despues de agregar el skeletalMesh dejamos de renderizar este mesh, pero igual lo utilizamos para calcular muchas cosas
            this.mesh = GameManager.Instance.ModeloRobot.clone("robot");

            giroInicial = Matrix.RotationY(-(float)Math.PI / 2);


            //carga de animaciones
            TgcSkeletalLoader skeletalLoader = new TgcSkeletalLoader();

            skeletalMesh = skeletalLoader.loadMeshAndAnimationsFromFile(
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Robot-TgcSkeletalMesh.xml",
                new string[] {
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Caminando-TgcSkeletalAnim.xml",
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Patear-TgcSkeletalAnim.xml",
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Arrojar-TgcSkeletalAnim.xml",
            });

            skeletalMesh.playAnimation("Caminando", true);
            skeletalMesh.AnimationEnds += this.onAnimationEnds;

            skeletalMesh.Effect = GameManager.Instance.skeletalEnvMap;
            //skeletalMesh.Technique = "SkeletalEnvMap";

            skeletalMesh.Effect.SetValue("lightColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("lightPosition", TgcParserUtils.vector3ToFloat4Array(new Vector3(0, 1400, 0)));
            skeletalMesh.Effect.SetValue("eyePosition", TgcParserUtils.vector3ToFloat4Array(CustomFpsCamera.Instance.getPosition()));
            skeletalMesh.Effect.SetValue("lightIntensity", 0.3f);
            skeletalMesh.Effect.SetValue("lightAttenuation", 0.3f);
            skeletalMesh.Effect.SetValue("reflection", 0.65f);

            //Cargar variables de shader de Material. El Material en realidad deberia ser propio de cada mesh. Pero en este ejemplo se simplifica con uno comun para todos
            skeletalMesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
            skeletalMesh.Effect.SetValue("materialAmbientColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("materialSpecularColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("materialSpecularExp", 7);

            skeletalMesh.Effect.SetValue("texCubeMap", GameManager.Instance.cubeMap);

            skeletalMesh.setColor(Color.Peru);

            //realizamos el init() comun a todos los enemigos
            base.Init();
            //Creamos boundingBox nuevas para la cabeza, pecho y piernas del robot
            HEADSHOT_BOUNDINGBOX = this.mesh.BoundingBox.clone();
            CHEST_BOUNDINGBOX    = this.mesh.BoundingBox.clone();
            LEGS_BOUNDINGBOX     = this.mesh.BoundingBox.clone();
            Matrix escalabox     = Matrix.Scaling(new Vector3(0.43f, 0.3f, 0.43f));
            Matrix traslationbox = Matrix.Translation(new Vector3(0, 90f, 0));

            HEADSHOT_BOUNDINGBOX.transform(escalabox * traslationbox);
            posicionActualHeadshot = escalabox * traslationbox * posicionActual;
            Matrix escalabox2     = Matrix.Scaling(new Vector3(0.6f, 0.3f, 0.6f));
            Matrix traslationbox2 = Matrix.Translation(new Vector3(0, 50f, 0));

            CHEST_BOUNDINGBOX.transform(escalabox2 * traslationbox2);
            posicionActualChest = escalabox2 * traslationbox2 * posicionActual;
            Matrix escalabox3     = Matrix.Scaling(new Vector3(0.4f, 0.38f, 0.4f));
            Matrix traslationbox3 = Matrix.Translation(new Vector3(0, 0f, 0));

            LEGS_BOUNDINGBOX.transform(escalabox3 * traslationbox3);
            posicionActualLegs = escalabox3 * traslationbox3 * posicionActual;


            skeletalMesh.AutoTransformEnable = false;

            //carga de sonido
            SonidoMovimiento             = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio\\Robot\\servomotor.wav", getPosicionActual());
            SonidoMovimiento.MinDistance = 70f;
            SonidoMovimiento.play(true);

            //setBaseEffect();
            skeletalMesh.computeNormals();
        }