public static FigureDefinition Load(IArchiveDirectory dataDir, string name, FigureDefinition parent)
    {
        IArchiveDirectory figureDir = dataDir.Subdirectory("figures").Subdirectory(name);

        var channelSystemRecipe = Persistance.Load <ChannelSystemRecipe>(figureDir.File("channel-system-recipe.dat"));
        var channelSystem       = channelSystemRecipe.Bake(parent?.ChannelSystem);

        BoneSystem boneSystem;

        RigidTransform[] childToParentBindPoseTransforms;
        if (parent != null)
        {
            boneSystem = parent.BoneSystem;
            childToParentBindPoseTransforms = Persistance.Load <RigidTransform[]>(figureDir.File("child-to-parent-bind-pose-transforms.dat"));
        }
        else
        {
            var boneSystemRecipe = Persistance.Load <BoneSystemRecipe>(figureDir.File("bone-system-recipe.dat"));
            boneSystem = boneSystemRecipe.Bake(channelSystem.ChannelsByName);
            childToParentBindPoseTransforms = null;
        }

        var shapeOptions       = Shape.LoadAllForFigure(figureDir, channelSystem);
        var materialSetOptions = MaterialSetOption.LoadAllForFigure(figureDir);

        return(new FigureDefinition(name, figureDir,
                                    channelSystem, boneSystem,
                                    childToParentBindPoseTransforms,
                                    shapeOptions, materialSetOptions));
    }
 public FigureRendererLoader(IArchiveDirectory dataDir, Device device, ShaderCache shaderCache, TextureCache textureCache)
 {
     this.dataDir      = dataDir;
     this.device       = device;
     this.shaderCache  = shaderCache;
     this.textureCache = textureCache;
 }
Beispiel #3
0
    public void SyncWithModel(FigureModel model, List <ControlVertexProvider> children)
    {
        //sync occluder
        var materialSetDirector   = model.MaterialSet.Directory;
        var newOcclusionDirectory =
            OccluderLoader.IsOcclusionDirectory(materialSetDirector) ? materialSetDirector :
            (model.Shape.Directory ?? occluderLoader.DefaultDirectory);

        if (newOcclusionDirectory != occlusionDirectory)
        {
            var newOccluder = occluderLoader.Load(newOcclusionDirectory);

            occluder?.Dispose();

            occlusionDirectory = newOcclusionDirectory;
            occluder           = newOccluder;
        }

        //sync visible
        isVisible = model.IsVisible;

        //register child occluders
        if (children != null)
        {
            //children are synced first so all children should have occluders by this point
            var childOccluders = children
                                 .Where(child => child.isVisible)
                                 .Select(child => child.occluder)
                                 .ToList();

            occluder.SetChildOccluders(childOccluders);
        }
    }
Beispiel #4
0
 public FigureLoader(IArchiveDirectory dataDir, Device device, ShaderCache shaderCache, FigureRendererLoader figureRendererLoader)
 {
     this.dataDir              = dataDir;
     this.device               = device;
     this.shaderCache          = shaderCache;
     this.figureRendererLoader = figureRendererLoader;
 }
        private void RebuildBinaryFile(IArchiveBinaryFile sourceFile, IArchiveDirectory destinationDirectory, RageArchiveEncryption7 archiveEncryption)
        {
            foreach (var handler in BinaryFileHandlers)
            {
                if (handler.CanRebuild(sourceFile))
                {
                    handler.Rebuild(sourceFile, destinationDirectory, archiveEncryption);
                    return;
                }
            }

            var ms = new MemoryStream();

            sourceFile.Export(ms);
            ms.Position = 0;

            var buf = new byte[ms.Length];

            ms.Position = 0;
            ms.Read(buf, 0, buf.Length);

            var newF = destinationDirectory.CreateBinaryFile();

            newF.Name = sourceFile.Name;

            newF.Import(new MemoryStream(buf));
            newF.IsEncrypted = sourceFile.IsEncrypted;

            if (sourceFile.IsCompressed)
            {
                newF.IsCompressed     = sourceFile.IsCompressed;
                newF.UncompressedSize = sourceFile.UncompressedSize;
            }
        }
