Beispiel #1
0
        public bool Frame(DDX11 direct3D, DInput input, DShaderManager shaderManager, DTextureManager textureManager, float frameTime, int fps)
        {
            // Do the frame input processing.
            if (!HandleInput(input, frameTime))
            {
                return(false);
            }

            // Do the frame processing for the user interface.
            if (!UserInterface.Frame(direct3D.DeviceContext, fps, Position.PositionX, Position.PositionY, Position.PositionZ, Position.RotationX, Position.RotationY, Position.RotationZ))
            {
                return(false);
            }

            // Do the terrain frame processing.
            Terrain.Frame();

            // Render the graphics.
            if (!Render(direct3D, shaderManager, textureManager))
            {
                return(false);
            }

            return(true);
        }
        static unsafe bool EnumDevicesHandler(IntPtr /*DIDEVICEINSTANCE*/ lpddi, void *pvRef)
        {
            DIDEVICEINSTANCE *deviceInstance = (DIDEVICEINSTANCE *)lpddi.ToPointer();

            //ignore XInput devices
            if (Instance.haveXInput && DInput.IsXInputDevice(ref deviceInstance->guidProduct))
            {
                return(true);                //continue
            }
            if ((deviceInstance->dwDevType & DInput.DI8DEVTYPE_JOYSTICK) != 0)
            {
                string deviceName = new string( deviceInstance->tszInstanceName );

                DirectInputJoystickInputDevice joystick = new DirectInputJoystickInputDevice(
                    deviceName, deviceInstance->guidInstance);

                if (!joystick.Init())
                {
                    joystick.CallOnShutdown();
                    return(true);
                }

                Instance.RegisterDevice(joystick);
            }

            return(true);            //continue
        }
Beispiel #3
0
        unsafe internal override bool OnInit()
        {
            NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative");

            try
            {
                void *directInputTemp;
                GUID  iidDirectInput = DInput.IID_IDirectInput8W;
                int   hr             = DInput.DirectInput8Create(ref iidDirectInput, out directInputTemp);
                if (global::DirectInput.Wrapper.FAILED(hr))
                {
                    Log.Warning("WindowsInputDeviceManager: DirectInput8Create failed.");
                    return(false);
                }
                directInput = (IDirectInput *)directInputTemp;

                if (!CreateDevices())
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Beispiel #4
0
 public void RemoveInput(KeyCode code, DInput dG)
 {
     if (s_inputs.ContainsKey(code))
     {
         s_inputs[code] -= dG;
     }
 }
Beispiel #5
0
    public DIInputDevice()
    {
        _directInput = DInput.DirectInput8Create();

        _keyboardDevices = new Dictionary <Guid, IDirectInputDevice8>();
        _joystickDevices = new Dictionary <Guid, IDirectInputDevice8>();
    }
 public DInputPad(int idx)
     : base(idx)
 {
     this._name        = "dinput" + (object)idx;
     this._productName = DInput.GetProductName(this.index);
     this._productGUID = DInput.GetProductGUID(this.index);
 }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectInput"/> class.
        /// </summary>
        public DirectInput() : base(IntPtr.Zero)
        {
            IntPtr temp;

            DInput.DirectInput8Create(Win32Native.GetModuleHandle(null), DInput.SdkVersion, Utilities.GetGuidFromType(typeof(DirectInput)), out temp, null);
            NativePointer = temp;
        }
        // Methods
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            }

            // Initialize Window.
            InitializeWindows(title);

            if (Input == null)
            {
                Input = new DInput();
                Input.Initialize();
            }
            if (Graphics == null)
            {
                Graphics = new DGraphics();
                result   = Graphics.Initialize(Configuration, RenderForm.Handle);
            }

            DPerfLogger.Initialize("RenderForm C# SharpDX: " + Configuration.Width + "x" + Configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + RenderForm.Text, testTimeSeconds, Configuration.Width, Configuration.Height);

            return(result);
        }
    void Start()
    {
        mbShowErrorMessage = true;
        mbUseGyro          = false;

        //load some settings from PlayerPrefs
        DInput.load();

        rot = Quaternion.identity;

        //Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        //set Frame Rate hint to 60 FPS
        Application.targetFrameRate = 60;
#if UNITY_EDITOR
#elif UNITY_ANDROID
        // Java part
        DiveJava.init();
        dive_set_path(Application.persistentDataPath);
        Network.logLevel = NetworkLogLevel.Full;
        use_udp(1);
        initialize_sensors();
        int err = get_error();
        if (err == 0)
        {
            mbShowErrorMessage = false;
            mbUseGyro          = true;
            if (correctCenterTransition)
            {
                get_q(ref q0, ref q1, ref q2, ref q3);
                rot.x = -q2;
                rot.y = q3;
                rot.z = -q1;
                rot.w = q0;
                Quaternion temp = Quaternion.identity;
                temp.eulerAngles      = new Vector3(0, rot.eulerAngles.y, 0);
                this.centerTransition = Quaternion.identity * Quaternion.Inverse(temp);
            }

            if (no.GetDeviceDefaultOrientation() == NaturalOrientation.LANDSCAPE)
            {
                is_tablet = 1;
                Debug.Log("Dive Unity Tablet Mode activated");
            }
            else
            {
                Debug.Log("Dive Phone Mode activated");
            }
        }
        else
        {
            mbShowErrorMessage = true;
            mbUseGyro          = false;
        }
#elif UNITY_IPHONE
        initialize_sensors();
        mbShowErrorMessage = false;
        mbUseGyro          = true;
#endif
    }
