-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmesh-file-format.txt
49 lines (34 loc) · 1.63 KB
/
mesh-file-format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
I want a engine-1 specific file format for meshes. Why? I don't need it to be complicated and I want it to be easy to parse with C.
What we need:
* Triangle mesh
* Texture and shader specified per triangle
* Binary
And then I can have Python conversion scripts to this file format, which should be easier than directly parsing the .obj files with C.
I do potentially lose interactivity with this. If I want to make it interactive, I need to save the file from Blender, run a script which converts the .obj to my custom format, then launch the engine. This adds an additional step and slows the time from modeling to inserting in the engine.
File format philosophy: Prepare everything ahead of time. Make parsing the file as easy as possible. There should be no need to calculate additional information at runtime. This violates the philosophy that invalid states should be made unrepresentable, but I think it's a worthwhile tradeoff. I will assume that the tool that generates the script does not lie.
Rendering mesh
{
magic (uint8_t[4]) = "RMSH"
version (uint32_t)
aabb (float[2][3])
texture name length (uint32_t)
vertices length (uint32_t)
faces length (uint32_t)
texture name (uint8_t[texture name length]) // Not null terminated.
vertices (float[vertices length][3])
vertex normals (float[vertices length][3])
vertex texture coordinates (float[faces length][3][2])
faces (uint32_t[faces length][3])
checksum (uint64_t)
}
Collision mesh
{
magic (uint8_t[4]) = "CMSH"
version (uint32_t)
aabb (float[2][3])
vertices length (uint32_t)
faces length (uint32_t)
vertices (float[vertices length][3])
faces (uint32_t[faces length][3])
checksum (uint64_t)
}