Example #1
0
        public void InitGraphics(ViewerForm form, TreeView treeViewExamples, Panel panel3D,
                                 ToolStripStatusLabel toolStripStatusCurrentExample)
        {
            ApplicationRunning = true;

            Form = form;

            //Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(panel3D);
            D3DDevice.Instance.Device.DeviceReset += OnResetDevice;

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(Form, panel3D);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(panel3D);

            //Directorio actual de ejecucion
            var currentDirectory = Environment.CurrentDirectory + "\\";

            //Cargar shaders del framework
            TgcShaders.Instance.loadCommonShaders(currentDirectory + Settings.Default.ShadersDirectory +
                                                  Settings.Default.CommonShaders);
        }
Example #2
0
        /// <summary>
        ///     Inicio todos los objetos necesarios para cargar el ejemplo y directx.
        /// </summary>
        public void InitGraphics()
        {
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().ToString());
            // Se inicio la aplicación
            ApplicationRunning = true;

            // Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(panel3D);

            // Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(this, panel3D);

            // Inicio sonido
            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(panel3D);

            // Directorio actual de ejecución
            currentDirectory = Environment.CurrentDirectory;
            currentDirectory = currentDirectory.Substring(0, currentDirectory.LastIndexOf('\\'));
            currentDirectory = currentDirectory.Substring(0, currentDirectory.LastIndexOf('\\')) + "\\";
            //independiente de build. Medio garca pero no encontre una forma estandar de hacerlo

            // Cargar shaders del framework
            TGCShaders.Instance.LoadCommonShaders(currentDirectory + Game.Default.ShadersDirectory, D3DDevice.Instance);

            // Juego a ejecutar, si quisiéramos tener diferentes modelos aquí podemos cambiar la instancia e invocar a otra clase.
            Modelo = new GameModel(currentDirectory + Game.Default.MediaDirectory, currentDirectory + Game.Default.ShadersDirectory);

            // Cargar juego.
            ExecuteModel();
        }
Example #3
0
        /// <summary>
        ///     Inicio todos los objetos necesarios para cargar el ejemplo y directx.
        /// </summary>
        public void InitGraphics()
        {
            //Se inicio la aplicación
            ApplicationRunning = true;

            //Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(panel3D);

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(this, panel3D);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(panel3D);

            //Directorio actual de ejecución
            var currentDirectory = Environment.CurrentDirectory + "\\";

            //Cargar shaders del framework
            TgcShaders.Instance.loadCommonShaders(currentDirectory + Game.Default.ShadersDirectory);

            //Juego a ejecutar, si quisiéramos tener diferentes modelos aquí podemos cambiar la instancia e invocar a otra clase.
            Modelo = new GameModel(currentDirectory + Game.Default.MediaDirectory,
                                   currentDirectory + Game.Default.ShadersDirectory);

            //Cargar juego.
            ExecuteModel();
        }
Example #4
0
        /// <summary>
        /// Inicio todos los objetos necesarios para cargar el ejemplo y directx
        /// </summary>
        public void InitGraphics()
        {
            //Se inicio la aplicacion
            ApplicationRunning = true;

            //Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(panel3D);

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(this, panel3D);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(panel3D);

            //Directorio actual de ejecucion
            var currentDirectory = Environment.CurrentDirectory + "\\";

            //Cargar shaders del framework
            TgcShaders.Instance.loadCommonShaders(currentDirectory + Game.Default.ShadersDirectory);

            //Juego a ejecutar
            Modelo = new Juego(currentDirectory + Game.Default.MediaDirectory, currentDirectory + Game.Default.ShadersDirectory);

            //Cargar juego
            ExecuteModel();
        }
Example #5
0
        /// <summary>
        /// Inicia el device basado en el panel, el sonido, los inputs y carga los shaders basicos.
        /// </summary>
        /// <param name="form"> Ventana que contiene la aplicacion.</param>
        /// <param name="control"> Control donde van a correr los ejemplos.</param>
        /// <param name="pathCommonShaders"> Ruta con los shaders basicos.</param>
        public void InitGraphics(ToolsForm form, Panel control)
        {
            ApplicationRunning = true;
            Form    = form;
            Panel3d = control;

            //Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(control);
            D3DDevice.Instance.Device.DeviceReset += OnResetDevice;

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(Form, control);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            try
            {
                DirectSound.InitializeD3DDevice(control);
            }
            catch (ApplicationException ex)
            {
                throw new Exception("No se pudo inicializar el sonido", ex);
            }
        }
