michaeldjackson wrote at 2012-06-24 18:07:
Awesome job on Helix3D.
I'm searching for guidance or best practices on a project I'm working on.
In my application, I have an ObservableCollection of pipe segments, which describe length, diameter, inclination from vertical and azimuth from north. I need to iterate thru this collection (note: collection will number in the hundreds and sometimes thousands of segments), and build the pipe system, one segment at a time. Each 3D pipe segment will eventually be re-colored according to some calculation and hopefully each pipe segment object will contain the numerical results of the calculations performed on each segment. I will need to click or hover over the segment in the 3D view, and display the numerical results per segment in a wpf control.
Anyone have thoughts or suggestions?
Thanks in advance.
objo wrote at 2012-06-25 08:33:
You should add the pipes to the 3D model yourself (I don't think ItemsControl will work in a Viewport3D), and modify the 3D model when the observable collection changes.
I would suggest the following
- Use a ModelUIElement3D for each pipe to make the segments clickable.
- Use the HelixToolkit's MeshBuilder to create the pipe geometry (as in PipeVisual3D).
- Create a Transform3D to set the position and orientation (you can also set the start and endpoints, but if you use a transform you can easily change position/orientation later).
- Create a Material to define the color (see HelixToolkit's MaterialHelper.CreateMaterial)
If performance is not good enough, you should combine all pipes into a common geometry and use texture coordinates and a gradient brush material to set the colors.
Use of the MeshBuilder:
var builder = new MeshBuilder(false,false);
builder.AddPipe(this.Point1, this.Point2, this.InnerDiameter, this.Diameter, this.ThetaDiv);
(returns a MeshGeometry3D)
dturvey wrote at 2012-06-25 11:22:
I am also trying to add 1000+ Visual3D objects to a viewport and would be interested in the most efficient way to do this.
I am currently binding to an observable collection as shown in the MVVM demo and just adding each Visual3D individually in a loop. This is firing a collection changed event for each call to the Add method. Is there a better way accomplish a bulk add?
objo wrote at 2012-06-26 05:54:
Combine objects that can share the same material.
Yes, you should avoid the collection change event when initializing your collection - don't bind it to the visual tree before it has been initialized.
michaeldjackson wrote at 2012-06-26 20:34:
Thanks for the reply. I have another question, though.
As mentioned in my initial post, I need the ability to hover over or clicka pipe segment in order to obtain properties of that segment, ie: length, temperature, pressure, etc. I also need to draw a sem-transparent 3D element (basically another pipe segment) around the segment, thus creating a pipe within a pipe. However, I need to "click" the inner pipe to obtain it's properties. The outer pipe will no doubt hinder hit-test on the inner pipe, correct? So, I'm wondering how to select the inner pipe when clicking. Maybe 1) propogate the inner pipes properties to the outer pipe or 2) allow a pipe segment to have children pipe segments.
BTW, I am just barely getting started with Helix 3D.
objo wrote at 2012-06-27 14:42:
These will give you all hits in the model!
Customer support service by UserEcho