Beispiel #10
0
        public void Initialise(IntPtr handle)
        {
            try
            {
                DirectInput = DInput.DirectInput8Create();

                _keyboards = EnumerateAllAttachedKeyboardDevices(DirectInput);

                foreach (var item_ in _keyboards)
                {
                    InitialiseKeyboardDevice(DirectInput, item_.Key, handle);
                }

                _joysticks = EnumerateAllAttachedGameDevices(DirectInput);

                foreach (var item_ in _joysticks)
                {
                    InitialiseJoystickDevice(DirectInput, item_.Key, handle);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #11
0
 public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle, Surface surface)
 {
     try
     {
         Input = new DInput();
         Input.Initialize(configuration, windowHandle);
         D3D = new DDX11();
         D3D.Initialize(configuration, windowHandle);
         Camera = new DCamera();
         Camera.SetPosition(0.0f, 0.0f, -1.0f);
         Camera.Render();
         Camera.SetPosition(50.0f, 2.0f, 10.0f);
         Terrain = new DSurface();
         Terrain.Initialize(D3D.Device, surface);
         ColorShader = new DColorShader();
         ColorShader.Initialize(D3D.Device, windowHandle);
         Position = new DPosition();
         Position.SetPosition(Camera.GetPosition().X, Camera.GetPosition().Y, Camera.GetPosition().Z);  // Ustawienie Position == Camera
         Camera.SetRotation(0.32f, -0.9f, 0);
         Position.RotationX    = 0.32f;
         Position.RotationY    = -90f;
         PositionChangeHandler = new DPositionChangeHandler(Position, Input);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #12
0
        public static DataTable SearchNameDate(string searchtext, string searchtext2)
        {
            DInput Obj = new DInput();

            //Obj.SearchText = searchtext;

            return(Obj.SearchNameDate(searchtext, searchtext2));
        }
Beispiel #13
0
        public static string Cancel(int id)
        {
            DInput Obj = new DInput();

            Obj.IdInput = id;


            return(Obj.Cancel(Obj));
        }
Beispiel #14
0
 public void BindInput(KeyCode code, DInput dG)
 {
     if (s_inputs.ContainsKey(code))
     {
         s_inputs[code] += dG;
     }
     else
     {
         s_inputs.Add(code, dG);
     }
 }
Beispiel #15
0
        // Methods
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            }

            // Initialize Window.
            InitializeWindows(title);

            if (Input == null)
            {
                Input = new DInput();
                if (!Input.Initialize(Configuration, RenderForm.Handle))
                {
                    return(false);
                }
            }
            if (Graphics == null)
            {
                Graphics = new DGraphics();
                result   = Graphics.Initialize(Configuration, RenderForm.Handle);
            }

            DPerfLogger.Initialize("RenderForm C# SharpDX: " + Configuration.Width + "x" + Configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + RenderForm.Text, testTimeSeconds, Configuration.Width, Configuration.Height);;

            // Create and initialize Timer.
            Timer = new DTimer();
            if (!Timer.Initialize())
            {
                MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK);
                return(false);
            }

            // Create the sound object   sound01.wav  sound02.wav
            Sound = new DWaveSound("sound02.wav");

            // Initialize the sound object.
            if (!Sound.Initialize(RenderForm.Handle))
            {
                MessageBox.Show("Could not initialize Direct Sound", "Error", MessageBoxButtons.OK);
                return(false);
            }

            // This seperates out the creation of one DirectSound object and one PrimaryBuffer nad loads as many SecondaryBuffers as there are Sound.LoadAudio Calls. We pass in only the first instanceances DirectSound to play from both secondaryBuffers from the one primaryBuffer.
            Sound.LoadAudio(Sound._DirectSound);
            Sound.Play(0, new SharpDX.Vector3(-2.0f, 0, 0.0f)); // Front Center

            return(result);
        }
        private bool HandleInput(DInput input, float frameTime)
        {
            // Set the frame time for calculating the updated position.
            Position.SetFrameTime(frameTime);

            // Handle the input
            bool keydown = input.IsLeftArrowPressed();

            Position.TurnLeft(keydown);
            keydown = input.IsRightArrowPressed();
            Position.TurnRight(keydown);
            keydown = input.IsUpArrowPressed();
            Position.MoveForward(keydown);
            keydown = input.IsDownArrowPressed();
            Position.MoveBackward(keydown);
            keydown = input.IsPageUpPressed();
            Position.LookUpward(keydown);
            keydown = input.IsPageDownPressed();
            Position.LookDownward(keydown);
            keydown = input.IsAPressed();
            Position.MoveUpward(keydown);
            keydown = input.IsZPressed();
            Position.MoveDownward(keydown);

            // Determine if the user interface should be displayed or not.
            if (input.IsF1Toogled())
            {
                DisplayUI = !DisplayUI;
            }
            // Determine if the terrain should be rendered in wireframe or not.
            if (input.IsF2Toogled())
            {
                WireFrame = !WireFrame;
            }
            // Determine if we should render the lines around each terrain cell.
            if (input.isF3Toggled())
            {
                CellLines = !CellLines;
            }
            // Determine if we should be locked to the terrain height when we move around or not.
            if (input.isF4Toggled())
            {
                HeightLocked = !HeightLocked;
            }

            // Set the position and rOTATION of the camera.
            Camera.SetPosition(Position.PositionX, Position.PositionY, Position.PositionZ);
            Camera.SetRotation(Position.RotationX, Position.RotationY, Position.RotationZ);

            return(true);
        }
Beispiel #17
0
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            InitializeWindows(title);
            RenderForm.BackColor = Color.Black;
            Input    = new DInput();
            result   = Input.Initialize();
            Graphics = new DGraphics();
            result   = Graphics.Initialize(Configuration);
            Timer    = new DTimer();
            result   = Timer.Initialize();

            return(result);
        }
        // Methods
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            }

            // Initialize Window.
            InitializeWindows(title);

            if (Input == null)
            {
                Input = new DInput();
                if (!Input.Initialize(Configuration, RenderForm.Handle))
                {
                    return(false);
                }
            }
            if (Graphics == null)
            {
                Graphics = new DGraphics();
                result   = Graphics.Initialize(Configuration, RenderForm.Handle);
            }

            DPerfLogger.Initialize("RenderForm C# SharpDX: " + Configuration.Width + "x" + Configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + RenderForm.Text, testTimeSeconds, Configuration.Width, Configuration.Height);;

            // Create and initialize the FpsClass.
            FPS = new DFPS();
            FPS.Initialize();

            // Create and initialize the CPU.
            CPU = new DCPU();
            CPU.Initialize();

            // Create and initialize Timer.
            Timer = new DTimer();
            if (!Timer.Initialize())
            {
                MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK);
                return(false);
            }

            return(result);
        }
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            // Create the input object.  The input object will be used to handle reading the keyboard and mouse input from the user.
            Input = new DInput();
            // Initialize the input object.
            if (!Input.Initialize(configuration, windowHandle))
            {
                return(false);
            }

            // Create the Direct3D object.
            D3D = new DDX11();
            // Initialize the Direct3D object.
            if (!D3D.Initialize(configuration, windowHandle))
            {
                return(false);
            }

            // Create the shader manager object.
            ShaderManager = new DShaderManager();
            // Initialize the shader manager object.
            if (!ShaderManager.Initilize(D3D, windowHandle))
            {
                return(false);
            }

            // Create and initialize Timer.
            Timer = new DTimer();
            if (!Timer.Initialize())
            {
                return(false);
            }

            // Create the fps object.
            FPS = new DFPS();
            FPS.Initialize();

            // Create and Initialize the Zone object.
            Zone = new DZone();
            if (!Zone.Initialze(D3D, windowHandle, configuration))
            {
                return(false);
            }

            return(true);
        }