Example #6
0
        /// <summary>
        ///     Inicio todos los objetos necesarios para cargar el ejemplo y directx.
        /// </summary>
        public void InitGraphics()
        {
            ApplicationRunning = true;
            D3DDevice.Instance.InitializeD3DDevice(panel3D);

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(this, panel3D);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            try
            {
                DirectSound.InitializeD3DDevice(panel3D);
            }
            catch (ApplicationException ex)
            {
                throw new Exception("No se pudo inicializar el sonido", ex);
            }

            //Directorio actual de ejecución
            var currentDirectory = Environment.CurrentDirectory + "\\";

            //Cargar shaders del framework
            TGCShaders.Instance.LoadCommonShaders(currentDirectory + Game.Default.ShadersDirectory, D3DDevice.Instance);

            Modelo = new GameModel(currentDirectory + Game.Default.MediaDirectory,
                                   currentDirectory + Game.Default.ShadersDirectory);

            ExecuteModel();
        }
Example #7
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);
        }
        public Jugador(string NombreJugador, string MediaDir, int NroJugador, TgcDirectSound directSound)
        {
            //Guardo variables
            this.NombreJugador = NombreJugador;
            this.MediaDir      = MediaDir;
            this.NroJugador    = NroJugador;

            //Creo las clases de HUD y el auto
            this.claseHUD  = new HUDJugador(MediaDir, this.NombreJugador, this.NroJugador);
            this.claseAuto = new Auto(MediaDir, this.NroJugador, directSound);
            if (this.NroJugador == 0)
            {
                this.claseHUDVelocimetro = new HUDVelocimetro(MediaDir);
            }

            return;
        }
 public GameSoundManager(string mediaDir, TgcDirectSound sound)
 {
     Menu          = new TgcMp3Player();
     Ambient       = new TgcMp3Player();
     SharkStalking = new TgcStaticSound();
     Crafting      = new TgcStaticSound();
     SharkDead     = new TgcStaticSound();
     SharkAppear   = new TgcStaticSound();
     SharkAttack   = new TgcStaticSound();
     Collect       = new TgcStaticSound();
     EquipWeapon   = new TgcStaticSound();
     WeaponHit     = new TgcStaticSound();
     HitToShark    = new TgcStaticSound();
     ToSurface     = new TgcStaticSound();
     Submerge      = new TgcStaticSound();
     Init(mediaDir, sound);
 }
 private void Init(string mediaDir, TgcDirectSound sound)
 {
     Menu.FileName      = mediaDir + @"\Sounds\Menu.mp3";
     AmbientFileName    = mediaDir + @"\Sounds\Ambient.mp3";
     UnderWaterFileName = mediaDir + @"\Sounds\UnderWater.mp3";
     SharkStalking.loadSound(mediaDir + @"\Sounds\SharkNear.wav", sound.DsDevice);
     Crafting.loadSound(mediaDir + @"\Sounds\Crafting.wav", sound.DsDevice);
     SharkDead.loadSound(mediaDir + @"\Sounds\SharkDead.wav", sound.DsDevice);
     SharkAppear.loadSound(mediaDir + @"\Sounds\SharkAppear.wav", sound.DsDevice);
     SharkAttack.loadSound(mediaDir + @"\Sounds\SharkAttack.wav", sound.DsDevice);
     Collect.loadSound(mediaDir + @"\Sounds\gather_resource.wav", sound.DsDevice);
     EquipWeapon.loadSound(mediaDir + @"\Sounds\WeaponEquip.wav", sound.DsDevice);
     WeaponHit.loadSound(mediaDir + @"\Sounds\WeaponHit.wav", sound.DsDevice);
     HitToShark.loadSound(mediaDir + @"\Sounds\HitToShark.wav", sound.DsDevice);
     ToSurface.loadSound(mediaDir + @"\Sounds\ToSurface.wav", sound.DsDevice);
     Submerge.loadSound(mediaDir + @"\Sounds\Submerge.wav", sound.DsDevice);
 }
