本文整理汇总了C#中FarseerPhysics.Dynamics.Body.GetTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Body.GetTransform方法的具体用法?C# Body.GetTransform怎么用?C# Body.GetTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Dynamics.Body
的用法示例。
在下文中一共展示了Body.GetTransform方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateOrigin
public static Vector2 CalculateOrigin(Body body)
{
Vector2 origin = Vector2.Zero;
if (body != null)
{
Vector2 leftBound = new Vector2(float.MaxValue);
Transform trans;
body.GetTransform(out trans);
for (int i = 0; i < body.FixtureList.Count; ++i)
{
for (int j = 0; j < body.FixtureList[i].Shape.ChildCount; ++j)
{
AABB bounds;
body.FixtureList[i].Shape.ComputeAABB(out bounds, ref trans, j);
Vector2.Min(ref leftBound, ref bounds.LowerBound, out leftBound);
}
}
// calculate body offset from its center and add a 1 pixel border
// because we generate the textures a little bigger than the actual body's fixtures
origin = ConvertUnits.ToDisplayUnits(body.Position - leftBound) + new Vector2(1f);
}
return origin;
}
示例2: ScaleToBody
public void ScaleToBody(Body body)
{
Transform t;
body.GetTransform(out t);
AABB aabb;
aabb.LowerBound = new Vector2(Settings.MaxFloat, Settings.MaxFloat);
aabb.UpperBound = new Vector2(-Settings.MaxFloat, -Settings.MaxFloat);
AABB tempAABB;
int fixtureCount = body.FixtureList.Count;
for (int i = 0; i < fixtureCount; ++i)
{
body.FixtureList[i].Shape.ComputeAABB(out tempAABB, ref t, 0);
aabb.Combine(ref tempAABB);
}
Vector2 scale = new Vector2(
ConvertUnits.ToDisplayUnits(aabb.Width) / sourceRect.Width,
ConvertUnits.ToDisplayUnits(aabb.Height) / sourceRect.Height
);
this.scale = scale;
}
示例3: GetAABBFromBody
public static AABB GetAABBFromBody(Body body)
{
Transform t;
body.GetTransform(out t);
AABB aabb;
aabb.LowerBound = new Vector2(Settings.MaxFloat, Settings.MaxFloat);
aabb.UpperBound = new Vector2(-Settings.MaxFloat, -Settings.MaxFloat);
AABB tempAABB;
int fixtureCount = body.FixtureList.Count;
for (int i = 0; i < fixtureCount; ++i)
{
body.FixtureList[i].Shape.ComputeAABB(out tempAABB, ref t, 0);
aabb.Combine(ref tempAABB);
}
return aabb;
}
示例4: DrawBody
/// <summary>
/// Draws a single body
/// </summary>
/// <param name="body">the body to draw</param>
public void DrawBody(Body body)
{
Transform xf;
body.GetTransform(out xf);
foreach (Fixture f in body.FixtureList)
{
PolygonShape poly = (PolygonShape)f.Shape;
int vertexCount = poly.Vertices.Count;
if (vertexCount > MAX_VERTICES)
throw new Exception("Num vertices in polygon exceeds maximum number allowed");
for (int i = 0; i < vertexCount; i++)
tempVertices[i] = MathUtils.Multiply(ref xf, poly.Vertices[i]);
DrawPolygon(tempVertices, vertexCount, Color.SaddleBrown);
}
}