Beispiel #20
0
        // Methods
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            }

            // Initialize Window.
            InitializeWindows(title);

            if (Input == null)
            {
                Input = new DInput();
                if (!Input.Initialize(Configuration, RenderForm.Handle))
                {
                    return(false);
                }
            }
            if (Graphics == null)
            {
                Graphics = new DGraphics();
                result   = Graphics.Initialize(Configuration, RenderForm.Handle);
            }

            DPerfLogger.Initialize("RenderForm C# SharpDX: " + Configuration.Width + "x" + Configuration.Height + " VSync:" + DSystemConfiguration.VerticalSyncEnabled + " FullScreen:" + DSystemConfiguration.FullScreen + "   " + RenderForm.Text, testTimeSeconds, Configuration.Width, Configuration.Height);;

            // Create and initialize Timer.
            Timer = new DTimer();
            if (!Timer.Initialize())
            {
                MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK);
                return(false);
            }

            // Create the position object.
            Position = new DPosition();

            // Set the initial position of the viewer to the same as the initial camera position.
            SharpDX.Vector3 camPos = Graphics.Camera.GetPosition();
            Position.SetPosition(camPos.X, camPos.Y, camPos.Z);

            return(result);
        }
                public DecisionNet express(T p_controller)
                {
                    DInput[] inputs = new DInput[m_inputs.Length];

                    for (int i = 0; i < m_inputs.Length; i++)
                    {
                        inputs[i] = m_inputs[i](p_controller);
                    }

                    DOutput[] outputs = new DOutput[m_outputs.Length];

                    for (int i = 0; i < outputs.Length; i++)
                    {
                        outputs[i] = m_outputs[i](p_controller);
                    }

                    return(new DecisionNet(inputs, outputs, m_weights));
                }
