diff --git a/README.md b/README.md index 73f15aa..eb395d4 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Hex patterns, include patterns and magic files for the use with the ImHex Hex Ed | Bencode | `application/x-bittorrent` | `patterns/bencode.hexpat` | Bencode encoding, used by Torrent files | | Protobuf | | `patterns/protobuf.hexpat` | Google Protobuf encoding | | Ogg | `audio/ogg` | `patterns/ogg.hexpat` | Ogg Audio format | +| Ogg | `model/stl` | `patterns/stl.hexpat` | STL 3D Model format | ### Scripts diff --git a/patterns/stl.hexpat b/patterns/stl.hexpat new file mode 100644 index 0000000..ed2941b --- /dev/null +++ b/patterns/stl.hexpat @@ -0,0 +1,38 @@ +#pragma MIME model/stl +#pragma MIME model/x.stl-binary +#pragma MIME model/x.stl-ascii +#pragma MIME application/sla + +#include +#include + +struct Vector3f { + float x, y, z; +} [[static, format("format_vector3f")]]; + +fn format_vector3f(Vector3f vec) { + return std::format("[ {}, {}, {} ]", vec.x, vec.y, vec.z); +}; + +struct Triangle { + Vector3f normal; + Vector3f points[3]; + u16 flags; +} [[static]]; + +struct BinarySTLHeader { + char caption[]; + padding[80 - sizeof(caption)]; + u32 triangleCount; +}; + +struct STL { + if (std::mem::read_string(0, 6) == "solid ") + std::warning("ASCII STL file!"); + else { + BinarySTLHeader header; + Triangle triangles[header.triangleCount]; + } +}; + +STL stl @ 0x00; \ No newline at end of file