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


C# DiscreteDynamicsWorld.SetInternalTickCallback方法代码示例

本文整理汇总了C#中BulletSharp.DiscreteDynamicsWorld.SetInternalTickCallback方法的典型用法代码示例。如果您正苦于以下问题:C# DiscreteDynamicsWorld.SetInternalTickCallback方法的具体用法?C# DiscreteDynamicsWorld.SetInternalTickCallback怎么用?C# DiscreteDynamicsWorld.SetInternalTickCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BulletSharp.DiscreteDynamicsWorld的用法示例。


在下文中一共展示了DiscreteDynamicsWorld.SetInternalTickCallback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnInitializePhysics

        protected override void OnInitializePhysics()
        {
            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new DefaultCollisionConfiguration();
            Dispatcher = new CollisionDispatcher(CollisionConf);

            Vector3 worldAabbMin = new Vector3(-10000, -10000, -10000);
            Vector3 worldAabbMax = new Vector3(10000, 10000, 10000);
            Broadphase = new AxisSweep3(worldAabbMin, worldAabbMax);

            Solver = new SequentialImpulseConstraintSolver();

            World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.Gravity = new Vector3(0, -10, 0);
            World.SetInternalTickCallback(MotorPreTickCallback, this, true);

            // create the ground
            CollisionShape groundShape = new BoxShape(200, 10, 200);
            CollisionShapes.Add(groundShape);
            CollisionObject ground = LocalCreateRigidBody(0, Matrix.Translation(0, -10, 0), groundShape);
            ground.UserObject = "Ground";

            fCyclePeriod = 2000.0f;
            fMuscleStrength = 0.5f;
            m_Time = 0;

            SpawnTestRig(new Vector3(1, 0.5f, 0), false);
            SpawnTestRig(new Vector3(-2, 0.5f, 0), true);
        }
开发者ID:raiker,项目名称:BulletSharp,代码行数:29,代码来源:MotorDemo.cs

示例2: TestGCCollection

        public static void TestGCCollection()
        {
            var conf = new DefaultCollisionConfiguration();
            var dispatcher = new CollisionDispatcher(conf);
            var broadphase = new DbvtBroadphase();
            var world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf);
            world.Gravity = new Vector3(0, -10, 0);

            var conf_wr = new WeakReference(conf);
            var dispatcher_wr = new WeakReference(dispatcher);
            var broadphase_wr = new WeakReference(broadphase);
            var world_wr = new WeakReference(broadphase);

            //conf.Dispose();
            conf = null;
            dispatcher.OnDisposing += onDisposing;
            dispatcher.OnDisposed += onDisposed;
            //dispatcher.Dispose();
            dispatcher = null;
            broadphase.OnDisposing += onDisposing;
            broadphase.OnDisposed += onDisposed;
            //broadphase.Dispose();
            broadphase = null;
            world.OnDisposing += onDisposing;
            world.OnDisposed += onDisposed;
            world.SetInternalTickCallback(WorldPreTickCallback);
            world.StepSimulation(1.0f/60.0f);
            //world.SetInternalTickCallback(null);
            //world.Dispose();
            world = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
            TestWeakRef("CollisionConfiguration", conf_wr);
            TestWeakRef("CollisionDispatcher", dispatcher_wr);
            TestWeakRef("DbvtBroadphase", broadphase_wr);
            TestWeakRef("DiscreteDynamicsWorld", world_wr);
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:38,代码来源:Program.cs

