Exemplo n.º 1
0
 public ImporterMain(ContentFileLocator fileLocator, DsonObjectLocator objectLocator)
 {
     this.fileLocator   = fileLocator;
     this.objectLocator = objectLocator;
     this.device        = new Device(DriverType.Hardware, DeviceCreationFlags.None, FeatureLevel.Level_11_1);
     this.shaderCache   = new ShaderCache(device);
 }
Exemplo n.º 2
0
    private static ImporterMain Make(string[] args)
    {
        ContentFileLocator fileLocator   = new ContentFileLocator();
        DsonObjectLocator  objectLocator = new DsonObjectLocator(fileLocator);

        return(new ImporterMain(fileLocator, objectLocator));
    }
 public FaceTransparencyDemo()
 {
     fileLocator   = new ContentFileLocator();
     objectLocator = new DsonObjectLocator(fileLocator);
     device        = new Device(DriverType.Hardware, DeviceCreationFlags.None, FeatureLevel.Level_11_1);
     shaderCache   = new ShaderCache(device);
 }
Exemplo n.º 4
0
    public static FigureRecipe ImportFor(string figureName, DsonObjectLocator locator, FigureUris figureUris, FigureRecipe parentRecipe, double hdCorrectionInitialValue)
    {
        var geometryRecipe = GeometryImporter.ImportForFigure(locator, figureUris);

        FigureRecipe recipe = new FigureRecipe {
            Name        = figureName,
            Geometry    = geometryRecipe,
            Channels    = ChannelImporter.ImportForFigure(locator, figureUris).ToList(),
            Formulas    = FormulaImporter.ImportForFigure(locator, figureUris).ToList(),
            Bones       = BoneImporter.ImportForFigure(locator, figureUris).ToList(),
            Morphs      = MorphImporter.ImportForFigure(locator, figureUris).ToList(),
            SkinBinding = SkinBindingImporter.ImportForFigure(locator, figureUris),
            UvSets      = UvSetImporter.ImportForFigure(locator, figureUris, geometryRecipe).ToList()
        };

        Geometry geometry = recipe.Geometry.Bake();

        var correctionSynthesizer = new HdCorrectionMorphSynthesizer(figureName, geometry);

        recipe.Channels.Add(correctionSynthesizer.SynthesizeChannel(hdCorrectionInitialValue));
        recipe.Morphs.Add(correctionSynthesizer.SynthesizeMorph());

        if (parentRecipe != null)
        {
            Geometry parentGeometry = parentRecipe.Geometry.Bake();
            recipe.Automorpher = AutomorpherRecipe.Make(parentGeometry, geometry);
        }

        return(recipe);
    }
 public DsonMaterialAggregator(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Dictionary <string, DsonTypes.Image> imagesByUrl, Dictionary <string, MaterialBag> bags)
 {
     this.fileLocator   = fileLocator;
     this.objectLocator = objectLocator;
     this.imagesByUrl   = imagesByUrl;
     this.bags          = bags;
 }
    public static IEnumerable <BoneRecipe> ImportForFigure(DsonObjectLocator locator, FigureUris figureUris)
    {
        BoneImporter importer = new BoneImporter();

        importer.ImportFrom(locator.LocateRoot(figureUris.DocumentUri));

        return(importer.BoneRecipes);
    }
    public static SkinBindingRecipe ImportForFigure(DsonObjectLocator locator, FigureUris figureUris)
    {
        SkinBindingImporter importer = new SkinBindingImporter();

        importer.ImportFrom(locator.LocateRoot(figureUris.DocumentUri));

        return(importer.recipes.Single());
    }
 public MaterialBag(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Dictionary <string, DsonTypes.Image> imagesByUrl, HashSet <string> extraTypes, Dictionary <string, object> values)
 {
     this.fileLocator   = fileLocator;
     this.objectLocator = objectLocator;
     this.imagesByUrl   = imagesByUrl;
     this.extraTypes    = extraTypes;
     this.values        = values;
 }
