public void SetMaterial(string name, Material material)
 {
     if (name == "Material")
     {
         MaterialInstance.Material = material;
     }
 }
示例#2
0
        public void UpdateMaterial()
        {
            var materialIndex = Mesh.MaterialIndex;
            Material = RenderModel.GetMaterial(materialIndex);
            var materialInstance = RenderModel.GetMaterialInstance(materialIndex);
            if (Material != null)
            {
                HasTransparency = Material.HasTransparency;
            }

            IsShadowCaster = RenderModel.ModelComponent.IsShadowCaster;
            IsShadowReceiver = RenderModel.ModelComponent.IsShadowReceiver;
            if (materialInstance != null)
            {
                IsShadowCaster = IsShadowCaster && materialInstance.IsShadowCaster;
                IsShadowReceiver = IsShadowReceiver && materialInstance.IsShadowReceiver;
            }
        }
示例#3
0
        public bool UpdateMaterial()
        {
            var materialIndex = Mesh.MaterialIndex;
            Material = RenderModel.GetMaterial(materialIndex);
            var materialInstance = RenderModel.GetMaterialInstance(materialIndex);
            HasTransparency = Material != null && Material.HasTransparency;

            var modelComponent = RenderModel.ModelComponent;
            IsShadowCaster = modelComponent.IsShadowCaster;
            IsShadowReceiver = modelComponent.IsShadowReceiver;
            if (materialInstance != null)
            {
                IsShadowCaster = IsShadowCaster && materialInstance.IsShadowCaster;
                IsShadowReceiver = IsShadowReceiver && materialInstance.IsShadowReceiver;
            }

            return Material != null;
        }
示例#4
0
        private void ChangeMaterial(int i)
        {
            currentMaterialIndex = ((currentMaterialIndex + i + materials.Count) % materials.Count);
            currentMaterial = materials[currentMaterialIndex];

            if (currentEntity != null)
            {
                var modelComponent = currentEntity.Get<ModelComponent>();
                modelComponent.Materials.Clear();

                if (modelComponent.Model != null)
                {
                    // ensure the same number of materials than original model.
                    for (int j = 0; j < modelComponent.Model.Materials.Count; j++)
                        modelComponent.Materials.Add(currentMaterial);
                }
            }

            SetWireframe(isWireframe);
        }
        private Entity CreateStandBorder(Material material)
        {
            var mesh = new Mesh
            {
                Draw = GeometricPrimitive.Torus.New(GraphicsDevice, 720, 10, 64).ToMeshDraw(),
                Material = material
            };
            mesh.Parameters.Set(LightingKeys.ReceiveShadows, true);

            return new Entity()
            {
                new ModelComponent
                {
                    Model = new Model()
                    {
                        mesh
                    },
                    Parameters =
                    {
                        {TexturingKeys.Texture0, Asset.Load<Texture>("red")},
                        {TexturingKeys.Sampler0, GraphicsDevice.SamplerStates.AnisotropicWrap},
                        {MaterialKeys.SpecularColorValue, 0.3f*Color4.White}
                    }
                }
            };
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialInstance"/> class.
 /// </summary>
 /// <param name="material">The material.</param>
 public MaterialInstance(Material material)
 {
     Material = material;
     IsShadowCaster = true;
     IsShadowReceiver = true;
 }