Beispiel #6
0
    public Scene(IArchiveDirectory dataDir, Device device, ShaderCache shaderCache, StandardSamplers standardSamplers, TrackedDeviceBufferManager trackedDeviceBufferManager, ControllerManager controllerManager)
    {
        var textureCache = new TextureCache(device);

        toneMappingSettings = new ToneMappingSettings();
        iblEnvironment      = new ImageBasedLightingEnvironment(device, standardSamplers, dataDir, InitialSettings.Environment, InitialSettings.EnvironmentRotation);
        backdrop            = new Backdrop(device, shaderCache);
        floor = new PlayspaceFloor(device, shaderCache);
        renderModelRenderer = new RenderModelRenderer(device, shaderCache, trackedDeviceBufferManager);
        primitiveRenderer   = new MeshRenderer(device, shaderCache, Matrix.Translation(0, 1.25f, 0), GeometricPrimitiveFactory.MakeSphere(0.5f, 100).AsTriMesh());

        var shapeNormalsLoader   = new ShapeNormalsLoader(dataDir, device, textureCache);
        var figureRendererLoader = new FigureRendererLoader(dataDir, device, shaderCache, textureCache);
        var figureLoader         = new FigureLoader(dataDir, device, shaderCache, shapeNormalsLoader, figureRendererLoader);

        actor = Actor.Load(dataDir, device, shaderCache, controllerManager, figureLoader);

        var iblMenu = LightingEnvironmentMenu.MakeMenuLevel(dataDir, iblEnvironment);
        var toneMappingMenuLevel    = new ToneMappingMenuLevel(toneMappingSettings);
        var renderSettingsMenuLevel = new StaticMenuLevel(
            new SubLevelMenuItem("Lighting Enviroment", iblMenu),
            new SubLevelMenuItem("Tone Mapping", toneMappingMenuLevel),
            new FloorVisibilityToggleMenuItem(floor)
            );
        var scenePersistenceMenuLevel = ScenePersistenceMenuLevel.Make(this);
        var appMenuLevel = new StaticMenuLevel(
            new SubLevelMenuItem("Save/Load", scenePersistenceMenuLevel),
            new SubLevelMenuItem("Render Settings", renderSettingsMenuLevel)
            );

        var rootMenuLevel = new CombinedMenuLevel(appMenuLevel, actor.MenuLevel);

        menu = new Menu(device, shaderCache, trackedDeviceBufferManager, controllerManager, rootMenuLevel);
    }
 public OccluderLoader(Device device, ShaderCache shaderCache, FigureDefinition figureDefinition)
 {
     this.device                 = device;
     this.shaderCache            = shaderCache;
     channelSystem               = figureDefinition.ChannelSystem;
     unmorphedOcclusionDirectory = figureDefinition.Directory.Subdirectory("occlusion");
 }
    public ShapeNormals Load(IArchiveDirectory figureDir, Shape shape)
    {
        var file = shape.Directory?.File("shape-normals.dat");

        if (file == null)
        {
            return(null);
        }

        var recipe = Persistance.Load <ShapeNormalsRecipe>(file);

        var uvSetName = recipe.UvSetName;
        IArchiveDirectory uvSetsDirectory = figureDir.Subdirectory("uv-sets");
        IArchiveDirectory uvSetDirectory  = uvSetsDirectory.Subdirectory(uvSetName);
        var texturedVertexInfos           = uvSetDirectory.File("textured-vertex-infos.array").ReadArray <TexturedVertexInfo>();

        var texturesDirectory   = dataDir.Subdirectory("textures");
        var textureLoader       = new TextureLoader(device, textureCache, texturesDirectory);
        var normalMapsBySurface = recipe.TextureNamesBySurface
                                  .Select(name => name != ShapeNormalsRecipe.DefaultTextureName ? name : null)
                                  .Select(name => textureLoader.Load(name, TextureLoader.DefaultMode.Bump))
                                  .ToArray();

        return(new ShapeNormals(textureLoader, texturedVertexInfos, normalMapsBySurface));
    }
