本文整理汇总了C#中Particle.AddForce方法的典型用法代码示例。如果您正苦于以下问题:C# Particle.AddForce方法的具体用法?C# Particle.AddForce怎么用?C# Particle.AddForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Particle
的用法示例。
在下文中一共展示了Particle.AddForce方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateForce
public override void UpdateForce(Particle particle, float duaration)
{
float depth = particle.Position.Y;
if (depth >= WaterHeight + MaxDepth) return;
Vector3 force = new Vector3();
if (depth <= WaterHeight - MaxDepth)
{
force.Y = LiquidDensity * Volume;
particle.AddForce(force);
return;
}
// Otherwise we are partly submerged.
force.Y = LiquidDensity * Volume * (depth - MaxDepth - WaterHeight) / 2 * MaxDepth;
particle.AddForce(force);
}
示例2: UpdateForce
public override void UpdateForce(Particle particle, float duaration)
{
Vector3 force = particle.Velocity;
float dragcoef = force.Magnitude;
dragcoef = K1 * dragcoef * K2 * dragcoef * dragcoef;
force.Normalize();
force *= -dragcoef;
particle.AddForce(force);
}
示例3: UpdateForce
public override void UpdateForce(Particle particle, float duaration)
{
Vector3 force = particle.Position;
force -= Other.Position;
float magnit = force.Magnitude;
magnit = MathHelper.Abs(magnit - RestLength);
magnit *= SpringConstant;
force.Normalize();
force *= -magnit;
particle.AddForce(force);
}
示例4: UpdateForce
public override void UpdateForce(Particle particle, float duaration)
{
Vector3 force = particle.Position;
force -= Other.Position;
float magnitude = force.Magnitude;
if (magnitude <= RestLength) return;
magnitude = SpringConstant * (RestLength - magnitude);
force.Normalize();
force *= -magnitude;
particle.AddForce(force);
}
示例5: UpdateForce
public override void UpdateForce(Particle particle, float duration)
{
if (!(particle.Mass > 0.0f)) return;
Vector3 position = particle.Position;
position -= Anchor;
float gamma = 0.5f * MathHelper.Sqrt((4 * SpringConstant - Damping * Damping));
if (gamma == 0.0f) return;
Vector3 c = position * (Damping / (2.0f * gamma)) +
particle.Velocity * (1.0f / gamma);
Vector3 target = position * MathHelper.Cos(gamma * duration) +
c * MathHelper.Sin(gamma * duration);
target *= MathHelper.Exp(-0.5f * duration * Damping);
Vector3 accel = (target - position) * (1.0f / duration * duration) -
particle.Velocity * duration;
particle.AddForce(accel * particle.Mass);
}
示例6: Particle
public void Integrate_CanAddForcesTogether_AndWithCombinedForcesAddedToGravity_WhenIntegrating_ParticlesVelocityIsUpdated()
{
var particleNoForces = new Particle(Vector3.ZeroVector, Vector3.ZeroVector, 0.5);
var particleWithForces = new Particle(Vector3.ZeroVector, Vector3.ZeroVector, 0.5);
for (var i = 0; i < 5; i++)
{
particleWithForces.AddForce(new Vector3(0.5, 1.0, 1.5));
}
particleNoForces.Integrate(1.0);
particleWithForces.Integrate(1.0);
Assert.IsTrue(particleNoForces.Velocity.Equals(new Vector3(0.0, -10.0, 0.0)));
Assert.IsTrue(particleWithForces.Velocity.Equals(new Vector3(1.25, -7.5, 3.75)));
}
示例7: Integrate_IfTheMassOfTheParticleIsInfinite_ForcesOtherThanGravityHaveNoEffect
public void Integrate_IfTheMassOfTheParticleIsInfinite_ForcesOtherThanGravityHaveNoEffect()
{
var particleNoForces = new Particle();
var particleForces = new Particle();
particleForces.AddForce(new Vector3(3.0, 4.0, 5.0));
particleNoForces.Integrate(1.0);
particleForces.Integrate(1.0);
Assert.IsTrue(particleForces.Position.Equals(particleNoForces.Position));
}