05-20-2016, 09:30 AM
I need to plot a 3D representation of a graph line (measurement) in an 3D view of an measurement instrument. I have tried doing this with a meshgeometry3d to draw a ribbon (extruding the line to form a flat ribbon) that follows the points of the graph line, however, this has issues that it disappears when rotated. I've therefore started looking at the PolyLineVisual3D class - this is what I need as it will be visible in all orientations of the view. What i need to do is draw one or more of these dynamically and add points to each line dynamically. I'd ideally like to do this via binding. So I'd bind to a ObservableCollection<something> and for each something I'd be able to add points as I receive data. The points would then be plotted in the three d view. I'm having some issues. Firstly I tried a very simple approach:
<visuals:PolyLineVisual3D Positions="{Binding PointsCollection}" LineColor="Red" EndLineCap="ArrowAnchor" LineThickness="10"/>
and then using a timer I simply add some points to the points collection at a rate of 10 per second:
i+=1;
PointsCollection.Add(i,i,i);
This works but its very slow and gets rapidly slower taking several seconds once there are more than about 50 points. With the ribbon approach I described above it copes fine with a large number of points.
Secondly, I can't really work out how to bind multiple polylines. I need to bind a somethingcollection in the xaml to an ObservableCollection<something> in the view model.
What is the best way to solve this problem?
Thanks
<visuals:PolyLineVisual3D Positions="{Binding PointsCollection}" LineColor="Red" EndLineCap="ArrowAnchor" LineThickness="10"/>
and then using a timer I simply add some points to the points collection at a rate of 10 per second:
i+=1;
PointsCollection.Add(i,i,i);
This works but its very slow and gets rapidly slower taking several seconds once there are more than about 50 points. With the ribbon approach I described above it copes fine with a large number of points.
Secondly, I can't really work out how to bind multiple polylines. I need to bind a somethingcollection in the xaml to an ObservableCollection<something> in the view model.
What is the best way to solve this problem?
Thanks

