/// <summary> /// Initializes the <see cref="Komodo.Core.Engine.Graphics.GraphicsManager"/> and all <see cref="Komodo.Core.ECS.Systems.ISystem"/> objects. /// </summary> public void Initialize() { GraphicsManager.Initialize(); DefaultSpriteShader = new BasicEffect(GraphicsManager.GraphicsDeviceManager.GraphicsDevice) { TextureEnabled = true, VertexColorEnabled = true, }; GraphicsManager.VSync = false; CameraSystem.Initialize(); SoundSystem.Initialize(); var physicsSystems = PhysicsSystems.ToArray(); foreach (var system in physicsSystems) { system.Initialize(); } var render3DSystems = Render3DSystems.ToArray(); foreach (var system in render3DSystems) { system.Initialize(); } var render2DSystems = Render2DSystems.ToArray(); foreach (var system in render2DSystems) { system.Initialize(); } BehaviorSystem.Initialize(); }
public Screen() { this.g = G.g; this.spriteBatch = g.spriteBatch; this.e = g.e; this.GraphicsDevice = g.GraphicsDevice; this.font = g.font; }
private static void PrepareEffectForRendering(PositionedModel model, BasicEffect effect) #endif { ApplyLighting(model, effect); // Set this to false and all is fixed magically! effect.VertexColorEnabled = false; ApplyColorOperation(model, effect); SpriteManager.Camera.SetDeviceViewAndProjection(effect, false); }
private static void ApplyLighting(PositionedModel model, BasicEffect effect) { if (!LightManager.EnableLighting) { effect.LightingEnabled = false; } else if (AvailableLights != null && AvailableLights.Count > 0) { //effect.EnableDefaultLighting(); //Start by turning off all the lights. effect.LightingEnabled = true; effect.DirectionalLight0.Enabled = effect.DirectionalLight1.Enabled = effect.DirectionalLight2.Enabled = false; //This tracks which directional light in the shader we are working with. int effectLightIndex = 0; //Loop through all lights for (int i = 0; i < AvailableLights.Count; i++) { LightBase baseLight = AvailableLights[i]; if (baseLight.Enabled) { if (baseLight is AmbientLight) { SetAmbientLight(effect, baseLight); } else { #if XNA4 Microsoft.Xna.Framework.Graphics.DirectionalLight directionalLight; if (effectLightIndex == 0) directionalLight = effect.DirectionalLight0; else if (effectLightIndex == 1) directionalLight = effect.DirectionalLight1; else directionalLight = effect.DirectionalLight2; SetDirectionalLight(directionalLight, baseLight, model.Position); effectLightIndex++; #endif } } } } else { effect.EnableDefaultLighting(); effect.DirectionalLight0.Enabled = effect.DirectionalLight1.Enabled = effect.DirectionalLight2.Enabled = false; effect.AmbientLightColor = Vector3.Zero; } }
private static void ApplyColorOperation(PositionedModel model, BasicEffect effect)