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


C# Dynamics.PhysicsWorld类代码示例

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


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


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