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(); }
public SunlightSystem(GraphicsDevice device, PostProcessTriangle postProcessTriangle, SunlightEffect effect, FrameService frameService) { this.Device = device; this.FrameService = frameService; this.PostProcessTriangle = postProcessTriangle; this.Effect = effect; }
public SunlightSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <Sunlight> Lights, CascadedShadowMapFactory cascadedShadowMapFactory) { this.Device = device; this.Effect = effectFactory.Construct <SunlightEffect>(); this.Lights = Lights; this.FullScreenTriangle = new FullScreenTriangle(); this.Frustum = new Frustum(); }
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); }