Beispiel #22
0
        /*PID*/
        private async void SendPID_Click(object sender, RoutedEventArgs e)
        {   //Send PID coefficients to Oven
            SendPID.IsEnabled = false;

            PID hmi  = (PInput.ValueFloat(), IInput.ValueFloat(), DInput.ValueFloat());
            PID psoc = await Oven.SetPID(hmi);

            if (psoc == hmi)
            {
                POven.Text = psoc.Proportional.ToString();
                IOven.Text = psoc.Integral.ToString();
                DOven.Text = psoc.Derivative.ToString();
                await ShowSuccess("PID updated successfully");

                Settings[nameof(PID)] = psoc.ToString();
            }

            SendPID.IsEnabled = true;
        }
Beispiel #23
0
        public void SwitchPlayerProfile()
        {
            this.inputTypes.Clear();
            this.inputMaps.Clear();
            for (int index = 0; index < 4; ++index)
            {
                XInputPad device = Input.GetDevice <XInputPad>(index);
                if (device != null && device.isConnected)
                {
                    this.inputTypes.Add("XBOX GAMEPAD");
                    this.inputMaps.Add(Input.GetDefaultMapping(device.productName, device.productGUID).Clone());
                    break;
                }
            }
            List <string> stringList = new List <string>();

            for (int index = 0; index < 8; ++index)
            {
                if (DInput.GetState(index) != null)
                {
                    string productName = DInput.GetProductName(index);
                    string productGuid = DInput.GetProductGUID(index);
                    string str         = productName + productGuid;
                    if (!stringList.Contains(str))
                    {
                        stringList.Add(str);
                        this.inputMaps.Add(Input.GetDefaultMapping(productName, productGuid).Clone());
                        if (productName.Length > 24)
                        {
                            productName = productName.Substring(0, 24);
                        }
                        this.inputTypes.Add(productName);
                    }
                }
            }
            this.inputTypes.Add("KEYBOARD P1");
            this.inputMaps.Add(Input.GetDefaultMapping("KEYBOARD P1", "").Clone());
            this.inputTypes.Add("KEYBOARD P2");
            this.inputMaps.Add(Input.GetDefaultMapping("KEYBOARD P2", "").Clone());
            this.inputConfigType = 0;
            this.SwitchConfigType();
        }
