Пример #1
0
        public Texture(AssetManager assetManager, IReadableFileSystem fileSystem, string path)
        {
            this.Id = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, this.Id);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);

            var tga = new Tga(fileSystem.Read(path) !);

            GL.TexImage2D(
                TextureTarget.Texture2D,
                0,
                PixelInternalFormat.Rgba8,
                tga.Width,
                tga.Height,
                0,
                PixelFormat.Rgba,
                PixelType.UnsignedByte,
                tga.Pixels
                );
        }
Пример #2
0
        public XbfMesh(AssetManager assetManager, IReadableFileSystem fileSystem, string path)
        {
            this.assetManager = assetManager;

            var xbf = new Xbf(fileSystem.Read(path) !);

            this.Name = Path.GetFileNameWithoutExtension(path);

            // TODO: Some textures are using additional flags by prefixing their filenames:
            // TODO: = => apply player color to 0000?? pixels
            // TODO: ! => render additive
            // TODO: % might be ""
            // TODO: @ might be ""

            this.Children = xbf.Objects.Select(
                xbfObject => XbfMesh.LoadXbfObject(
                    xbfObject,
                    this.assetManager.Load <XbfShader>(this),
                    xbf.Textures.Select(
                        name =>
            {
                try
                {
                    return(this.assetManager.Load <Texture>(this, $"Textures/{name}").Id);
                }
                catch (Exception)
                {
                    return(this.assetManager.Load <Texture>(this, "Textures/white.tga").Id);
                }
            }
                        )
                    .ToArray()
                    )
                )
                            .ToArray();
        }