SharpDX fork no BackMaterial property in MeshGeometryModel3D

Anonymous 9 years ago 0
This discussion was imported from CodePlex

Lolipedobear wrote at 2014-03-05 14:27:

Didn't find BackMaterial property in MeshGeometryModel3D. Back side of the polygon is black - is there any solution to apply texture to it? Tried to add additional points with inversed normals, but polygons overlap when displayed, so that color from the back side of polygon is also visible.

geoarsal wrote at 2014-03-12 18:49:

Today I face the same issue with meshbuilder and following is the code I used to create duplicate triangles. Here mb is the meshbuilder class.
            var copytri = new int[mb.TriangleIndices.Count];

            var copynorm = new Vector3[mb.Normals.Count];
            for (int i = 0; i < copynorm.Length; i++)
                copynorm[i] = -1 * mb.Normals[i];
            mb.Append(mb.Positions.ToArray(), copytri, copynorm, mb.TextureCoordinates.ToArray());

Lolipedobear wrote at 2014-03-14 06:23:

Thanks for your reply. I tried to do the same thing manually. Sometimes polygons overlaps and scene glitches when i try to scale or rotate. In WPF branch i had the same problem and it was resolved by setting NearPlaneDistance in camera. Possible, I made a mistake. Did you try your solution for large scenes (1000 or more units)?

geoarsal wrote at 2014-03-14 08:07:

I had used that approach to render mesh surface consisiting of more than 200,000 triangles, and I haven't faced the overplap issue. However for some cases, i have to reverse the original normals prior to creating their copy, may be thats the issue your facing. Also, i had set NearPlaneDistance to 0.5 and FarPlaneDistance to 10000.
var copynorm = new Vector3[mb.Normals.Count];
for (int i = 0; i < copynorm.Length; i++)
         mb.Normals[i] *= -1;
         copynorm[i] = -1 * mb.Normals[i];
Hope that will help you with your issue.

P.S. Reversing the original normal was required when your building triangles using Right Hand Rule (WPF approach) instead of using Left Hand Rule (DirectX/SharpDX approach)