• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Shapes.Shape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: DrawLineShape

		public void DrawLineShape(Shape shape, Color color)
		{
			if (!_hasBegun)
				throw new InvalidOperationException("Begin must be called before DrawLineShape can be called.");

			if (shape.ShapeType != ShapeType.Edge && shape.ShapeType != ShapeType.Chain)
				throw new NotSupportedException("The specified shapeType is not supported by LineBatch.");

			if (shape.ShapeType == ShapeType.Edge)
			{
				if (_lineVertsCount >= _lineVertices.Length)
					Flush();

				EdgeShape edge = (EdgeShape)shape;
				_lineVertices[_lineVertsCount].Position = new Vector3(edge.Vertex1, 0f);
				_lineVertices[_lineVertsCount + 1].Position = new Vector3(edge.Vertex2, 0f);
				_lineVertices[_lineVertsCount].Color = _lineVertices[_lineVertsCount + 1].Color = color;
				_lineVertsCount += 2;
			}
			else if (shape.ShapeType == ShapeType.Chain)
			{
				ChainShape chain = (ChainShape)shape;
				for (int i = 0; i < chain.Vertices.Count; ++i)
				{
					if (_lineVertsCount >= _lineVertices.Length)
						Flush();

					_lineVertices[_lineVertsCount].Position = new Vector3(chain.Vertices[i], 0f);
					_lineVertices[_lineVertsCount + 1].Position = new Vector3(chain.Vertices.NextVertex(i), 0f);
					_lineVertices[_lineVertsCount].Color = _lineVertices[_lineVertsCount + 1].Color = color;
					_lineVertsCount += 2;
				}
			}
		}
开发者ID:ayls,项目名称:Ayls.Game.Framework,代码行数:34,代码来源:LineBatch.cs


