Пример #1
0
 public override void Initialise(GraphicsDevice device, ContentManager content)
 {
     level = new Q3BSPLevel(@"C:\GitHub\Monogame-tools\LibraryDemos\LibraryDemos\Data\Q3\", @"Q3\basicQ3Effect", ".jpg");
     level.LoadFromFile(@"maps\13tokay.bsp");
     level.InitializeLevel(Game1.Instance.GraphicsDevice, Game1.Instance.Content);
     camera = new QuatCamera(Game1.Instance.GraphicsDevice.Viewport);
 }
Пример #2
0
        public Level3D(SceneContainer scene, Vector3 pos, Matrix rotation, Vector3 scale, bool renderSkybox)
            : base(scene, pos, rotation, scale)
        {
            level          = new Q3BSPLevel(Q3BSPRenderType.BSPCulling); //Q3BSPRenderType.BSPCulling
            level.BasePath = "q3dm1";
            string t = scene.Game.Content.RootDirectory;

            if (level.LoadFromFile(level.BasePath + ".bsp"))
            {
                levelLoaded = level.InitializeLevel(GraphicsDevice, scene.Game.Content, @"q3\scripts\", @"q3\");
            }
            this.renderSkybox = renderSkybox;
            setObject(pos.X, pos.Y, pos.Z);
        }
Пример #3
0
        public bool loadLevel(string levelName)
        {
            if (levelName == null)
            {
                return(false);
            }

            levelName = levelName.Trim();

            // initialize a new level
            Q3BSPLevel newLevel = new Q3BSPLevel(Q3BSPRenderType.StaticBuffer);

            newLevel.BasePath = levelName;

            // check if the filename ends with .bsp
            bool addBsp = !levelName.ToLower().EndsWith(".bsp");

            // attempt to load and initialize the level
            try {
                if (newLevel.LoadFromFile(Content.RootDirectory + "/maps/" + newLevel.BasePath + (addBsp ? ".bsp" : "")))
                {
                    if (!newLevel.InitializeLevel(GraphicsDevice, Content, @"Shaders\"))
                    {
                        return(false);
                    }
                }
            }
            catch (Exception) {
                return(false);
            }

            // set the active level to the new level and reset all game systems, parse all entities from level
            level = newLevel;
            collisionSystem.level = level;
            entitySystem.reset();
            entitySystem.initialize(level);

            player.reset();

            // create entity objects from entity list
            List <Entity> entities = new List <Entity>();

            entities.Clear();
            entities.Add((Entity)player);
            entities.AddRange(entitySystem.entities);

            // initialize the collision system
            collisionSystem.initialize(this, settings, entities, level);

            // check for a spawn point
            Q3BSPEntity spawn = level.GetEntity("info_player_start");

            if (spawn != null)
            {
                // convert the spawn's BSP co-ordinates to XNA co-ordinates
                Vector3 position = Q3BSPLevel.GetXNAPosition(spawn);

                // offset spawn position to bottom-center of entity
                position.Y -= 6.0f;

                // assign the spawn position to the player's position
                player.position = position;
            }

            // add 0.001 to prevent falling through level
            player.position += new Vector3(0, 0.001f, 0);

            // set model lighting based on map lighting (temporarily hard-coded)
            Vector3 lighting = Vector3.One;

            if (levelName.Equals("core", StringComparison.OrdinalIgnoreCase) ||
                levelName.Equals("core.bsp", StringComparison.OrdinalIgnoreCase))
            {
                lighting = new Vector3(0.5f, 0.6f, 0.7f);
            }
            else if (levelName.Equals("foundry", StringComparison.OrdinalIgnoreCase) ||
                     levelName.Equals("foundry.bsp", StringComparison.OrdinalIgnoreCase))
            {
                lighting = new Vector3(0.9f, 0.8f, 0.3f);
            }
            player.setLighting(lighting);
            entitySystem.setLighting(lighting);

            return(true);
        }