Exemple #1
0
        public override void Start()
        {
            Art.Load();

            var   graphics = AtomicNET.GetSubsystem <Graphics>();
            float width    = graphics.Width;
            float height   = graphics.Height;

            ScreenSize   = new Vector2(width, height);
            ScreenBounds = new IntRect(0, 0, (int)ScreenSize.X, (int)ScreenSize.Y);

            var renderer = AtomicNET.GetSubsystem <Renderer>();
            var viewport = renderer.GetViewport(0);

            renderer.HDRRendering = true;

            var cache      = GetSubsystem <ResourceCache>();
            var renderpath = viewport.GetRenderPath().Clone();

            renderpath.Append(cache.GetResource <XMLFile>("RenderPath/BloomHDR.xml"));
            renderpath.Append(cache.GetResource <XMLFile>("RenderPath/Blur.xml"));
            viewport.SetRenderPath(renderpath);

            Scene = new Scene();
            Scene.CreateComponent <Octree>();

            var camera = Scene.CreateChild("Camera").CreateComponent <Camera>();

            camera.Node.Position = new Vector3(width / 2.0f, height / 2.0f, 0.0f);
            camera.Orthographic  = true;
            camera.OrthoSize     = height;

            viewport.Scene  = Scene;
            viewport.Camera = camera;

            CustomRenderer.Initialize();

            ParticleManager = new ParticleManager <ParticleState>(1024 * 20, ParticleState.UpdateParticle);

#if ATOMIC_DESKTOP
            const int maxGridPoints = 1600;
#else
            const int maxGridPoints = 400;
#endif

            float   amt         = (float)Math.Sqrt(ScreenBounds.Width * ScreenBounds.Height / maxGridPoints);
            Vector2 gridSpacing = new Vector2(amt, amt);

            IntRect expandedBounds = ScreenBounds;
            expandedBounds.Inflate((int)gridSpacing.X, (int)gridSpacing.Y);
            Grid = new Grid(expandedBounds, gridSpacing);

            EntityManager.Add(PlayerShip.Instance);

            SubscribeToEvent("Update", HandleUpdate);
            SubscribeToEvent("RenderPathEvent", HandleRenderPathEvent);
        }