techkaczynski.dev / code

summaryrefslogtreecommitdiff
path: root/fgsf_spec.txt
blob: 6978afa1f1cf6d603fab2a522e3e9a3a4b1ab92c (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
FUN GAME SAVE FILE FORMAT VERSION 0.3
	- 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

VERSION CHANGES
	0.3:
		Added root_body to identify which body drives the entity pose.
		Stored after body_cnt; adds 4 bytes per physics component.
		Zero-based body index. Empty rigs store 0.

	0.2:
		Replaced axis_a/axis_b with frame_rot_a/frame_rot_b.
		Joint records increased from 85 to 93 bytes.

CHUNK LABELS
	- ENVR
	- ENTT
	- TRFM
	- MODL
	- MTEX
	- MUVS
	- MSHD
	- PHYS

DATA RECORDS
	- environment record
	- entity record
	- transform component record
	- model component record
	- texture override record
	- texcoord override record
	- shader override 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

ENVR
	f32 day_start
	f32 day_len

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

MTEX
	u32 texture_override_cnt

	repeat texture_override_cnt:
		u64 entity_pid
		u32 material_idx
		u32 key_len
		char[key_len] texture_key

MUVS
	u32 material_uv_cnt

	repeat material_uv_cnt:
		u64 entity_pid
		u32 material_idx
		f32[2] uv_scale
		f32[2] uv_offset

MSHD
	u32 shader_override_cnt

	repeat shader_override_cnt:
		u64 entity_pid
		u32 material_idx
		u32 key_len
		char[key_len] shader_key

PHYS
	u32 physics_cnt

	repeat physics_cnt:
		u64 pid
		u32 body_cnt
		u32 root_body
			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[4] axis_a
	f32[4] axis_b
	f32 lower
	f32 upper
	f32 spring_hz
	f32 spring_damping
	f32 motor_speed
	f32 motor_force