Beispiel #9
0
        /// <summary>
        /// Imports a file.
        /// </summary>
        public void Import(IArchiveDirectory directory, string fileName)
        {
            var fi = new FileInfo(fileName);

            var fs    = new FileStream(fileName, FileMode.Open);
            var fsR   = new DataReader(fs);
            var ident = fsR.ReadUInt32();

            fs.Close();


            // delete existing file
            var existingFile = directory.GetFile(fi.Name);

            if (existingFile != null)
            {
                directory.DeleteFile(existingFile);
            }


            if (ident == 0x07435352)
            {
                var newF = directory.CreateResourceFile();
                newF.Name = fi.Name;
                newF.Import(fileName);
            }
            else
            {
                var newF = directory.CreateBinaryFile();
                newF.Name = fi.Name;
                newF.Import(fileName);
            }
        }
    public static AnimationModel Load(FigureDefinition figureDefinition, string startingAnimationName)
    {
        List <Animation> animations      = new List <Animation>();
        Animation        activeAnimation = null;

        Animation noneAnimation = Animation.MakeNone(figureDefinition.BoneSystem);

        animations.Add(noneAnimation);
        activeAnimation = noneAnimation;

        IArchiveDirectory animationDir = figureDefinition.Directory.Subdirectory("animations");

        if (animationDir != null)
        {
            foreach (IArchiveFile animationFile in animationDir.GetFiles())
            {
                Animation animation = Animation.Load(animationFile);
                animations.Add(animation);
                if (animation.Label == startingAnimationName)
                {
                    activeAnimation = animation;
                }
            }
        }

        return(new AnimationModel(animations, activeAnimation));
    }
            static void CopyIntoRecursive(FileSystemArchiveDirectory from, IArchiveDirectory to, string rename)
            {
                foreach (var fromFile in from.Files)
                {
                    var toFile = to.Files.GetFile(fromFile.Name);

                    if (toFile is FileSystemArchiveFile toFileSystemFile)
                    {
                        fromFile.FileInfo.CopyTo(toFileSystemFile.FileInfo.FullName, true);
                    }
                    else
                    {
                        using var readStream  = fromFile.OpenRead();
                        using var writeStream = toFile.OpenWrite();

                        readStream.CopyTo(writeStream);
                    }
                }
                foreach (var childFromDirectory in from.Directories)
                {
                    var childToDirectory = to.Directories.GetDirectory(childFromDirectory.Name);

                    CopyIntoRecursive(childFromDirectory, childToDirectory, childFromDirectory.Name);
                }
            }
    public IOccluder Load(IArchiveDirectory occlusionDirectory)
    {
        bool isMainFigure = channelSystem.Parent == null;

        if (isMainFigure)
        {
            IArchiveFile occluderParametersFile = occlusionDirectory.File("occluder-parameters.dat");
            if (occluderParametersFile == null)
            {
                throw new InvalidOperationException("expected main figure to have occlusion system");
            }

            var             occluderParameters      = Persistance.Load <OccluderParameters>(occluderParametersFile);
            OcclusionInfo[] unmorphedOcclusionInfos = OcclusionInfo.UnpackArray(unmorphedOcclusionDirectory.File("occlusion-infos.array").ReadArray <uint>());
            var             occluder = new DeformableOccluder(device, shaderCache, channelSystem, unmorphedOcclusionInfos, occluderParameters);
            return(occluder);
        }
        else
        {
            OcclusionInfo[] figureOcclusionInfos = OcclusionInfo.UnpackArray(occlusionDirectory.File("occlusion-infos.array").ReadArray <uint>());
            OcclusionInfo[] parentOcclusionInfos = OcclusionInfo.UnpackArray(occlusionDirectory.File("parent-occlusion-infos.array").ReadArray <uint>());
            var             occluder             = new StaticOccluder(device, figureOcclusionInfos, parentOcclusionInfos);
            return(occluder);
        }
    }
Beispiel #13
0
 public Shape(string label, IArchiveDirectory directory, ChannelInputs channelInputs, ParentOverride[] parentOverrides)
 {
     Label           = label;
     Directory       = directory;
     ChannelInputs   = channelInputs;
     ParentOverrides = parentOverrides;
 }
