Temporarily Disable hit detection

Topics: Developer Forum, User Forum
Jun 1, 2007 at 5:41 PM
I have a cube, and each side of the cube has four cubes on it. Thanks to your tool kit everthing is working well and interactive. One problem i am running into though is when I animate the maincube to go to another side and have the mouse curser over it, the animation is very choppy and/or bogged down. I assumed it has something to do with the 3dtools and it checking where the mouse was on the viewport(s) of the cube so it can interact with it. I threw a quick band aid to temperaly disable the mouse if it went over the main 3d viewport while the cube was rotating and the animation ran fine again. I can stick with the solution i have, but i thought i would ask if there was a way i could turn the hit detection on or off in 3dTools? Thanks for your help!
Sep 22, 2007 at 2:47 PM
Edited Sep 22, 2007 at 4:36 PM
hmm, what I did was...

public class Trackball
private FrameworkElement _eventSource;
private Point _previousPosition2D;
private Vector3D _previousPosition3D = new Vector3D(0, 0, 1);

private Transform3DGroup _transform;
private ScaleTransform3D _scale = new ScaleTransform3D();
private AxisAngleRotation3D _rotation = new AxisAngleRotation3D();
private bool _trackingActive;

public Trackball()
_transform = new Transform3DGroup();
transform.Children.Add(new RotateTransform3D(rotation));
_trackingActive = true;

then added

public Boolean TrackingActive
get { return _trackingActive; }
set { _trackingActive = value; }

to getter/setters

Then in event Handling:

private void OnMouseMove(object sender, MouseEventArgs e)
Point currentPosition = e.GetPosition(EventSource);

// Prefer tracking to zooming if both buttons are pressed.
if (_trackingActive)

if (e.LeftButton == MouseButtonState.Pressed)
else if (e.RightButton == MouseButtonState.Pressed)

_previousPosition2D = currentPosition;

Which I then reference in the app during hit testing or in your case during animations...


obviously you have to rebuild from source and re-reference the new DLL.


Sep 22, 2007 at 2:49 PM
Edited Sep 22, 2007 at 4:43 PM
Perhaps you can use a similar idea for the area you are after...

Sep 22, 2007 at 8:46 PM

Marshall wrote:
... i thought i would ask if there was a way i could turn the hit detection on or off in 3dTools? Thanks for your help!

The answer is yes, but I dont know how right now.

Daniel says in his demo with Kurt that 3d hit testing can be turned off for performance reasons so no brainer that you can.