Triangulation method inquiry
#1
I read the data using Reader3DS and wrote the code below, but something went wrong and the basic shape came out fine, but the triangular face came out broken.
help

for (int i = 0; i < model3D.Children.Count; i++)
{
switch (model3D.Children[i].GetType().Name)
{
case "GeometryModel3D":
foreach (var item in ((model3D.Children[i] as GeometryModel3D).Geometry as MeshGeometry3D).Positions)
{
double x = item.X; double y = item.Y; double z = item.Z;
mesh.Positions.Add(new Point3D(x, y, z));
}

foreach (int item in ((MeshGeometry3D)((GeometryModel3D)model3D.Children[i]).Geometry).TriangleIndices)
{
mesh.TriangleIndices.Add(item);
//double x = item.X; double y = item.Y; double z = item.Z;
//mesh.Positions.Add(new Point3D(x, y, z));
}

foreach (var item in ((MeshGeometry3D)((GeometryModel3D)model3D.Children[i]).Geometry).Normals)
{
double x = item.X; double y = item.Y; double z = item.Z;
mesh.Normals.Add(new System.Windows.Media.Media3D.Vector3D(x, y, z));
}

foreach (var item in ((MeshGeometry3D)((GeometryModel3D)model3D.Children[i]).Geometry).TextureCoordinates)
{
double x = item.X; double y = item.Y;
mesh.TextureCoordinates.Add(new Point(x, y));
}
gmodel.Material = ((GeometryModel3D)model3D.Children[i]).Material;
gmodel.Geometry = mesh;
break;
case "Model3DGroup":
break;

default:
break;
}

}

thank you
  


Messages In This Thread
Triangulation method inquiry - by kanta8819@cadian.com - 03-08-2024, 06:35 AM
RE: Triangulation method inquiry - by abenedik - 03-08-2024, 08:48 AM
RE: Triangulation method inquiry - by abenedik - 03-08-2024, 05:05 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)