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


C# BEPUphysics.Space类代码示例

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


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

示例1: Explosion

 /// <summary>
 /// Constructs an explosion.
 /// </summary>
 /// <param name="pos">Initial position of the explosion.</param>
 /// <param name="explosionMagnitude">Base strength of the blast as applied in units of impulse.</param>
 /// <param name="maxDist">Maximum radius of effect.</param>
 /// <param name="containingSpace">Space in which the explosion resides.</param>
 public Explosion(Vector3 pos, float explosionMagnitude, float maxDist, Space containingSpace)
 {
     Position = pos;
     Magnitude = explosionMagnitude;
     MaxDistance = maxDist;
     Space = containingSpace;
 }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:14,代码来源:Explosion.cs

示例2: CollisionManager

        // _divisions is the divisions in one direction / 2
        public CollisionManager(int _width, int _height, int _depth, int _divisions)
        {
            width = _width;
            height = _height;
            depth = _depth;
            divisions = _divisions * _divisions * _divisions;

            toAdd = new LinkedList<CollisionBase>();
            toRemove = new LinkedList<CollisionBase>();

            /*#if DEBUG
            drawList = new List<SceneObject>();
            #endif*/

            space = new Space();
            space.Solver.AllowMultithreading = true;
            space.Solver.IterationLimit = 1;

            Vector3 offset = new Vector3(-_width / 2, -_height / 2, -_depth / 2);

            sectors = new CollisionSector[divisions]; // Though we use _divisions for calculating
            for (int i = 0; i < _divisions; i++)
            {
                for (int j = 0; j < _divisions; j++)
                {
                    for (int l = 0; l < _divisions; l++)
                    {
                        int x = ((i * width) / (2 * _divisions)) + (width / _divisions);
                        int y = ((j * height) / (2 * _divisions)) + (height / _divisions);
                        int z = ((l * depth) / (2 * _divisions)) + (depth / _divisions);
                        sectors[i*_divisions*_divisions + j*_divisions + l] = new CollisionSector(offset + new Vector3(x, y, z), width / _divisions, height / _divisions, depth / _divisions);
                    }
                }
            }
        }
开发者ID:NatalieWojciechowski,项目名称:Space394,代码行数:36,代码来源:CollisionManager.cs

示例3: Demo

        protected Demo(DemosGame game)
        {
            Game = game;
            parallelLooper = new ParallelLooper();
            //This section lets the engine know that it can make use of multithreaded systems
            //by adding threads to its thread pool.
            #if XBOX360
            parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 1 }); });
            parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 3 }); });
            parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 4 }); });
            parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 5 }); });

            #else
            if (Environment.ProcessorCount > 1)
            {
                for (int i = 0; i < Environment.ProcessorCount; i++)
                {
                    parallelLooper.AddThread();
                }
            }
            #endif

            Space = new Space(parallelLooper);

            game.Camera.LockedUp = Vector3.Up;
            game.Camera.ViewDirection = new Vector3(0, 0, -1);
        }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:27,代码来源:Demo.cs

示例4: RemoveFromSpace

 public void RemoveFromSpace(Space space)
 {
     LeftTread.RemoveFromSpace(space);
     RightTread.RemoveFromSpace(space);
     Turret.RemoveFromSpace(space);
     space.Remove(Body);
 }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:7,代码来源:TankDemo.cs

示例5: ApplyHighStabilitySettings

 /// <summary>
 /// Applies some high quality, low performance settings.
 /// By using universal continuous collision detection, missed collisions
 /// will be much, much rarer.  This actually doesn't have a huge performance cost.
 /// However, increasing the iteration limit and the minimum iterations to 5x the default
 /// will incur a pretty hefty overhead.
 /// On the upside, pretty much every simulation will be rock-solid.
 /// </summary>
 /// <param name="space">Space to configure.</param>
 public static void ApplyHighStabilitySettings(Space space)
 {
     MotionSettings.DefaultPositionUpdateMode = PositionUpdateMode.Continuous;
     MotionSettings.UseExtraExpansionForContinuousBoundingBoxes = true;
     SolverSettings.DefaultMinimumIterations = 5;
     space.Solver.IterationLimit = 50;
 }
开发者ID:gpforde,项目名称:GPBrakes,代码行数:16,代码来源:ConfigurationHelper.cs

示例6: AddToSpace

 public void AddToSpace(Space space)
 {
     LeftTread.AddToSpace(space);
     RightTread.AddToSpace(space);
     Turret.AddToSpace(space);
     space.Add(Body);
 }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:7,代码来源:TankDemo.cs

