Represents the bsp geometry. This is added to the RenderQueue so that i can determine at RenderSingleObject when the geometry needs to be rendered and with what lights.
Inheritance: IRenderable
Beispiel #1
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;
		}
Beispiel #2
0
		/// <summary>
		///		Specialized from SceneManager to support Quake3 bsp files.
		/// </summary>
		public override void LoadWorldGeometry( string filename )
		{
			this.bspGeometry = new BspGeometry();

			if ( Path.GetExtension( filename ).ToLower() == ".xml" )
			{
#if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE)
				var optionData = new DataSet();
				optionData.ReadXml( filename );

				DataTable table = optionData.Tables[ 0 ];
				DataRow row = table.Rows[ 0 ];

				if ( table.Columns[ "Map" ] != null )
				{
					optionList[ "Map" ] = (string)row[ "Map" ];
				}

				if ( table.Columns[ "SetYAxisUp" ] != null )
				{
					optionList[ "SetYAxisUp" ] = ( string.Compare( (string)row[ "SetYAxisUp" ], "yes", true ) ) == 0 ? true : false;
				}

				if ( table.Columns[ "Scale" ] != null )
				{
					optionList[ "Scale" ] = StringConverter.ParseFloat( (string)row[ "Scale" ] );
				}

				Vector3 move = Vector3.Zero;

				if ( table.Columns[ "MoveX" ] != null )
				{
					move.x = StringConverter.ParseFloat( (string)row[ "MoveX" ] );
				}

				if ( table.Columns[ "MoveY" ] != null )
				{
					move.y = StringConverter.ParseFloat( (string)row[ "MoveY" ] );
				}

				if ( table.Columns[ "MoveZ" ] != null )
				{
					move.z = StringConverter.ParseFloat( (string)row[ "MoveZ" ] );
				}

				optionList[ "Move" ] = move;
				optionList[ "MoveX" ] = move.x;
				optionList[ "MoveY" ] = move.y;
				optionList[ "MoveZ" ] = move.z;

				if ( table.Columns[ "UseLightmaps" ] != null )
				{
					optionList[ "UseLightmaps" ] = ( string.Compare( (string)row[ "UseLightmaps" ], "yes", true ) ) == 0 ? true : false;
				}

				if ( table.Columns[ "AmbientEnabled" ] != null )
				{
					optionList[ "AmbientEnabled" ] = ( string.Compare( (string)row[ "AmbientEnabled" ], "yes", true ) ) == 0
					                                 	? true
					                                 	: false;
				}

				if ( table.Columns[ "AmbientRatio" ] != null )
				{
					optionList[ "AmbientRatio" ] = StringConverter.ParseFloat( (string)row[ "AmbientRatio" ] );
				}
#endif
			}
			else
			{
				optionList[ "Map" ] = filename;
			}

			LoadWorldGeometry();
		}