locked
Coordinate system of CoreWindow in Metro-style app

    Question

  • I'd like to make it clear how the coordinate system of CoreWindow in a Metro-style app is defined. I cannot find any reference on MSDN similar to SetMapMode of Win32. With the GestureRecognizerSample app, I find the origin of the coordinate system is at the center of the screen,  and ordinate axis increase downwards. Can I change this default configuration?
    Monday, August 06, 2012 4:13 AM

Answers

  • They are using a relative position to the screen elements in that routine. Call GetCurrentPoint without the transform parameter this to obtain a pointer with the actual coordinates.

            // Creates a PointerPoint
    		auto ap = Windows::UI::Input::PointerPoint::GetCurrentPoint(
                pointerId);
    		// Creates a transformed PointerPoint relative to parent object
    		Windows::UI::Input::PointerPoint^ pointerPoint = Windows::UI::Input::PointerPoint::GetCurrentPoint(
                pointerId,
                ref new ManipulatableObjectTransform(_objects[iz]->Parent()));


    David Lamb

    • Marked as answer by Leonard Wednesday, August 08, 2012 3:49 PM
    Tuesday, August 07, 2012 6:25 PM
    Moderator

All replies

  • Can you elaborate on what you were seeing in the Gesture sample that led to this conclusion?

    David Lamb

    Tuesday, August 07, 2012 12:19 AM
    Moderator
  • I set a breakpoint in GestureRecognizerSample::OnPointerPressed() and observe the values of pointerPoint->RawPosition.
    Tuesday, August 07, 2012 2:20 AM
  • They are using a relative position to the screen elements in that routine. Call GetCurrentPoint without the transform parameter this to obtain a pointer with the actual coordinates.

            // Creates a PointerPoint
    		auto ap = Windows::UI::Input::PointerPoint::GetCurrentPoint(
                pointerId);
    		// Creates a transformed PointerPoint relative to parent object
    		Windows::UI::Input::PointerPoint^ pointerPoint = Windows::UI::Input::PointerPoint::GetCurrentPoint(
                pointerId,
                ref new ManipulatableObjectTransform(_objects[iz]->Parent()));


    David Lamb

    • Marked as answer by Leonard Wednesday, August 08, 2012 3:49 PM
    Tuesday, August 07, 2012 6:25 PM
    Moderator
  • Thanks David. I misunderstand the code.

    After some debug, I found Windows::UI::Input::PointerPoint::GetCurrentPoint(unsigned int) return pointer positions in device coordinate system. I may use D3D11 model-view-projection transforms to simulate win32 SetMapMode function.

    Wednesday, August 08, 2012 3:49 PM