Holds all the data associated with a Binary Space Parition (BSP) based indoor level.
The data used here is populated by loading level files via the BspLevelManager.Load method, although application users are more likely to call SceneManager.SetWorldGeometry which will automatically arrange the loading of the level. Note that this assumes that you have asked for an indoor-specialized SceneManager (specify SceneType.Indoor when calling Engine.GetSceneManager).

We currently only support loading from Quake3 Arena level files, although any source that can be converted into this classes structure could also be used. The Quake3 level load process is in a different class called Quake3Level to keep the specifics separate.

Inheritance: Axiom.Core.Resource
Ejemplo n.º 1
0
        /// <summary>
        ///		Loads a BSP-based level from the named file.  Currently only supports loading of Quake3 .bsp files.
        /// </summary>
        public BspLevel Load(string fileName, int priority)
        {
            // TODO: Bleh?!
            // UnloadAndDestroyAll();

            BspLevel bsp = (BspLevel)Create(fileName);

            base.Load(bsp, priority);

            return(bsp);
        }
Ejemplo n.º 2
0
		public void LoadWorldGeometry()
		{
			this.bspGeometry = new BspGeometry();

			if ( !optionList.ContainsKey( "Map" ) )
			{
				throw new AxiomException( "Unable to load world geometry. \"Map\" filename option is not set." );
			}

			if ( Path.GetExtension( ( (string)optionList[ "Map" ] ).ToLower() ) != ".bsp" )
			{
				throw new AxiomException( "Unable to load world geometry. Invalid extension of map filename option (must be .bsp)." );
			}

			if ( !optionList.ContainsKey( "SetYAxisUp" ) )
			{
				optionList[ "SetYAxisUp" ] = false;
			}

			if ( !optionList.ContainsKey( "Scale" ) )
			{
				optionList[ "Scale" ] = 1f;
			}

			if ( !optionList.ContainsKey( "Move" ) )
			{
				optionList[ "Move" ] = Vector3.Zero;
				optionList[ "MoveX" ] = 0;
				optionList[ "MoveY" ] = 0;
				optionList[ "MoveZ" ] = 0;
			}

			if ( !optionList.ContainsKey( "UseLightmaps" ) )
			{
				optionList[ "UseLightmaps" ] = true;
			}

			if ( !optionList.ContainsKey( "AmbientEnabled" ) )
			{
				optionList[ "AmbientEnabled" ] = false;
			}

			if ( !optionList.ContainsKey( "AmbientRatio" ) )
			{
				optionList[ "AmbientRatio" ] = 1f;
			}

			InitTextureLighting();

			if ( this.spotlightFrustum == null )
			{
				this.spotlightFrustum = new SpotlightFrustum();
			}

			var paramList = new NameValuePairList();

			foreach ( DictionaryEntry option in optionList )
			{
				paramList.Add( option.Key.ToString(), option.Value.ToString() );
			}

			// Load using resource manager
			this.level =
				(BspLevel)
				BspResourceManager.Instance.Load( (string)optionList[ "Map" ], ResourceGroupManager.Instance.WorldResourceGroupName,
				                                  false, null, paramList );

			// Init static render operation
			this.renderOp.vertexData = this.level.VertexData;

			// index data is per-frame
			this.renderOp.indexData = new IndexData();
			this.renderOp.indexData.indexStart = 0;
			this.renderOp.indexData.indexCount = 0;

			// Create enough index space to render whole level
			this.renderOp.indexData.indexBuffer = HardwareBufferManager.Instance.CreateIndexBuffer( IndexType.Size32,
			                                                                                        this.level.NumIndexes,
			                                                                                        BufferUsage.Dynamic, false );
			this.renderOp.operationType = OperationType.TriangleList;
			this.renderOp.useIndices = true;
		}
