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


C# Shapes.Shape类代码示例

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


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


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