示例3: TestGCCollection

        static void TestGCCollection()
        {
            var conf = new DefaultCollisionConfiguration();
            var dispatcher = new CollisionDispatcher(conf);
            var broadphase = new DbvtBroadphase();
            //var broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
            world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf);
            world.Gravity = new Vector3(0, -10, 0);
            dispatcher.NearCallback = DispatcherNearCallback;

            CreateBody(0.0f, new BoxShape(50, 1, 50), Vector3.Zero);
            var dynamicObject = CreateBody(10.0f, new SphereShape(1.0f), new Vector3(2, 2, 0));
            var dynamicObject2 = CreateBody(1.0f, new SphereShape(1.0f), new Vector3(0, 2, 0));

            var ghostPairCallback = new GhostPairCallback();
            broadphase.OverlappingPairCache.SetInternalGhostPairCallback(ghostPairCallback);
            AddToDisposeQueue(ghostPairCallback);
            ghostPairCallback = null;
            var ghostObject = new PairCachingGhostObject();
            ghostObject.CollisionShape = new BoxShape(2);
            ghostObject.WorldTransform = Matrix.Translation(2,2,0);
            world.AddCollisionObject(ghostObject);

            var trimesh = new TriangleMesh();
            Vector3 v0 = new Vector3(0, 0, 0);
            Vector3 v1 = new Vector3(1, 0, 0);
            Vector3 v2 = new Vector3(0, 1, 0);
            Vector3 v3 = new Vector3(1, 1, 0);
            trimesh.AddTriangle(v0, v1, v2);
            trimesh.AddTriangle(v1, v3, v2);
            var triangleMeshShape = new BvhTriangleMeshShape(trimesh, false);
            var triMeshObject = CreateBody(0, triangleMeshShape, new Vector3(20,0,20));
            AddToDisposeQueue(triangleMeshShape);
            AddToDisposeQueue(trimesh);
            AddToDisposeQueue(triMeshObject);
            triangleMeshShape = null;
            trimesh = null;

            AddToDisposeQueue(conf);
            AddToDisposeQueue(dispatcher);
            AddToDisposeQueue(broadphase);
            AddToDisposeQueue(world);

            //conf.Dispose();
            conf = null;
            //dispatcher.Dispose();
            dispatcher = null;
            //broadphase.Dispose();
            broadphase = null;
            world.DebugDrawer = new DebugDrawTest();
            AddToDisposeQueue(world.DebugDrawer);
            world.SetInternalTickCallback(WorldPreTickCallback);
            for (int i = 0; i < 600; i++)
            {
                world.StepSimulation(1.0f / 60.0f);
            }

            world.DispatchInfo.DebugDraw = new DebugDrawTest2();
            AddToDisposeQueue(world.DispatchInfo.DebugDraw);
            world.DispatchInfo.DebugDraw = world.DispatchInfo.DebugDraw;
            AddToDisposeQueue(world.DispatchInfo.DebugDraw);
            world.DispatchInfo.DebugDraw = null;
            world.DebugDrawer = null;
            world.DebugDrawer = new DebugDrawTest2();
            world.StepSimulation(1.0f / 60.0f);
            world.DebugDrawWorld();
            AddToDisposeQueue(world.DispatchInfo.DebugDraw);

            world.DebugDrawer = new DebugDrawTest();
            world.DebugDrawWorld();
            AddToDisposeQueue(world.DebugDrawer);
            world.DebugDrawer = null;

            TestContactTest(dynamicObject, dynamicObject2);
            TestGhostObjectPairs(ghostObject);
            TestRayCast(dynamicObject);
            TestTriangleMeshRayCast(triMeshObject);
            dynamicObject = null;
            dynamicObject2 = null;
            triMeshObject = null;

            //world.SetInternalTickCallback(null);
            world.Dispose();
            world = null;

            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();

            TestWeakRefs();
            disposeQueue.Clear();
        }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:91,代码来源:Program.cs

示例4: InitBullet

        public static void InitBullet()
        {
            // collision configuration contains default setup for memory, collision setup. Advanced users can create their own configuration.
            BtEngineCollisionConfiguration = new DefaultCollisionConfiguration();

            // use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
            BtEngineDispatcher = new CollisionDispatcher(BtEngineCollisionConfiguration);
            BtEngineDispatcher.NearCallback = RoomNearCallback;

            // btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
            BtEngineOverlappingPairCache = new DbvtBroadphase();
            BtEngineGhostPairCallback = new GhostPairCallback();
            BtEngineOverlappingPairCache.OverlappingPairCache.SetInternalGhostPairCallback(BtEngineGhostPairCallback);

            // the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
            BtEngineSolver = new SequentialImpulseConstraintSolver();

            BtEngineDynamicsWorld = new DiscreteDynamicsWorld(BtEngineDispatcher,
                BtEngineOverlappingPairCache, BtEngineSolver, BtEngineCollisionConfiguration);
            BtEngineDynamicsWorld.SetInternalTickCallback(InternalTickCallback);
            BtEngineDynamicsWorld.Gravity = new BulletSharp.Math.Vector3(0, 0, -4500.0f);

            DebugDrawer = new RenderDebugDrawer();
            DebugDrawer.DebugMode = DebugDrawModes.DrawWireframe | DebugDrawModes.DrawConstraints;
            BtEngineDynamicsWorld.DebugDrawer = DebugDrawer;
            //Global.BtEngineDynamicsWorld.PairCache.SetInternalGhostPairCallback(Global.BtEngineFilterCallback);
        }
开发者ID:zdimension,项目名称:FreeRaider,代码行数:27,代码来源:Engine.cs


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