Exemplo n.º 1
0
        public static void AddRegularPolygon(this MeshGeometry3D mesh,
                                             int numSides, Point3D center, Vector3D vx, Vector3D vy,
                                             Dictionary <Point3D, int> pointDict = null,
                                             Point[] textureCoords = null)
        {
            // Generate the points.
            Point3D[] points = G3.MakePolygonPoints(numSides, center, vx, vy);

            // Make the polygon.
            mesh.AddPolygon(points, textureCoords);
        }
        // Define the model.
        private void DefineModel(Model3DGroup group)
        {
            // Define a polygon in the XZ plane.
            Point3D center = new Point3D(0, 0, 4.5);

            Point3D[] polygon = G3.MakePolygonPoints(6, center,
                                                     new Vector3D(1, 0, 0), new Vector3D(0, 0, -1));

            // Make a transform to move the polygon in the -Z direction.
            TranslateTransform3D translate = new TranslateTransform3D(0, 0, -3);

            // Make a right cone.
            MeshGeometry3D mesh1 = new MeshGeometry3D();

            mesh1.AddCone(center, polygon, new Vector3D(0, 3, 0));
            group.Children.Add(mesh1.MakeModel(Brushes.Pink));

            // Make a skewed cone.
            translate.Transform(polygon);
            center = translate.Transform(center);
            MeshGeometry3D mesh2 = new MeshGeometry3D();

            mesh2.AddCone(center, polygon, new Vector3D(0, 3, 2));
            group.Children.Add(mesh2.MakeModel(Brushes.LightBlue));

            // Make a conic frustum with cutting plane parallel to the base.
            translate.Transform(polygon);
            center = translate.Transform(center);
            MeshGeometry3D mesh3 = new MeshGeometry3D();

            mesh3.AddConeFrustum(center, polygon, new Vector3D(0, 4, 0), 2);
            group.Children.Add(mesh3.MakeModel(Brushes.LightGreen));

            // Make a conic frustum with cutting plane not parallel to the base.
            translate.Transform(polygon);
            center = translate.Transform(center);
            MeshGeometry3D mesh4   = new MeshGeometry3D();
            Point3D        planePt = center + new Vector3D(0, 2, 0);
            Vector3D       planeN  = new Vector3D(1, 1, 1);

            mesh4.AddConeFrustum(center, polygon, new Vector3D(0, 4, 0), planePt, planeN);
            group.Children.Add(mesh4.MakeModel(Brushes.Orange));

            // Show the axes.
            MeshExtensions.AddAxes(group);
        }
Exemplo n.º 3
0
        // Define the model.
        private void DefineModel(Model3DGroup group)
        {
            // Define a polygon in the XZ plane.
            Point3D center = new Point3D(0, -1, 0);

            Point3D[] polygon = G3.MakePolygonPoints(20, center,
                                                     new Vector3D(1, 0, 0), new Vector3D(0, 0, -1));

            // Make a conic frustum with cutting plane parallel to the base.
            MeshGeometry3D mesh3 = new MeshGeometry3D();

            mesh3.AddConeFrustum(center, polygon, new Vector3D(0, 3, 0), 2);
            group.Children.Add(mesh3.MakeModel(Brushes.LightBlue));

            //// Define a polygon in the XZ plane.
            //Point3D center = new Point3D(0, -1, 1.25);
            //Point3D[] polygon = G3.MakePolygonPoints(20, center,
            //    new Vector3D(1, 0, 0), new Vector3D(0, 0, -1));

            //// Make a transform to move the polygon in the -Z direction.
            //TranslateTransform3D translate = new TranslateTransform3D(0, 0, -2.5);

            //// Make a pyramidal frustum.
            //MeshGeometry3D mesh1 = new MeshGeometry3D();
            //mesh1.AddFrustum(center, polygon, new Vector3D(0, 3, 0), 2);
            //group.Children.Add(mesh1.MakeModel(Brushes.LightBlue));

            //// Make a conic frustum with cutting plane parallel to the base.
            //translate.Transform(polygon);
            //center = translate.Transform(center);
            //MeshGeometry3D mesh3 = new MeshGeometry3D();
            //mesh3.AddConeFrustum(center, polygon, new Vector3D(0, 3, 0), 2);
            //group.Children.Add(mesh3.MakeModel(Brushes.LightBlue));

            // Show the axes.
            //MeshExtensions.AddAxes(group);
        }