Axiom.SceneManagers.Bsp.Quake3Level.ExtractLightmaps C# (CSharp) Method

ExtractLightmaps() public method

Extracts the embedded lightmap texture data and loads them as textures.
Calling this method makes the lightmap texture data embedded in the .bsp file available to the renderer. Lightmaps are extracted and loaded as Texture objects (subclass specific to RenderSystem subclass) and are named "@lightmap1", "@lightmap2" etc.
public ExtractLightmaps ( ) : void
return void
		public void ExtractLightmaps()
		{
			chunk.Seek( header.lumps[ (int)Quake3LumpType.Lightmaps ].offset, SeekOrigin.Begin );
			int numLightmaps = header.lumps[ (int)Quake3LumpType.Lightmaps ].size / BspLevel.LightmapSize;

			// Lightmaps are always 128x128x24 (RGB).
			for ( int i = 0; i < numLightmaps; i++ )
			{
				string name = String.Format( "@lightmap{0}", i );
				byte[] buffer = new byte[ BspLevel.LightmapSize ];
				chunk.Read( buffer, 0, BspLevel.LightmapSize );

				// Load, no mipmaps, brighten by factor 4
				// Set gamma explicitly, OpenGL doesn't apply it
				// CHECK: Make OpenGL apply gamma at LoadImage
				Image.ApplyGamma( buffer, 4, buffer.Length, 24 );
				MemoryStream stream = new MemoryStream( buffer );
				Image img = Image.FromRawStream( stream, 128, 128, PixelFormat.R8G8B8 );
				TextureManager.Instance.LoadImage( name, ResourceGroupManager.Instance.WorldResourceGroupName, img, TextureType.TwoD );
			}
		}

Usage Example

Beispiel #1
0
        /// <summary>
        ///		/** Internal utility function for loading data from Quake3.
        /// </summary>
        protected void LoadQuake3Level(Quake3Level q3lvl)
        {
            SceneManager sm = SceneManagerEnumerator.Instance.GetSceneManager(SceneType.Interior);

            LoadEntities(q3lvl);

            Quake3ShaderManager.Instance.ParseAllSources(".shader");
            q3lvl.ExtractLightmaps();

            LoadLevelVertices(q3lvl);

            LoadLevelFaces(q3lvl);

            // now build patch information
            BuildQuake3Patches(q3lvl.NumVertices, q3lvl.NumElements);

            //-----------------------------------------------------------------------
            // Create materials for shaders
            //-----------------------------------------------------------------------
            CreateShaderMaterials(q3lvl, sm);

            //-----------------------------------------------------------------------
            // Nodes
            //-----------------------------------------------------------------------
            CreateNodes(q3lvl);

            //-----------------------------------------------------------------------
            // Brushes
            //-----------------------------------------------------------------------
            CreateBrushes(q3lvl);

            //-----------------------------------------------------------------------
            // Leaves
            //-----------------------------------------------------------------------
            CreateLeaves(q3lvl);

            // Vis - just copy
            visData.numClusters = q3lvl.VisData.clusterCount;
            visData.rowLength   = q3lvl.VisData.rowSize;
            visData.tableData   = new byte[q3lvl.VisData.rowSize * q3lvl.VisData.clusterCount];

            Array.Copy(q3lvl.VisData.data, 0, visData.tableData, 0, visData.tableData.Length);
        }
All Usage Examples Of Axiom.SceneManagers.Bsp.Quake3Level::ExtractLightmaps