Exemplo n.º 9
0
    public static GeometryRecipe ImportForFigure(DsonObjectLocator locator, FigureUris figureUris)
    {
        GeometryImporter importer = new GeometryImporter();

        importer.ImportFrom(locator.LocateRoot(figureUris.DocumentUri));

        return(importer.recipes.Single());
    }
    public FaceTransparencyDemo()
    {
        fileLocator   = new ContentFileLocator();
        objectLocator = new DsonObjectLocator(fileLocator);
        var contentPackConfs = ContentPackImportConfiguration.LoadAll(CommonPaths.ConfDir);

        pathManager = ImporterPathManager.Make(contentPackConfs);
        device      = new Device(DriverType.Hardware, DeviceCreationFlags.None, FeatureLevel.Level_11_1);
        shaderCache = new ShaderCache(device);
    }
Exemplo n.º 11
0
    public static IEnumerable <MorphRecipe> ImportForFigure(DsonObjectLocator locator, FigureUris figureUris)
    {
        MorphImporter importer = new MorphImporter();

        foreach (DsonTypes.DsonDocument doc in locator.GetAllDocumentsUnderPath(figureUris.MorphsBasePath))
        {
            importer.ImportFrom(doc);
        }

        return(importer.MorphRecipes);
    }
    public static IEnumerable <UvSetRecipe> ImportForFigure(DsonObjectLocator locator, FigureUris figureUris, GeometryRecipe geometry)
    {
        UvSetImporter importer = new UvSetImporter(geometry);

        foreach (DsonTypes.DsonDocument doc in locator.GetAllDocumentsUnderPath(figureUris.UvSetsBasePath))
        {
            importer.ImportFrom(doc);
        }

        return(importer.Recipes);
    }
Exemplo n.º 13
0
    public static IEnumerable <FormulaRecipe> ImportForFigure(DsonObjectLocator locator, FigureUris figureUris)
    {
        FormulaImporter importer = new FormulaImporter(locator, figureUris.RootNodeId);

        importer.ImportFrom(locator.LocateRoot(figureUris.DocumentUri));
        foreach (DsonTypes.DsonDocument doc in locator.GetAllDocumentsUnderPath(figureUris.MorphsBasePath))
        {
            importer.ImportFrom(doc);
        }

        return(importer.FormulaRecipes);
    }
    public static IEnumerable <ChannelRecipe> ImportForFigure(DsonObjectLocator locator, FigureUris figureUris, ImmutableHashSet <string> visibleProducts)
    {
        ChannelImporter importer = new ChannelImporter(locator, figureUris.RootNodeId);

        importer.ImportFrom(locator.LocateRoot(figureUris.DocumentUri), false);
        foreach (DsonTypes.DsonDocument doc in locator.GetAllDocumentsUnderPath(figureUris.MorphsBasePath))
        {
            bool forceModifiersHidden = visibleProducts != null && !visibleProducts.Contains(doc.Product);
            importer.ImportFrom(doc, forceModifiersHidden);
        }

        return(importer.ChannelRecipes);
    }
Exemplo n.º 15
0
 public FigureDumper(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Device device, ShaderCache shaderCache, Figure parentFigure, Figure figure, SurfaceProperties surfaceProperties, MaterialSetImportConfiguration baseMaterialSetImportConfiguration, ShapeImportConfiguration baseShapeImportConfiguration, ShapeDumper shapeDumper)
 {
     this.device            = device;
     this.shaderCache       = shaderCache;
     this.fileLocator       = fileLocator;
     this.objectLocator     = objectLocator;
     this.parentFigure      = parentFigure;
     this.figure            = figure;
     this.surfaceProperties = surfaceProperties;
     this.baseMaterialSetImportConfiguration = baseMaterialSetImportConfiguration;
     this.baseShapeImportConfiguration       = baseShapeImportConfiguration;
     this.shapeDumper = shapeDumper;
 }
