示例#1
0
        public BulletXScene()
        {
            cDispatcher = new CollisionDispatcherLocal(this);
            Vector3 worldMinDim = new Vector3((float) minXY, (float) minXY, (float) minZ);
            Vector3 worldMaxDim = new Vector3((float) maxXY, (float) maxXY, (float) maxZ);
            opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles);
            sicSolver = new SequentialImpulseConstraintSolver();

            lock (BulletXLock)
            {
                ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver);
                ddWorld.Gravity = new Vector3(0, 0, -gravity);
            }
            //this._heightmap = new float[65536];
        }
示例#2
0
        /// <summary>
        /// Reinitializes physics.
        /// </summary>
        public void ResetPhysics()
        {
            _collisionDispatcher = new CollisionDispatcher();

            if (_useSweepAndPrune)
            {
                Vector3 worldAabbMin = new Vector3(-10000, -10000, -10000);
                Vector3 worldAabbMax = new Vector3(10000, 10000, 10000);
                const int maxProxies = 32766;
                _broadphase = new AxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
            }
            else
                _broadphase = new SimpleBroadphase();

            _solver = new SequentialImpulseConstraintSolver();
            _world = new DiscreteDynamicsWorld(_collisionDispatcher, _broadphase, _solver);

            //world.setConstraintSolver(solver);
            _world.Gravity = new Vector3(0, -10, 0);

            _shapePtr = new CollisionShape[4];
            _shapePtr[0] = new BoxShape(new Vector3(50, 10, 50));
            _shapePtr[1] = new CylinderShape(new Vector3(_cubeHalfExtent - _collisionMargin, _cubeHalfExtent - _collisionMargin, _cubeHalfExtent - _collisionMargin));
            _shapePtr[2] = new SphereShape(_cubeHalfExtent);
            _shapePtr[3] = new BoxShape(new Vector3(_cubeHalfExtent, _cubeHalfExtent, _cubeHalfExtent));

            _shapeIndex = new int[_maxNumObjects];
            Matrix tr = Matrix.Identity;

            for (int i = 0; i < _numObjects; i++)
            {
                if (i > 0)
                    // set shape
                    _shapeIndex[i] = 1;
                else
                    _shapeIndex[i] = 0;
            }

            GC.Collect();
        }