mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
patterns: Added stl pattern
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
38
patterns/stl.hexpat
Normal file
38
patterns/stl.hexpat
Normal file
@@ -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 <std/sys.pat>
|
||||
#include <std/mem.pat>
|
||||
|
||||
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;
|
||||
Reference in New Issue
Block a user