Example #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()
        {
            X = new XMain(graphics.GraphicsDevice, Services, "", freeCamera);
            //We are going to use a right hand corrdinate system switch default cull mode to refelect this
            //NOTE: Using the default model processor will not work with this since its winding order is backwards
            X.GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace;
#if DEBUG
            XDebugVolumeRenderer.InitializeBuffers(X.GraphicsDevice, 50);
#endif
            X.FrameRate.DisplayFrameRate = true;
            X.Console.AutoDraw           = false;
            X.Debug.StartPosition.Y      = 200;

            resources = new XResourceGroup(ref X);
            input     = new InputProcessor(ref X, this);
            menus     = new MenuManager(ref X);
            //menu to the debugnodraw list
            X.Renderer.DebugNoDraw.Add(menus);

            //Make some Cameras
            freeCamera          = new XFreeLookCamera(ref X, .1f, 1000f);
            freeCamera.Position = new Vector3(0, 10, 50);
            driverCamera        = new XFreeLookCamera(ref X, .1f, 1000f);
            chase           = new XChaseCamera(ref X, .1f, 1000f);
            currentCamera   = chase;
            X.DefaultCamera = freeCamera;

            base.Initialize();
        }
Example #2
0
        protected override void Initialize()
        {
            time = new XEditorGameTime();
            X    = new XMain(this.GraphicsDevice, this.Services, ContentRootDir, camera);
            //setup some basic usefull settings
            X.Gravity       = new Vector3(0, -40, 0);
            X.UpdatePhysics = false;
            X.FrameRate.DisplayFrameRate = true;
            X.Console.AutoDraw           = false;
            X.Debug.StartPosition.Y      = 200;

            camera = new XFreeLookCamera(ref X, 0.1f, 1000f);
            //set the initial position of the camera such that we are looking at the center of the game world (0,0,0)
            camera.Position = new Vector3(30f, 15f, 40f);
            //so we look at center add in a rotation (trial and error)
            camera.Rotate(new Vector3(MathHelper.ToRadians(-10f), MathHelper.ToRadians(40f), 0));

            X.LoadContent();

            X.Physics.EnableFreezing = true;

            time.TotalGameTime.Reset();
            time.TotalGameTime.Start();
            time.ElapsedGameTime.Reset();
            time.ElapsedGameTime.Start();

            hasFocus        = false;
            dragdroprelease = false;
            SetupBaseComponents();

            //Begin draw timer!
            //redraw = new Timer();
            //redraw.Interval = 1;
            //redraw.Start();

            //redraw.Tick += new EventHandler(redraw_Tick);
            // Hook the idle event to constantly redraw our animation.
            Application.Idle += delegate { Invalidate(); };
        }