goat3d
view src/chunk.h @ 23:b59a3650ed51
mac fixes
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 27 Sep 2013 07:20:22 +0300 |
parents | 798df5111b56 |
children | da3f335e0069 |
line source
1 #ifndef CHUNK_H_
2 #define CHUNK_H_
4 #include <stdint.h>
6 enum {
7 CNK_INVALID, // this shouldn't appear in files
8 CNK_SCENE, // the root chunk
10 // general purpose chunks
11 CNK_INT,
12 CNK_INT4,
13 CNK_FLOAT,
14 CNK_FLOAT3,
15 CNK_FLOAT4,
16 CNK_STRING,
18 // --- first level chunks ---
19 // children of CNK_SCENE
20 CNK_ENV, // environmental parameters
21 CNK_MTL, // material
22 CNK_MESH,
23 CNK_LIGHT,
24 CNK_CAMERA,
25 CNK_NODE,
27 // --- second level chunks ---
28 // children of CNK_ENV
29 CNK_ENV_AMBIENT, // ambient color, contains a single CNK_FLOAT3
30 CNK_ENV_FOG,
32 // --- third level chunks ---
33 // children of CNK_FOG
34 CNK_FOG_COLOR, // fog color, contains a single CNK_FLOAT3
35 CNK_FOG_EXP, // fog exponent, contains a single CNK_FLOAT
37 // children of CNK_MTL
38 CNK_MTL_NAME, // has a single CNK_STRING
39 CNK_MTL_ATTR, // material attribute, has a CNK_STRING for its name,
40 // a CNK_MTL_ATTR_VAL, and optionally a CNK_MTL_ATTR_MAP
41 // children of CNK_MTL_ATTR
42 CNK_MTL_ATTR_NAME, // has a single CNK_STRING
43 CNK_MTL_ATTR_VAL, // can have a single CNK_FLOAT, CNK_FLOAT3, or CNK_FLOAT4
44 CNK_MTL_ATTR_MAP, // has a single CNK_STRING
46 // children of CNK_MESH
47 CNK_MESH_NAME, // has a single CNK_STRING
48 CNK_MESH_MATERIAL, // has one of CNK_STRING or CNK_INT to identify the material
49 CNK_MESH_VERTEX_LIST, // has a series of CNK_FLOAT3 chunks
50 CNK_MESH_NORMAL_LIST, // has a series of CNK_FLOAT3 chunks
51 CNK_MESH_TANGENT_LIST, // has a series of CNK_FLOAT3 chunks
52 CNK_MESH_TEXCOORD_LIST, // has a series of CNK_FLOAT3 chunks
53 CNK_MESH_SKINWEIGHT_LIST, // has a series of CNK_FLOAT4 chunks (4 skin weights)
54 CNK_MESH_SKINMATRIX_LIST, // has a series of CNK_INT4 chunks (4 matrix indices)
55 CNK_MESH_COLOR_LIST, // has a series of CNK_FLOAT4 chunks
56 CNK_MESH_BONES_LIST, // has a series of CNK_INT or CNK_STRING chunks identifying the bone nodes
57 CNK_MESH_FACE_LIST, // has a series of CNK_FACE chunks
58 CNK_MESH_FILE, // optionally mesh data may be in another file, has a CNK_STRING filename
60 // child of CNK_MESH_FACE_LIST
61 CNK_MESH_FACE, // has three CNK_INT chunks
63 // children of CNK_LIGHT
64 CNK_LIGHT_NAME, // has a single CNK_STRING
65 CNK_LIGHT_POS, // has a single CNK_FLOAT3
66 CNK_LIGHT_COLOR, // has a single CNK_FLOAT3
67 CNK_LIGHT_ATTEN, // has a single CNK_FLOAT3 (constant, linear, squared attenuation)
68 CNK_LIGHT_DISTANCE, // has a single CNK_FLOAT
69 CNK_LIGHT_DIR, // a single CNK_FLOAT3 (for spotlights and dir-lights)
70 CNK_LIGHT_CONE_INNER, // single CNK_FLOAT, inner cone angle (for spotlights)
71 CNK_LIGHT_CONE_OUTER, // single CNK_FLOAT, outer cone angle (for spotlights)
73 // children of CNK_CAMERA
74 CNK_CAMERA_NAME, // has a single CNK_STRING
75 CNK_CAMERA_POS, // single CNK_FLOAT3
76 CNK_CAMERA_TARGET, // single CNK_FLOAT3
77 CNK_CAMERA_FOV, // single CNK_FLOAT (field of view in radians)
78 CNK_CAMERA_NEARCLIP, // single CNK_FLOAT (near clipping plane distance)
79 CNK_CAMERA_FARCLIP, // signle CNK_FLOAT (far clipping plane distance)
81 // children of CNK_NODE
82 CNK_NODE_NAME, // node name, a single CNK_STRING
83 CNK_NODE_PARENT, // it can have a CNK_INT or a CNK_STRING to identify the parent node
85 CNK_NODE_MESH, // it can have a CNK_INT or a CNK_STRING to identify this node's mesh
86 CNK_NODE_LIGHT, // same as CNK_NODE_MESH
87 CNK_NODE_CAMERA, // same as CNK_NODE_MESH
89 CNK_NODE_POS, // has a CNK_FLOAT3, position vector
90 CNK_NODE_ROT, // has a CNK_FLOAT4, rotation quaternion (x, y, z imaginary, w real)
91 CNK_NODE_SCALE, // has a CNK_FLOAT3, scaling
92 CNK_NODE_PIVOT, // has a CNK_FLOAT3, pivot point
94 CNK_NODE_MATRIX0, // has a CNK_FLOAT4, first matrix row (4x3)
95 CNK_NODE_MATRXI1, // has a CNK_FLOAT4, second matrix row (4x3)
96 CNK_NODE_MATRIX2, // has a CNK_FLOAT4, third matrix row (4x3)
98 MAX_NUM_CHUNKS
99 };
101 #define UNKNOWN_SIZE ((uint32_t)0xbaadf00d)
103 struct ChunkHeader {
104 uint32_t id;
105 uint32_t size;
106 };
108 struct Chunk {
109 ChunkHeader hdr;
110 char data[1];
111 };
114 ChunkHeader chunk_header(int id);
115 bool write_chunk_header(const ChunkHeader *hdr, goat3d_io *io);
116 bool read_chunk_header(ChunkHeader *hdr, goat3d_io *io);
117 void skip_chunk(const ChunkHeader *hdr, goat3d_io *io);
120 #endif // CHUNK_H_