Example #1
0
 private void CreateDecoration(int decorationID, int matID, string outputDirectory)
 {
     string name = decorationID + "_on_" + matID;
     XNamespace ns = COLLADA_NAMESPACE;
     Material material = LDDDB.GetMaterial(matID);
     string dbFilename = Path.Combine(LDDDB.PartDBPath, "Decorations", decorationID + ".png");
     string destFilename;
     if (LDDDB.CopyTextures)
     {
         if (LDDDB.ColorizeTextures)
         {
             destFilename = Path.GetFullPath(Path.Combine(outputDirectory, name + ".png"));
             ApplyBackgroundColor(dbFilename, destFilename, material.Red, material.Green, material.Blue, material.Alpha);
         }
         else
         {
             destFilename = Path.Combine(outputDirectory, decorationID + ".png");
             File.Copy(dbFilename, destFilename);
         }
     }
     else
     {
         destFilename = dbFilename;
     }
     ImageLibrary.Add(new XElement(ns + "image", new XAttribute("id", "deco-" + name + "-TEX"), new XAttribute("name", "deco_" + name),
         new XElement(ns + "init_from", "file://" + destFilename.Replace('\\', '/'))));
     MaterialLibrary.Add(new XElement(ns + "material", new XAttribute("id", "mat_deco" + name), new XAttribute("name", "Mat_Deco" + name),
         new XElement(ns + "instance_effect", new XAttribute("url", "#mat_deco" + name + "-FX"))));
     EffectLibrary.Add(new XElement(ns + "effect", new XAttribute("id", "mat_deco" + name + "-FX"), new XAttribute("name", "Mat_Deco" + name),
         new XElement(ns + "profile_COMMON",
             new XElement(ns + "technique", new XAttribute("sid", "standard"),
                 new XElement(ns + "phong",
                     new XElement(ns + "emission",
                         new XElement(ns + "color", new XAttribute("sid", "emission"), "0.0 0.0 0.0 1.0")),
                     new XElement(ns + "ambient",
                         new XElement(ns + "color", new XAttribute("sid", "ambient"), "0 0 0 1.0")),
                     new XElement(ns + "diffuse",
                         new XElement(ns + "texture", new XAttribute("texture", "deco-" + name + "-TEX"), new XAttribute("texcoord", "CHANNEL0")/*,
                                 new XElement(ns + "extra",
                                     new XElement(ns + "techique", new XAttribute("profile", "MAYA"),
                                         new XElement(ns + "wrapU", new XAttribute("sid", "wrapU0"), "FALSE"),
                                         new XElement(ns + "wrapV", new XAttribute("sid", "wrapV0"), "FALSE")))*/)),
                     new XElement(ns + "specular",
                         new XElement(ns + "color", new XAttribute("sid", "specular"), "0.5 0.5 0.5 1.0")),
                     new XElement(ns + "shininess",
                         new XElement(ns + "float", new XAttribute("sid", "shininess"), "0.3"))/*,
                         new XElement(ns + "transparent", new XAttribute("opaque", "RGB_ZERO"),
                             new XElement(ns + "texture", new XAttribute("texture", "deco-" + name + "-TEX"), new XAttribute("texcoord", "CHANNEL0")))*/)))));
 }
Example #2
0
 private void CreateMaterial(int matID)
 {
     XNamespace ns = COLLADA_NAMESPACE;
     Material material = LDDDB.GetMaterial(matID);
     MaterialLibrary.Add(new XElement(ns + "material", new XAttribute("id", "mat" + matID), new XAttribute("name", "Mat" + matID),
         new XElement(ns + "instance_effect", new XAttribute("url", "#mat" + matID + "-FX"))));
     EffectLibrary.Add(new XElement(ns + "effect", new XAttribute("id", "mat" + matID + "-FX"), new XAttribute("name", "Mat" + matID),
         new XElement(ns + "profile_COMMON",
             new XElement(ns + "technique", new XAttribute("sid", "standard"),
                 new XElement(ns + "phong",
                     new XElement(ns + "emission",
                         new XElement(ns + "color", new XAttribute("sid", "emission"), "0.0 0.0 0.0 1.0")),
                     new XElement(ns + "ambient",
                         new XElement(ns + "color", new XAttribute("sid", "ambient"), "0 0 0 1.0")),
                     new XElement(ns + "diffuse",
                         new XElement(ns + "color", new XAttribute("sid", "diffuse"), UnSRGB(material.Red / 255.0f) + " " + UnSRGB(material.Green / 255.0f) + " " + UnSRGB(material.Blue / 255.0f) + " 1.0")),
                     new XElement(ns + "specular",
                         new XElement(ns + "color", new XAttribute("sid", "specular"), "0.5 0.5 0.5 1.0")),
                     new XElement(ns + "shininess",
                         new XElement(ns + "float", new XAttribute("sid", "shininess"), "0.3")),
                     new XElement(ns + "transparency",
                         new XElement(ns + "float", new XAttribute("sid", "transparency"), material.Alpha / 255.0f)))))));
 }