Hi,
I'm having a problem when drawing a 3D line on MouseMove event in WPF. The drawing seemed to be trailing (like mouse cursor-trailing effect)/smeared in Viewport3D, and it doesnt 'clean' the previous drawing (from previous mouse move)
I'm using ScreenSpaceLines3D from CodePlex to draw the 3D line on top of a 3D cube. I want it to be cleaned in every mouse move so that viewport3d will display the current updated drawings.
It should behave like: (1) onLeftButtondown, get 3D Point from HitTest on existing 3D cube == first point for 3d line (2) onMouseMove, always get current mouse move == second point for 3d line
private void onMouseMoveViewPort3D(object sender, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
if (mainViewport.IsMouseCaptured)
{
Draw3DLineOn3DObject(e);
}
}...
private void Draw3DLineOn3DObject(System.Windows.Input.MouseEventArgs e)
{
RayMeshGeometry3DHitTestResult rayMeshResult = (RayMeshGeometry3DHitTestResult)
VisualTreeHelper.HitTest
(mainViewport,e.GetPosition(mainViewport));
if (rayMeshResult == null)
return;
_point3DBtnCurrent = rayMeshResult.PointHit;
if (_thisLine== null)
{
_thisLine = new ScreenSpaceLines3D();
_thisLine.Color = Colors.Red;
_thisLine.Thickness = 1;
this.mainViewport.Children.Add(_thisLine);
}
_thisLine.Points.Add(_point3DBtnDown);
_thisLine.Points.Add(_point3DBtnCurrent);
}
I tried to invalidate visual the mainViewport, but it still nave no effect. Result of the above code:
http://www.imagechicken.com/viewpic.php?p=1258950572004579200&x=jpg
Thanks & Best Regards,
F.Notts