Beispiel #1
0
        static CL.common_color_or_texture_type ColladaColor(string sid, Color4 c)
        {
            var cl = new CL.common_color_or_texture_type();

            cl.Item = new CL.common_color_or_texture_typeColor()
            {
                sid = sid, Text =
                    String.Join(" ", new[] { c.R, c.G, c.B, c.A }.Select((x) => x.ToString()))
            };
            return(cl);
        }
Beispiel #2
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");
     }
 }
Beispiel #3
0
        protected void CreateMaterial(Color color, string textureName, string textureCoord, string material, out effect effectColor, out material materialColor)
        {
            string effect_ID = string.Format("effect_{0}_ID", material);
            string effectName = string.Format("effect_{0}", material);

            common_color_or_texture_type diffuseColorOrTexture = new common_color_or_texture_type();
            if (string.IsNullOrEmpty(textureName))
                diffuseColorOrTexture.Item = new common_color_or_texture_typeColor() { Values = new double[] { (double)color.R / 255.0, (double)color.G / 255.0, (double)color.B / 255.0, 1.000000 } };
            else
                diffuseColorOrTexture.Item = new common_color_or_texture_typeTexture() { texture = "sampler_" + textureName, texcoord = textureCoord };

            effectFx_profile_abstractProfile_COMMON effectFx_prof = new effectFx_profile_abstractProfile_COMMON()
            {
                technique = new effectFx_profile_abstractProfile_COMMONTechnique()
                {
                    Item = new effectFx_profile_abstractProfile_COMMONTechniquePhong()
                    {
                        ambient = new common_color_or_texture_type()
                        {
                            Item = new common_color_or_texture_typeColor() { Values = new double[] { 0.300000, 0.300000, 0.300000, 1.000000 } }
                        },
                        emission = new common_color_or_texture_type()
                        {
                            Item = new common_color_or_texture_typeColor() { Values = new double[] { 0.050000, 0.050000, 0.050000, 1.000000 } }
                        },
                        diffuse = diffuseColorOrTexture,
                        specular = new common_color_or_texture_type()
                        {
                            Item = new common_color_or_texture_typeColor() { Values = new double[] { 0.500000, 0.500000, 0.500000, 1.000000 } }
                        },
                        transparent = new common_transparent_type()
                        {
                            Item = new common_color_or_texture_typeColor() { Values = new double[] { 1.000000, 1.000000, 1.000000, 1.000000 } }
                        },
                        reflectivity = new common_float_or_param_type()
                        {
                            Item = new common_float_or_param_typeFloat() { Value = 0.000000 }
                        },
                        shininess = new common_float_or_param_type()
                        {
                            Item = new common_float_or_param_typeFloat() { Value = 25.00000 }
                        },
                        transparency = new common_float_or_param_type()
                        {
                            Item = new common_float_or_param_typeFloat() { Value = 0.000000 }
                        }
                    }
                }
            };
            if (!string.IsNullOrEmpty(textureName))
            {
                effectFx_prof.Items = new object[]
                {
                    new common_newparam_type()
                    {
                        sid = "surf_" + textureName,
                        Item = new fx_surface_common()
                        {
                            type = fx_surface_type_enum.Item2D,
                            init_from = new fx_surface_init_from_common[]
                            {
                                new fx_surface_init_from_common() { Value = textureName + ".jpg" }
                            },
                            mipmap_generate = false,
                            mipmap_generateSpecified = true
                        },
                        ItemElementName = ItemChoiceType.surface
                    },
                    new common_newparam_type()
                    {
                        sid = "sampler_" + textureName,
                        Item = new fx_sampler2D_common()
                        {
                            source = "surf_"+ textureName
                        },
                        ItemElementName = ItemChoiceType.sampler2D
                    } 
                };
            }
            // effect color
            effectColor = new effect()
            {
                id = string.Format("effect_{0}_ID", material),
                name = string.Format("effect_{0}", material),
                Items = new effectFx_profile_abstractProfile_COMMON[] { effectFx_prof }
            };
            // materials
            materialColor = new material()
            {
                id = string.Format("material_{0}_ID", material),
                name = string.Format("material_{0}", material),
                instance_effect = new instance_effect()
                {
                    url = string.Format("#{0}", effectColor.id)
                }
            };
        }