Beispiel #14
0
    public FigureRenderer Load(IArchiveDirectory figureDir, MaterialSetAndVariantOption materialSetOption)
    {
        SurfaceProperties surfaceProperties = Persistance.Load <SurfaceProperties>(figureDir.File("surface-properties.dat"));

        var refinementDirectory = figureDir.Subdirectory("refinement");

        var controlMeshDirectory = refinementDirectory.Subdirectory("control");

        int[] surfaceMap = controlMeshDirectory.File("surface-map.array").ReadArray <int>();

        var             refinedMeshDirectory = refinementDirectory.Subdirectory("level-" + surfaceProperties.SubdivisionLevel);
        SubdivisionMesh mesh = SubdivisionMeshPersistance.Load(refinedMeshDirectory);

        int[] controlFaceMap = refinedMeshDirectory.File("control-face-map.array").ReadArray <int>();

        var materialSet = MaterialSet.LoadActive(device, shaderCache, textureCache, dataDir, figureDir, materialSetOption, surfaceProperties);
        var materials   = materialSet.Materials;

        Scatterer scatterer = surfaceProperties.PrecomputeScattering ? Scatterer.Load(device, shaderCache, figureDir, materialSetOption.MaterialSet.Label) : null;

        var uvSetName = materials[0].UvSet;
        IArchiveDirectory uvSetDirectory = figureDir.Subdirectory("uv-sets").Subdirectory(uvSetName);

        var texturedVertexInfos = uvSetDirectory.File("textured-vertex-infos.array").ReadArray <TexturedVertexInfo>();

        Quad[] texturedFaces = uvSetDirectory.File("textured-faces.array").ReadArray <Quad>();

        var vertexRefiner = new VertexRefiner(device, shaderCache, mesh, texturedVertexInfos);

        FigureSurface[] surfaces = FigureSurface.MakeSurfaces(device, materials.Length, texturedFaces, controlFaceMap, surfaceMap, materialSet.FaceTransparencies);

        HashSet <int> visitedSurfaceIndices = new HashSet <int>();
        List <int>    surfaceOrder          = new List <int>(surfaces.Length);

        bool[] areUnorderedTransparent = new bool[surfaces.Length];

        //first add surfaces with an explicity-set render order
        foreach (int surfaceIdx in surfaceProperties.RenderOrder)
        {
            visitedSurfaceIndices.Add(surfaceIdx);
            surfaceOrder.Add(surfaceIdx);
            areUnorderedTransparent[surfaceIdx] = false;
        }

        //then add any remaining surfaces
        for (int surfaceIdx = 0; surfaceIdx < surfaces.Length; ++surfaceIdx)
        {
            if (visitedSurfaceIndices.Contains(surfaceIdx))
            {
                continue;
            }
            surfaceOrder.Add(surfaceIdx);
            areUnorderedTransparent[surfaceIdx] = true;
        }

        var isOneSided = figureDir.Name == "genesis-3-female";         //hack

        return(new FigureRenderer(device, shaderCache, scatterer, vertexRefiner, materialSet, surfaces, isOneSided, surfaceOrder.ToArray(), areUnorderedTransparent));
    }