示例7: PhysicsSimulationComponent

 public PhysicsSimulationComponent(Entity parent)
     : base(parent, "PhysicsSimulationComponent")
 {
     space = new Space();
     space.ForceUpdater.Gravity = GRAVITY;
     space.TimeStepSettings.TimeStepDuration = TIME_STEP_DURATION;
 }
开发者ID:regenvanwalbeek,项目名称:BattleFury,代码行数:7,代码来源:PhysicsSimulationComponent.cs

示例8: Initialize

        public override void Initialize()
        {
            Children = new System.Collections.Generic.List<Aperture3D.Base.INode>();
            physicsSpace = new Space();

            Initialized = true;
        }
开发者ID:himanshugoel2797,项目名称:Aperture3D-PSM,代码行数:7,代码来源:SceneNode.cs

示例9: ParallelSpaceTestDemo

        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public ParallelSpaceTestDemo(DemosGame game)
            : base(game)
        {
            for (int i = 0; i < 32; i++)
            {
                var space = new Space(null);
                space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
                var box = new Box(new Vector3(20 * i, 0, 0), 100, 1, 100);
                space.Add(box);
                //game.ModelDrawer.Add(box);
                for (int j = 0; j < 30; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        box = new Box(new Vector3(20 * i, 2 + j * 1.1f, 0), 1, 1, 1, 1);
                        entities.Add(box);
                        space.Add(box);
                        //game.ModelDrawer.Add(box);
                    }
                }
                spaces.Add(space);
            }
            game.Camera.Position = new Vector3(20, 10, 70);

        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:29,代码来源:ParallelSpaceTestDemo.cs

