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

C# Dynamics.PhysicsWorld类代码示例

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

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



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

示例1: CreateFixedAngleJoint

        /// <summary>
        /// Creates a fixed angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="body">The body.</param>
        /// <returns></returns>
        public static FixedAngleJoint CreateFixedAngleJoint(PhysicsWorld world, PhysicsBody body)
        {
            FixedAngleJoint angleJoint = new FixedAngleJoint(body);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:13,代码来源:JointFactory.cs


示例2: CreateDistanceJoint

 public static DistanceJoint CreateDistanceJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs


示例3: CreateFixedPrismaticJoint

 public static FixedPrismaticJoint CreateFixedPrismaticJoint(PhysicsWorld world, PhysicsBody body, Vector2 worldAnchor,
                                                             Vector2 axis)
 {
     FixedPrismaticJoint joint = new FixedPrismaticJoint(body, worldAnchor, axis);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs


示例4: CreateFixedDistanceJoint

 public static FixedDistanceJoint CreateFixedDistanceJoint(PhysicsWorld world, PhysicsBody body, Vector2 localAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs


示例5: CreateFixedRevoluteJoint

 /// <summary>
 /// Creates the fixed revolute joint.
 /// </summary>
 /// <param name="world">The world.</param>
 /// <param name="body">The body.</param>
 /// <param name="bodyAnchor">The body anchor.</param>
 /// <param name="worldAnchor">The world anchor.</param>
 /// <returns></returns>
 public static FixedRevoluteJoint CreateFixedRevoluteJoint(PhysicsWorld world, PhysicsBody body, Vector2 bodyAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedRevoluteJoint fixedRevoluteJoint = new FixedRevoluteJoint(body, bodyAnchor, worldAnchor);
     world.AddJoint(fixedRevoluteJoint);
     return fixedRevoluteJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:15,代码来源:JointFactory.cs


示例6: AttachBodiesWithSliderJoint

        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        /// <param name="minLength">Minimum length of the slider joint.</param>
        /// <param name="maxLength">Maximum length of the slider joint.</param>
        /// <returns></returns>
        public static List<SliderJoint> AttachBodiesWithSliderJoint(PhysicsWorld world, List<PhysicsBody> bodies, Vector2 localAnchorA,
                                                                    Vector2 localAnchorB, bool connectFirstAndLast,
                                                                    bool collideConnected, float minLength,
                                                                    float maxLength)
        {
            List<SliderJoint> joints = new List<SliderJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                SliderJoint joint = new SliderJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB, minLength,
                                                    maxLength);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                SliderJoint lastjoint = new SliderJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA, localAnchorB,
                                                        minLength, maxLength);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:39,代码来源:PathManager.cs


示例7: CreateAngleJoint

        /// <summary>
        /// Creates an angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodyA">The first body.</param>
        /// <param name="bodyB">The second body.</param>
        /// <returns></returns>
        public static AngleJoint CreateAngleJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB)
        {
            AngleJoint angleJoint = new AngleJoint(bodyA, bodyB);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:14,代码来源:JointFactory.cs


示例8: Deserialize

 public static void Deserialize(PhysicsWorld world, string filename)
 {
     using (FileStream fs = new FileStream(filename, FileMode.Open))
     {
         new WorldXmlDeserializer().Deserialize(world, fs);
     }
 }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:7,代码来源:Serialization.cs


示例9: CreateBreakableBody

        /// <summary>
        /// Creates a breakable body. You would want to remove collinear points before using this.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="vertices">The vertices.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static PhysicsBreakableBody CreateBreakableBody(PhysicsWorld world, Vertices vertices, float density, Vector2 position,
            object userData)
        {
            List<Vertices> triangles = EarclipDecomposer.ConvexPartition(vertices);

            PhysicsBreakableBody breakableBody = new PhysicsBreakableBody(triangles, world, density, userData);
            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return breakableBody;
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:19,代码来源:BodyFactory.cs


示例10: PhysicsBreakableBody

        public PhysicsBreakableBody(IEnumerable<Vertices> vertices, PhysicsWorld world, float density, object userData)
        {
            _world = world;
            _world.ContactManager.PostSolve += PostSolve;
            MainBody = new PhysicsBody(_world);
            MainBody.BodyType = BodyType.Dynamic;

            foreach (Vertices part in vertices)
            {
                PolygonShape polygonShape = new PolygonShape(part, density);
                Fixture fixture = MainBody.CreateFixture(polygonShape, userData);
                Parts.Add(fixture);
            }
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:14,代码来源:PhysicsBreakableBody.cs


示例11: CreateChain

        /// <summary>
        /// Creates a chain.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <param name="linkWidth">The width.</param>
        /// <param name="linkHeight">The height.</param>
        /// <param name="fixStart">if set to <c>true</c> [fix start].</param>
        /// <param name="fixEnd">if set to <c>true</c> [fix end].</param>
        /// <param name="numberOfLinks">The number of links.</param>
        /// <param name="linkDensity">The link density.</param>
        /// <returns></returns>
        public static Path CreateChain(PhysicsWorld world, Vector2 start, Vector2 end, float linkWidth, float linkHeight,
            bool fixStart, bool fixEnd, int numberOfLinks, float linkDensity)
        {
            //Chain start / end
            Path path = new Path();
            path.Add(start);
            path.Add(end);

            //A single chainlink
            PolygonShape shape = new PolygonShape(PolygonTools.CreateRectangle(linkWidth, linkHeight), linkDensity);

            //Use PathManager to create all the chainlinks based on the chainlink created before.
            List<PhysicsBody> chainLinks = PathManager.EvenlyDistributeShapesAlongPath(world, path, shape, BodyType.Dynamic,
                                                                                numberOfLinks);

            if (fixStart)
            {
                //Fix the first chainlink to the world
                JointFactory.CreateFixedRevoluteJoint(world, chainLinks[0], new Vector2(0, -(linkHeight / 2)),
                                                      chainLinks[0].Position);
            }

            if (fixEnd)
            {
                //Fix the last chainlink to the world
                JointFactory.CreateFixedRevoluteJoint(world, chainLinks[chainLinks.Count - 1],
                                                      new Vector2(0, (linkHeight / 2)),
                                                      chainLinks[chainLinks.Count - 1].Position);
            }

            //Attach all the chainlinks together with a revolute joint
            PathManager.AttachBodiesWithRevoluteJoint(world, chainLinks, new Vector2(0, -linkHeight),
                                                      new Vector2(0, linkHeight),
                                                      false, false);

            return (path);
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:50,代码来源:LinkFactory.cs


示例12: EvenlyDistributeShapesAlongPath

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


示例13: PhysicsBody

        public PhysicsBody(PhysicsWorld world, object userData)
        {
            FixtureList = new List<Fixture>(32);
            BodyId = _bodyIdCounter++;

            World = world;
            UserData = userData;

            FixedRotation = false;
            IsBullet = false;
            SleepingAllowed = true;
            Awake = true;
            BodyType = BodyType.Static;
            Enabled = true;

            Xf.R.Set(0);

            world.AddBody(this);
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:19,代码来源:PhysicsBody.cs


示例14: CreateWeldJoint

 public static WeldJoint CreateWeldJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 localAnchorA,
                                         Vector2 localAnchorB)
 {
     WeldJoint weldJoint = new WeldJoint(bodyA, bodyB, localAnchorA, localAnchorB);
     world.AddJoint(weldJoint);
     return weldJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs


示例15: CreateFrictionJoint

 public static FrictionJoint CreateFrictionJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     FrictionJoint frictionJoint = new FrictionJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(frictionJoint);
     return frictionJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs


示例16: CreateCapsule

        /// <summary>
        /// Creates a capsule.
        /// Note: Automatically decomposes the capsule if it contains too many vertices (controlled by Settings.MaxPolygonVertices)
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="height">The height.</param>
        /// <param name="topRadius">The top radius.</param>
        /// <param name="topEdges">The top edges.</param>
        /// <param name="bottomRadius">The bottom radius.</param>
        /// <param name="bottomEdges">The bottom edges.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static PhysicsBody CreateCapsule(PhysicsWorld world, float height, float topRadius, int topEdges,
            float bottomRadius,
            int bottomEdges, float density, Vector2 position, object userData)
        {
            Vertices verts = PolygonTools.CreateCapsule(height, topRadius, topEdges, bottomRadius, bottomEdges);

            PhysicsBody body;

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count >= Settings.MaxPolygonVertices)
            {
                List<Vertices> vertList = EarclipDecomposer.ConvexPartition(verts);
                body = CreateCompoundPolygon(world, vertList, density, userData);
                body.Position = position;

                return body;
            }

            body = CreatePolygon(world, verts, density, userData);
            body.Position = position;

            return body;
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:36,代码来源:BodyFactory.cs


示例17: Cut

        /// <summary>
        /// This is a high-level function to cuts fixtures inside the given world, using the start and end points.
        /// Note: We don't support cutting when the start or end is inside a shape.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="start">The startpoint.</param>
        /// <param name="end">The endpoint.</param>
        /// <param name="thickness">The thickness of the cut</param>
        public static void Cut(PhysicsWorld world, Vector2 start, Vector2 end, float thickness)
        {
            List<Fixture> fixtures = new List<Fixture>();
            List<Vector2> entryPoints = new List<Vector2>();
            List<Vector2> exitPoints = new List<Vector2>();

            //We don't support cutting when the start or end is inside a shape.
            if (world.TestPoint(start) != null || world.TestPoint(end) != null)
                return;

            //Get the entry points
            world.RayCast((f, p, n, fr) =>
                              {
                                  fixtures.Add(f);
                                  entryPoints.Add(p);
                                  return 1;
                              }, start, end);

            //Reverse the ray to get the exitpoints
            world.RayCast((f, p, n, fr) =>
                              {
                                  exitPoints.Add(p);
                                  return 1;
                              }, end, start);

            //We only have a single point. We need at least 2
            if (entryPoints.Count + exitPoints.Count < 2)
                return;

            for (int i = 0; i < fixtures.Count; i++)
            {
                // can't cut circles yet !
                if (fixtures[i].Shape.ShapeType != ShapeType.Polygon)
                    continue;

                if (fixtures[i].Body.BodyType != BodyType.Static)
                {
                    //Split the shape up into two shapes
                    Vertices first;
                    Vertices second;
                    SplitShape(fixtures[i], entryPoints[i], exitPoints[i], thickness, out first, out second);

                    //Delete the original shape and create two new. Retain the properties of the body.
                    if (SanityCheck(first))
                    {
                        PhysicsBody firstFixture = BodyFactory.CreatePolygon(world, first, fixtures[i].Shape.Density,
                                                                            fixtures[i].Body.Position);
                        firstFixture.Rotation = fixtures[i].Body.Rotation;
                        firstFixture.LinearVelocity = fixtures[i].Body.LinearVelocity;
                        firstFixture.AngularVelocity = fixtures[i].Body.AngularVelocity;
                        firstFixture.BodyType = BodyType.Dynamic;
                    }

                    if (SanityCheck(second))
                    {
                        PhysicsBody secondFixture = BodyFactory.CreatePolygon(world, second, fixtures[i].Shape.Density,
                                                                             fixtures[i].Body.Position);
                        secondFixture.Rotation = fixtures[i].Body.Rotation;
                        secondFixture.LinearVelocity = fixtures[i].Body.LinearVelocity;
                        secondFixture.AngularVelocity = fixtures[i].Body.AngularVelocity;
                        secondFixture.BodyType = BodyType.Dynamic;
                    }
                    world.RemoveBody(fixtures[i].Body);
                }
            }
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:74,代码来源:CuttingTools.cs


示例18: CreatePrismaticJoint

 /// <summary>
 /// Creates a prismatic joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localanchorB"></param>
 /// <param name="axis"></param>
 /// <returns></returns>
 public static PrismaticJoint CreatePrismaticJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 localanchorB,
                                                   Vector2 axis)
 {
     PrismaticJoint joint = CreatePrismaticJoint(bodyA, bodyB, localanchorB, axis);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:16,代码来源:JointFactory.cs


示例19: CreatePulleyJoint

 public static PulleyJoint CreatePulleyJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 groundAnchorA,
                                             Vector2 groundAnchorB, Vector2 anchorA, Vector2 anchorB, float ratio)
 {
     PulleyJoint pulleyJoint = new PulleyJoint(bodyA, bodyB, groundAnchorA, groundAnchorB, anchorA, anchorB,
                                               ratio);
     world.AddJoint(pulleyJoint);
     return pulleyJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:8,代码来源:JointFactory.cs


示例20: CreateRevoluteJoint

 /// <summary>
 /// Creates a revolute joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="anchor"></param>
 /// <returns></returns>
 public static RevoluteJoint CreateRevoluteJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchor)
 {
     RevoluteJoint joint = CreateRevoluteJoint(bodyA, bodyB, anchor);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:14,代码来源:JointFactory.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# GameObjects.Architecture类代码示例发布时间:2022-05-26
下一篇:
C# GameFramework.EntityInfo类代码示例发布时间: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