Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            model = new ModelVisual3D();

            const int    rows     = 5;
            const int    columns  = 4;
            const double distance = 120;

            var turbine = new WindTurbine();
            var r       = new Random();

            for (int i = 0; i < rows; i++)
            {
                double y = i * distance;
                for (int j = 0; j + (i % 2) * 0.5 <= columns - 1; j++)
                {
                    double x      = (j + (i % 2) * 0.5) * distance;
                    var    visual = new WindTurbineVisual3D
                    {
                        RotationAngle = r.Next(360),
                        RotationSpeed = 20,
                        WindTurbine   = turbine,
                        Transform     = new TranslateTransform3D(x, y, 0)
                    };
                    model.Children.Add(visual);
                }
            }


            var seasurface = new PlaneVisual3D
            {
                DivWidth  = 100,
                DivLength = 100,
                Origin    = new Point3D((rows - 2) * distance * 0.5, (columns) * distance * 0.5, 0),
                Width     = rows * distance * 2,
                Length    = columns * distance * 2
            };

            seasurface.Material = seasurface.BackMaterial = MaterialHelper.CreateMaterial(Colors.SeaGreen, 0.8);

            model.Children.Add(new GridLinesVisual3D()
            {
                Center = seasurface.Origin, Fill = Brushes.Gray, Width = seasurface.Width, Length = seasurface.Length
            });

            model.Children.Add(seasurface);
            view1.Children.Add(model);

            Loaded += MainWindowLoaded;
            Closed += MainWindowClosed;
        }
        public MainWindow()
        {
            InitializeComponent();

            model = new ModelVisual3D();

            const int rows = 5;
            const int columns = 4;
            const double distance = 120;

            var turbine = new WindTurbine();
            var r = new Random();
            for (int i = 0; i < rows; i++)
            {
                double y = i * distance;
                for (int j = 0; j + (i % 2) * 0.5 <= columns - 1; j++)
                {
                    double x = (j + (i % 2) * 0.5) * distance;
                    var visual = new WindTurbineVisual3D
                                     {
                                         RotationAngle = r.Next(360),
                                         RotationSpeed = 20,
                                         WindTurbine = turbine,
                                         Transform = new TranslateTransform3D(x, y, 0)
                                     };
                    model.Children.Add(visual);
                }
            }


            var seasurface = new PlaneVisual3D
                                 {
                                     DivWidth = 100,
                                     DivLength = 100,
                                     Origin = new Point3D((rows - 2) * distance * 0.5, (columns) * distance * 0.5, 0),
                                     Width = rows * distance * 2,
                                     Length = columns * distance * 2
                                 };
            seasurface.Material = seasurface.BackMaterial = MaterialHelper.CreateMaterial(Colors.SeaGreen, 0.8);

            model.Children.Add(new GridLinesVisual3D() { Center = seasurface.Origin, Fill = Brushes.Gray, Width = seasurface.Width, Length = seasurface.Length });

            model.Children.Add(seasurface);
            view1.Children.Add(model);

            Loaded += MainWindowLoaded;
            Closed += MainWindowClosed;
        }