示例#1
0
        public override void Perform()
        {
            SpotLight SpotLight = GetSpotLightFromViewport3D(Viewport3D);

            if (IsAnimateInnerConeAngle)
            {
                SpotLight.BeginAnimation(SpotLight.InnerConeAngleProperty, DoubleAnimation, HandoffBehavior);
            }
            else
            {
                SpotLight.BeginAnimation(SpotLight.OuterConeAngleProperty, DoubleAnimation, HandoffBehavior);
            }
        }
示例#2
0
        private void Load3DImages()
        {
            Model3DGroup  myModel3DGroup  = new Model3DGroup();
            ModelVisual3D myModelVisual3D = new ModelVisual3D();

            AmbientLight light = new AmbientLight(Color.FromRgb(96, 96, 96));

            myModel3DGroup.Children.Add(light);

            /*PointLight light2 = new PointLight(Colors.White, new Point3D(0, 0, 0.3));
             * myModel3DGroup.Children.Add(light2);
             * Point3DAnimation daLight = new Point3DAnimation(new Point3D(-10, 0, 0.3), new Point3D(10, 0, 0.3), TimeSpan.FromMilliseconds(25000).Duration());
             * light2.BeginAnimation(PointLight.PositionProperty, daLight);*/

            SpotLight light3 = new SpotLight(Colors.Red, new Point3D(0, 0, 10), new Vector3D(0, 0, -1), 90, 0);

            myModel3DGroup.Children.Add(light3);
            Vector3DAnimation daLight = new Vector3DAnimation(new Vector3D(-1, 0, -0.3), new Vector3D(1, 0, -0.3), TimeSpan.FromMilliseconds(15000).Duration());

            daLight.RepeatBehavior = RepeatBehavior.Forever;
            daLight.AutoReverse    = true;
            light3.BeginAnimation(SpotLight.DirectionProperty, daLight);

            /*ColorAnimation colorAnimation = new ColorAnimation(Colors.Red, Color.FromRgb(0, 0, 255), TimeSpan.FromSeconds(10).Duration());
             * colorAnimation.RepeatBehavior = RepeatBehavior.Forever;
             * colorAnimation.AutoReverse = true;
             * light3.BeginAnimation(SpotLight.ColorProperty, colorAnimation);*/

            myModelVisual3D.Content = myModel3DGroup;
            this.ImageWall3D.Children.Add(myModelVisual3D);

            allFiles = dataBase.GetAllFrontCovers(true);

            if (allFiles.Length == 0)
            {
                return;
            }

            // Shuffle
            allFiles = allFiles.OrderBy(file => random.Next()).ToArray();

            int    imageIndex = 0;
            double xPosStart  = -(double)imagesHorizontal / 2.0 - 31.415;
            double xPos       = xPosStart;
            double yPos       = (double)imagesVertical / 2.0;

            int xIndex = 0;
            int yIndex = 0;

            double centerX = 0;
            double centerZ = 20;
            double radius  = 20;

            List <BitmapImage> thumbnails = new List <BitmapImage>();

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += delegate
            {
                for (int i = 0; i < imagesHorizontal * imagesVertical; i++)
                {
                    if (imageIndex >= allFiles.Length)
                    {
                        imageIndex = 0;
                    }

                    BitmapImage bi = ImageLoader.GetThumbnailImage(allFiles[imageIndex]);

                    if (bi == null)
                    {
                        i--;
                        imageIndex++;
                        continue;
                    }

                    thumbnails.Add(bi);

                    imageIndex++;
                }
            };
            bw.RunWorkerCompleted += delegate
            {
                imageIndex = 0;
                for (int i = 0; i < imagesHorizontal * imagesVertical; i++)
                {
                    double circleXPos  = xPos / 20;
                    double circleXPos2 = xPos / 20 + 0.048;

                    double x1 = centerX + radius * Math.Cos(circleXPos);
                    double z1 = centerZ + radius * Math.Sin(circleXPos);

                    double x2 = centerX + radius * Math.Cos(circleXPos2);
                    double z2 = centerZ + radius * Math.Sin(circleXPos2);

                    Point3D leftTop     = new Point3D(x1, yPos, z1);
                    Point3D rightTop    = new Point3D(x2, yPos, z2);
                    Point3D leftBottom  = new Point3D(x1, yPos - 0.9, z1);
                    Point3D rightBottom = new Point3D(x2, yPos - 0.9, z2);

                    /*                Point3D leftTop = new Point3D(xPos, yPos, 0);
                     * Point3D rightTop = new Point3D(xPos+0.9, yPos, 0);
                     * Point3D leftBottom = new Point3D(xPos, yPos-0.9, 0);
                     * Point3D rightBottom = new Point3D(xPos+0.9, yPos-0.9, 0);*/
                    BitmapImage bi = thumbnails[imageIndex];

                    DiffuseMaterial material = new DiffuseMaterial(new ImageBrush(bi));

                    GeometryModel3D coverPlate = Create3DRectangle(leftTop, rightTop, leftBottom, rightBottom, material);

                    myModel3DGroup.Children.Add(coverPlate);

                    Transform3DGroup transformGroup = new Transform3DGroup();

                    TranslateTransform3D trans = new TranslateTransform3D();

                    DoubleAnimation daZ = new DoubleAnimation(30, 0, TimeSpan.FromMilliseconds(random.NextDouble() * 3000.0 + 5000.0).Duration());

                    daZ.EasingFunction = new PowerEase()
                    {
                        EasingMode = EasingMode.EaseInOut
                    };
                    trans.BeginAnimation(TranslateTransform3D.OffsetZProperty, daZ);

                    transformGroup.Children.Add(trans);

                    coverPlate.Transform = transformGroup;

                    xPos += 1;
                    xIndex++;

                    if (xIndex >= imagesHorizontal)
                    {
                        xIndex = 0;
                        xPos   = xPosStart;

                        yIndex++;
                        yPos -= 1;
                    }

                    imageIndex++;
                    if (imageIndex >= thumbnails.Count)
                    {
                        imageIndex = 0;
                    }
                }
            };

            bw.RunWorkerAsync();
        }