示例10: CollisionUtil

 public CollisionUtil(Space world)
 {
     World = world;
     // NonSolid Vs. Solid,NonSolid,WorldSolid (All)
     CollisionGroup.DefineCollisionRule(NonSolid, WorldSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(WorldSolid, NonSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(NonSolid, NonSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(NonSolid, Solid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Solid, NonSolid, CollisionRule.NoBroadPhase);
     // Player Vs. NonSolid,Player
     CollisionGroup.DefineCollisionRule(Player, NonSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(NonSolid, Player, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Player, Player, CollisionRule.NoBroadPhase);
     // Item Vs. NonSolid (All)
     CollisionGroup.DefineCollisionRule(Item, NonSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(NonSolid, Item, CollisionRule.NoBroadPhase);
     // Water Vs. NonSolid,Solid,Player,Item (All)
     CollisionGroup.DefineCollisionRule(Water, NonSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(NonSolid, Water, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Water, Solid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Solid, Water, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Water, Player, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Player, Water, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Water, Item, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Item, Water, CollisionRule.NoBroadPhase);
     // Non-player Character Vs. NonSolid,Item,Water
     CollisionGroup.DefineCollisionRule(Character, NonSolid, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(NonSolid, Character, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Character, Water, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Water, Character, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Character, Item, CollisionRule.NoBroadPhase);
     CollisionGroup.DefineCollisionRule(Item, Character, CollisionRule.NoBroadPhase);
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:33,代码来源:CollisionUtil.cs

示例11: Draw

        public void Draw(Effect effect, Space space)
        {
            contactLines.Clear();
            int contactCount = 0;
            foreach (var pair in space.NarrowPhase.Pairs)
            {
                var pairHandler = pair as CollidablePairHandler;
                if (pairHandler != null)
                {
                    foreach (ContactInformation information in pairHandler.Contacts)
                    {
                        contactCount++;
                        contactLines.Add(new VertexPositionColor(information.Contact.Position, Color.White));
                        contactLines.Add(new VertexPositionColor(information.Contact.Position + information.Contact.Normal * information.Contact.PenetrationDepth, Color.Red));
                        contactLines.Add(new VertexPositionColor(information.Contact.Position + information.Contact.Normal * information.Contact.PenetrationDepth, Color.White));
                        contactLines.Add(new VertexPositionColor(information.Contact.Position + information.Contact.Normal * (information.Contact.PenetrationDepth + .3f), Color.White));
                    }
                }
            }

            if (contactCount > 0)
            {
                foreach (var pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();

                    game.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, contactLines.Elements, 0, contactLines.Count / 2);
                }
            }

        }
开发者ID:VICOGameStudio-Ujen,项目名称:igf,代码行数:31,代码来源:ContactDrawer.cs

示例12: FindCliff

        /// <summary>
        /// Determines whether there is a cliff nearby.
        /// </summary>
        /// <param name="position">Position to look from.</param>
        /// <param name="facingDirection">Direction to check in.</param>
        /// <param name="filter">Anonymous function to filter out unwanted objects.</param>
        /// <param name="space">The space to check for a cliff in.</param>
        /// <param name="distance">The distance to check at.</param>
        /// <returns>True if a cliff was detected, false otherwise.</returns>
        public static bool FindCliff(Vector3 position, Vector3 facingDirection, Func<BroadPhaseEntry, bool> filter, Space space, float distance)
        {
            // If there is a wall before the requested distance assume there is no cliff.
            Ray forwardRay = new Ray(position, new Vector3(facingDirection.X, 0, facingDirection.Z));
            RayCastResult forwardResult = new RayCastResult();
            space.RayCast(forwardRay, filter, out forwardResult);
            if ((forwardResult.HitData.Location - position).Length() < distance)
            {
                return false;
            }

            facingDirection.Normalize();
            Ray futureDownRay = new Ray(position + new Vector3(facingDirection.X * distance, 0, facingDirection.Z * distance), Vector3.Down);
            RayCastResult result = new RayCastResult();
            space.RayCast(futureDownRay, filter, out result);

            Vector3 drop = result.HitData.Location - futureDownRay.Position;
            if (drop.Y < -6.0f)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:thormme,项目名称:Chimera,代码行数:35,代码来源:ObstacleDetector.cs

示例13: ApplyDefaultSettings

        /// <summary>
        /// Applies the default settings to the space.
        /// These values are what the engine starts with; they don't have to be applied unless you just want to get back to the defaults.
        /// This doesn't cover every single tunable field in the entire engine, just the main ones that this helper class is messing with.
        /// </summary>
        /// <param name="space">Space to configure.</param>
        public static void ApplyDefaultSettings(Space space)
        {
            MotionSettings.DefaultPositionUpdateMode = PositionUpdateMode.Discrete;
            SolverSettings.DefaultMinimumIterationCount = 1;
            space.Solver.IterationLimit = 10;
            GeneralConvexPairTester.UseSimplexCaching = false;
            MotionSettings.UseExtraExpansionForContinuousBoundingBoxes = false;

            //Set all the scaling settings back to their defaults.
            space.DeactivationManager.VelocityLowerLimit = 0.26f;
            CollisionResponseSettings.MaximumPenetrationRecoverySpeed = 2;
            CollisionResponseSettings.BouncinessVelocityThreshold = 1;
            CollisionResponseSettings.StaticFrictionVelocityThreshold = .2f;
            CollisionDetectionSettings.ContactInvalidationLength = .1f;
            CollisionDetectionSettings.ContactMinimumSeparationDistance = .03f;
            CollisionDetectionSettings.MaximumContactDistance = .1f;
            CollisionDetectionSettings.DefaultMargin = .04f;
            CollisionDetectionSettings.AllowedPenetration = .01f;
            SolverSettings.DefaultMinimumImpulse = 0.001f;

            //Adjust epsilons back to defaults.
            Toolbox.Epsilon = 1e-7f;
            Toolbox.BigEpsilon = 1e-5f;
            MPRToolbox.DepthRefinementEpsilon = 1e-4f;
            MPRToolbox.RayCastSurfaceEpsilon = 1e-9f;
            MPRToolbox.SurfaceEpsilon = 1e-7f;
            PairSimplex.DistanceConvergenceEpsilon = 1e-7f;
            PairSimplex.ProgressionEpsilon = 1e-8f;

        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:36,代码来源:ConfigurationHelper.cs

示例14: PhysicsQB

        public PhysicsQB()
        {
            if (threadManager == null)
            {
                threadManager = new BEPUphysics.Threading.SpecializedThreadManager();
                //This section lets the engine know that it can make use of multithreaded systems
                //by adding threads to its thread pool.
            #if XBOX360
            threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 1 }); }, null);
            threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 3 }); }, null);
            threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 4 }); }, null);
            //threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 5 }); }, null);

            #else
                if (Environment.ProcessorCount > 1)
                {
                    for (int i = 0; i < Environment.ProcessorCount; i++)
                    {
                        threadManager.AddThread();
                    }
                }
            #endif
            }

            space = new Space(threadManager);
        }
开发者ID:scotttorgeson,项目名称:HeroesOfRock,代码行数:26,代码来源:PhysicsQB.cs

示例15: SphereCharacterControllerInput

        /// <summary>
        /// Constructs the character and internal physics character controller.
        /// </summary>
        /// <param name="owningSpace">Space to add the character to.</param>
        /// <param name="camera">Camera to attach to the character.</param>
        /// <param name="game">The running game.</param>
        public SphereCharacterControllerInput(Space owningSpace, Camera camera, DemosGame game)
        {
            CharacterController = new SphereCharacterController();
            Camera = camera;
            CameraControlScheme = new FixedOffsetCameraControlScheme(CharacterController.Body, camera, game);

            Space = owningSpace;
        }
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:14,代码来源:SphereCharacterControllerInput.cs


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