Model3d Hit Testing

Anonymous 9 years ago 0
This discussion was imported from CodePlex

cobra18t wrote at 2011-12-13 16:12:

I am trying to follow your Voxel example to highlight a 3D model in the viewport when the user mouses over it. I have multiple Model3D objects in the viewport and the hit testing works fine until I start adding transforms to the Model3Ds. Even if the model is transformed to say (100,20,0), the hit testing reports a Model3D that is positioned at its original location, (0,0,0). I tried to determine which model was moused over by the bounding box of the orignal model and the bounding box of the hit result, but this only worked for some of the models. Any ideas? should I be using a different object type?

cobra18t wrote at 2011-12-13 17:33:

Additionally, hits.First().Position is reporting a position that is scaled with the same scale transformation of the model that is moused over. So when mousing over a model so that the mouse is hitting point (1,1,1) on the surface of the model, Position reports (5,5,5) as the hit point since the model is scaled by 5 in each dimension. Is there a way to apply the transformation permanently to avoid these discrepancies?

objo wrote at 2011-12-13 18:38:

have a look at HelixToolkit.Wpf.Viewport3DHelper.GetTransform to get the total transforms applied to the Visual3Ds and Model3Ds in your hits.

Also see the Viewport3DHelper.FindNearestPoint method!

valdis1987 wrote at 2013-08-15 14:07:

Can't get necessary results.
Can someone help me? I think this question is a problem to others also.

So lets say i have:
 <Helix3D:HelixViewport3D x:Name="Mainviewport">
<Helix3D:HelixVisual3D  x:Name="Scene">
..Inside is  <Helix3D:HelixVisual3D.Content><Model3DGroup> with deep tree with   Model3dGroup[...]

<Helix3D:HelixVisual3D  x:Name="Obje1"/>
<Helix3D:HelixVisual3D  x:Name="Obje2"/>
<Helix3D:HelixVisual3D  x:Name="Obje3"/>
<Helix3D:HelixVisual3D  x:Name="Obje4"/>

Inside HelixViewport3D all items have transforms( ScaleTransform3D,RotateTransform3D,TranslateTransform3D)

Now how I can get notice that Obje1 have hit Scene? Or Obje1 have hit Obje2?

I done a lot of try's to get result but no success.

Can someone give me a couple tips how to accomplish my target?