Exemplo n.º 16
0
    public ApplyHdMorphDemo()
    {
        var fileLocator      = new ContentFileLocator();
        var objectLocator    = new DsonObjectLocator(fileLocator);
        var contentPackConfs = ContentPackImportConfiguration.LoadAll(CommonPaths.ConfDir);
        var pathManager      = ImporterPathManager.Make(contentPackConfs);
        var loader           = new FigureRecipeLoader(fileLocator, objectLocator, pathManager);
        var figureRecipe     = loader.LoadFigureRecipe("genesis-3-female", null);
        var figure           = figureRecipe.Bake(fileLocator, null);
        var geometry         = figure.Geometry;

        controlTopology        = new QuadTopology(geometry.VertexCount, geometry.Faces);
        controlVertexPositions = geometry.VertexPositions;
    }
Exemplo n.º 17
0
        public static DsonDocument LoadFromFile(DsonObjectLocator locator, string contentPath, string documentPath)
        {
            using (StreamReader reader = File.OpenText(contentPath)) {
                using (JsonReader jsonReader = new JsonTextReader(reader)) {
                    DsonDocument document = new DsonDocument(locator, documentPath);

                    var serializer = JsonSerializer.CreateDefault();
                    serializer.Converters.Add(new DsonObjectReferenceConverter(document));
                    DsonRoot root = serializer.Deserialize <DsonRoot>(jsonReader);

                    document.root = root;

                    return(document);
                }
            }
        }
    public void Run()
    {
        var fileLocator   = new ContentFileLocator();
        var objectLocator = new DsonObjectLocator(fileLocator);
        var loader        = new FigureRecipeLoader(objectLocator);
        var figureRecipe  = loader.LoadFigureRecipe("genesis-3-female", null);
        var figure        = figureRecipe.Bake(null);

        var calculator = new BoneAttributesCalculator(figure.ChannelSystem, figure.BoneSystem, figure.Geometry, figure.SkinBinding);

        BoneAttributes[] boneAttributes = calculator.CalculateBoneAttributes();

        for (int boneIdx = 0; boneIdx < figure.Bones.Count; ++boneIdx)
        {
            Console.WriteLine("{0}: {1}", figure.Bones[boneIdx].Name, boneAttributes[boneIdx]);
        }
    }
    public void Run()
    {
        var fileLocator      = new ContentFileLocator();
        var objectLocator    = new DsonObjectLocator(fileLocator);
        var contentPackConfs = ContentPackImportConfiguration.LoadAll(CommonPaths.ConfDir);
        var pathManager      = ImporterPathManager.Make(contentPackConfs);
        var loader           = new FigureRecipeLoader(fileLocator, objectLocator, pathManager);
        var figureRecipe     = loader.LoadFigureRecipe("genesis-3-female", null);
        var figure           = figureRecipe.Bake(fileLocator, null);

        var calculator = new BoneAttributesCalculator(figure.ChannelSystem, figure.BoneSystem, figure.Geometry, figure.SkinBinding);

        BoneAttributes[] boneAttributes = calculator.CalculateBoneAttributes();

        for (int boneIdx = 0; boneIdx < figure.Bones.Count; ++boneIdx)
        {
            Console.WriteLine("{0}: {1}", figure.Bones[boneIdx].Name, boneAttributes[boneIdx]);
        }
    }
