Exemplo n.º 1
0
 static void SetDc(ColladaMaterial material, CL.common_color_or_texture_type obj)
 {
     if (obj == null)
     {
         return;
     }
     if (obj.Item is CL.common_color_or_texture_typeColor col)
     {
         TryParseColor(col.Text, out material.Dc);
     }
     if (obj.Item is CL.common_color_or_texture_typeTexture tex)
     {
         material.Dc = Color4.White;
         FLLog.Warning("Collada", "Not Implemented: Diffuse texture import");
     }
 }
Exemplo n.º 2
0
        static ColladaMaterial ParseMaterial(string name, CL.library_materials matlib, CL.library_effects fxlib)
        {
            if (matlib == null)
            {
                return new ColladaMaterial()
                       {
                           Dc   = Color4.Red,
                           Name = name
                       }
            }
            ;
            var src = matlib.material.FirstOrDefault(mat => mat.id.Equals(name, StringComparison.InvariantCulture));

            if (src == null)
            {
                return new ColladaMaterial()
                       {
                           Dc   = Color4.Red,
                           Name = name
                       }
            }
            ;
            var output = new ColladaMaterial()
            {
                Dc = Color4.Red
            };

            output.Name = string.IsNullOrWhiteSpace(src.name) ? name : src.name;
            if (src.instance_effect == null)
            {
                return(output);
            }
            if (fxlib == null)
            {
                return(output);
            }
            var fx = fxlib.effect.FirstOrDefault(fx =>
                                                 fx.id.Equals(CheckURI(src.instance_effect.url), StringComparison.InvariantCulture));

            if (fx != null)
            {
                var profile = fx.Items.FirstOfType <CL.effectFx_profile_abstractProfile_COMMON>();
                if (profile == null)
                {
                    return(output);
                }
                if (profile.technique == null)
                {
                    return(output);
                }
                switch (profile.technique.Item)
                {
                case CL.effectFx_profile_abstractProfile_COMMONTechniquePhong phong:
                    SetDc(output, phong.diffuse);
                    break;

                case CL.effectFx_profile_abstractProfile_COMMONTechniqueBlinn blinn:
                    SetDc(output, blinn.diffuse);
                    break;

                case CL.effectFx_profile_abstractProfile_COMMONTechniqueConstant constant:
                    output.Dc = Color4.White;
                    break;

                case CL.effectFx_profile_abstractProfile_COMMONTechniqueLambert lambert:
                    SetDc(output, lambert.diffuse);
                    break;
                }
            }
            return(output);
        }