Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Creating geometry for Viewport3D using Multitasking?

$
0
0

Hi,

I'm trying to populate a Viewport3D with UIElement3D objects. Because there is no DataBinding and Templating available with the Viewport3D, I do this manually using code.

First, I create a PointCollection3D for each UIElement3D which is my VertexBuffer for the 3d geometry. (I cannot use an IndexBuffer because it does not support "flat shading" without smoothed normals for some reason!) The vertex buffer contains the vertices that are generated by the triangulation algorithm.

Then, I create my MeshGeometry3D and a GeometryModel3D which is finally used by the resulting ModelUIElement3D.

This takes a very long time or big models, so I need to do this in background! But this is not working because (1) I cannot create WPF objects like PointCollection3D in another thread, and (2) I cannot access objects that have been created in the UI Thread from another thread.

I can't even do the actual triangulation of my 3d objects in a seperate thread. The triangulation process returns a number of Point3D which have to be added to the PointCollection3D in the UI Thread. Using a BlockingCollection in the seperate thread and converting into a PointCollection3D in the UI Thread is not an option for performance reasons.

Which options do I have left? Is there another way to create 3d geometry in another thread and include it into the Viewport3D in the UIThread? What would you suggest?

Best regards
Christian


Viewing all articles
Browse latest Browse all 18858

Trending Articles