예제 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Form xnaWindow = (Form)Control.FromHandle((this.Window.Handle));

            xnaWindow.GotFocus += new EventHandler(xnaWindow_GotFocus);
            _editor.Show();
            _beamer.Show();

            _kinectSystem.SandstormKinectDepth += new EventHandler <SandstormKinectEvent>(_kinectSystem_SandstormKinectDepth);
            _kinectSystem.StartKinect();


            graphics.PreferredBackBufferWidth  = _editor.panel1.Width;
            graphics.PreferredBackBufferHeight = _editor.panel1.Height;
            graphics.PreferMultiSampling       = true;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            _sharedList = SharedList.getInstance(GraphicsDevice);

            _beamer.panel1.Resize += new EventHandler(_beamer_ResizeEnd);
            _editor.panel1.Resize += new EventHandler(_editor_ResizeEnd);



            _orthoCamera = Camera.LoadCamera(Camera.ProjectionType.ORTHOGRAPHIC_PROJECTION, _beamer.panel1.Width, _beamer.panel1.Height);
            _perspCamera = Camera.LoadCamera(Camera.ProjectionType.PERSPECTIVE_PROJECTION, _editor.panel1.Width, _editor.panel1.Height);

            _cameraController2 = new CameraController(_orthoCamera);
            _cameraController  = new CameraController(_perspCamera);

            _renderTargetMain     = new RenderTarget2D(GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
            _renderTargetNormal   = new RenderTarget2D(GraphicsDevice, SharedList.SquareSize, SharedList.SquareSize, false, SurfaceFormat.Vector4, DepthFormat.None);
            _renderTargetPosition = new RenderTarget2D(GraphicsDevice, SharedList.SquareSize, SharedList.SquareSize, false, SurfaceFormat.Vector4, DepthFormat.None);

            _heightMap      = new HeightMap(GraphicsDevice, Content, _renderTargetMain, _renderTargetNormal);
            _particleSystem = new Galaxy(GraphicsDevice, _sharedList, Content, _perspCamera, _heightMap);

            base.Initialize();
        }