本文整理汇总了C#中Box2DX.Dynamics.Body.GetAngularVelocity方法的典型用法代码示例。如果您正苦于以下问题:C# Body.GetAngularVelocity方法的具体用法?C# Body.GetAngularVelocity怎么用?C# Body.GetAngularVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2DX.Dynamics.Body
的用法示例。
在下文中一共展示了Body.GetAngularVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSpringForce
/// <summary>
/// Add a spring force
/// </summary>
void AddSpringForce(Body bA, Vec2 localA, Body bB, Vec2 localB, float k, float friction, float desiredDist)
{
Vec2 pA = bA.GetWorldPoint(localA);
Vec2 pB = bB.GetWorldPoint(localB);
Vec2 diff = pB - pA;
//Find velocities of attach points
Vec2 vA = bA.GetLinearVelocity() - Vec2.Cross(bA.GetWorldVector(localA), bA.GetAngularVelocity());
Vec2 vB = bB.GetLinearVelocity() - Vec2.Cross(bB.GetWorldVector(localB), bB.GetAngularVelocity());
Vec2 vdiff = vB - vA;
float dx = diff.Normalize(); //normalizes diff and puts length into dx
float vrel = vdiff.X * diff.X + vdiff.Y * diff.Y;
float forceMag = -k * (dx - desiredDist) - friction * vrel;
diff *= forceMag; // diff *= forceMag
bB.ApplyForce(diff, bA.GetWorldPoint(localA));
diff *= -1.0f;
bA.ApplyForce(diff, bB.GetWorldPoint(localB));
}