Esempio n. 1
0
        /// <summary>
        /// Renderer list generation by current world and camera
        /// </summary>
        public void GenWorldList()
        {
            if(World == null)
            {
                return;
            }

            CleanList(); // clear old render list
            DebugDrawer = new RenderDebugDrawer();

            // find room that contains camera
            var currRoom = Room.FindPosCogerrence(Camera.Position, Camera.CurrentRoom);

            Camera.CurrentRoom = currRoom; // set camera's cuttent room pointer
            if(currRoom != null) // camera located in some room
            {
                currRoom.Frustum.Clear(); // room with camera inside has no frustums!
                currRoom.MaxPath = 0;
                AddRoom(currRoom); // room with camera inside adds to the render list immediately
                foreach (var p in currRoom.Portals) // go through all start room portals
                {
                    var lastFrus = Frustum.PortalFrustumIntersect(p, Camera.Frustum, this);
                    if(lastFrus != null)
                    {
                        AddRoom(p.DestRoom); // portal destination room
                        lastFrus.ParentsCount = 1; // created by camera
                        ProcessRoom(p, lastFrus);// next start reccursion algorithm
                    }
                }
            }
            else if(ControlStates.NoClip) // camera is out of all rooms AND noclip is on
            {
                foreach (var r in World.Rooms)
                {
                    if(Camera.Frustum.IsAABBVisible(r.BBMin, r.BBMax, Camera))
                    {
                        AddRoom(r);
                    }
                }
            }
        }
Esempio n. 2
0
        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);
        }