none
How To Do Hit Test in WPF 3D

Answers

  • Hi mh1000,

    Thank you for your post.

    According to your description, I understand you want to do hit test in WPF 3D.

    Based on your code, I think you use the wrong parameter due to you want to do a hit test on a Viewport which should use the PointHitTestParameters . We use different parameter when do hit test on Viewprot and the Visual3D.

    As the code in the link you posted:

    public void MouseHitTest(object sender, MouseButtonEventArgs args)
    {
        Point mousePos = args.GetPosition(viewport3d);
        PointHitTestParameters hitParams = new PointHitTestParameters(mousePos);
        VisualTreeHelper.HitTest(viewport3d, null, ResultCallback, hitParams);
    }

    If you have any additional questions, please feel free to let me know.

    Have a nice day.


    Annabella Luo [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by mh1000 Thursday, November 17, 2011 4:58 PM
    Thursday, November 17, 2011 7:54 AM
    Moderator

All replies

  • Hi mh1000,

    Thank you for your post.

    According to your description, I understand you want to do hit test in WPF 3D.

    Based on your code, I think you use the wrong parameter due to you want to do a hit test on a Viewport which should use the PointHitTestParameters . We use different parameter when do hit test on Viewprot and the Visual3D.

    As the code in the link you posted:

    public void MouseHitTest(object sender, MouseButtonEventArgs args)
    {
        Point mousePos = args.GetPosition(viewport3d);
        PointHitTestParameters hitParams = new PointHitTestParameters(mousePos);
        VisualTreeHelper.HitTest(viewport3d, null, ResultCallback, hitParams);
    }

    If you have any additional questions, please feel free to let me know.

    Have a nice day.


    Annabella Luo [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by mh1000 Thursday, November 17, 2011 4:58 PM
    Thursday, November 17, 2011 7:54 AM
    Moderator
  • Thank you for the answer. I will try your solution.

    Makoto

     

    Thursday, November 17, 2011 5:01 PM