示例2: FarseerObject

 public FarseerObject(FarseerWorld world, Shape shape, BodyType BodyType = BodyType.Dynamic)
 {            
     body = new Body(world.World);
     body.BodyType = BodyType;
     body.CreateFixture(shape);
     body.Enabled = false;            
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:7,代码来源:FarseerObject.cs


示例3: testOverlap

		/// <summary>
		/// tests for an overlap of shapeA and shapeB. Returns false if both Shapes are chains or if they are not overlapping.
		/// </summary>
		/// <returns><c>true</c>, if overlap was tested, <c>false</c> otherwise.</returns>
		/// <param name="shapeA">Shape a.</param>
		/// <param name="shapeB">Shape b.</param>
		/// <param name="transformA">Transform a.</param>
		/// <param name="transformB">Transform b.</param>
		public static bool testOverlap( Shape shapeA, Shape shapeB, ref FSTransform transformA, ref FSTransform transformB )
		{
			if( shapeA.childCount == 1 && shapeB.childCount == 1 )
				return Collision.testOverlap( shapeA, 0, shapeB, 0, ref transformA, ref transformB );

			if( shapeA.childCount > 1 )
			{
				for( var i = 0; i < shapeA.childCount; i++ )
				{
					if( Collision.testOverlap( shapeA, i, shapeB, 0, ref transformA, ref transformB ) )
						return true;
				}
			}

			if( shapeB.childCount > 1 )
			{
				for( var i = 0; i < shapeB.childCount; i++ )
				{
					if( Collision.testOverlap( shapeA, 0, shapeB, i, ref transformA, ref transformB ) )
						return true;
				}
			}

			return false;
		}
开发者ID:prime31,项目名称:Nez,代码行数:33,代码来源:FarseerCollisions.cs


示例4: Set

        /// <summary>
        /// Initialize the proxy using the given shape. The shape
        /// must remain in scope while the proxy is in use.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="index">The index.</param>
        public void Set(Shape shape, int index)
        {
            switch (shape.ShapeType)
            {
                case ShapeType.Circle:
                    {
                        CircleShape circle = (CircleShape) shape;
                        Vertices = new Vertices(1);
                        Vertices.Add(circle.Position);
                        Radius = circle.Radius;
                    }
                    break;

                case ShapeType.Polygon:
                    {
                        PolygonShape polygon = (PolygonShape) shape;
                        Vertices = polygon.Vertices;
                        Radius = polygon.Radius;
                    }
                    break;

                case ShapeType.Loop:
                    {
                        LoopShape loop = (LoopShape) shape;
                        Debug.Assert(0 <= index && index < loop.Vertices.Count);

                        Buffer[0] = loop.Vertices[index];
                        if (index + 1 < loop.Vertices.Count)
                        {
                            Buffer[1] = loop.Vertices[index + 1];
                        }
                        else
                        {
                            Buffer[1] = loop.Vertices[0];
                        }

                        Vertices = new Vertices(2);
                        Vertices.Add(Buffer[0]);
                        Vertices.Add(Buffer[1]);
                        Radius = loop.Radius;
                    }
                    break;

                case ShapeType.Edge:
                    {
                        EdgeShape edge = (EdgeShape) shape;
                        Vertices = new Vertices(2);
                        Vertices.Add(edge.Vertex1);
                        Vertices.Add(edge.Vertex2);
                        Radius = edge.Radius;
                    }
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }
        }
开发者ID:dvgamer,项目名称:GhostLegend-XNA,代码行数:64,代码来源:Distance.cs


示例5: DynamicBody

 public DynamicBody(GameWorld World, Shape Shape, Vector2 Position, string TexName)
     : base(World)
 {
     Body BodyDec;
     BodyDec = new Body(World.PhysicalWorld);
     BodyDec.BodyType = BodyType.Dynamic;
     BodyFixture = BodyDec.CreateFixture(Shape);
     BodyFixture.Body.Position = Position;
     Texture = GeneralManager.Textures[TexName];
 }
开发者ID:vinterdo,项目名称:SteamAge,代码行数:10,代码来源:DynamicBody.cs


示例6: GetSizeFromShape

 /// <summary>
 /// Gets the size from shape.
 /// </summary>
 /// <param name="shape">The shape.</param>
 /// <returns></returns>
 public static Vector2 GetSizeFromShape( Shape shape )
 {
     switch ( shape.ShapeType ) {
         case ShapeType.Circle:
             return new Vector2( shape.Radius );
         case ShapeType.Polygon:
             return GetSizeFromVertices( ( (PolygonShape)shape ).Vertices );
         default:
             return Vector2.Zero;
     }
 }
开发者ID:headdetect,项目名称:Flux-XNA,代码行数:16,代码来源:VectorUtils.cs


示例7: TextureFromShape

		public Texture2D TextureFromShape(Shape shape, MaterialType type, Color color, float materialScale)
		{
			switch (shape.ShapeType)
			{
				case ShapeType.Circle:
				return CircleTexture(shape.Radius, type, color, materialScale);
				case ShapeType.Polygon:
				return TextureFromVertices(((PolygonShape)shape).Vertices, type, color, materialScale);
				default:
				throw new NotSupportedException("The specified shape type is not supported.");
			}
		}
开发者ID:ayls,项目名称:Ayls.Game.Framework,代码行数:12,代码来源:AssetCreator.cs


示例8: set

		// GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.

		/// <summary>
		/// Initialize the proxy using the given shape. The shape
		/// must remain in scope while the proxy is in use.
		/// </summary>
		/// <param name="shape">The shape.</param>
		/// <param name="index">The index.</param>
		public void set( Shape shape, int index )
		{
			switch( shape.shapeType )
			{
				case ShapeType.Circle:
					{
						var circle = (CircleShape)shape;
						vertices.Clear();
						vertices.Add( circle.position );
						radius = circle.radius;
					}
					break;

				case ShapeType.Polygon:
					{
						var polygon = (PolygonShape)shape;
						vertices.Clear();
						for( int i = 0; i < polygon.vertices.Count; i++ )
						{
							vertices.Add( polygon.vertices[i] );
						}
						radius = polygon.radius;
					}
					break;

				case ShapeType.Chain:
					{
						var chain = (ChainShape)shape;
						Debug.Assert( 0 <= index && index < chain.vertices.Count );
						vertices.Clear();
						vertices.Add( chain.vertices[index] );
						vertices.Add( index + 1 < chain.vertices.Count ? chain.vertices[index + 1] : chain.vertices[0] );

						radius = chain.radius;
					}
					break;

				case ShapeType.Edge:
					{
						var edge = (EdgeShape)shape;
						vertices.Clear();
						vertices.Add( edge.vertex1 );
						vertices.Add( edge.vertex2 );
						radius = edge.radius;
					}
					break;

				default:
					Debug.Assert( false );
					break;
			}
		}
开发者ID:prime31,项目名称:Nez,代码行数:60,代码来源:Distance.cs


示例9: Set

        /// <summary>
        /// Initialize the proxy using the given shape. The shape
        /// must remain in scope while the proxy is in use.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="index">The index.</param>
        public void Set(Shape shape, int index)
        {
            switch (shape.ShapeType)
            {
                case ShapeType.Circle:
                    {
                        CircleShape circle = (CircleShape)shape;
                        Vertices.Clear();
                        Vertices.Add(circle.Position);
                        Radius = circle.Radius;
                    }
                    break;

                case ShapeType.Polygon:
                    {
                        PolygonShape polygon = (PolygonShape)shape;
                        Vertices.Clear();
                        for (int i = 0; i < polygon.Vertices.Count; i++)
                        {
                            Vertices.Add(polygon.Vertices[i]);
                        }
                        Radius = polygon.Radius;
                    }
                    break;

                case ShapeType.Loop:
                    {
                        LoopShape loop = (LoopShape)shape;
                        Debug.Assert(0 <= index && index < loop.Vertices.Count);
                        Vertices.Clear();
                        Vertices.Add(loop.Vertices[index]);
                        Vertices.Add(index + 1 < loop.Vertices.Count ? loop.Vertices[index + 1] : loop.Vertices[0]);

                        Radius = loop.Radius;
                    }
                    break;

                case ShapeType.Edge:
                    {
                        EdgeShape edge = (EdgeShape)shape;
                        Vertices.Clear();
                        Vertices.Add(edge.Vertex1);
                        Vertices.Add(edge.Vertex2);
                        Radius = edge.Radius;
                    }
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:58,代码来源:Distance.cs


示例10: Collectible

        public Collectible(GameScreen gameScreen, Shape shape, World world, Camera2D camera)
            : base(gameScreen.ScreenManager.Game)
        {
            this.gameScreen = gameScreen;

            this.world = world;
            body = new Body(world);
            body.CreateFixture(shape);
            body.CollisionCategories = Category.Cat3;
            body.CollidesWith = Category.Cat2;
            body.BodyType = BodyType.Kinematic;

            body.OnCollision += body_OnCollision;

            shootParticles = false;
            collected = false;

            this.camera = camera;
        }
开发者ID:maxrevilo,项目名称:Juego2D,代码行数:19,代码来源:Collectable.cs


示例11: SerializeShape

        private void SerializeShape(Shape shape)
        {
            _writer.WriteStartElement("Shape");
            _writer.WriteAttributeString("Type", shape.ShapeType.ToString());

            switch (shape.ShapeType)
            {
                case ShapeType.Circle:
                    {
                        CircleShape circle = (CircleShape)shape;

                        _writer.WriteElementString("Radius", circle.Radius.ToString());

                        WriteElement("Position", circle.Position);
                    }
                    break;
                case ShapeType.Polygon:
                    {
                        PolygonShape poly = (PolygonShape)shape;

                        _writer.WriteStartElement("Vertices");
                        foreach (Vector2 v in poly.Vertices)
                            WriteElement("Vertex", v);
                        _writer.WriteEndElement();

                        WriteElement("Centroid", poly.MassData.Centroid);
                    }
                    break;
                case ShapeType.Edge:
                    {
                        EdgeShape poly = (EdgeShape)shape;
                        WriteElement("Vertex1", poly.Vertex1);
                        WriteElement("Vertex2", poly.Vertex2);
                    }
                    break;
                default:
                    throw new Exception();
            }

            _writer.WriteEndElement();
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:41,代码来源:Serialization.cs


示例12: DrawLineShape

 public void DrawLineShape( SpriteBatch batch, Shape shape, Color color, float width )
 {
     if ( shape.ShapeType != ShapeType.Edge &&
          shape.ShapeType != ShapeType.Loop ) {
         throw new NotSupportedException ( "The specified shapeType is not supported by LineBatch." );
     }
     switch ( shape.ShapeType ) {
         case ShapeType.Edge : {
             var edge = (EdgeShape) shape;
             DrawLine ( batch, width, color, edge.Vertex1, edge.Vertex2 );
         }
             break;
         case ShapeType.Polygon : {
             var chain = (LoopShape) shape;
             for ( int i = 0; i < chain.Vertices.Count; ++i ) {
                 DrawLine ( batch, width, color, chain.Vertices [i], chain.Vertices.NextVertex ( i ) );
             }
         }
             break;
     }
 }
开发者ID:headdetect,项目名称:Circular,代码行数:21,代码来源:LineBatch.cs


示例13: EvenlyDistributeShapesAlongPath

 public static List<Body> EvenlyDistributeShapesAlongPath(World world, Path path, Shape shape, BodyType type,
                                                          int copies)
 {
     return EvenlyDistributeShapesAlongPath(world, path, shape, type, copies, null);
 }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:5,代码来源:PathManager.cs


示例14: TextureFromShape

        public Texture2D TextureFromShape(Shape shape, string textureRef, Color color, float materialScale)
        {
            Texture2D shapeTexture = null;
            if (this.IsInitialized && shape != null)
            {
                switch (shape.ShapeType)
                {
                    case ShapeType.Circle:
                        shapeTexture = this.CircleTexture(shape.Radius, textureRef, color, materialScale);
                        break;

                    case ShapeType.Polygon:
                        shapeTexture = this.TextureFromVertices(((PolygonShape)shape).Vertices, textureRef, color, materialScale);
                        break;

                    case ShapeType.Chain:
                        ChainShape chain = shape as ChainShape;
                        if (chain != null)
                        {
                            shapeTexture = this.TextureFromVertices(AssetCreator.CreateChainVertices(chain), textureRef, color, materialScale);
                        }

                        break;
                }
            }

            return shapeTexture;
        }
开发者ID:00erik2,项目名称:Physicist,代码行数:28,代码来源:AssetCreator.cs


示例15: FindShapeIndex

        private int FindShapeIndex(Shape shape)
        {
            for (int i = 0; i < _serializedShapes.Count; ++i)
            {
                if (_serializedShapes[i].CompareTo(shape))
                    return i;
            }

            return -1;
        }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:10,代码来源:Serialization.cs


示例16: DrawLineShape

 public void DrawLineShape(Shape shape)
 {
     DrawLineShape(shape, Color.Black);
 }
开发者ID:tinco,项目名称:Farseer-Physics,代码行数:4,代码来源:LineBatch.cs


示例17: Fixture

        public Fixture(Body body, Shape shape, object userData)
        {
            if (Settings.UseFPECollisionCategories)
                _collisionCategories = Category.All;
            else
                _collisionCategories = Category.Cat1;

            _collidesWith = Category.All;
            _collisionGroup = 0;

            //Fixture defaults
            Friction = 0.2f;
            Restitution = 0;

            IsSensor = false;

            Body = body;
            UserData = userData;

            if (Settings.ConserveMemory)
                Shape = shape;
            else
                Shape = shape.Clone();

            RegisterFixture();
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:26,代码来源:Fixture.cs


示例18: LoadContent

        public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = new Vector2(0, 9.82f);

            _border = new Border(World, Lines, Framework.GraphicsDevice);

            // Bridge
            // We make a path using 2 points.
            Path bridgePath = new Path();
            bridgePath.Add(new Vector2(-15, 5));
            bridgePath.Add(new Vector2(15, 5));
            bridgePath.Closed = false;

            Vertices box = PolygonTools.CreateRectangle(0.125f, 0.5f);
            PolygonShape shape = new PolygonShape(box, 20);

            _bridgeBodies = PathManager.EvenlyDistributeShapesAlongPath(World, bridgePath, shape, BodyType.Dynamic, 29);

            // Attach the first and last fixtures to the world
            Body anchor = new Body(World, Vector2.Zero);
            anchor.BodyType = BodyType.Static;
            World.AddJoint(new RevoluteJoint(_bridgeBodies[0], anchor, _bridgeBodies[0].Position - new Vector2(0.5f, 0f), true));
            World.AddJoint(new RevoluteJoint(_bridgeBodies[_bridgeBodies.Count - 1], anchor, _bridgeBodies[_bridgeBodies.Count - 1].Position + new Vector2(0.5f, 0f), true));

            PathManager.AttachBodiesWithRevoluteJoint(World, _bridgeBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), false, true);

            // Soft body
            // We make a rectangular path.
            Path rectanglePath = new Path();
            rectanglePath.Add(new Vector2(-6, -11));
            rectanglePath.Add(new Vector2(-6, 1));
            rectanglePath.Add(new Vector2(6, 1));
            rectanglePath.Add(new Vector2(6, -11));
            rectanglePath.Closed = true;

            // Creating two shapes. A circle to form the circle and a rectangle to stabilize the soft body.
            Shape[] shapes = new Shape[2];
            shapes[0] = new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.5f, new Vector2(-0.1f, 0f), 0f), 1f);
            shapes[1] = new CircleShape(0.5f, 1f);

            // We distribute the shapes in the rectangular path.
            _softBodies = PathManager.EvenlyDistributeShapesAlongPath(World, rectanglePath, shapes, BodyType.Dynamic, 30);

            // Attach the bodies together with revolute joints. The rectangular form will converge to a circular form.
            PathManager.AttachBodiesWithRevoluteJoint(World, _softBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), true, true);

            // GFX
            _bridgeBox = new Sprite(ContentWrapper.TextureFromShape(shape, ContentWrapper.Orange, ContentWrapper.Brown));
            _softBodyBox = new Sprite(ContentWrapper.TextureFromShape(shapes[0], ContentWrapper.Green, ContentWrapper.Black));
            _softBodyBox.Origin += new Vector2(ConvertUnits.ToDisplayUnits(0.1f), 0f);
            _softBodyCircle = new Sprite(ContentWrapper.TextureFromShape(shapes[1], ContentWrapper.Lime, ContentWrapper.Grey));
        }
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:54,代码来源:D11_SoftBody.cs


示例19: CreateFixture

 public Fixture CreateFixture(Shape shape, Category collisionCategories)
 {
     return new Fixture(this, shape, collisionCategories);
 }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:4,代码来源:Body.cs


示例20: CreateFixture

 /// <summary>
 /// Creates a fixture with the supplied shape.
 /// Note: Default density is 1
 /// </summary>
 /// <param name="shape">The shape</param>
 /// <returns></returns>
 public Fixture CreateFixture(Shape shape)
 {
     return CreateFixture(shape, 1);
 }
开发者ID:scastle,项目名称:Solitude,代码行数:10,代码来源:Body.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Common.Path类代码示例发布时间:2022-05-26
下一篇:
C# Shapes.PolygonShape类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap