Updating visuals created from MeshGeometry3D
#1
I'm currently working with the Trial version to ensure we can smoothly migrate from our current WPF/Viewport3D based solution to using the AB4D library.

I just need a point in the right direction on how to deal with dynamically changing 3D geometry. For example, we have a sculpting tool, starting with a MeshGeometry3D, the Positions will be morphed to new positions.

For example, we create a 'ModelVisual3D' from a 'GeometryModel3D' made from the 'MeshGeometry3D'. This is added to the Viewport3D.

We then just modify the points in the MeshGeometry3D.Positions collection - even without disconnecting the Point3DCollection from the MeshGeometry3D before updating, the result is pretty good.

However using this technique within a DXViewportView, the refresh rate is poor.

Could you please advise a better path for me to take to handle this scenario.

Thank you in advance.

I wasn't actually disconnecting the Point3DCollection correctly from the MeshGeometry3D before update:

For example, this now works great...
Code:
Point3DCollection pts = myMesh.
myMesh.Positions = null;    // I had this after the loop...doh!!!!
for (int i = 0; i < pts.Count; i++)
{
     pts[i] = pts[i] + offset;
}
modelToBlockOut.Positions = pts;

Problems solved!

Just for my information, is this as good as any other way of handling dynamic meshes?

Thanks.
#2
Great! I am glad that you have solved the problem.

After your initial post I have spent some time with analyzing performance in a scenario similar that yours.

I did not find any performance problems in the code. The performance should be already very good.

But I have a few ideas on how to further improve the performance is such scenarios. I will implement that in the next version of DXEngine.

Therefore I would recommend you to use the exiting code with disconnecting Positions before changing them.

It would be possible to achieve even better performance using lower level DXEngine objects (instead of WPF's GeometryModel3D and MeshGeometry3D).
In the following hours I will try to prepare a sample on how
SimpleMesh<PositionNormalTexture> for that - I will post the sample code under this thread.


To get a good performance overview of how DXEngine is rendering the scene, I highly recommend that you try the DXEngineSnoop tool. It is installed in the Ab3d.DXEngine\Tools folder.

It is easy to use:
- First start your application so that the 3D scene that is rendered with DXEngine is shown.
- Then start DXEngineSnoop. It should show your application in the drop down list. Click Snoop button (you can also start DXEngineSnoop with -auto startup parameter to automatically snoop to your application)
- The DXEngineSnoop should attach to your application (change the title of the main window) and show diagnostics window. The diagnostics window shows rendering statistics that helps you analize the rendering times.
- Under the menu you can also start advanced performance analyzer and some other tools.
Andrej Benedik
#3
As promised, I have created a sample that shows different ways to do 3D morphing with WPF 3D and with DXEngine.

To check the sample, copy the two attached files into the Customizations folder of the DXEngine samples project. Then add the following line to the Samples.xml file:

<Sample Page="Customizations/OptimizedMeshMorphing.xaml" Title="Optimized Mesh morphing" IsNew="True" Description=""/>

After that you can run the "Optimized Mesh morphing" sample.


The sample shows how to optimize object morphing by using low level DXEngine objects and also how to use unsafe code to further improve morphing performance.


Attached Files
.xaml   OptimizedMeshMorphing.xaml (Size: 3.79 KB / Downloads: 2)
.cs   OptimizedMeshMorphing.xaml.cs (Size: 32.38 KB / Downloads: 4)
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)