importing Geometry3D

Anonymous 9 years ago updated by anonymous 5 years ago 1
This discussion was imported from CodePlex

medecai wrote at 2012-04-23 17:56:


Hey there,

first of all, i want to thank you for providing such an awesome Toolkit!

Second I have a question concerning the ModelImporter. I was using the beta (helixToolkit-release) for some time now and it was possible to import Geometry3D data by:

  private Geometry3D LoadGeoFromFile(string objPath)
            Model3DGroup group = ModelImporter.Load(objPath);
            GeometryModel3D model = group.Children[0] as GeometryModel3D;
            return model.Geometry;


I could afterwards bind the Geometry in Wpf like

                        <GeometryModel3D Geometry="{Binding TestFile}" Changed="GeometryModel3D_Changed">
                                        <SolidColorBrush Color="Gray"/>

and was therefore able to display the geometry just with a plain brush (to improve performance). Right now I tried
the newest source code (to check if loading times etc. improved) but the described procedure isn't working anymore.
The ViewPort only shows parts of the whole model at best.
Did something substantial change which could forbid this way of doing it or is it just a minor thing which I am not seeing ('cause
I am still starting to learn programming)?




objo wrote at 2012-04-25 07:08:

What kind of file are you importing? It should still be possible to extract the geometry from the returned Model3D, but I don't think you should depend on this being in Children[0] (an imported file could contain more than one GeometryModel3D).

medecai wrote at 2012-04-25 13:19:


Obj.-Files exportet by blender. And you are, of course, completely right concerning the number of geometries in the file. Which is most likely the problem of most models not be shown correctly . For me it seemed to be the easiest way to include lots of models/geometries and be able to transform them in relation to each other by binding (in Wpf), like moving an arm for example. Somehow it was working just fine for the beta-release of helix toolkit.

Seems that I have to find out how I can bind to different models and transform them the correct way =)


EDIT: I found a workaround:


private Geometry3D LoadFromFile(string objPath)
            Model3DGroup group = ModelImporter.Load(objPath);
            MeshBuilder TestMesh = new MeshBuilder(false, false);

            foreach (var m in group.Children)
                var mGeo = m as GeometryModel3D;
                var mesh = (MeshGeometry3D)((Geometry3D)mGeo.Geometry);
                if (mesh!=null) TestMesh.Append(mesh);
            return TestMesh.ToMesh();


Seems to work fine. Or am I again missing something?


Btw. Again: this toolkit is just great! Whenever I think I just don't now how the hell I should accomplish something I find again some nice method to help. =)