Reprsents material. MaterialInstance???
Inheritance: System.DisposableBase
Exemplo n.º 1
0
		/// <summary>
		/// Intializes graphics engine.
		/// </summary>
		public override void Initialize ()
		{
			whiteTexture	=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			whiteTexture.SetData( Enumerable.Range(0,16).Select( i => Color.White ).ToArray() );
			
			grayTexture		=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			grayTexture.SetData( Enumerable.Range(0,16).Select( i => Color.Gray ).ToArray() );

			blackTexture	=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			blackTexture.SetData( Enumerable.Range(0,16).Select( i => Color.Black ).ToArray() );

			flatNormalMap	=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			flatNormalMap.SetData( Enumerable.Range(0,16).Select( i => new Color(127,127,255,127) ).ToArray() );

			var baseIllum = new BaseIllum();
			defaultMaterial	=	baseIllum.CreateMaterialInstance(this, Game.Content);

			//	add default render world
			renderWorld	=	new RenderWorld(Game, Width, Height);
			AddLayer( renderWorld );
		}
Exemplo n.º 2
0
		/// <summary>
		/// Creates gpu material
		/// </summary>
		/// <param name="rs"></param>
		/// <returns></returns>
		internal MaterialInstance CreateMaterialInstance ( RenderSystem rs, ContentManager content )
		{
			var data = new MaterialData();
			
			GetMaterialData( ref data );

			var mtrl = new MaterialInstance( rs, content, data, GetTextureBindings(), GetSurfaceFlags() );

			return mtrl;
		}
Exemplo n.º 3
0
			public ShadingGroup( MeshSubset subset, MaterialInstance material )
			{
				StartIndex	=	subset.StartPrimitive * 3;
				IndicesCount=	subset.PrimitiveCount * 3;
				Material	=	material;
			}
Exemplo n.º 4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="material"></param>
		/// <param name="flags"></param>
		/// <returns></returns>
		SurfaceFlags ApplyFlags ( MaterialInstance material, MeshInstance instance, SurfaceFlags flags )
		{
			//if (material!=null) {
			//	switch ( material.Options ) {
			//		case MaterialOptions.SingleLayer : flags |= SurfaceFlags.LAYER0; break;	
			//		case MaterialOptions.DoubleLayer : flags |= SurfaceFlags.LAYER0|SurfaceFlags.LAYER1; break;
			//		case MaterialOptions.TripleLayer : flags |= SurfaceFlags.LAYER0|SurfaceFlags.LAYER1|SurfaceFlags.LAYER2; break;
			//		case MaterialOptions.QuadLayer	 : flags |= SurfaceFlags.LAYER0|SurfaceFlags.LAYER1|SurfaceFlags.LAYER2|SurfaceFlags.LAYER3; break;

			//		case MaterialOptions.Terrain : flags |= SurfaceFlags.TERRAIN; break;

			//		case MaterialOptions.TriplanarWorldSingle : flags |= SurfaceFlags.TRIPLANAR_SINGLE; break;
			//		case MaterialOptions.TriplanarWorldDouble : flags |= SurfaceFlags.TRIPLANAR_DOUBLE; break;
			//		case MaterialOptions.TriplanarWorldTriple : flags |= SurfaceFlags.TRIPLANAR_TRIPLE; break;
			//	}
			//}

			if (instance.IsSkinned) {
				flags |= SurfaceFlags.SKINNED;
			} else {
				flags |= SurfaceFlags.RIGID;
			}

			return flags;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Creates instance from mesh in scene.
		/// </summary>
		/// <param name="rs"></param>
		/// <param name="mesh"></param>
		public MeshInstance ( RenderSystem rs, Scene scene, Mesh mesh, MaterialInstance[] materials )
		{
			Visible		=	true;
			World		=	Matrix.Identity;
			Color		=	Color4.Zero;
			Blending	=	new Vector4(1,1,1,1);

			vb			=	mesh.VertexBuffer;
			ib			=	mesh.IndexBuffer;
			
			vertexCount	=	mesh.VertexCount;
			indexCount	=	mesh.IndexCount;

			ShadingGroups	=	mesh.Subsets	
							.Select( s => new ShadingGroup( s, materials[s.MaterialIndex] ) )
							.ToArray();

			IsSkinned	=	mesh.IsSkinned;

			if (IsSkinned && scene.Nodes.Count > SceneRenderer.MaxBones) {
				throw new ArgumentOutOfRangeException( string.Format("Scene contains more than {0} bones and cannot be used for skinning.", SceneRenderer.MaxBones ) );
			}

			if (IsSkinned) {
				BoneTransforms	=	Enumerable
					.Range(0, SceneRenderer.MaxBones)
					.Select( i => Matrix.Identity )
					.ToArray();
			}
		}