Exemplo n.º 20
0
    public FigureDumperLoader(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, ImporterPathManager pathManager, Device device, ShaderCache shaderCache)
    {
        this.fileLocator   = fileLocator;
        this.objectLocator = objectLocator;
        this.pathManager   = pathManager;
        this.device        = device;
        this.shaderCache   = shaderCache;

        figureRecipeLoader = new FigureRecipeLoader(objectLocator, pathManager);

        FigureRecipe      genesis3FemaleRecipe = figureRecipeLoader.LoadFigureRecipe("genesis-3-female", null);
        FigureRecipe      genitaliaRecipe      = figureRecipeLoader.LoadFigureRecipe("genesis-3-female-genitalia", genesis3FemaleRecipe);
        FigureRecipe      genesis3FemaleWithGenitaliaRecipe = new FigureRecipeMerger(genesis3FemaleRecipe, genitaliaRecipe).Merge();
        Figure            genesis3FemaleWithGenitalia       = genesis3FemaleWithGenitaliaRecipe.Bake(null);
        SurfaceProperties genesis3FemaleSurfaceProperties   = SurfacePropertiesJson.Load(pathManager, genesis3FemaleWithGenitalia);

        float[] genesis3FemaleFaceTransparencies = FaceTransparencies.For(genesis3FemaleWithGenitalia, genesis3FemaleSurfaceProperties, null);

        parentFigureRecipe       = genesis3FemaleRecipe;
        parentFigure             = genesis3FemaleWithGenitalia;
        parentFaceTransparencies = genesis3FemaleFaceTransparencies;
    }
Exemplo n.º 21
0
    public static void DumpMaterialSetAndScattering(ImportSettings settings, Device device, ShaderCache shaderCache, ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Figure figure, SurfaceProperties surfaceProperties,
                                                    MaterialSetImportConfiguration baseConfiguration, TextureProcessor sharedTextureProcessor, DirectoryInfo figureDestDir, MaterialSetImportConfiguration configuration)
    {
        var materialSettings = DumpMaterialSet(settings, device, shaderCache, fileLocator, objectLocator, figure, surfaceProperties, baseConfiguration, figureDestDir, configuration, sharedTextureProcessor);

        ScatteringDumper.Dump(figure, surfaceProperties, materialSettings.PerMaterialSettings, figureDestDir, configuration.name);
    }
 public MaterialBag(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Dictionary <string, DsonTypes.Image> imagesByUrl) : this(
         fileLocator, objectLocator, imagesByUrl,
         new HashSet <string>(),
         new Dictionary <string, object>())
 {
 }
Exemplo n.º 23
0
 private DsonDocument(DsonObjectLocator locator, string documentPath)
 {
     Locator = locator;
     BaseUri = documentPath;
 }
Exemplo n.º 24
0
 public FigureRecipeLoader(DsonObjectLocator objectLocator)
 {
     this.objectLocator = objectLocator;
 }
Exemplo n.º 25
0
 public FormulaImporter(DsonObjectLocator locator, string rootScope)
 {
     this.locator   = locator;
     this.rootScope = rootScope;
 }
 public DsonMaterialAggregator(ContentFileLocator fileLocator, DsonObjectLocator objectLocator)
 {
     this.fileLocator   = fileLocator;
     this.objectLocator = objectLocator;
 }
 public FigureRecipeLoader(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, ImporterPathManager pathManager)
 {
     this.fileLocator   = fileLocator;
     this.objectLocator = objectLocator;
     this.pathManager   = pathManager;
 }
Exemplo n.º 28
0
 public ChannelImporter(DsonObjectLocator locator, string rootScope)
 {
     this.locator   = locator;
     this.rootScope = rootScope;
 }
