Пример #1
0
        private void UpdateInit()
        {
            Circle3D circle3d = generalFiguresList[iterator] as Circle3D;

            if (circle3d != null)
            {
                figureName = "circle";
            }

            Rectangle3D rectangle3d = generalFiguresList[iterator] as Rectangle3D;

            if (rectangle3d != null)
            {
                if (rectangle3d.figureType == 3)
                {
                    figureName = "triang";
                }
                else
                {
                    figureName = "rectan";
                }
            }

            Custom3D custom3d = generalFiguresList[iterator] as Custom3D;

            if (custom3d != null)
            {
                figureName = "custom";
            }

            switch (figureName)
            {
            case "circle":
                Circle3D      circle3D      = (Circle3D)generalFiguresList[iterator];
                CircleUpdater circleUpdater = new CircleUpdater(circle3D, model3DGroup, generalFiguresList);
                break;

            case "rectan":
                Rectangle3D      rectangle3D      = (Rectangle3D)generalFiguresList[iterator];
                RectangleUpdater rectangleUpdater = new RectangleUpdater(rectangle3D, model3DGroup, generalFiguresList);
                break;

            case "triang":
                Rectangle3D     triangle3D      = (Rectangle3D)generalFiguresList[iterator];
                TriangleUpdater triangleUpdater = new TriangleUpdater(triangle3D, model3DGroup, generalFiguresList);
                break;

            case "custom":
                Custom3D      custom3D      = (Custom3D)generalFiguresList[iterator];
                CustomUpdater customUpdater = new CustomUpdater(custom3D, model3DGroup, generalFiguresList);
                break;
            }
        }
Пример #2
0
        private void UpdateInit()
        {
            Circle3D circle3d = generalFiguresList[iterator] as Circle3D;

            if (circle3d != null)
            {
                figureName = "circle";
            }

            Rectangle3D rectangle3d = generalFiguresList[iterator] as Rectangle3D;

            if (rectangle3d != null)
            {
                if (rectangle3d.figureType == 3)
                {
                    figureName = "triang";
                }
                else
                {
                    figureName = "rectan";
                }
            }

            Custom3D custom3d = generalFiguresList[iterator] as Custom3D;

            if (custom3d != null)
            {
                figureName = "custom";
            }

            string modelName = string.Concat(comboBox.SelectedItem.ToString(), figureName);

            int it = 0;
            Model3DCollection model3Ds = model3DGroup.Children;

            foreach (Model3D t in model3Ds)
            {
                if (t.GetValue(FrameworkElement.NameProperty).ToString() == modelName)
                {
                    model3Ds.RemoveAt(it);
                    break;
                }
                it++;
            }

            generalFiguresList.RemoveAt(iterator);

            MainWindow.FiguresListChanges();
        }
Пример #3
0
        private void InitCircle()
        {
            Model3DCollection model3Ds = model3DGroup.Children;

            int index = 0;

            foreach (GeometryModel3D model in model3Ds)
            {
                if (model.GetValue(FrameworkElement.NameProperty).ToString() == name)
                {
                    model3Ds.RemoveAt(index);
                    break;
                }
                index++;
            }

            MeshGeometry3D meshGeometry3D = new MeshGeometry3D();

            meshGeometry3D.Positions.Add(new Point3D(0, 0, 0));

            double t = 2 * Math.PI / resolution;

            for (int i = 0; i < resolution; i++)
            {
                meshGeometry3D.Positions.Add(new Point3D(radius * Math.Cos(t * i), 0, -radius * Math.Sin(t * i)));
            }

            for (int i = 0; i < resolution; i++)
            {
                int a = 0;
                int b = i + 1;
                int c = (i < (resolution - 1)) ? i + 2 : 1;

                meshGeometry3D.TriangleIndices.Add(a);
                meshGeometry3D.TriangleIndices.Add(b);
                meshGeometry3D.TriangleIndices.Add(c);
            }

            Transform3DGroup trn      = new Transform3DGroup();
            Vector3D         up       = new Vector3D(0, 100, 0);
            Vector3D         vector3D = normal;

            normal.Normalize();
            Vector3D axis  = Vector3D.CrossProduct(up, normal);
            double   angle = Vector3D.AngleBetween(up, normal);

            trn.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(axis, angle)));
            trn.Children.Add(new TranslateTransform3D(new Vector3D(center.X, center.Y, center.Z)));

            GeometryModel3D geometry = new GeometryModel3D(meshGeometry3D, new DiffuseMaterial(new SolidColorBrush(color)));

            geometry.Transform = trn;
            geometry.SetValue(FrameworkElement.NameProperty, name);

            model3DGroup.Children.Add(geometry);
            Circle3D circle3D = new Circle3D(radius, resolution, vector3D, center, model3DGroup, color, name, generalFiguresList, false);

            generalFiguresList.Add(circle3D);

            MainWindow.FiguresListChanges();
        }