AB4D Forum

Full Version: problem with assimpwpfimporter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everybody!
I have a strange problem...
I try to describe it.
I have two projects with the same code and  same refereces. In the first project the code:
Dim readmodel3d As GeometryModel3D = AssimpWpfImporter.ReadModel3D(mfile)
returns a geometrymodel and works perfectly.

In the other project (same code) the code:
Dim readmodel3d As GeometryModel3D = AssimpWpfImporter.ReadModel3D(mfile)
returns the error: : 'Impossibile eseguire il cast di oggetti di tipo 'System.Windows.Media.Media3D.Model3DGroup' sul tipo 'System.Windows.Media.Media3D.GeometryModel3D'.'

why???
The ReadModel3D method returns a Model3D object. This is a base class for GeometryModel3D and Model3DGroup classes. In case the ReadModel3D reads a file that defines only one simple 3D model, then the method returns a GeometryModel3D object. When a more complex 3D model is defined in a file, then a Model3DGroup - this object is used to hierarchically organized the GeometryModel3D and other Model3DGroup in the Children collection.

Therefore, it is much better to check the type of the returned object before using it (except in case when you are reading a fixed file and are sure of the content of the file).
(05-04-2020, 11:35 AM)abenedik Wrote: [ -> ]The ReadModel3D method returns a Model3D object. This is a base class for GeometryModel3D and Model3DGroup classes. In case the ReadModel3D reads a file that defines only one simple 3D model, then the method returns a GeometryModel3D object. When a more complex 3D model is defined in a file, then a Model3DGroup - this object is used to hierarchically organized the GeometryModel3D and other Model3DGroup in the Children collection.

Therefore, it is much better to check the type of the returned object before using it (except in case when you are reading a fixed file and are sure of the content of the file).

ok clear.
Now i get a geometrymodel3d (there is one simple obj in the file) and i need to access to geometry positions to change them.
But geometry.position is not a member of geometrymodel3d. I i can do to access to geometry positions ?
To get positions you need to cast GeometryModel3D.Geometry to MeshGeometry3D. Then you will be able to access Positions, TriangleIndices, ...

This are the very basics of the WPF 3D. Please try to find answers to such questions by yourself. Check internet and the samples that come with Ab3d.PowerToys - there is even a "Basic WPF 3D objects tutorial" that explains the basics by example. So please use this form for specific Ab3d.PowerToys questions.