Exemplo n.º 29
0
    private static MultiMaterialSettings DumpMaterialSet(ImportSettings settings, Device device, ShaderCache shaderCache, ContentFileLocator fileLocator, DsonObjectLocator objectLocator, Figure figure, SurfaceProperties surfaceProperties, MaterialSetImportConfiguration baseConfiguration, DirectoryInfo figureDestDir, MaterialSetImportConfiguration configuration, TextureProcessor textureProcessor)
    {
        DirectoryInfo materialsSetsDirectory     = figureDestDir.Subdirectory("material-sets");
        DirectoryInfo materialSetDirectory       = materialsSetsDirectory.Subdirectory(configuration.name);
        FileInfo      materialSettingsFileInfo   = materialSetDirectory.File("material-settings.dat");
        FileInfo      faceTransparenciesFileInfo = materialSetDirectory.File("face-transparencies.array");

        if (materialSettingsFileInfo.Exists && faceTransparenciesFileInfo.Exists)
        {
            return(Persistance.Load <MultiMaterialSettings>(UnpackedArchiveFile.Make(materialSettingsFileInfo)));
        }

        var aggregator = new DsonMaterialAggregator(fileLocator, objectLocator);
        IEnumerable <string> dufPaths = Enumerable.Concat(baseConfiguration.materialsDufPaths, configuration.materialsDufPaths);

        foreach (string path in dufPaths)
        {
            DsonTypes.DsonDocument doc = objectLocator.LocateRoot(path);
            aggregator.IncludeDuf(doc.Root);
        }

        var faceTransparencyProcessor = new FaceTransparencyProcessor(device, shaderCache, figure, surfaceProperties);

        IMaterialImporter materialImporter;

        if (figure.Name.EndsWith("-hair"))
        {
            materialImporter = new HairMaterialImporter(figure, textureProcessor, faceTransparencyProcessor);
        }
        else
        {
            materialImporter = new UberMaterialImporter(figure, textureProcessor, faceTransparencyProcessor);
        }

        string[] surfaceNames = figure.Geometry.SurfaceNames;
        Dictionary <string, int> surfaceNameToIdx = Enumerable.Range(0, surfaceNames.Length)
                                                    .ToDictionary(idx => surfaceNames[idx], idx => idx);

        var perMaterialSettings = Enumerable.Range(0, figure.Geometry.SurfaceCount)
                                  .Select(surfaceIdx => {
            string surfaceName   = figure.Geometry.SurfaceNames[surfaceIdx];
            var bag              = aggregator.GetBag(surfaceName);
            var materialSettings = materialImporter.Import(surfaceIdx, bag);
            return(materialSettings);
        })
                                  .ToArray();

        var variantCategories = configuration.variantCategories
                                .Select(variantCategoryConf => {
            int[] surfaceIdxs = variantCategoryConf.surfaces
                                .Select(surfaceName => surfaceNameToIdx[surfaceName])
                                .ToArray();

            var variants = variantCategoryConf.variants
                           .Select(variantConf => {
                var variantAggregator = aggregator.Branch();
                foreach (string path in variantConf.materialsDufPaths)
                {
                    DsonTypes.DsonDocument doc = objectLocator.LocateRoot(path);
                    variantAggregator.IncludeDuf(doc.Root);
                }

                var settingsBySurface = variantCategoryConf.surfaces
                                        .Select(surfaceName => {
                    int surfaceIdx       = surfaceNameToIdx[surfaceName];
                    var bag              = variantAggregator.GetBag(surfaceName);
                    var materialSettings = materialImporter.Import(surfaceIdx, bag);
                    return(materialSettings);
                })
                                        .ToArray();

                return(new MultiMaterialSettings.Variant(variantConf.name, settingsBySurface));
            })
                           .ToArray();

            return(new MultiMaterialSettings.VariantCategory(variantCategoryConf.name, surfaceIdxs, variants));
        })
                                .ToArray();

        var multiMaterialSettings = new MultiMaterialSettings(perMaterialSettings, variantCategories);

        materialSetDirectory.CreateWithParents();

        textureProcessor.RegisterAction(() => {
            Persistance.Save(materialSettingsFileInfo, multiMaterialSettings);
        });

        var faceTranparencies = faceTransparencyProcessor.FaceTransparencies;

        faceTransparenciesFileInfo.WriteArray(faceTranparencies);

        faceTransparencyProcessor.Dispose();

        return(multiMaterialSettings);
    }
 public DsonMaterialAggregator(ContentFileLocator fileLocator, DsonObjectLocator objectLocator) : this(
         fileLocator, objectLocator,
         new Dictionary <string, DsonTypes.Image>(),
         new Dictionary <string, MaterialBag>())
 {
 }