コード例 #1
0
        public override IDAEMaterial CreateMaterial(DAEVector4 ambient, DAEVector4 diffuse, DAEVector4 specular, double shininess, bool isTransparent, string texturePath)
        {
            SceneMaterial m = new SceneMaterial();

            foreach (KeyValuePair <string, List <Shader> > shaderPass in Options.Shaders)
            {
                m.SetShaders(shaderPass.Key, shaderPass.Value.ToArray());

                if (!String.IsNullOrEmpty(texturePath))
                {
                    var tex = ResourceLoader.LoadTexture2DFromFile(texturePath);
                    m.SetTexture(shaderPass.Key, "ColorMap", tex);
                    isTransparent |= tex.IsSemiTransparent;
                }

                ColladaMaterialParameters matDesc = new ColladaMaterialParameters();
                matDesc.UseColorMap   = !String.IsNullOrEmpty(texturePath);
                matDesc.AmbientColor  = GetColor4(ambient);
                matDesc.DiffuseColor  = GetColor4(diffuse);
                matDesc.SpecularColor = GetColor4(specular);
                matDesc.Shininess     = (float)shininess;

                IConstantBuffer matBuffer = new ConstantBuffer <ColladaMaterialParameters>(matDesc);
                m.SetConstantBuffer(shaderPass.Key, "MaterialParameters", matBuffer);
                m.SetConstantBuffer(shaderPass.Key, "AmbientLightParameters", Options.AmbientLight);

                m.SetTextureFilter(shaderPass.Key, "ColorMapSamplerState", Options.TextureFilter);
                m.SetTextureFilter(shaderPass.Key, "ShadowMapSamplerState", Options.ShadowMapFilter);
            }

            if (isTransparent)
            {
                m.MaterialClass = "Translucent";
            }

            return(m);
        }
コード例 #2
0
        public override IDAEDirectionalLightNode CreateDirectionalLightNode(string name, DAEVector4 color)
        {
            var light = new DirectionalLightNode();

            light.Name  = name;
            light.Color = GetColor4(color);
            return(light);
        }
コード例 #3
0
 public override IDAEAmbientLightNode CreateAmbientLightNode(string name, DAEVector4 color)
 {
     return(null);
 }
コード例 #4
0
 internal static Vector4 GetVector4(DAEVector4 vec)
 {
     return(new Vector4((float)vec.X, (float)vec.Y, (float)vec.Z, (float)vec.W));
 }
コード例 #5
0
 internal static Color4 GetColor4(DAEVector4 col)
 {
     return(new Color4((float)col.X, (float)col.Y, (float)col.Z, (float)col.W));
 }