当前位置: 首页>>代码示例>>C#>>正文


C# Particle类代码示例

本文整理汇总了C#中Particle的典型用法代码示例。如果您正苦于以下问题:C# Particle类的具体用法?C# Particle怎么用?C# Particle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Particle类属于命名空间,在下文中一共展示了Particle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        /// <summary>
        /// Processes the specified Particle.
        /// </summary>
        /// <param name="dt">Elapsed time in whole and fractional seconds.</param>
        /// <param name="particle">The particle to be processed.</param>
        /// <param name="tag">The tag which has been attached to the Particle (or null).</param>
        public override unsafe void Process(float dt, Particle* particle, object tag)
        {
            float a = particle->Age * 0.07f,
                  aInv = 1f - a;

            particle->Scale = (particle->Scale * aInv) + (this.MergeScale * a);
        }
开发者ID:danielselnick,项目名称:Sentry-Smash,代码行数:13,代码来源:ScaleMergeModifier.cs

示例2: ProcessLinear

		protected override void ProcessLinear(float bias, float scale, float deltaTime, Particle[] particles, int begin, int end)
		{
			for (int i = begin; i < end; ++i)
			{
				particles[i].m_rotation = bias + scale * particles[i].m_age / particles[i].m_life;
			}
		}
开发者ID:galaxyyao,项目名称:TouhouGrave,代码行数:7,代码来源:RotationAnimation.cs