Beispiel #24
0
        unsafe bool CreateDevices()
        {
            // check for XInput presense
            haveXInput = XInput.IsXInputPresent();

            if (haveXInput)
            {
                XINPUT_STATE state = new XINPUT_STATE();

                for (int n = 0; n < XInput.MaxControllers; n++)
                {
                    int result = XInput.GetState(n, ref state);
                    if (!XInputNativeWrapper.Wrapper.FAILED(result))
                    {
                        string name = string.Format("XBox Controller {0}", n);

                        WindowsXBoxGamepad device = new WindowsXBoxGamepad(name, n);
                        if (!device.Init())
                        {
                            device.CallOnShutdown();
                            continue;
                        }

                        RegisterDevice(device);
                    }
                }
            }

            // check for DirectInput devices

            int hr = IDirectInput.EnumDevices(directInput, DInput.DI8DEVCLASS_GAMECTRL,
                                              EnumDevicesHandler, null, DInput.DIEDFL_ATTACHEDONLY);

            if (global::DirectInput.Wrapper.FAILED(hr))
            {
                Log.Warning("WindowsInputDeviceManager: IDirectInput.EnumDevices failed ({0}).",
                            DInput.GetOutString(DInput.DXGetErrorStringW(hr)));
                return(false);
            }

            return(true);
        }
        public bool Frame(DDX11 direct3D, DInput input, DShaderManager shaderManager, DTextureManager textureManager, float frameTime, int fps)
        {
            // Do the frame input processing.
            if (!HandleInput(input, frameTime))
            {
                return(false);
            }

            // Do the frame processing for the user interface.
            if (!UserInterface.Frame(direct3D.DeviceContext, fps, Position.PositionX, Position.PositionY, Position.PositionZ, Position.RotationX, Position.RotationY, Position.RotationZ))
            {
                return(false);
            }

            // Do the terrain frame processing.
            Terrain.Frame();

            float height = 99.0f;

            // If the height is locked to the terrain then position the camera on top of it.
            if (HeightLocked)
            {
                Terrain.GetHeightAtPosition(Position.PositionX, Position.PositionZ, out height);
            }

            Position.SetPosition(Position.PositionX, height + 1.0f, Position.PositionZ);
            Camera.SetPosition(Position.PositionX, height + 1.0f, Position.PositionZ);


            // Render the graphics.
            if (!Render(direct3D, shaderManager, textureManager))
            {
                return(false);
            }

            return(true);
        }
