diff --git a/BlendFile/BlendFile.csproj b/BlendFile/BlendFile.csproj index 3a63532..f45969b 100644 --- a/BlendFile/BlendFile.csproj +++ b/BlendFile/BlendFile.csproj @@ -6,4 +6,14 @@ enable + + + + + + + BlendFile.cs + + + diff --git a/BlendFile/Reader.cs b/BlendFile/Reader.cs new file mode 100644 index 0000000..20f0c3b --- /dev/null +++ b/BlendFile/Reader.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using Kaitai; + + +namespace BlendFile; + +public class Reader { + readonly string _path; + private readonly Dictionary dnaTypes = new(); + + private List objects = new(); + public List Objects => objects; + + public Reader(string path) { + _path = path; + var types = Assembly.GetExecutingAssembly().DefinedTypes; + foreach (var type in types) { + var attrib = type.GetCustomAttribute(); + if (attrib ==null) continue; + dnaTypes.Add(attrib.OriginalIndex, type); + } + } + + public void Read() { + var file = new KaitaiStream(_path); + var blend = new Kaitai.BlendFile(file); + + foreach (var block in blend.Blocks) { + Type t = dnaTypes[(int)block.SdnaIndex]; + var obj = Activator.CreateInstance(t); + if(obj == null) continue; + objects.Add(obj); + + foreach (var field in t.GetFields()) { + var attrib = field.GetCustomAttribute(); + if (attrib == null) continue; + + } + } + + } +} \ No newline at end of file diff --git a/CodeGenerator/BlenderBlend.cs b/CodeGenerator/BlendFile.cs similarity index 100% rename from CodeGenerator/BlenderBlend.cs rename to CodeGenerator/BlendFile.cs