Beispiel #1
0
        public void DumpButtonCallback()
        {
            try
            {
                // Obtain the currently selected clothes.
                DAZClothingItem clothes = GameObject
                                          .FindObjectsOfType <DAZClothingItem>()
                                          .Where(dci => dci.containingAtom == containingAtom)
                                          .Where(dci => dci.name == clothingItems.val)
                                          .DefaultIfEmpty((DAZClothingItem)null)
                                          .FirstOrDefault();

                // Bug out if it doesn't exist.
                if (clothes == null)
                {
                    SuperController.LogError($"Could not finding clothing item '{clothingItems.val}'");
                    return;
                }

                // Get the first skinwrap mesh.
                DAZMesh mesh = clothes
                               .GetComponentsInChildren <DAZMesh>()
                               .FirstOrDefault();

                // Export
                OBJExporter exporter = new OBJExporter();
                exporter.Export(clothes.name + ".obj", mesh.uvMappedMesh, mesh.uvMappedMesh.vertices, mesh.uvMappedMesh.normals, mesh.materials);
            }
            catch (Exception ex)
            {
                SuperController.LogMessage($"Could not export OBJ file for this clothing item: {ex}");
            }
        }
Beispiel #2
0
        //
        // Outfit application methods

        private void ApplyOutfit(string forClothing, string outfitName)
        {
            string outfitDirectory = FindOutfitDirectory(forClothing, outfitName);

            // Get the clothing item materials.
            DAZClothingItem clothes = GameObject
                                      .FindObjectsOfType <DAZClothingItem>()
                                      .Where(dci => dci.containingAtom == containingAtom)
                                      .Where(dci => dci.name == forClothing)
                                      .FirstOrDefault();

            if (clothes == null)
            {
                throw new Exception("Tried to apply '{outfitName}' to '{forClothing}' but '{myPerson.name}' isn't wearing that.");
            }

            string[] files = SuperController.singleton.GetFilesAtPath(outfitDirectory);

            foreach (Material mat in clothes
                     .GetComponentsInChildren <DAZSkinWrap>()
                     .SelectMany(dsw => dsw.GPUmaterials))
            {
                ApplyTexture(outfitDirectory, mat, PROP_DIFFUSE);
                ApplyTexture(outfitDirectory, mat, PROP_CUTOUT);
                ApplyTexture(outfitDirectory, mat, PROP_NORMAL);
                ApplyTexture(outfitDirectory, mat, PROP_SPEC);
                ApplyTexture(outfitDirectory, mat, PROP_GLOSS);
            }
        }
Beispiel #3
0
 public bool Prepare()
 {
     foreach (var wrap in _clothing.GetComponentsInChildren <DAZSkinWrap>())
     {
         if (wrap == null)
         {
             return(false);
         }
         if (wrap.GPUuseSimpleMaterial)
         {
             AddMaterial(wrap.GPUsimpleMaterial);
         }
         else
         {
             if (wrap.GPUmaterials == null)
             {
                 return(false);
             }
             foreach (var mat in wrap.GPUmaterials)
             {
                 AddMaterial(mat);
             }
         }
     }
     return(_materials.Count != 0);
 }