Beispiel #26
0
        public static string Insert(int idstaff, int supplier, DateTime date, string type,
                                    string serie, string corelativ, decimal vat, string status, DataTable dtDetail)
        {
            DInput Obj = new DInput();

            Obj.IdStaff       = idstaff;
            Obj.IdSupplier    = supplier;
            Obj.DateInput     = date;
            Obj.TypeDoc       = type;
            Obj.SerieDoc      = serie;
            Obj.Corelativ     = corelativ;
            Obj.Vat           = vat;
            Obj.CurrentStatus = status;


            //Details of th purchase
            List <DDetail_Input> details = new List <DDetail_Input>();

            foreach (DataRow row in dtDetail.Rows)
            {
                DDetail_Input detail = new DDetail_Input();


                detail.IdProduct     = Convert.ToInt32(row["idproduct"].ToString());
                detail.ValuePurchase = Convert.ToDecimal(row["value_purchased"].ToString());
                detail.ValueSold     = Convert.ToDecimal(row["value_sold"].ToString());
                detail.InitialStoque = Convert.ToInt32(row["initial_stoque"].ToString());
                detail.CurrentStoque = Convert.ToInt32(row["initial_stoque"].ToString());
                detail.ProductioDate = Convert.ToDateTime(row["produced_date"].ToString());
                detail.ExpiredDate   = Convert.ToDateTime(row["expired_date"].ToString());

                details.Add(detail);
            }


            return(Obj.Insert(Obj, details));
        }
        // Methods
        public virtual bool Initialize(string title, int width, int height, bool vSync, bool fullScreen, int testTimeSeconds)
        {
            bool result = false;

            if (Configuration == null)
            {
                Configuration = new DSystemConfiguration(title, width, height, fullScreen, vSync);
            }

            // Initialize Window.
            InitializeWindows(title);

            // And for this tutorial only paint the Forms Background Black.
            RenderForm.BackColor = Color.Black;

            if (Input == null)
            {
                Input = new DInput();
                Input.Initialize();
            }
            if (Graphics == null)
            {
                Graphics = new DGraphics();
                result   = Graphics.Initialize(Configuration);
            }

            // Create and initialize Timer.
            Timer = new DTimer();
            if (!Timer.Initialize())
            {
                MessageBox.Show("Could not initialize Timer object", "Error", MessageBoxButtons.OK);
                return(false);
            }

            return(result);
        }
        private bool HandleInput(DInput input, float frameTime)
        {
            // Set the frame time for calculating the updated position.
            Position.SetFrameTime(frameTime);

            // Handle the input
            bool keydown = input.IsLeftArrowPressed();

            Position.TurnLeft(keydown);
            keydown = input.IsRightArrowPressed();
            Position.TurnRight(keydown);
            keydown = input.IsUpArrowPressed();
            Position.MoveForward(keydown);
            keydown = input.IsDownArrowPressed();
            Position.MoveBackward(keydown);
            keydown = input.IsPageUpPressed();
            Position.LookUpward(keydown);
            keydown = input.IsPageDownPressed();
            Position.LookDownward(keydown);
            keydown = input.IsAPressed();
            Position.MoveUpward(keydown);
            keydown = input.IsZPressed();
            Position.MoveDownward(keydown);

            // Determine if the user interface should be displayed or not.
            if (input.IsF1Toogled())
            {
                DisplayUI = !DisplayUI;
            }

            // Set the position and rOTATION of the camera.
            Camera.SetPosition(Position.PositionX, Position.PositionY, Position.PositionZ);
            Camera.SetRotation(Position.RotationX, Position.RotationY, Position.RotationZ);

            return(true);
        }
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the input object.  The input object will be used to handle reading the keyboard and mouse input from the user.
                Input = new DInput();

                // Initialize the input object.
                if (!Input.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // #region Initialize System
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // Create the camera object
                Camera = new DCamera();

                // Initialize a base view matrix with the camera for 2D user interface rendering.
                Camera.SetPosition(0.0f, 0.0f, -10.0f);
                Camera.RenderBaseViewMatrix();
                Matrix baseViewMatrix = Camera.BaseViewMatrix;

                // Set the initial position of the camera. (Since the ViewMatrix is already created from a base position.)              250.0f
                Camera.SetPosition(100.0f, 2.0f, 250.0f);
                Camera.SetRotation(0, 180.0f, 0);

                // Create the model object.
                TerrainModel = new DTerrainHeightMap();

                // Initialize the terrain object.
                if (!TerrainModel.Initialize(D3D.Device, "heightmap01.bmp", "dirt02.bmp", "bump.bmp"))
                {
                    return(false);
                }

                // Create the position object.
                Position = new DPosition();

                // Set the initial position of the viewer to the same as the initial camera position.
                Position.SetPosition(Camera.GetPosition().X, Camera.GetPosition().Y, Camera.GetPosition().Z);
                Position.SetRotation(Camera.GetRotation().X, Camera.GetRotation().Y, Camera.GetRotation().Z);

                // Create the fps object.
                FPS = new DFPS();

                // Initialize the fps object.
                FPS.Initialize();

                // Create the cpu object.
                CPU = new DCPU();

                // Initialize the cpu object.
                CPU.Initialize();

                // Create the text object.
                Text = new DText();

                // Initialize the text object.
                if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix))
                {
                    return(false);
                }

                // Set the video card information in the text object.
                if (!Text.SetVideoCard(D3D.VideoCardDescription, D3D.VideoCardMemory, D3D.DeviceContext))
                {
                    return(false);
                }

                // Create the color shader object.
                TerrainBumpMapShader = new DBumpMapShader();

                // Initialize the color shader object.
                if (!TerrainBumpMapShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the light object.
                Light = new DLight();

                // Initialize the light object.
                Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
                Light.Direction = new Vector3(0.75f, -0.5f, 0.0f);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }
        // Methods.
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                // Create the input object.  The input object will be used to handle reading the keyboard and mouse input from the user.
                Input = new DInput();

                // Initialize the input object.
                if (!Input.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // #region Initialize System
                // Create the Direct3D object.
                D3D = new DDX11();

                // Initialize the Direct3D object.
                if (!D3D.Initialize(configuration, windowHandle))
                {
                    return(false);
                }

                // Create the position object.
                Position = new DPosition();

                // Set the initial position and rotation of the viewer.
                Position.SetPosition(280.379f, 24.5225f, 367.018f);
                Position.SetRotation(19.6834f, 222.013f, 0.0f);

                // Create the camera object
                Camera = new DCamera();

                // Initialize a base view matrix with the camera for 2D user interface rendering.
                Camera.SetPosition(0.0f, 0.0f, -10.0f);
                Camera.RenderBaseViewMatrix();
                Matrix baseViewMatrix = Camera.BaseViewMatrix;

                // Create the light object.
                Light = new DLight();

                // Initialize the light object.
                Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
                Light.Direction = new Vector3(0.5f, -0.75f, 0.25f);

                // Create the model object.
                TerrainModel = new DTerrainHeightMap();

                // Initialize the terrain object.
                if (!TerrainModel.Initialize(D3D.Device, "hm.bmp", "cm.bmp", 20.0f, "dirt04.bmp", "normal01.bmp"))
                {
                    return(false);
                }

                // Create the color shader object.
                TerrainShader = new DTerrainShader();

                //// Initialize the color shader object.
                if (!TerrainShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the sky dome object.
                SkyDome = new DSkyDome();

                // Initialize the sky dome object.
                if (!SkyDome.Initialize(D3D.Device))
                {
                    return(false);
                }

                // Create the sky dome shader object.
                SkyDomeShader = new DSkyDomeShader();

                // Initialize the sky dome shader object.
                if (!SkyDomeShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the sky plane object.
                SkyPlane = new DSkyPlane();

                // Initialize the sky plane object.
                if (!SkyPlane.Initialze(D3D.Device, "cloud001.bmp", "perturb001.bmp"))
                {
                    return(false);
                }

                // Create the sky plane shader object.
                SkyPlaneShader = new DSkyPlaneShader();

                // Initialize the sky plane shader object.
                if (!SkyPlaneShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the fps object.
                FPS = new DFPS();

                // Initialize the fps object.
                FPS.Initialize();

                // Create the cpu object.
                CPU = new DCPU();

                // Initialize the cpu object.
                CPU.Initialize();

                // Create the text object.
                Text = new DText();

                // Initialize the text object.
                if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix))
                {
                    return(false);
                }

                // Set the video card information in the text object.
                if (!Text.SetVideoCard(D3D.VideoCardDescription, D3D.VideoCardMemory, D3D.DeviceContext))
                {
                    return(false);
                }

                // Create the refraction render to texture object.
                RefractionTexture = new DRenderTexture();

                // Initialize the refraction render to texture object.
                if (!RefractionTexture.Initialize(D3D.Device, configuration))
                {
                    return(false);
                }

                // Create the reflection render to texture object.
                ReflectionTexture = new DRenderTexture();

                // Initialize the reflection render to texture object.
                if (!ReflectionTexture.Initialize(D3D.Device, configuration))
                {
                    return(false);
                }

                // Create the reflection shader object.
                ReflectionShader = new DReflectionShader();

                // Initialize the reflection shader object.
                if (!ReflectionShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                // Create the water object.
                WaterModel = new DWater();

                // Initialize the water object.
                if (!WaterModel.Initilize(D3D.Device, "waternormal.bmp", 3.75f, 110.0f))
                {
                    return(false);
                }

                // Create the water shader object.
                WaterShader = new DWaterShader();

                // Initialize the water shader object.
                if (!WaterShader.Initialize(D3D.Device, windowHandle))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'");
                return(false);
            }
        }