Example #11
0
        /// <summary>
        /// Inicia el device basado en el panel, el sonido, los inputs y carga los shaders basicos.
        /// </summary>
        /// <param name="form"> Ventana que contiene la aplicacion.</param>
        /// <param name="control"> Control donde van a correr los ejemplos.</param>
        /// <param name="pathCommonShaders"> Ruta con los shaders basicos.</param>
        public void InitGraphics(ViewerForm form, Control control, string pathCommonShaders)
        {
            ApplicationRunning = true;
            Form = form;

            //Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(control);
            D3DDevice.Instance.Device.DeviceReset += OnResetDevice;

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(Form, control);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(control);

            //Cargar shaders del framework
            TGCShaders.Instance.LoadCommonShaders(pathCommonShaders, D3DDevice.Instance);
        }
        public void InitGraphics()
        {
            ApplicationRunning = true;

            D3DDevice.Instance.InitializeD3DDevice(panel3D);

            Input = new TgcD3dInput();
            Input.Initialize(this, panel3D);

            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(panel3D);

            var currentDirectory = Environment.CurrentDirectory + "\\";

            //Cargar shaders del framework
            TgcShaders.Instance.loadCommonShaders(currentDirectory + Game.Default.ShadersDirectory);

            Modelo = new TwistedModel(currentDirectory + Game.Default.MediaDirectory,
                                      currentDirectory + Game.Default.ShadersDirectory);

            //Cargar juego.
            ExecuteModel();
        }
Example #13
0
        public Level1Model(UnderseaModel gameModel, TgcCamera camera, TgcD3dInput input, string mediaDir, string shadersDir, TgcFrustum frustum, TgcText2D drawText, TgcDirectSound directSound)
            : base(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText)
        {
            hudModel = new HUDModel(MediaDir, D3DDevice.Instance.Device);

            initialLookAt   = new TGCVector3(6000, 4120f, 6600f);
            initialPosition = new TGCVector3(6000, 4120f, 6600f);

            //Camara
            Camera = new FpsCamera(initialLookAt, Input);

            //Player
            playerModel = new PlayerModel(surfacePosition.Y, initialPosition, gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText, directSound);

            //Collect Model
            collectModel = new CollectModel(gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText, directSound);

            // History Model
            historyModel = new HistoryModel(gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText);

            // You Win Model
            youWinModel = new YouWinModel(gameModel, Camera, input, mediaDir, shadersDir, frustum, drawText, directSound);
        }
 public YouWinModel(UnderseaModel gameModel, TgcCamera camera, TgcD3dInput input, string mediaDir, string shadersDir, TgcFrustum frustum, TgcText2D drawText, TgcDirectSound directSound)
     : base(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText)
 {
     DirectSound = directSound;
 }
 public CollectModel(UnderseaModel gameModel, TgcCamera camera, TgcD3dInput input, string mediaDir, string shadersDir, TgcFrustum frustum, TgcText2D drawText, TgcDirectSound directSound)
     : base(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText)
 {
     rotationSpeed = 0.1f;
     DirectSound   = directSound;
 }
 public Sonido(string mediaDir, string shadersDir, TgcDirectSound DS) : base(mediaDir, shadersDir)
 {
     myInstance       = this;
     this.DirectSound = DS;
     Init();
 }
 public PlayerModel(float surfacePosition, TGCVector3 initialPosition, UnderseaModel gameModel, TgcCamera camera, TgcD3dInput input, string mediaDir, string shadersDir, TgcFrustum frustum, TgcText2D drawText, TgcDirectSound directSound)
     : base(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText)
 {
     surfaceYPosition            = surfacePosition;
     Position                    = initialPosition;
     WithoutHelmet               = true;
     InventoryModel              = new InventoryModel(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText);
     InventoryModel.PlayerModel  = this;
     fatherNoteModel             = new FatherNoteModel(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText);
     fatherNoteModel.PlayerModel = this;
     craftModel                  = new CraftModel(gameModel, camera, input, mediaDir, shadersDir, frustum, drawText, directSound);
     craftModel.PlayerModel      = this;
 }
