Skip over processing of absolute mouse data from the CoreWindow::PointerMoved event when your app changes to handling relative mouse movement values. The position of the mouse pointer is passed to the handler as a MouseEventArgs object. The event handler in this code example, OnMouseMoved, renders the view based on the movements of the mouse. keep longitude in useful range by wrapping M_pitch = (float) _min( +limit, m_pitch ) M_pitch = (float) _max( -limit, m_pitch ) limit pitch to straight up or straight down M_yaw -= rotationDelta.x // yaw defined as CCW around y-axis M_pitch -= rotationDelta.y // mouse y increases down, but pitch increases up update our orientation based on the command RotationDelta = pointerDelta * ROTATION_GAIN // scale for control sensitivity PointerDelta.y = static_cast(args->MouseDelta.Y) PointerDelta.x = static_cast(args->MouseDelta.X) _In_ Windows::Devices::Input::MouseEventArgs^ args _In_ Windows::Devices::Input::MouseDevice^ mouseDevice, Ref new TypedEventHandler(this, &MoveLookController::OnMouseMoved) Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += register handler for relative mouse movement events To access relative mouse delta values, register for the MouseDevice::MouseMoved event as shown here. The cursor re-appears in the same screen coordinate location as it was previous to enabling the relative mouse movement mode. With this pattern, the location of the absolute mouse cursor is preserved on entering the cursorless relative mode. Set the mouse cursor to a non-null value (which makes it visible).Enable default/absolute mouse handling.When the user takes an action that moves the app out of a relative 3-D object/scene manipulation mode, the app must: Hide the mouse cursor by setting it a null pointer (nullptr).When the user takes an action that moves the app into a relative 3-D object/scene manipulation mode, the app must: Also, apps often hide the mouse cursor since the position of the cursor with respect to the screen coordinates is not relevant when manipulating a 3-D object or scene. Relative mouse values represent how far the mouse moved since the last frame, rather than the absolute x-y coordinate values within a window or screen. In these scenarios, the app requires relative mouse data. For example, a 3-D modeler might use mouse input to orient a 3-D object by simulating a virtual trackball or a game might use the mouse to change the direction of the viewing camera via mouse-look controls. Some apps, such as games, use the mouse as a more general input device. Here we discuss the implementation of relative mouse controls, which don't use the system cursor and don't return absolute screen coordinates instead, they track the pixel delta between mouse movements. In games, the mouse is a common control option that is familiar to many players, and is likewise essential to many genres of games, including first- and third-person shooters, and real-time strategy games.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |