techkaczynski.dev / code

summaryrefslogtreecommitdiff
path: root/fgsf_spec.txt
blob: ce302cefe668c8e0b072846a36e7d9e5a60fb14f (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
FUN GAME SAVE FILE FORMAT VERSION 0.1
	- little endian
	- 32-bit IEEE-754 floats
	- UTF-8 strings which are *not* null terminated
	- units are metric and 1 unit is 1 meter
	- quaternions are xyzw and need normalization
	- pids start at 1 and are monotonic, 0 is reserved for null parent

CHUNK LABELS
	- ENTT
	- TRFM
	- MODL
	- PHYS

DATA RECORDS
	- entity record
	- transform component record
	- model component record
	- physics component record
		- physics body record
		- physics shape record
			- box
			- sphere
			- cylinder
			- capsule
			- convex hull
			- static trimesh
		- physics joint record

FILE HEADER
	char[4] magic "FGSF"
	u16 major
	u16 minor

CHUNK
	char[4] label
	u32 size
	u8[size] data

ENTT
	u64 next_pid
	u32 entity_cnt

	repeat entity_cnt:
		u64 pid
		u32 name_len
		char[name_len] name

TRFM
	u32 transform_cnt

	repeat transform_cnt:
		u64 pid
		u64 parent_pid
		f32[3] pos
		f32[4] rot
		f32[3] scale

MODL
	u32 model_cnt

	repeat model_cnt:
		u64 entity_pid
		u32 key_len
		char[key_len] key
		bool(u8) draw

PHYS
	u32 physics_cnt

	repeat physics_cnt:
		u64 pid
		u32 body_cnt
			body[body_cnt]
		u32 joint_cnt
			joint[joint_cnt]

PHYSICS BODY
	f32[3] pos
	f32[4] rot
	f32 linear_damping
	f32 angular_damping
	f32 gravity_scale
	u8 physics_mode
	bool(u8) enable_sleep
	u32 shape_cnt
		shape[shape_cnt]

PHYSICS SHAPE
	u8 tag
	f32[3] pos
	f32[4] rot
	f32 density
	f32 friction
	f32 restitution
	u32 category_bits
	u32 mask_bits

	switch tag:
		BOX
		f32[3] sz

		SPHERE
		f32 radius

		CYLINDER or CAPSULE
		f32 height
		f32 radius

		CONVEX HULL
		u32 points_cnt
		f32[points_cnt][3] points

		TRIMESH
		u32 point_cnt
		u32 index_cnt
		f32[point_cnt][3] points
		u32[index_cnt] indices

PHYSICS JOINT
	u8 tag
	u32 body_a
	u32 body_b
	u32 flags
	f32[3] anchor_a
	f32[3] anchor_b
	f32[3] axis_a
	f32[3] axis_b
	f32 lower
	f32 upper
	f32 spring_hz
	f32 spring_damping
	f32 motor_speed
	f32 motor_force