Example #18
0
        /// <summary>
        ///     constructor principal
        /// </summary>
        /// <param name="directSound"></param>
        /// <param name="mediaDir"></param>
        public SoundPlayer(TgcDirectSound directSound, String mediaDir)
        {
            mp3Player = new TgcMp3Player();

            SoundsPath = mediaDir + "Sounds\\";
            //inicializo sonidos

            //materiales
            TgcStaticSound glassSound = new TgcStaticSound();

            glassSound.loadSound(SoundsPath + "Materials\\glass.wav", directSound.DsDevice);
            TgcStaticSound metalSound = new TgcStaticSound();

            metalSound.loadSound(SoundsPath + "Materials\\metal.wav", directSound.DsDevice);
            //TODO buscar un sonido de planta, por ahora uso default
            TgcStaticSound plantSound = new TgcStaticSound();

            plantSound.loadSound(SoundsPath + "Materials\\default.wav", directSound.DsDevice);
            TgcStaticSound woodSound = new TgcStaticSound();

            woodSound.loadSound(SoundsPath + "Materials\\wood.wav", directSound.DsDevice);
            TgcStaticSound noneSound = new TgcStaticSound();

            noneSound.loadSound(SoundsPath + "Materials\\default.wav", directSound.DsDevice);
            TgcStaticSound rockSound = new TgcStaticSound();

            rockSound.loadSound(SoundsPath + "Materials\\rock.wav", directSound.DsDevice);

            MaterialSounds = new Dictionary <InteractiveObject.Materials, TgcStaticSound>();
            MaterialSounds.Add(InteractiveObject.Materials.Wood, woodSound);
            MaterialSounds.Add(InteractiveObject.Materials.Glass, glassSound);
            MaterialSounds.Add(InteractiveObject.Materials.Metal, metalSound);
            MaterialSounds.Add(InteractiveObject.Materials.Plant, noneSound);
            MaterialSounds.Add(InteractiveObject.Materials.None, noneSound);
            MaterialSounds.Add(InteractiveObject.Materials.Rock, rockSound);

            //acciones
            TgcStaticSound drinkSound = new TgcStaticSound();

            drinkSound.loadSound(SoundsPath + "Actions\\drink.wav", directSound.DsDevice);
            TgcStaticSound treeFallSound = new TgcStaticSound();

            treeFallSound.loadSound(SoundsPath + "Actions\\tree_fall.wav", directSound.DsDevice);
            TgcStaticSound chestOpenSound = new TgcStaticSound();

            chestOpenSound.loadSound(SoundsPath + "Actions\\chest_open.wav", directSound.DsDevice);
            TgcStaticSound successSound = new TgcStaticSound();

            successSound.loadSound(SoundsPath + "Actions\\success.wav", directSound.DsDevice);
            TgcStaticSound hurtSound = new TgcStaticSound();

            hurtSound.loadSound(SoundsPath + "Actions\\hurt.wav", directSound.DsDevice);
            TgcStaticSound dieSound = new TgcStaticSound();

            dieSound.loadSound(SoundsPath + "Actions\\die.wav", directSound.DsDevice);
            TgcStaticSound jumpSound = new TgcStaticSound();

            jumpSound.loadSound(SoundsPath + "Actions\\jump.wav", directSound.DsDevice);
            //menu
            TgcStaticSound menuWrongSound = new TgcStaticSound();

            menuWrongSound.loadSound(SoundsPath + "Actions\\menu_wrong.wav", directSound.DsDevice);
            TgcStaticSound menuNextSound = new TgcStaticSound();

            menuNextSound.loadSound(SoundsPath + "Actions\\menu_next.wav", directSound.DsDevice);
            TgcStaticSound menuSelectSound = new TgcStaticSound();

            menuSelectSound.loadSound(SoundsPath + "Actions\\menu_select.wav", directSound.DsDevice);
            TgcStaticSound menuDiscardSound = new TgcStaticSound();

            menuDiscardSound.loadSound(SoundsPath + "Actions\\menu_discard.wav", directSound.DsDevice);

            ActionSounds = new Dictionary <Actions, TgcStaticSound>();
            ActionSounds.Add(Actions.Drink, drinkSound);
            ActionSounds.Add(Actions.TreeFall, treeFallSound);
            ActionSounds.Add(Actions.OpenChest, chestOpenSound);
            ActionSounds.Add(Actions.Success, successSound);
            ActionSounds.Add(Actions.Hurt, hurtSound);
            ActionSounds.Add(Actions.Die, dieSound);
            ActionSounds.Add(Actions.Jump, jumpSound);
            ActionSounds.Add(Actions.Menu_Discard, menuDiscardSound);
            ActionSounds.Add(Actions.Menu_Wrong, menuWrongSound);
            ActionSounds.Add(Actions.Menu_Next, menuNextSound);
            ActionSounds.Add(Actions.Menu_Select, menuSelectSound);

            //environment
            TgcStaticSound rainSound = new TgcStaticSound();

            rainSound.loadSound(SoundsPath + "Environment\\rain.wav", directSound.DsDevice);
            TgcStaticSound windSound = new TgcStaticSound();

            windSound.loadSound(SoundsPath + "Environment\\wind.wav", directSound.DsDevice);

            EnvironmentSounds = new Dictionary <EnvironmentConditions, TgcStaticSound>();
            EnvironmentSounds.Add(EnvironmentConditions.Rain, rainSound);
            EnvironmentSounds.Add(EnvironmentConditions.Wind, windSound);

            mp3Player.FileName = SoundsPath + "Environment\\ambient.mp3";
        }
Example #19
0
 public static void init(TgcDirectSound directSound)
 {
     DirectSound = directSound;
     MotorSound  = new StaticSound(Motor, DirectSound.DsDevice, false);
 }