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


C# Body.GetTransform方法代码示例

本文整理汇总了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;
        }
开发者ID:00erik2,项目名称:Physicist,代码行数:27,代码来源:AssetCreator.cs

示例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;
		}
开发者ID:Woktopus,项目名称:Gamejam_lib,代码行数:25,代码来源:Image.cs

示例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;
		}
开发者ID:Woktopus,项目名称:Acllacuna,代码行数:20,代码来源:PhysicsUtils.cs

示例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);
            }
        }
开发者ID:brgj,项目名称:Wizards-or-whatever,代码行数:22,代码来源:Terrain.cs


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