All the samples I found seem to use Methods and Classes that became obsolote with the September CTP.
So far, I managed to have my application react when an object withint the viewport is clicked. To do so, I use the following MouseButtonDown event handler ...
private void Window_Click(object sender, MouseButtonEventArgs e) { Point p = e.GetPosition(viewport); VisualOperations.HitTest(viewport, null, new HitTestResultDelegate(ResultsOfHit), new PointHitTestParameters(p)); } |
... which triggers the following delegate method ...
private HitTestResultBehavior ResultsOfHit(HitTestResult hitTestResult) { } |
Where do I go from here That is,
a. how do I find out which of my Model3DGroups was affected by the click
b. how do I find out which of my Geometry3DModel(s) was affected by the click
(I have no problems doing this by using the ray and check its intersection with the Bounding-Boxes of my 3D objects - just as I would do it in openGL or directX if I wanted to do it 'by hand' - but I am under the impression that the MPF offers a more conventient way to do this)

Hittesting in 3D
sinan m al dabagh
HitTestResult is (amongst other classes) inherited by Ray3DHitTestResult ... so all I had to do was to typecasst the HitTestResult to Ray3DHitTestResult ... hence
private HitTestResultBehavior ResultsOfHit(HitTestResult hitTestResult)
{
Model3D modelHit = (hitTestResult as Ray3DHitTestResult).ModelHit;
return HitTestResultBehavior.Continue; // or .Stop ... depending on what you want to do
}