Beispiel #15
0
 public static IArchiveFile File(this IArchiveDirectory dir, string[] path)
 {
     for (int i = 0; i < path.Length - 1; ++i)
     {
         dir = dir.Subdirectory(path[i]);
     }
     return(dir.File(path[path.Length - 1]));
 }
 public TextureLoader(Device device, TextureCache textureCache, IArchiveDirectory texturesDirectory)
 {
     this.device                 = device;
     this.textureCache           = textureCache;
     this.texturesDirectory      = texturesDirectory;
     this.defaultStandardTexture = MakeMonochromeTexture(device, Vector4.One);
     this.defaultBumpTexture     = MakeMonochromeTexture(device, new Vector4(0.5f, 0.5f, 1, 1));
 }
        public void Initialize()
        {
            Debug.WriteLine(this, "Begin initializing");
            Logger.Debug("Begin initializing");
            _fileManager.ReferenceLoudness = _engine.VolumeReferenceLoudness;
            ArchiveDirectory      = EngineController.Database.LoadArchiveDirectory <ArchiveDirectory>(this, _engine.IdArchive);
            MediaDirectoryPRI     = ((CasparServerChannel)_engine.PlayoutChannelPRI)?.Owner.MediaDirectory;
            MediaDirectorySEC     = ((CasparServerChannel)_engine.PlayoutChannelSEC)?.Owner.MediaDirectory;
            MediaDirectoryPRV     = ((CasparServerChannel)_engine.PlayoutChannelPRV)?.Owner.MediaDirectory;
            AnimationDirectoryPRI = ((CasparServerChannel)_engine.PlayoutChannelPRI)?.Owner.AnimationDirectory;
            AnimationDirectorySEC = ((CasparServerChannel)_engine.PlayoutChannelSEC)?.Owner.AnimationDirectory;
            AnimationDirectoryPRV = ((CasparServerChannel)_engine.PlayoutChannelPRV)?.Owner.AnimationDirectory;
            IMediaDirectory[] initializationList = { MediaDirectoryPRI, MediaDirectorySEC, MediaDirectoryPRV, AnimationDirectoryPRI, AnimationDirectorySEC, AnimationDirectoryPRV, ArchiveDirectory };
            foreach (var mediaDirectory in initializationList.Distinct())
            {
                (mediaDirectory as MediaDirectory)?.Initialize();
            }
            if (ArchiveDirectory != null)
            {
                ArchiveDirectory.MediaDeleted += ArchiveDirectory_MediaDeleted;
            }

            ServerDirectory sdir = MediaDirectoryPRI as ServerDirectory;

            if (sdir != null)
            {
                sdir.MediaPropertyChanged += _serverMediaPropertyChanged;
                sdir.PropertyChanged      += _onServerDirectoryPropertyChanged;
                sdir.MediaSaved           += _onServerDirectoryMediaSaved;
                sdir.MediaVerified        += _mediaPRIVerified;
                sdir.MediaRemoved         += _mediaPRIRemoved;
            }
            sdir = MediaDirectorySEC as ServerDirectory;
            if (MediaDirectoryPRI != MediaDirectorySEC && sdir != null)
            {
                sdir.MediaPropertyChanged += _serverMediaPropertyChanged;
                sdir.PropertyChanged      += _onServerDirectoryPropertyChanged;
                sdir.MediaSaved           += _onServerDirectoryMediaSaved;
            }
            AnimationDirectory adir = AnimationDirectoryPRI as AnimationDirectory;

            if (adir != null)
            {
                adir.PropertyChanged      += _onAnimationDirectoryPropertyChanged;
                adir.MediaAdded           += _onAnimationDirectoryMediaAdded;
                adir.MediaRemoved         += _onAnimationDirectoryMediaRemoved;
                adir.MediaPropertyChanged += _onAnimationDirectoryMediaPropertyChanged;
            }
            adir = AnimationDirectorySEC as AnimationDirectory;
            if (adir != null)
            {
                adir.PropertyChanged += _onAnimationDirectoryPropertyChanged;
            }

            _loadIngestDirs(Path.Combine(Directory.GetCurrentDirectory(), ConfigurationManager.AppSettings["IngestFolders"]));
            Debug.WriteLine(this, "End initializing");
            Logger.Debug("End initializing");
        }