示例3: Process

        /// <summary>
        /// Processes the particles.
        /// </summary>
        /// <param name="dt">Elapsed time in whole and fractional seconds.</param>
        /// <param name="particleArray">A pointer to an array of particles.</param>
        /// <param name="count">The number of particles which need to be processed.</param>
        protected internal override unsafe void Process(float dt, Particle* particleArray, int count)
        {
            this.TotalSeconds += dt;

            float deltaAmp = this.Amplitude * dt;

            for (int i = 0; i < count; i++)
            {
                Particle* particle = (particleArray + i);

                float secondsAlive = this.TotalSeconds - particle->Inception;

                float sin = Calculator.Cos(secondsAlive * this.Frequency);

                Vector2 force = new Vector2(sin, 0f);

                force.X = ((force.X * this.AngleCos) + (force.Y * -this.AngleSin));
                force.Y = ((force.X * this.AngleSin) + (force.Y * this.AngleCos));

                force.X *= deltaAmp;
                force.Y *= deltaAmp;

                particle->Velocity.X += force.X;
                particle->Velocity.Y += force.Y;
            }
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:32,代码来源:SineForceModifier.cs

示例4: IteratesOverEachParticle

            public void IteratesOverEachParticle()
            {
                var buffer = new Particle
                {
                    Age = new float[100],
                    R = new float[100],
                    G = new float[100],
                    B = new float[100]
                };

                for (var i = 0; i < buffer.Age.Length; i++)
                    buffer.Age[i] = 1.0f;

                var subject = new ColourInterpolator2
                {
                    InitialColour = new Colour(1f, 0f, 0f),
                    FinalColour = new Colour(0f, 0f, 1f)
                };

                subject.Update(0.1666666f, ref buffer, buffer.Age.Length);

                for (int i = 0; i < buffer.Age.Length; i++)
                {
                    buffer.B[0].Should().BeApproximately(1f, 0.000001f);
                }
            }
开发者ID:BraveSirAndrew,项目名称:mercury-particle-engine,代码行数:26,代码来源:ColourInterpolator2Tests.cs

示例5: Update

        protected internal override void Update(float elapsedSeconds, ref Particle particle, int count)
        {
            fixed (float* agePtr = particle.Age)
            fixed (float* rPtr = particle.R)
            fixed (float* gPtr = particle.G)
            fixed (float* bPtr = particle.B)
            fixed (float* aPtr = particle.Opacity)
            {
                var ageDataPtr = agePtr;
                var rDataPtr = rPtr;
                var gDataPtr = gPtr;
                var bDataPtr = bPtr;
                var aDataPtr = aPtr;

                for (var j = 0; j < count; j++)
                {
                    var age = *(ageDataPtr + j);
                    var inverseAge = 1.0f - age;
                    var alpha = InitialColour.A * age;
                    *(aDataPtr + j) = alpha;
                    *(rDataPtr + j) = InitialColour.H * inverseAge;
                    *(gDataPtr + j) = InitialColour.S * inverseAge;
                    *(bDataPtr + j) = InitialColour.L * inverseAge;
                }
            }
        }
开发者ID:BraveSirAndrew,项目名称:mercury-particle-engine,代码行数:26,代码来源:OpacityFastFadeModifier.cs

示例6: Process

        /// <summary>
        /// Processes the particles.
        /// </summary>
        /// <param name="elapsedSeconds">Elapsed time in whole and fractional seconds.</param>
        /// <param name="particle">A pointer to the first item in an array of particles.</param>
        /// <param name="count">The number of particles which need to be processed.</param>
        protected internal override unsafe void Process(float elapsedSeconds, Particle* particle, int count)
        {
            particle->Colour.X = (this.InitialColour.X + ((this.UltimateColour.X - this.InitialColour.X) * particle->Age));
            particle->Colour.Y = (this.InitialColour.Y + ((this.UltimateColour.Y - this.InitialColour.Y) * particle->Age));
            particle->Colour.Z = (this.InitialColour.Z + ((this.UltimateColour.Z - this.InitialColour.Z) * particle->Age));

            Particle* previousParticle = particle;

            particle++;

            for (int i = 1; i < count; i++)
            {
                if (particle->Age < previousParticle->Age)
                {
                    particle->Colour.X = (this.InitialColour.X + ((this.UltimateColour.X - this.InitialColour.X) * particle->Age));
                    particle->Colour.Y = (this.InitialColour.Y + ((this.UltimateColour.Y - this.InitialColour.Y) * particle->Age));
                    particle->Colour.Z = (this.InitialColour.Z + ((this.UltimateColour.Z - this.InitialColour.Z) * particle->Age));
                }
                else
                {
                    particle->Colour.X = previousParticle->Colour.X;
                    particle->Colour.Y = previousParticle->Colour.Y;
                    particle->Colour.Z = previousParticle->Colour.Z;
                }

                previousParticle++;
                particle++;
            }
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:35,代码来源:ColourModifier.cs

示例7: Start

    void Start()
    {
        // Calculate the number of warp needed to handle all the particles
        if (particleCount <= 0)
            particleCount = 1;
        mWarpCount = Mathf.CeilToInt((float)particleCount / WARP_SIZE);

        // Initialize the Particle at the start
        Particle[] particleArray = new Particle[particleCount];
        for (int i = 0; i < particleCount; ++i)
        {
            particleArray[i].position.x = Random.value * 2 - 1.0f;
            particleArray[i].position.y = Random.value * 2 - 1.0f;
            particleArray[i].position.z = 0;

            particleArray[i].velocity.x = 0;
            particleArray[i].velocity.y = 0;
            particleArray[i].velocity.z = 0;
        }

        // Create the ComputeBuffer holding the Particles
        particleBuffer = new ComputeBuffer(particleCount, SIZE_PARTICLE);
        particleBuffer.SetData(particleArray);

        // Find the id of the kernel
        mComputeShaderKernelID = computeShader.FindKernel("CSMain");

        // Bind the ComputeBuffer to the shader and the compute shader
        computeShader.SetBuffer(mComputeShaderKernelID, "particleBuffer", particleBuffer);
        material.SetBuffer("particleBuffer", particleBuffer);
    }
开发者ID:ArieLeo,项目名称:XParticle,代码行数:31,代码来源:FreeParticle.cs

示例8: Process

        /// <summary>
        /// Processes the particles.
        /// </summary>
        /// <param name="dt">Elapsed time in whole and fractional seconds.</param>
        /// <param name="particle">A pointer to an array of particles.</param>
        /// <param name="count">The number of particles which need to be processed.</param>
        protected internal override unsafe void Process(float dt, Particle* particle, int count)
        {
            for (int i = 0; i < count; i++)
            {
                Particle* previousParticle = particle - 1;

                if (particle->Momentum == previousParticle->Momentum)
                {
                    particle->Rotation = previousParticle->Rotation;

                    continue;
                }

                float rads = Calculator.Atan2(particle->Momentum.Y, particle->Momentum.X);

                particle->Rotation = (rads + this.RotationOffset);

                if (particle->Rotation > Calculator.Pi)
                    particle->Rotation -= Calculator.TwoPi;

                else if (particle->Rotation < -Calculator.Pi)
                    particle->Rotation += Calculator.TwoPi;

                particle++;
            }
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:32,代码来源:TrajectoryRotationModifier.cs

示例9: ParticleSpring

		public ParticleSpring(Particle particle, Particle other, float springConstant, float restLength) 
			: base(particle)
		{
			_other = other;
			_springConstant = springConstant;
			_restLength = restLength;
		}
开发者ID:modulexcite,项目名称:jolt,代码行数:7,代码来源:ParticleSpring.cs

示例10: ParticleSystem

        public ParticleSystem(int maxParticles)
        {
            MAX_PARTICLES = maxParticles;

            random = new Random();
            _textures = new Texture2D[MAX_TEXTURES];
            _particles = new Particle[MAX_PARTICLES];

            for (int i = 0; i < MAX_PARTICLES; ++i)
            {
                _particles[i] = new Particle(null, _ttl, 0, 0, 0, 0, 0, 0);
                _particles[i]._exists = false;
            }

            _spawnBox.X = 0;
            _spawnBox.Y = 0;
            _minRotSpeed = 0;
            _maxRotSpeed = 0;
            _minRotInit = 0;
            _maxRotInit = 0;
            Angle = 0;
            _spawnCone = (float)Math.PI * 2f;
            _minSpeed = 10;
            _maxSpeed = 10;

            _alphaDecrement = 0.2f;
            _decrementTick = 5;

            _alphaIncrement = 0.2f;
            _incrementTick = 5;

            _isOn = true;
        }
开发者ID:TastyWithPasta,项目名称:pastalib_psm,代码行数:33,代码来源:ParticleSystem.cs

示例11: ParticleAnchoredSpring

		public ParticleAnchoredSpring(Particle particle, Point3D anchor, float springConstant, float restLength)
			: base(particle)
		{
			Anchor = anchor;
			SpringConstant = springConstant;
			RestLength = restLength;
		}
开发者ID:modulexcite,项目名称:jolt,代码行数:7,代码来源:ParticleAnchoredSpring.cs

示例12: UpdateParticle

        public override void UpdateParticle(GameTime time, Particle spawn)
        {
            _momentum.X = (float)Math.Cos(spawn.Orientation) * spawn.Speed;
            _momentum.Y = (float)Math.Sin(spawn.Orientation) * spawn.Speed;

            if (spawn.Position.X < (float)_rect.X)
            {
                spawn.Position.X = (float)_rect.X;
                _momentum.X *= -1f; _momentum.X *= _bounce;
            }
            else if (spawn.Position.X > (float)_rect.Width)
            {
                spawn.Position.X = (float)_rect.Width;
                _momentum.X *= -1f; _momentum.X *= _bounce;
            }

            if (spawn.Position.Y < (float)_rect.Y)
            {
                spawn.Position.Y = (float)_rect.Y;
                _momentum.Y *= -1f; _momentum.Y *= _bounce;
            }
            else if (spawn.Position.Y > (float)_rect.Height)
            {
                spawn.Position.Y = (float)_rect.Height;
                _momentum.Y *= -1f; _momentum.Y *= _bounce;
            }

            spawn.Orientation = (float)Math.Atan2(_momentum.Y, _momentum.X);
            spawn.Speed = _momentum.Length();
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:30,代码来源:WindowBounceModifier.cs

示例13: Particle

		public void Construction_CanCreateAParticleWithAnInitialPositionAndVelocity_AndItsPositionAndVelocityAreInitialised()
		{
			var particle = new Particle(TestPosition, TestVelocity);

			Assert.IsTrue(particle.Position.Equals(TestPosition));
			Assert.IsTrue(particle.Velocity.Equals(TestVelocity));
		}
开发者ID:dazpaz,项目名称:Cyclone,代码行数:7,代码来源:ParticleTests.cs

示例14: Construction_CanCreateAParticleWithAnInitialPosition_AndItsPositionIsInitialised

		public void Construction_CanCreateAParticleWithAnInitialPosition_AndItsPositionIsInitialised()
		{
			var particle = new Particle(TestPosition);

			Assert.IsTrue(particle.Position.Equals(TestPosition));
			Assert.IsTrue(particle.Velocity.Equals(Vector3.ZeroVector));
		}
开发者ID:dazpaz,项目名称:Cyclone,代码行数:7,代码来源:ParticleTests.cs

示例15: Update

        protected internal unsafe override void Update(float elapsedSeconds, ref Particle particle, int count)
        {
            _totalSeconds += elapsedSeconds;

            fixed (float* agePtr = particle.Age)
            fixed (float* inceptionPtr = particle.Inception)
            {
                var ageDataPtr = agePtr;
                var inceptionDataPtr = inceptionPtr;
                var term = _term;
                var totalSeconds = _totalSeconds;

                for (var j = 0; j < count; j++)
                {
                    var age = (totalSeconds - *(inceptionDataPtr + j)) / term;

                    // TODO: There is a fairly systemic bug in the emitter code right now that means that the inception time
                    // of a particle can be later than the total elapsed time in here. It happens because the modifiers are
                    // not necessarily updated every frame, while the emitter is.
                    if (age < 0)
                        age = 0;
                    if (age > 1)
                        age = 1;

                    *(ageDataPtr + j) = age;
                }
            }
        }
开发者ID:BraveSirAndrew,项目名称:mercury-particle-engine,代码行数:28,代码来源:AgeModifier.cs


注:本文中的Particle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。