03-25-2021, 06:19 PM
(03-25-2021, 12:48 PM)abenedik Wrote: I have checked exporting objects with textures to .x files and have found out that for an unknown reason the normals of the 3D mesh are inverted when exporting (normals are vectors that define the orientation of the triangles).
Because they are inverted, they point into the opposite side of the triangles - this means that when using lighting calculation to get the color of each pixel, this will produce black colors.
This is caused by the problem in an assimp library.
A workaround to this problem is to reset the normals (set Normals to null) after models from .x file are read. When the normals are specified (are null), then they will be automatically calculated by WPF 3D or DXEngine based on the actual orientation of the triangels. This will correct the problem and show the models.
You can use ModelIterator from Ab3d.Utilities namespace to easily iterate through all GeometryModel3D in your read objects collection and set all Normals to null:
Code:ModelIterator.IterateGeometryModel3DObjects(readModel, null, delegate(GeometryModel3D geometryModel3D, Transform3D transform3D)
{
var meshGeometry3D = (MeshGeometry3D)geometryModel3D.Geometry;
meshGeometry3D.Normals = null;
});
thank you for your explanation :) i am trying to convert your code to vb.net but having a problem with it,
as in i cannot get it to work in VB.NET LOL
Kevan Hampson

