public Model3DGroup CreatePolygonModel(Point3D[] points)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();
            int indexPoints = 0;
            int totalPoints = points.Count();

            for (indexPoints = 0; indexPoints < totalPoints; indexPoints++)
            {
                mesh.Positions.Add(points.ElementAt(indexPoints));
            }

            //Solo se necesitan tres puntos para poder obtener la normal del triangulo
            for (int i = 0; i < 3; i++)
            {
                mesh.TriangleIndices.Add(i);
            }

            //Para obtener el vector normal solo se necesitan tres puntos del plano
            Vector3D normal = CalculateNormal(points.ElementAt(0), points.ElementAt(1), points.ElementAt(2));

            //¿Checar por que se agrega 3 veces la normal?
            //for (int i = 0; i < 3; i++)
            //{
            mesh.Normals.Add(normal);
            //}

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.DarkCyan));
            GeometryModel3D model = new GeometryModel3D(mesh, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model);
            return group;
        }
Exemple #2
0
 public static double[,] Point3DToPointArrays(Point3D[] points)
 {
     double[,] vectors = new double[points.Count(), 4];
     for (int i = 0; i < points.Count(); i++)
     {
         double x = points[i].X;
         double y = points[i].Y;
         double z = points[i].Z;
         vectors[i, 0] = x;
         vectors[i, 1] = y;
         vectors[i, 2] = z;
         vectors[i, 3] = 1;
     }
     return vectors;
 }