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); }
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; }
public static void Import(ImporterPathManager pathManager, FileInfo outfitConfFile, DirectoryInfo contentDestDirectory) { string name = outfitConfFile.GetNameWithoutExtension(); var outfitsDir = contentDestDirectory.Subdirectory("outfits"); var destinationFile = outfitsDir.File(name + ".dat"); if (destinationFile.Exists) { return; } string json = outfitConfFile.ReadAllText(); var proxy = JsonConvert.DeserializeObject <OutfitJsonProxy>(json); var items = proxy.items .Select(itemProxy => { ImportProperties.Load(pathManager, itemProxy.figure); //verify that that a figure with this name exists return(new Outfit.Item(itemProxy.figure, itemProxy.label, itemProxy.isInitiallyVisible)); }) .ToList(); List <Outfit.Fabric> fabrics = proxy.fabrics? .Select(entry => { var label = entry.Key; var materialSetsByFigureName = entry.Value; //verify that the material set for each figure exists foreach (var entry2 in materialSetsByFigureName) { var figureName = entry2.Key; var materialSetName = entry2.Value; var figureConfDir = pathManager.GetConfDirForFigure(figureName); var materialSetsConfs = MaterialSetImportConfiguration.Load(figureConfDir); materialSetsConfs.Where(conf => conf.name == materialSetName).Single(); } return(new Outfit.Fabric(label, materialSetsByFigureName)); }) .ToList(); var outfit = new Outfit(proxy.label, items, fabrics); outfitsDir.CreateWithParents(); Persistance.Save(destinationFile, outfit); }
public static ImportProperties Load(ImporterPathManager pathManager, string figureName) { JsonSerializerSettings settings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }; string json = pathManager.GetConfDirForFigure(figureName).File("import-properties.json").ReadAllText(); JsonProxy proxy = JsonConvert.DeserializeObject <JsonProxy>(json, settings); UrisJsonProxy urisProxy = proxy.uris; var uris = new FigureUris( urisProxy.basePath, urisProxy.documentName, urisProxy.geometryId, urisProxy.rootNodeId, urisProxy.skinBindingId); return(new ImportProperties(uris, proxy.hdCorrectionInitialValue)); }
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]); } }
public static void Import(ImporterPathManager pathManager, FileInfo characterConfFile, DirectoryInfo contentDestDirectory) { string name = characterConfFile.GetNameWithoutExtension(); var charactersDir = contentDestDirectory.Subdirectory("characters"); var destinationFile = charactersDir.File(name + ".dat"); if (destinationFile.Exists) { return; } string json = characterConfFile.ReadAllText(); var proxy = JsonConvert.DeserializeObject <CharacterJsonProxy>(json); var character = new Character(proxy.label, proxy.shape, proxy.materialSet); charactersDir.CreateWithParents(); Persistance.Save(destinationFile, character); }
public static SurfaceProperties Load(ImporterPathManager pathManager, Figure figure) { JsonSerializerSettings settings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }; string json = pathManager.GetConfDirForFigure(figure.Name).File("surface-properties.json").ReadAllText(); JsonProxy proxy = JsonConvert.DeserializeObject <JsonProxy>(json, settings); int subdivisionLevel = proxy.subdivisionLevel; string[] surfaceNames = figure.Geometry.SurfaceNames; Dictionary <string, int> surfaceNameToIdx = Enumerable.Range(0, surfaceNames.Length) .ToDictionary(idx => surfaceNames[idx], idx => idx); int[] renderOrder; if (proxy.renderOrder == null) { renderOrder = new int[] { }; } else { renderOrder = proxy.renderOrder.Select(surfaceName => surfaceNameToIdx[surfaceName]).ToArray(); } float[] opacities = surfaceNames.Select(name => proxy.defaultOpacity).ToArray(); if (proxy.opacities != null) { foreach (var entry in proxy.opacities) { opacities[surfaceNameToIdx[entry.Key]] = entry.Value; } } bool precomputeScattering = proxy.precomputeScattering; string materialSetForOpacities = proxy.materialSetForOpacities; return(new SurfaceProperties(subdivisionLevel, renderOrder, opacities, precomputeScattering, materialSetForOpacities)); }
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; }
public FigureRecipeLoader(ContentFileLocator fileLocator, DsonObjectLocator objectLocator, ImporterPathManager pathManager) { this.fileLocator = fileLocator; this.objectLocator = objectLocator; this.pathManager = pathManager; }
private void Run(string[] args) { ImportSettings settings; if (args.Length > 0 && args[0] == "release") { settings = ImportSettings.MakeReleaseSettings(); } else { settings = ImportSettings.MakeFromViewerInitialSettings(); } var contentDestDir = CommonPaths.WorkDir.Subdirectory("content"); var contentPackConfs = ContentPackImportConfiguration.LoadAll(CommonPaths.ConfDir); var pathManager = ImporterPathManager.Make(contentPackConfs); var figureDumperLoader = new FigureDumperLoader(fileLocator, objectLocator, pathManager, device, shaderCache); foreach (var contentPackConf in contentPackConfs) { var destDir = contentDestDir.Subdirectory(contentPackConf.Name); if (contentPackConf.IsCore) { new UiImporter(destDir).Run(); new EnvironmentCubeGenerator().Run(settings, destDir); } var texturesDir = destDir.Subdirectory("textures").Subdirectory(contentPackConf.Name); var textureProcessor = new TextureProcessor(device, shaderCache, texturesDir, contentPackConf.Name, settings.CompressTextures); bool shouldImportAnything = false; foreach (var figureConf in contentPackConf.Figures) { string figureName = figureConf.Name; if (!settings.FiguresToImport.Contains(figureName)) { continue; } var figureDumper = figureDumperLoader.LoadDumper(figureName); MaterialSetImportConfiguration[] materialSetConfigurations = MaterialSetImportConfiguration.Load(figureConf.Directory); ShapeImportConfiguration[] shapeImportConfigurations = ShapeImportConfiguration.Load(figureConf.Directory); var figureDestDir = destDir.Subdirectory("figures").Subdirectory(figureName); if (figureConf.IsPrimary) { shouldImportAnything = true; figureDumper.DumpFigure(shapeImportConfigurations, figureDestDir); } foreach (var materialSetConf in materialSetConfigurations) { if (!settings.ShouldImportMaterialSet(figureConf.Name, materialSetConf.name)) { continue; } shouldImportAnything = true; figureDumper.DumpMaterialSet(settings, textureProcessor, figureDestDir, materialSetConf); } if (figureConf.IsPrimary) { shouldImportAnything = true; figureDumper.DumpBaseShape(figureDestDir); } foreach (var shapeConf in shapeImportConfigurations) { if (!settings.ShouldImportShape(figureConf.Name, shapeConf.name)) { continue; } shouldImportAnything = true; figureDumper.DumpShape(textureProcessor, figureDestDir, shapeConf); } } if (shouldImportAnything) { foreach (var characterConf in contentPackConf.Characters) { CharacterImporter.Import(pathManager, characterConf.File, destDir); } foreach (var outfitConf in contentPackConf.Outfits) { OutfitImporter.Import(pathManager, outfitConf.File, destDir); } } textureProcessor.ImportAll(); } }
public void Run() { LeakTracking.Setup(); var device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug, FeatureLevel.Level_11_1); var shaderCache = new ShaderCache(device); 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; var ldChannelInputs = figure.ChannelSystem.MakeDefaultChannelInputs(); figure.ChannelsByName["PBMNavel?value"].SetValue(ldChannelInputs, 1); figure.ChannelsByName["PBMNipples?value"].SetValue(ldChannelInputs, 1); figure.ChannelsByName["CTRLRune7?value"].SetValue(ldChannelInputs, 1); var hdChannelInputs = figure.ChannelSystem.MakeDefaultChannelInputs(); figure.ChannelsByName["PBMNavel?value"].SetValue(hdChannelInputs, 1); figure.ChannelsByName["PBMNipples?value"].SetValue(hdChannelInputs, 1); figure.ChannelsByName["CTRLRune7?value"].SetValue(hdChannelInputs, 1); figure.ChannelsByName["CTRLRune7HD?value"].SetValue(hdChannelInputs, 1); var converter = new HdMorphToNormalMapConverter(device, shaderCache, figure); var mapRenderer = converter.MakeNormalMapRenderer(ldChannelInputs, hdChannelInputs, figure.UvSets["Rune 7"]); string character = "rune"; var faceMap = mapRenderer.Render(new HashSet <int> { 9, 13, 5, 6 }); faceMap.Save(CommonPaths.WorkDir.File(character + "-face.png")); faceMap.Dispose(); var torsoMap = mapRenderer.Render(new HashSet <int> { 12 }); torsoMap.Save(CommonPaths.WorkDir.File(character + "-torso.png")); torsoMap.Dispose(); var legsMap = mapRenderer.Render(new HashSet <int> { 11, 2 }); legsMap.Save(CommonPaths.WorkDir.File(character + "-legs.png")); legsMap.Dispose(); var armsMap = mapRenderer.Render(new HashSet <int> { 16, 1 }); armsMap.Save(CommonPaths.WorkDir.File(character + "-arms.png")); armsMap.Dispose(); mapRenderer.Dispose(); shaderCache.Dispose(); device.Dispose(); LeakTracking.Finish(); }
public FigureRecipeLoader(DsonObjectLocator objectLocator, ImporterPathManager pathManager) { this.objectLocator = objectLocator; this.pathManager = pathManager; }