Ejemplo n.º 1
0
        public ParticleSystem(int maxCount, Color color)
        {
            this.maxParticleCount = maxCount;

            this.particleList = new List <Particle>();

            this.particleModel          = new GeometryModel3D();
            this.particleModel.Geometry = new MeshGeometry3D();
            Ellipse e = new Ellipse();

            e.Width  = 32.0;
            e.Height = 32.0;
            RadialGradientBrush b = new RadialGradientBrush();

            b.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, color.R, color.G, color.B), 0.25));
            b.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, color.R, color.G, color.B), 1.0));
            e.Fill = b;

            e.Measure(new Size(32, 32));
            e.Arrange(new Rect(0, 0, 32, 32));
            Brush brush = null;

            RenderTargetBitmap renderTarget = new RenderTargetBitmap(32, 32, 96, 96, PixelFormats.Pbgra32);

            renderTarget.Render(e);
            renderTarget.Freeze();
            brush = new ImageBrush(renderTarget);

            DiffuseMaterial material = new DiffuseMaterial(brush);

            this.particleModel.Material = material;

            this.rand = new Random(brush.GetHashCode());
        }
Ejemplo n.º 2
0
        public ParticleSystem(int maxCount, System.Windows.Media.Color color, Uri source)
        {
            this.maxParticleCount = maxCount;

            this.particleList = new List <Particle>();

            this.particleModel          = new GeometryModel3D();
            this.particleModel.Geometry = new MeshGeometry3D();

            Image e = new Image();

            e.Source = new BitmapImage(source);

            //  Ellipse e = new Ellipse();

            e.Width  = 32.0;
            e.Height = 32.0;
            // RadialGradientBrush b = new RadialGradientBrush();
            // b.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromArgb(0xFF, color.R, color.G, color.B), 0.25));
            // b.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromArgb(0x00, color.R, color.G, color.B), 1.0));

            // e.Fill = b;

            e.Measure(new System.Windows.Size(32, 32));
            e.Arrange(new Rect(0, 0, 32, 32));

            System.Windows.Media.Brush brush = null;

#if USE_VISUALBRUSH
            brush = new VisualBrush(e);
#else
            RenderTargetBitmap renderTarget = new RenderTargetBitmap(32, 32, 96, 96, PixelFormats.Pbgra32);
            renderTarget.Render(e);
            renderTarget.Freeze();
            brush = new ImageBrush(renderTarget);
#endif

            DiffuseMaterial material = new DiffuseMaterial(brush);

            this.particleModel.Material = material;

            this.rand = new Random(brush.GetHashCode());
        }
Ejemplo n.º 3
0
        public ParticleSystem(int maxCount, Color color)
        {
            MaxParticleCount = maxCount;

            _particleList = new List <Particle>();

            _particleModel = new GeometryModel3D {
                Geometry = new MeshGeometry3D()
            };

            var e = new Ellipse
            {
                Width  = 32.0,
                Height = 32.0
            };
            var b = new RadialGradientBrush();

            b.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, color.R, color.G, color.B), 0.25));
            b.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, color.R, color.G, color.B), 1.0));
            e.Fill = b;
            e.Measure(new Size(32, 32));
            e.Arrange(new Rect(0, 0, 32, 32));

            Brush brush = null;

#if USE_VISUALBRUSH
            brush = new VisualBrush(e);
#else
            var renderTarget = new RenderTargetBitmap(32, 32, 96, 96, PixelFormats.Pbgra32);
            renderTarget.Render(e);
            renderTarget.Freeze();
            brush = new ImageBrush(renderTarget);
#endif

            var material = new DiffuseMaterial(brush);

            _particleModel.Material = material;

            _rand = new Random(brush.GetHashCode());
        }