Beispiel #18
0
        public void Initialize()
        {
            Debug.WriteLine(this, "Begin initializing");
            Logger.Debug("Begin initializing");
            _fileManager.ReferenceLoudness = _engine.VolumeReferenceLoudness;
            var archiveDirectory = EngineController.Database.LoadArchiveDirectory <ArchiveDirectory>(this, _engine.IdArchive);

            ArchiveDirectory      = archiveDirectory;
            MediaDirectoryPRI     = ((CasparServerChannel)_engine.PlayoutChannelPRI)?.Owner.MediaDirectory;
            MediaDirectorySEC     = ((CasparServerChannel)_engine.PlayoutChannelSEC)?.Owner.MediaDirectory;
            MediaDirectoryPRV     = ((CasparServerChannel)_engine.PlayoutChannelPRV)?.Owner.MediaDirectory;
            AnimationDirectoryPRI = ((CasparServerChannel)_engine.PlayoutChannelPRI)?.Owner.AnimationDirectory;
            AnimationDirectorySEC = ((CasparServerChannel)_engine.PlayoutChannelSEC)?.Owner.AnimationDirectory;
            AnimationDirectoryPRV = ((CasparServerChannel)_engine.PlayoutChannelPRV)?.Owner.AnimationDirectory;
            IWatcherDirectory[] initializationList = { MediaDirectoryPRI, MediaDirectorySEC, MediaDirectoryPRV, AnimationDirectoryPRI, AnimationDirectorySEC, AnimationDirectoryPRV };
            foreach (var mediaDirectory in initializationList.Distinct())
            {
                (mediaDirectory as WatcherDirectory)?.Initialize();
            }
            if (archiveDirectory != null)
            {
                archiveDirectory.MediaRemoved += ArchiveDirectory_MediaRemoved;
            }

            if (MediaDirectoryPRI is ServerDirectory sdir)
            {
                sdir.MediaPropertyChanged += _serverMediaPropertyChanged;
                sdir.PropertyChanged      += _serverDirectoryPropertyChanged;
                sdir.MediaSaved           += _serverDirectoryMediaSaved;
                sdir.MediaVerified        += _mediaPRIVerified;
                sdir.MediaRemoved         += _mediaPRIRemoved;
            }
            sdir = MediaDirectorySEC as ServerDirectory;
            if (MediaDirectoryPRI != MediaDirectorySEC && sdir != null)
            {
                sdir.MediaPropertyChanged += _serverMediaPropertyChanged;
                sdir.PropertyChanged      += _serverDirectoryPropertyChanged;
                sdir.MediaSaved           += _serverDirectoryMediaSaved;
            }
            if (AnimationDirectoryPRI is AnimationDirectory adir)
            {
                adir.MediaSaved           += _animationDirectoryMediaSaved;
                adir.PropertyChanged      += _animationDirectoryPropertyChanged;
                adir.MediaAdded           += _animationDirectoryMediaAdded;
                adir.MediaRemoved         += _animationDirectoryMediaRemoved;
                adir.MediaPropertyChanged += _animationDirectoryMediaPropertyChanged;
            }
            adir = AnimationDirectorySEC as AnimationDirectory;
            if (adir != null)
            {
                adir.PropertyChanged += _animationDirectoryPropertyChanged;
            }

            LoadIngestDirs();
            Debug.WriteLine(this, "End initializing");
            Logger.Debug("End initializing");
        }
Beispiel #19
0
    public static List <Character> LoadList(IArchiveDirectory dataDir)
    {
        var dir        = dataDir.Subdirectory("characters");
        var characters = dir.GetFiles()
                         .Select(file => Persistance.Load <Character>(file))
                         .ToList();

        return(characters);
    }
Beispiel #20
0
        /// <summary>
        /// Removes the current directory.
        /// </summary>
        /// <param name="dir">Directory to remove.</param>
        public static bool Remove(this IArchiveDirectory dir)
        {
            if (dir.Parent is IArchiveDirectory directory)
            {
                return(directory.RemoveDirectory(dir.Name));
            }

            return(false);
        }
Beispiel #21
0
    public static Shape Load(ChannelSystem channelSystem, IArchiveDirectory shapeDirectory)
    {
        var channelInputsFile = shapeDirectory.File("channel-inputs.dat");
        var channelInputs     = LoadChannelInputs(channelSystem, channelInputsFile);

        var parentOverridesFile = shapeDirectory.File("parent-overrides.dat");
        var parentOverrides     = LoadParentOverrides(channelSystem, parentOverridesFile);

        return(new Shape(shapeDirectory.Name, shapeDirectory, channelInputs, parentOverrides));
    }