Ejemplo n.º 3
0
		public override void SetWorldGeometry( Stream stream, string typeName )
		{
			// Load using resource manager
			this.level =
				(BspLevel)BspResourceManager.Instance.Load( stream, ResourceGroupManager.Instance.WorldResourceGroupName );

			//if (this.level.IsSkyEnabled)
			//{
			//    // Quake3 is always aligned with Z upwards
			//    Quaternion q = Quaternion.FromAngleAxis(Utility.HALF_PI, Vector3.UnitX);
			//    // Also draw last, and make close to camera (far clip plane is shorter)
			//    SetSkyDome(true, this.level.SkyMaterialName, this.level.SkyCurvature, 12, 2000, false, q);
			//}
			//else
			//{
			//    SetSkyDome(false, String.Empty);
			//}

			// Init static render operation
			this.renderOp.vertexData = this.level.VertexData;
			// index data is per-frame
			this.renderOp.indexData = new IndexData();
			this.renderOp.indexData.indexStart = 0;
			this.renderOp.indexData.indexCount = 0;
			// Create enough index space to render whole level
			this.renderOp.indexData.indexBuffer = HardwareBufferManager.Instance.CreateIndexBuffer( IndexType.Size32,
			                                                                                        // always 32-bit
			                                                                                        this.level.NumIndexes,
			                                                                                        BufferUsage.
			                                                                                        	DynamicWriteOnlyDiscardable,
			                                                                                        false );

			this.renderOp.operationType = OperationType.TriangleList;
			this.renderOp.useIndices = true;
		}
Ejemplo n.º 4
0
		public BspSceneManager( string name )
			: base( name )
		{
			// Set features for debugging render
			this.showNodeAABs = false;

			// No sky by default
			isSkyPlaneEnabled = false;
			isSkyBoxEnabled = false;
			isSkyDomeEnabled = false;

			this.level = null;

			new BspResourceManager();
		}
Ejemplo n.º 5
0
 /// <summary>
 ///		Constructor, only to be used by BspLevel.
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="isLeaf"></param>
 public BspNode(BspLevel owner, bool isLeaf)
 {
     this.owner = owner;
     this.isLeaf = isLeaf;
 }
 /// <summary>
 ///		Constructor, only to be used by BspLevel.
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="isLeaf"></param>
 public BspNode(BspLevel owner, bool isLeaf)
 {
     this.owner  = owner;
     this.isLeaf = isLeaf;
 }
        public void LoadWorldGeometry()
        {
            if (!optionList.ContainsKey("Map"))
                throw new AxiomException("Unable to load world geometry. \"Map\" filename option is not set.");

            if(Path.GetExtension(((string)optionList["Map"]).ToLower()) != ".bsp")
                throw new AxiomException("Unable to load world geometry. Invalid extension of map filename option (must be .bsp).");

            if (!optionList.ContainsKey("SetYAxisUp"))
                optionList["SetYAxisUp"] = false;

            if (!optionList.ContainsKey("Scale"))
                optionList["Scale"] = 1f;

            if (!optionList.ContainsKey("Move"))
                optionList["Move"] = Vector3.Zero;

            if (!optionList.ContainsKey("UseLightmaps"))
                optionList["UseLightmaps"] = true;

            if (!optionList.ContainsKey("AmbientEnabled"))
                optionList["AmbientEnabled"] = false;

            if (!optionList.ContainsKey("AmbientRatio"))
                optionList["AmbientRatio"] = 1f;

            InitTextureLighting();

            if (spotlightFrustum == null)
                spotlightFrustum = new SpotlightFrustum();

            // Load using resource manager
            level = BspResourceManager.Instance.Load((string)optionList["Map"]);

            // Init static render operation
            renderOp.vertexData = level.VertexData;

            // index data is per-frame
            renderOp.indexData = new IndexData();
            renderOp.indexData.indexStart = 0;
            renderOp.indexData.indexCount = 0;

            // Create enough index space to render whole level
            renderOp.indexData.indexBuffer = HardwareBufferManager.Instance.CreateIndexBuffer(
                IndexType.Size32,
                level.NumIndexes,
                BufferUsage.Dynamic, false
                );
            renderOp.operationType = OperationType.TriangleList;
            renderOp.useIndices = true;
        }
        public BspSceneManager()
        {
            // Set features for debugging render
            showNodeAABs = false;

            // No sky by default
            isSkyPlaneEnabled = false;
            isSkyBoxEnabled = false;
            isSkyDomeEnabled = false;

            level = null;
        }