Exemplo n.º 1
0
        protected override void LoadContent()
        {
            _sunlightEffect = SunlightEffect.Create(GraphicsDevice, Game.Content);
            _model          = Game.Content.Load <Model>(_modelName);

//            var basicEffect = new BasicEffect(GraphicsDevice, null);
            if (_sunlightEffect != null)
            {
                // Replace the object's effects with our provided effect
                foreach (ModelMesh mesh in _model.Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        // Reuse existing model texture in sunlight effect
//                        if (part.Effect as BasicEffect != null)
//                            _sunlightEffect.Texture = ((BasicEffect) part.Effect).Texture;
//
                        // Assign sunlight shader
//                        part.Effect = _sunlightEffect;
                    }
                }
            }

            base.LoadContent();
        }
        protected override void LoadContent()
        {
            _spriteBatch  = new SpriteBatch(GraphicsDevice);
            _hudInfo1Font = _game.Content.Load <SpriteFont>("HUDInfo1");
            _helicopter   = _game.Content.Load <Model>("Models/gunship");

            _engineSound              = _game.Content.Load <SoundEffect>("Audio/full_throttle");
            _engineSoundInst          = _engineSound.CreateInstance();
            _engineSoundInst.Volume   = 0.7f;
            _engineSoundInst.IsLooped = true;

            _sunlightEffect = SunlightEffect.Create(GraphicsDevice, _game.Content);

            // TODO This is a hack for this helicopter mesh, which has only one texture.
            // Normally we would need to create a new sunlight effect for each mesh part.
            foreach (ModelMesh mesh in _helicopter.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    if (_sunlightEffect != null)
                    {
                        // Reuse existing model texture in sunlight effect
                        if (part.Effect as BasicEffect != null)
                        {
                            _sunlightEffect.Texture = ((BasicEffect)part.Effect).Texture;
                        }

                        // Assign sunlight shader
                        part.Effect = _sunlightEffect;
                    }
                }
            }


            base.LoadContent();

//            Reset(TimeSpan.Zero, _scenario, Autopilot.Map);
        }