public void SetMaterial(string name, Material material)
 {
     if (name == "Material")
     {
         MaterialInstance.Material = material;
     }
 }
Exemple #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;
            }
        }
Exemple #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;
        }
Exemple #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}
                    }
                }
            };
        }
Exemple #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;
 }