WPF controls stop working when .3ds is loaded
#1
Good morning. I'm trying to integrate .3ds models into my application to make the 3D development faster, since converting to XAML (our actual approach) has a lot of issues. The model loading works fine, but every control on the screen - buttons, sliders, comboboxes etc - stops working immediately. Is this supposed to happen, should I be loading the model in a different window or page?
I'm using Ab3d.Reader3ds.ReadFile to load the model into a viewport3D. The samples have a differente way of building menus, but I'm in a trial-an-error effort for several days and I don't have much time left for radically differente methods, any advice would be very helpful.

Thanks in advance.
#2
It is possible to load the models in a different thread.

There is a sample that comes with Reader3ds that demonstrates this - please check the "Multithreaded sample" - the code is in the ProgressReport\MultithreadedSample.cs

The trick is to read the file in another thread (note that it must be STA apartment). Once the objects are read, they must be frozen (call Freeze on the models). This way they can be used on the UI thread.

The drawback of this method is that once the objects are forzen than they cannot be changed any more. If you would like to modify the objects, you will need to clone them - for example if you need to change material on some of the objects, you can preserve the frozen MeshGeometry3D but you will need to clone the Material on the UI thread. The sample for example clones the camera so it can be changed.

If you will load very complex models, than there will still be a slight pause when you will add the loaded models to the Viewport3D or some other control on the UI - this is probably caused because the data are copied to the GPU or some other internal process need to manipulate the 3D data.
Andrej Benedik
#3
I'll give a try on those, I think that will do for our application. Thank you very much for the help.
  


Forum Jump:


Users browsing this thread:
1 Guest(s)