コード例 #1
0
 public void Add(SpriteSet <TVertexData> set)
 {
     foreach (var pair in set.Sprites)
     {
         this.sprites.Add(pair.Key, pair.Value);
     }
     this.spriteSets.Add(set);
 }
コード例 #2
0
ファイル: SpriteSet.cs プロジェクト: photones/awgraphics
        static public SpriteSet <TVertexData> FromJsonFile(
            string filename, Func <IndexedSurface <TVertexData>, UVQuadGeometry <TVertexData> > geometryMaker,
            ISurfaceShader shaderProgram           = null, SurfaceSetting[] surfaceSettings = null,
            Func <string, Texture> textureProvider = null, bool texturesRelativeToJson      = false)
        {
            if (textureProvider == null)
            {
                textureProvider = file => new Texture(file);
            }

            if (texturesRelativeToJson)
            {
                string path         = Path.GetDirectoryName(filename) ?? "";
                var    providerCopy = textureProvider;
                textureProvider = file => providerCopy(Path.Combine(path, file));
            }

            return(SpriteSet <TVertexData> .FromJsonTextReader(File.OpenText(filename), geometryMaker, shaderProgram,
                                                               surfaceSettings, textureProvider));
        }
コード例 #3
0
ファイル: SpriteSet.cs プロジェクト: photones/awgraphics
        public static SpriteSet <TVertexData> Copy <TVertexDataIn>
            (SpriteSet <TVertexDataIn> template, Func <IndexedSurface <TVertexData>, UVQuadGeometry <TVertexData> > geometryMaker,
            ISurfaceShader shaderProgram = null, SurfaceSetting[] surfaceSettings = null, bool keepTextureUniforms = true)
            where TVertexDataIn : struct, IVertexData
        {
            var set = new SpriteSet <TVertexData>(shaderProgram, surfaceSettings);

            foreach (var item in template.sprites)
            {
                set.sprites.Add(item.Key, Sprite <TVertexData>
                                .Copy(item.Value, geometryMaker(set.surface)));
            }

            if (keepTextureUniforms)
            {
                set.surface.AddSettings(template.surface.Settings.Where(setting => setting is TextureUniform));
            }

            return(set);
        }