Information about one element of a sampler / texture within a layer.
Example #1
0
		public static bool ReadLayerDeclaration( ref StreamSerializer stream, ref TerrainLayerDeclaration targetDecl )
		{
			if ( stream.ReadChunkBegin( TERRAINLAYERDECLARATION_CHUNK_ID, TERRAINLAYERDECLARATION_CHUNK_VERSION ) == null )
			{
				return false;
			}

			//  samplers
			byte numSamplers;
			stream.Read( out numSamplers );
			targetDecl.Samplers = new List<TerrainLayerSampler>( numSamplers );
			for ( var s = 0; s < numSamplers; ++s )
			{
				if ( stream.ReadChunkBegin( TERRAINLAYERSAMPLER_CHUNK_ID, TERRAINLAYERSAMPLER_CHUNK_VERSION ) == null )
				{
					return false;
				}

				var sampler = new TerrainLayerSampler();
				stream.Read( out sampler.Alias );
				byte pixFmt;
				stream.Read( out pixFmt );
				sampler.Format = (PixelFormat)pixFmt;
				stream.ReadChunkEnd( TERRAINLAYERSAMPLER_CHUNK_ID );
				targetDecl.Samplers.Add( sampler );
			}

			//  elements
			byte numElems;
			stream.Read( out numElems );
			targetDecl.Elements = new List<TerrainLayerSamplerElement>( numElems );
			for ( var e = 0; e < numElems; ++e )
			{
				if ( stream.ReadChunkBegin( TERRAINLAYERSAMPLERELEMENT_CHUNK_ID, TERRAINLAYERSAMPLERELEMENT_CHUNK_VERSION ) == null )
				{
					return false;
				}

				var samplerElem = new TerrainLayerSamplerElement();

				stream.Read( out samplerElem.Source );
				byte sem;
				stream.Read( out sem );
				samplerElem.Semantic = (TerrainLayerSamplerSemantic)sem;
				stream.Read( out samplerElem.ElementStart );
				stream.Read( out samplerElem.ElementCount );
				stream.ReadChunkEnd( TERRAINLAYERSAMPLERELEMENT_CHUNK_ID );
				targetDecl.Elements.Add( samplerElem );
			}
			stream.ReadChunkEnd( TERRAINLAYERDECLARATION_CHUNK_ID );

			return true;
		}