Exported X File all black
#1
Hi
i am exporting an OBJ to X, selecting a texture first, when i load in the exported X the model is completely black,
any idea where i have gone wrong?
   

the same model exported as FBX
   
#2
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;
});
Andrej Benedik
#3
(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
#4
is there anyway to 'Flip' the normals on an X file when i export ?

if i invert normals before i export Assimp will then invert again which will correct the issue if my logic is correct.

LOL yes that works :rolleyes:  answered my own question
#5
There is a Ab3d.Utilities.MeshUtils.FlipNormals method that takes MeshGeometry3D as a parameter and flips its normals.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)