EuropaTools/datadoc/imhex/msh.hexpat
modeco80 2a2d7073a3 *: move //hexpat to //datadoc/imhex
This commit moves the existing files to better fitting places. It is part of a documentation rework I'm doing.
2025-01-20 00:03:19 -05:00

81 lines
No EOL
1.5 KiB
Text

//
// EuropaTools
//
// (C) 2021-2025 modeco80 <lily.modeco80@protonmail.ch>
//
// SPDX-License-Identifier: MIT
//
import std.io;
import std.mem;
// Fundamental Types
struct Vec3 {
float x;
float y;
float z;
// std::print("Vec3: {:4.4f}, {:4.4f}, {:4.4f}",
// x,
// y,
// z
//);
};
struct Uvf {
float u;
float v;
};
struct Face {
u16 faceX;
u16 faceY;
u16 faceZ;
};
// Europa .MSH types
// a generic block
struct tMeshBlock<Item> {
u16 count;
// count == 0 means no items in block
if(count != 0) {
std::print("Block with {:6d} items", count);
Item items[count];
}
};
// Used for vertex colors.
struct VertexColor {
u8 r;
u8 g;
u8 b;
u8 a;
};
struct UvBlockEntry {
Uvf uvs[parent.parent.vertexBlock.count];
};
struct MeshPiece {
char mtl_filename[while(std::mem::read_unsigned($-1, 1) != '\n')];
tMeshBlock<Vec3> vertexBlock;
tMeshBlock<VertexColor> vertexColorBlock;
tMeshBlock<Vec3> normalBlock;
tMeshBlock<UvBlockEntry> uvBlock;
tMeshBlock<Face> faceBlock;
};
struct MshFile {
// This should just be read as lines in any real code.
// I just do this to feel something
char magic[while(std::mem::read_unsigned($-1, 1) != '\n')];
char version[while(std::mem::read_unsigned($, 1) != '\n')];
char dummy; // fuckkk dude
// There is a meshpiece per material change I guess.
tMeshBlock<MeshPiece> meshPieceBlock;
};
MshFile msh @ 0;