2 goat3d - 3D scene, and animation file format library.
3 Copyright (C) 2013-2023 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 CNK_INVALID, /* this shouldn't appear in files */
25 CNK_SCENE, /* the root chunk */
27 /* general purpose chunks */
35 /* --- first level chunks --- */
36 /* children of CNK_SCENE */
37 CNK_ENV, /* environmental parameters */
38 CNK_MTL, /* material */
44 /* --- second level chunks --- */
45 /* children of CNK_ENV */
46 CNK_ENV_AMBIENT, /* ambient color, contains a single CNK_FLOAT3 */
49 /* --- third level chunks --- */
50 /* children of CNK_FOG */
51 CNK_FOG_COLOR, /* fog color, contains a single CNK_FLOAT3 */
52 CNK_FOG_EXP, /* fog exponent, contains a single CNK_FLOAT */
54 /* children of CNK_MTL */
55 CNK_MTL_NAME, /* has a single CNK_STRING */
56 CNK_MTL_ATTR, /* material attribute, has a CNK_STRING for its name, */
57 /* a CNK_MTL_ATTR_VAL, and optionally a CNK_MTL_ATTR_MAP */
58 /* children of CNK_MTL_ATTR */
59 CNK_MTL_ATTR_NAME, /* has a single CNK_STRING */
60 CNK_MTL_ATTR_VAL, /* can have a single CNK_FLOAT, CNK_FLOAT3, or CNK_FLOAT4 */
61 CNK_MTL_ATTR_MAP, /* has a single CNK_STRING */
63 /* children of CNK_MESH */
64 CNK_MESH_NAME, /* has a single CNK_STRING */
65 CNK_MESH_MATERIAL, /* has one of CNK_STRING or CNK_INT to identify the material */
66 CNK_MESH_VERTEX_LIST, /* has a series of CNK_FLOAT3 chunks */
67 CNK_MESH_NORMAL_LIST, /* has a series of CNK_FLOAT3 chunks */
68 CNK_MESH_TANGENT_LIST, /* has a series of CNK_FLOAT3 chunks */
69 CNK_MESH_TEXCOORD_LIST, /* has a series of CNK_FLOAT3 chunks */
70 CNK_MESH_SKINWEIGHT_LIST, /* has a series of CNK_FLOAT4 chunks (4 skin weights) */
71 CNK_MESH_SKINMATRIX_LIST, /* has a series of CNK_INT4 chunks (4 matrix indices) */
72 CNK_MESH_COLOR_LIST, /* has a series of CNK_FLOAT4 chunks */
73 CNK_MESH_BONES_LIST, /* has a series of CNK_INT or CNK_STRING chunks identifying the bone nodes */
74 CNK_MESH_FACE_LIST, /* has a series of CNK_FACE chunks */
75 CNK_MESH_FILE, /* optionally mesh data may be in another file, has a CNK_STRING filename */
77 /* child of CNK_MESH_FACE_LIST */
78 CNK_MESH_FACE, /* has three CNK_INT chunks */
80 /* children of CNK_LIGHT */
81 CNK_LIGHT_NAME, /* has a single CNK_STRING */
82 CNK_LIGHT_POS, /* has a single CNK_FLOAT3 */
83 CNK_LIGHT_COLOR, /* has a single CNK_FLOAT3 */
84 CNK_LIGHT_ATTEN, /* has a single CNK_FLOAT3 (constant, linear, squared attenuation) */
85 CNK_LIGHT_DISTANCE, /* has a single CNK_FLOAT */
86 CNK_LIGHT_DIR, /* a single CNK_FLOAT3 (for spotlights and dir-lights) */
87 CNK_LIGHT_CONE_INNER, /* single CNK_FLOAT, inner cone angle (for spotlights) */
88 CNK_LIGHT_CONE_OUTER, /* single CNK_FLOAT, outer cone angle (for spotlights) */
90 /* children of CNK_CAMERA */
91 CNK_CAMERA_NAME, /* has a single CNK_STRING */
92 CNK_CAMERA_POS, /* single CNK_FLOAT3 */
93 CNK_CAMERA_TARGET, /* single CNK_FLOAT3 */
94 CNK_CAMERA_FOV, /* single CNK_FLOAT (field of view in radians) */
95 CNK_CAMERA_NEARCLIP, /* single CNK_FLOAT (near clipping plane distance) */
96 CNK_CAMERA_FARCLIP, /* signle CNK_FLOAT (far clipping plane distance) */
98 /* children of CNK_NODE */
99 CNK_NODE_NAME, /* node name, a single CNK_STRING */
100 CNK_NODE_PARENT, /* it can have a CNK_INT or a CNK_STRING to identify the parent node */
102 CNK_NODE_MESH, /* it can have a CNK_INT or a CNK_STRING to identify this node's mesh */
103 CNK_NODE_LIGHT, /* same as CNK_NODE_MESH */
104 CNK_NODE_CAMERA, /* same as CNK_NODE_MESH */
106 CNK_NODE_POS, /* has a CNK_FLOAT3, position vector */
107 CNK_NODE_ROT, /* has a CNK_FLOAT4, rotation quaternion (x, y, z imaginary, w real) */
108 CNK_NODE_SCALE, /* has a CNK_FLOAT3, scaling */
109 CNK_NODE_PIVOT, /* has a CNK_FLOAT3, pivot point */
111 CNK_NODE_MATRIX0, /* has a CNK_FLOAT4, first matrix row (4x3) */
112 CNK_NODE_MATRXI1, /* has a CNK_FLOAT4, second matrix row (4x3) */
113 CNK_NODE_MATRIX2, /* has a CNK_FLOAT4, third matrix row (4x3) */
115 CNK_ANIM, /* the animation root chunk */
120 #define UNKNOWN_SIZE ((uint32_t)0xbaadf00d)
122 struct chunk_header {
128 struct chunk_header hdr;
133 void g3dimpl_chunk_header(struct chunk_header *hdr, int id);
134 int g3dimpl_write_chunk_header(const struct chunk_header *hdr, struct goat3d_io *io);
135 int g3dimpl_read_chunk_header(struct chunk_header *hdr, struct goat3d_io *io);
136 void g3dimpl_skip_chunk(const struct chunk_header *hdr, struct goat3d_io *io);
138 #endif /* CHUNK_H_ */