I am working on a WPF application which has 4 viewports. I build a 3D model which is fairly complex and contains 50,000-100,000 Triangles. I then want to display the same 3D model in all 4 viewports. The way I am doing this, it takes about 10 seconds for the model to display in all 4 viewports (which are actually HelixViewports, from the Helix 3D Toolkit for WPF). I have never used multi threading, but I am thinking this may be a good idea. I need the models to render in all 4 viewports in less than 2 seconds. I am probably writing my code inefficiently as well, a sample is below. Thanks for your help!
Render() function (C#):
//Each Viewport must have it's own ModelVisual3D
ModelVisual3D renderModel = new ModelVisual3D();
ModelVisual3D renderModel2 = new ModelVisual3D();
ModelVisual3D renderModel3 = new ModelVisual3D();
ModelVisual3D renderModel4 = new ModelVisual3D();
Model3DGroup modelGroup = new Model3DGroup();
//Here is an example of the 2 different ways
//I add components to the Models:
//Add the cylinder to the viewport
if (isCylinder)
{
//Each viewport must have its' own
PipeVisual3D ballBat = dO.getRound();
PipeVisual3D ballBat2, ballBat3, ballBat4;
ballBat2 = new PipeVisual3D();
ballBat2.Content = ballBat.Content;
ballBat3 = new PipeVisual3D();
ballBat3.Content = ballBat.Content;
ballBat4 = new PipeVisual3D();
ballBat4.Content = ballBat.Content;
this.mainViewport.Children.Add(ballBat);
this.mainViewport2.Children.Add(ballBat2);
this.mainViewport3.Children.Add(ballBat3);
this.mainViewport4.Children.Add(ballBat4);
}
//OR this way:
//Add inner top wane to the viewport
if (isTopWane)
{
modelGroup.Children.Add(dO.getTopWane());
}
//Add inner bottom wane to the viewport
if (isBottomWane)
{
modelGroup.Children.Add(dO.getBottomWane());
}
//Then, at the end of all my IF checks, this is how I
//'Draw' the models into the viewports:
//Each ModelVisual3D has the same content
renderModel2.Content = renderModel.Content;
renderModel3.Content = renderModel.Content;
renderModel4.Content = renderModel.Content;
//"Paint" the viewports
this.mainViewport.Children.Add(renderModel);
this.mainViewport2.Children.Add(renderModel2);
this.mainViewport3.Children.Add(renderModel3);
this.mainViewport4.Children.Add(renderModel4);
Also, it may help to know that I am testing this app on a laptop with 16GB ram, a core i7 processor, and an NVIDIA Quadro 3000M graphics card. I have been searching for ways to speed up my app and will continue to do so, if anyone has a suggestion or can point me to useful information it will be greatly appreciated!
Why don't you put your entire model in one GeometryModel3D? You have 35000-40000 triangles, it means that you have 35000-40000 GeometryModel3D!? That's huge...
You should have one Visual (which equals a scene or a model containing multiple parts) containing a Model3DGroup, containing as many GeometryModel3D as you have models (and not triangles!). Each GeometryModel3D containing a MeshGeometry3D which contains all the triangles, indices, normales, uv coords of one model.