Beispiel #22
0
        /// <summary>
        /// Gets the total size of items in the directory.
        /// </summary>
        /// <param name="useUncompressedSize">Use the uncompressed sizes.</param>
        /// <param name="includeSubdirectories">Include subdirectories in iteration.</param>
        public static int GetTotalSize(this IArchiveDirectory self, bool useUncompressedSize = true, bool includeSubdirectories = true)
        {
            int totalSize = 0;

            foreach (var item in self)
            {
                if (item is IArchiveDirectory dir && includeSubdirectories)
                {
                    totalSize += dir.GetTotalSize(useUncompressedSize);
                }
 private static string MakeFullName(IArchiveDirectory parent, string key)
 {
     if (parent == null || string.IsNullOrEmpty(parent.FullName))
     {
         return(key);
     }
     else
     {
         return($"{parent.FullName}/{key}");
     }
 }
    public ImageBasedLightingEnvironment(Device device, StandardSamplers standardSamplers, IArchiveDirectory dataDir, string environmentName, float rotation)
    {
        this.device           = device;
        this.standardSamplers = standardSamplers;
        this.dataDir          = dataDir;

        constantBufferManager = new ConstantBufferManager <ShaderConstants>(device);

        EnvironmentName = environmentName;
        Rotation        = rotation;
    }
    public static List <Outfit> LoadList(IArchiveDirectory dataDir)
    {
        var outfitsDir = dataDir.Subdirectory("outfits");
        var outfits    = outfitsDir.GetFiles()
                         .Select(outfitFile => Persistance.Load <Outfit>(outfitFile))
                         .Concat(new List <Outfit> {
            Naked
        })
                         .ToList();

        return(outfits);
    }
Beispiel #26
0
    public static Scatterer Load(Device device, ShaderCache shaderCache, IArchiveDirectory figureDir, String materialSetName)
    {
        var             l0GeometryDir = figureDir.Subdirectory("refinement").Subdirectory("level-0");
        SubdivisionMesh level0Mesh    = SubdivisionMeshPersistance.Load(l0GeometryDir);

        var scatteringDir      = figureDir.Subdirectory("scattering").Subdirectory(materialSetName);
        var formFactorSegments = scatteringDir.File(FormFactorSegmentsFilename).ReadArray <ArraySegment>();
        var formFactorElements = scatteringDir.File(FormFactoryElementsFilename).ReadArray <Vector3WeightedIndex>();
        var formFactors        = new PackedLists <Vector3WeightedIndex>(formFactorSegments, formFactorElements);

        return(new Scatterer(device, shaderCache, level0Mesh, formFactors));
    }
Beispiel #27
0
    public static Shape LoadDefault(ChannelSystem channelSystem, IArchiveDirectory figureDirectory)
    {
        var channelInputsFile = figureDirectory.File("channel-inputs.dat");
        var channelInputs     = channelInputsFile != null?
                                LoadChannelInputs(channelSystem, channelInputsFile) :
                                    channelSystem.MakeDefaultChannelInputs();

        var parentOverridesFile = figureDirectory.File("parent-overrides.dat");
        var parentOverrides     = LoadParentOverrides(channelSystem, parentOverridesFile);

        return(new Shape(DefaultLabel, null, channelInputs, parentOverrides));
    }
    public FramePreparer(IArchiveDirectory dataDir, Device device, ShaderCache shaderCache, StandardSamplers standardSamplers, Size2 targetSize)
    {
        this.standardSamplers = standardSamplers;

        deferredContext = new DeviceContext(device);
        viewProjectionTransformBufferManager = new ViewProjectionConstantBufferManager(device);
        passController             = new RenderPassController(device, shaderCache, targetSize);
        masker                     = new HiddenAreaMasker(device, shaderCache);
        trackedDeviceBufferManager = new TrackedDeviceBufferManager(device);
        controllerManager          = new ControllerManager();
        scene = new Scene(dataDir, device, shaderCache, standardSamplers, trackedDeviceBufferManager, controllerManager);
    }
        public DirectoryViewModel(IArchiveDirectory directory, DirectoryViewModel parent)
        {
            this.directory       = directory;
            this.parentDirectory = parent;

            childDirectories = new List <DirectoryViewModel>();
            foreach (var f in directory.GetDirectories())
            {
                var dd = new DirectoryViewModel(f, this);
                childDirectories.Add(dd);
            }
        }
        private static void CopyResource(IArchiveResourceFile sourceResource, IArchiveDirectory targetDirectory)
        {
            var resourceStream = new MemoryStream();

            sourceResource.Export(resourceStream);

            var targetResource = targetDirectory.CreateResourceFile();

            targetResource.Name     = sourceResource.Name;
            resourceStream.Position = 0;
            targetResource.Import(resourceStream);
        }
 public VendorPusher(
     Lazy<IItemUpdates<UpdateQuantityHeader, VendorQtyEntry>> inventoryUpdater,
     IItemUpdates<PriceHeader, VendorPriceEntry> costsUpdater,
     IReadyDirectory readyDirectory,
     IFileHelpersCache fileHelpersCache,
     IArchiveDirectory archiveDirectory,
     SystemClock systemClock,
     ILogger logger)
 {
     _inventoryUpdater = inventoryUpdater;
     _readyDirectory = readyDirectory;
     _fileHelpersCache = fileHelpersCache;
     _archiveDirectory = archiveDirectory;
     _systemClock = systemClock;
     _logger = logger;
     _costsUpdater = costsUpdater;
 }
 /// <summary>
 /// Deletes an existing directory inside this directory.
 /// </summary>
 public void DeleteDirectory(IArchiveDirectory directory)
 {
     this.directory.Directories.Remove(((RageArchiveDirectoryWrapper7)directory).directory);
 }
Beispiel #33
0
 private static void NewImport(IArchiveDirectory root, RpfListBuilder.IFileContent fc, IAbsoluteFilePath tmpRpf,
     string name)
 {
     var existingFile = root.GetFile(name);
     var af = root.CreateArchiveFile(tmpRpf.ToString(),
         fc.Type == FileType.Default && existingFile != null ? DetermineType(existingFile) : fc.Type);
     if (existingFile != null)
         root.DeleteFile(existingFile);
     //af.IsCompressed = true;
     af.Name = name;
     af.Import(tmpRpf.ToString());
 }
Beispiel #34
0
        /// <summary>
        /// Imports a file.
        /// </summary>
        public void Import(IArchiveDirectory directory, string fileName)
        {
            var fi = new FileInfo(fileName);

            var fs = new FileStream(fileName, FileMode.Open);
            var fsR = new DataReader(fs);
            var ident = fsR.ReadUInt32();
            fs.Close();

            // delete existing file
            var existingFile = directory.GetFile(fi.Name);
            if (existingFile != null)
                directory.DeleteFile(existingFile);

            if (ident == 0x07435352)
            {

                var newF = directory.CreateResourceFile();
                newF.Name = fi.Name;
                newF.Import(fileName);

            }
            else
            {

                var newF = directory.CreateBinaryFile();
                newF.Name = fi.Name;
                newF.Import(fileName);

            }
        }
Beispiel #35
0
 private void ProcessContent(KeyValuePair<string, RpfListBuilder.IInnerContent> keyValuePair,
     IArchiveDirectory dir)
 {
     Handle(dir, (dynamic) keyValuePair.Value, keyValuePair.Key);
 }
Beispiel #36
0
 private void Handle(IArchiveDirectory root, RpfListBuilder.IDirectory innerD, string name)
 {
     var dir = root.GetDirectory(name);
     foreach (var c in innerD.Contents)
         ProcessContent(c, dir);
 }
Beispiel #37
0
 private void Handle(IArchiveDirectory root, RpfListBuilder.InnerFile file, string name)
 {
     switch (file.Action)
     {
         case ContentAction.Delete:
             var archiveFile = root.GetFile(name);
             if (archiveFile != null)
                 root.DeleteFile(archiveFile);
             break;
         case ContentAction.Import:
         {
             if (!_config.TreatImportsAsInserts)
                 break;
             NewImport(root, file, file.FilePath, name);
             break;
         }
         case ContentAction.Insert:
         {
             NewImport(root, file, file.FilePath, name);
             break;
         }
     }
 }
        public DirectoryViewModel(IArchiveDirectory directory, DirectoryViewModel parent)
        {
            this.directory = directory;
            this.parentDirectory = parent;

            childDirectories = new List<DirectoryViewModel>();
            foreach (var f in directory.GetDirectories())
            {
                var dd = new DirectoryViewModel(f, this);
                childDirectories.Add(dd);
            }
        }
Beispiel #39
0
 private void Handle(IArchiveDirectory root, RpfListBuilder.InnerRpf innerRpf,
     string name)
 {
     var rpf = root.GetFile(name);
     // IMPORTANT: The RPF must have the exact filename like original or it seems to make the RPF corrupt (loading either in RageLib, or in OIV)
     var tmpRpf = _tempPath.GetChildFileWithName(name);
     if (tmpRpf.Exists)
         tmpRpf.FileInfo.Delete();
     try
     {
         rpf.Export(tmpRpf.ToString());
         WriteModdedArchive(innerRpf, tmpRpf);
         NewImport(root, innerRpf, tmpRpf, name);
     }
     finally
     {
         tmpRpf.FileInfo.Delete();
     }
 }