public override object Load(string path, VFS.IFileSystem fs) { var obj = fs.ReadLines($"{path}.{FileExtension}"); var fileData = obj.Aggregate("", (a, b) => a + b + "\r\n"); return(new ConfigTable(Parser.Parse(fileData))); }
public override object Load(string path, VFS.IFileSystem fs) { using (BinaryReader b = new BinaryReader(File.Open(path, FileMode.Open))) return(null); }
public override object Load(string path, VFS.IFileSystem fs) { var bytes = fs.ReadBytes($"{path}.{FileExtension}"); Texture texture; using (var stream = new MemoryStream(bytes)) { var bmp = new Bitmap(stream); texture = new Texture(bmp, path); } return(texture); }
public ResourceManager(VFS.IFileSystem _fs) { FS = _fs; _resourceConstructors = new Dictionary <string, ResorceConstructor>() { { ConfigResource.FileExtension, (path, target, fs) => new ConfigResource(path, target, fs) }, { LuaScriptResource.FileExtension, (path, target, fs) => new LuaScriptResource(path, target, fs) }, { MeshesResource.FileExtension, (path, target, fs) => new MeshesResource(path, target, fs) }, { TextureJpegResource.FileExtension, (path, target, fs) => new TextureJpegResource(path, target, fs) }, { TexturePngResource.FileExtension, (path, target, fs) => new TexturePngResource(path, target, fs) }, { BezierCurveResource.FileExtension, (path, target, fs) => new BezierCurveResource(path, target, fs) }, }; }
public override object Load(string path, VFS.IFileSystem fs) { var parser = ConfigResource.Parser; var text = fs .ReadLines($"{path}.{FileExtension}") .Aggregate("", (a, b) => a + b + "\r\n"); var data = new ConfigTable(parser.Parse(text)); var length = int.Parse(data["curve"]["amount"]) - 1; var segments = new BezierCurve.Segment[length]; for (int i = 0; i < length; i++) { var start = Vec3.Parse(data["s" + i]["start"]); var end = Vec3.Parse(data["s" + i]["end"]); var dirStart = Vec3.Parse(data["s" + i]["dir_start"]); var dirEnd = Vec3.Parse(data["s" + i]["dir_end"]); segments[i] = new BezierCurve.Segment(start, end, dirStart, dirEnd); } return(new BezierCurve(segments.ToList(), 10)); }
public MeshesResourceBin(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
public ConfigResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
public override object Load(string path, VFS.IFileSystem fs) { var text = fs.ReadAllText($"{path}.{FileExtension}"); return(new Script(path, text)); }
public LuaScriptResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
public TexturePngResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
public override object Load(string path, VFS.IFileSystem fs) { var obj = fs.ReadLines($"{path}.{FileExtension}"); var vert = new List <Vec3>(); var uvw = new List <Vec3>(); var normals = new List <Vec3>(); var vertexIndices = new List <uint>(); var normalIndices = new List <uint>(); var uvwIndices = new List <uint>(); var lines = obj .Select(s => s.Split(new[] { '/', ' ' }, StringSplitOptions.RemoveEmptyEntries)) .Where(arr => arr.Length != 0); foreach (var str in lines) { if (str[0] == "v") { vert.Add(new Vec3(float.Parse(str[1], NumberStyles.Any, GetParsingCulture), float.Parse(str[2], NumberStyles.Any, GetParsingCulture), float.Parse(str[3], NumberStyles.Any, GetParsingCulture)) ); } if (str[0] == "vn") { normals.Add(new Vec3(float.Parse(str[1], NumberStyles.Any, GetParsingCulture), float.Parse(str[2], NumberStyles.Any, GetParsingCulture), float.Parse(str[3], NumberStyles.Any, GetParsingCulture)) ); } if (str[0] == "vt") { uvw.Add(new Vec3(float.Parse(str[1], NumberStyles.Any, GetParsingCulture), 1 - float.Parse(str[2], NumberStyles.Any, GetParsingCulture), 0.0f) // todo: delete this zero!! ); } if (str[0] == "f" && str.Length - 1 == 6) // w/out texture coords { vertexIndices.Add(uint.Parse(str[1]) - 1); normalIndices.Add(uint.Parse(str[2]) - 1); vertexIndices.Add(uint.Parse(str[3]) - 1); normalIndices.Add(uint.Parse(str[4]) - 1); vertexIndices.Add(uint.Parse(str[5]) - 1); normalIndices.Add(uint.Parse(str[6]) - 1); } if (str[0] == "f" && str.Length - 1 == 9) // with texture coords { vertexIndices.Add(uint.Parse(str[1]) - 1); uvwIndices.Add(uint.Parse(str[2]) - 1); normalIndices.Add(uint.Parse(str[3]) - 1); vertexIndices.Add(uint.Parse(str[4]) - 1); uvwIndices.Add(uint.Parse(str[5]) - 1); normalIndices.Add(uint.Parse(str[6]) - 1); vertexIndices.Add(uint.Parse(str[7]) - 1); uvwIndices.Add(uint.Parse(str[8]) - 1); normalIndices.Add(uint.Parse(str[9]) - 1); } } if (uvw.Count == 0) { uvwIndices = vertexIndices; uvw = vert; } return(new Mesh( vert.ToArray(), uvw.ToArray(), normals.ToArray(), vertexIndices.ToArray(), uvwIndices.ToArray(), normalIndices.ToArray() )); }
public BezierCurveResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
/// <summary> /// Loads resource from the specified path. Parses it to <see cref="Resource"/> property. /// </summary> /// <param name="path">Path to file which contains specified type of resource.</param> /// <remarks> /// <paramref name="path"/> is not contains: /// - path to gamedata, /// - folder name inside gamedata, /// - file extention. /// </remarks> public abstract object Load(string path, VFS.IFileSystem fs);
protected Resource(string path, ResourceTarget target, VFS.IFileSystem fs) { Target = target; RC = Load(path, fs); }