コード例 #1
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo,factory, contentManager);
            this.contentManager = contentManager;
    
            SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
            TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            DeferredNormalShader shader = new DeferredNormalShader();
            DeferredMaterial fmaterial = new DeferredMaterial(shader);
            IObject obj = new IObject(fmaterial, simpleModel, tmesh);
            this.World.AddObject(obj);            
            
            //ap = new SoundAudioPlayer(contentManager);
            //ap.AddSoundToRepository("Songs/bye", "bye");

            //se = new SimpleSoundEffect(contentManager, "Songs/alarm");

            //LocalMediaAudioPlayer lm = new LocalMediaAudioPlayer();
            //AlbumCollection ac = lm.MediaLibrary.Albums;
            //lm.PlayAlbum(ac[0]);
            
            sound = new Static3DSound(factory, "Songs/pianosong", Vector3.Zero);
            this.World.AddSoundEmitter(sound, true);

            //ObjectFollower3DSound sound2 = new ObjectFollower3DSound(contentManager, "Songs/pianosong", obj);

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            this.World.CameraManager.AddCamera(new CameraFirstPerson(true,GraphicInfo));

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);

        }
コード例 #2
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo,factory, contentManager);

            {
                ///Create the xml file model extractor
                ///Loads a XML file that was export by our 3DS MAX plugin
                ExtractXmlModelLoader ext = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//");
                this.AttachCleanUpAble(ext);
                ///Extract all the XML info (Model,Cameras, ...)
                ModelLoaderData data = ext.Load(factory, GraphicInfo, "ilha");
                ///Create the WOrld Loader
                ///Convert the ModelLoaderData in World Entities
                WorldLoader wl = new WorldLoader(); ///all default                
                wl.LoadWorld(factory, GraphicInfo, World, data);
            }


            ///Create and add a sound to the SoundAudioPlayer
            ap = new SoundAudioPlayer(factory);
            ap.AddSoundToRepository("Songs/bye", "bye");

            ///Create a sound effect without the SoundAudioPlayer (internaly the SoundAudioPlayer is a container of SimpleSoundEffect -- and some stuffs more)
            se = new SimpleSoundEffect(factory, "Songs/alarm");

            ///Load the Sounds that you hear in your Microsoft Media Player
            ///Just loading the first album found =P
            lm = new LocalMediaAudioPlayer();
            AlbumCollection ac = lm.MediaLibrary.Albums;
            lm.PlayAlbum(ac[0]);
            
            ///Creating a static 3D sound in the 0,0,0 (Bellow the island tree, go there and hear the sound getting louder)
            sound = new Static3DSound(factory, "Songs/pianosong", Vector3.Zero);            
            this.World.AddSoundEmitter(sound, true);

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(30), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);

        }
コード例 #3
0
        protected override void Update(GameTime gameTime)
        {
            //if (Keyboard.GetState().IsKeyDown(Keys.Space))
            //{
            //    se.Play();
            //}

            //if (Keyboard.GetState().IsKeyDown(Keys.Enter))
            //{
            //    se.Pause();
            //}

            //if (Keyboard.GetState().IsKeyDown(Keys.RightAlt))
            //{
            //    ap.PlaySoundEffect("bye");
            //}
            //if (Keyboard.GetState().IsKeyDown(Keys.RightShift))
            //{
            //    ap.StopSoundEffect("bye");
            //}

            if (Keyboard.GetState().IsKeyDown(Keys.LeftControl))
            {
                this.World.RemoveSoundEmitter(sound);
                sound = new Static3DSound(GraphicFactory, "Songs/pianosong", Vector3.Zero);
                this.World.AddSoundEmitter(sound, true);
                
                sound.Play();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.RightControl))
            {
                sound.Stop(true);
            }
            

            base.Update(gameTime);
        }