Ejemplo n.º 1
0
        public bool CheckConsistency(string[] inputFiles)
        {
            MyRenderProxy.Assert(inputFiles.Length != 0);
            MyFileTextureManager texManager       = MyManagers.FileTextures;
            ISrvBindable         firstSrvBindable = texManager.GetTexture(inputFiles[0], MyFileTextureEnum.GPUPARTICLES, true);
            Texture2D            firstTex2D       = firstSrvBindable.Resource as Texture2D;

            if (firstTex2D == null)
            {
                return(false);
            }
            for (int i = 1; i < inputFiles.Length; i++)
            {
                ISrvBindable srvBindable = texManager.GetTexture(inputFiles[i], MyFileTextureEnum.GPUPARTICLES, true);
                Texture2D    tex2D       = srvBindable.Resource as Texture2D;
                if (tex2D == null)
                {
                    return(false);
                }
                bool consistent = MyResourceUtils.CheckTexturesConsistency(firstTex2D.Description, tex2D.Description);

                if (!consistent)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        static void ParseAtlasDescription(string textureDir, string atlasFile, out Dictionary <string, Element> atlasDict)
        {
            atlasDict = new Dictionary <string, Element>();
            MyFileTextureManager texManager = MyManagers.FileTextures;

            try
            {
                //var atlas = new MyTextureAtlas(64);
                var fsPath = Path.Combine(MyFileSystem.ContentPath, atlasFile);
                using (var file = MyFileSystem.OpenRead(fsPath))
                    using (StreamReader sr = new StreamReader(file))
                    {
                        while (!sr.EndOfStream)
                        {
                            string line = sr.ReadLine();

                            if (line.StartsWith("#"))
                            {
                                continue;
                            }
                            if (line.Trim(' ').Length == 0)
                            {
                                continue;
                            }

                            string[] parts = line.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);

                            string name      = parts[0];
                            string atlasName = parts[1];

                            Vector4 uv = new Vector4(
                                Convert.ToSingle(parts[4], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[5], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[7], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[8], System.Globalization.CultureInfo.InvariantCulture));

                            name = textureDir + System.IO.Path.GetFileName(name);
                            var atlasTexture = textureDir + atlasName;

                            var element = new Element();
                            element.Texture       = texManager.GetTexture(atlasTexture, MyFileTextureEnum.GUI, true);
                            element.UvOffsetScale = uv;
                            atlasDict[name]       = element;
                        }
                    }
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLine("Warning: " + e.ToString());
            }
        }