00001 00002 /* WORK IN PROGRESS!!! */ 00003 00004 /* 00005 * .pwn Format definition 00006 * 00007 * This file functions as the actual definition of the .pwn format. Any pwn- 00008 * writer or reader has to comply with the format specified here. 00009 * 00010 * Node hierarchy is listed in a depth-first manner. 00011 * 00012 */ 00013 00014 #ifndef PWN_H 00015 #define PWN_H 00016 00017 #define PWN_STRING_MAX_LENGTH 256 00018 #define PWN_GEOMETRY_MAX_MESHES 1024 00019 #define PWN_GEOMETRY_MAX_ATTRIBUTES 16 00020 #define PWN_GEOMETRY_MAX_ATTRIB_NAME_LENGTH 32 00021 00022 00023 00024 00025 /* 00026 * The .pwn format has the following blocks: 00027 * 00028 * - Header 00029 * - Resources & Nodes 00030 * - Node hierarchy 00031 * 00032 */ 00033 00034 /*---------------------------------------------------------------------------*/ 00035 00036 /* 00037 * Field Type Comment 00038 * 00039 */ 00040 00041 /*---------------------------------------------------------------------------*/ 00042 00043 /* Required */ 00044 00045 /* 00046 * -- Header -- 00047 * 00048 * Header prefix uint "pwnd" 00049 * Major version ushort 00050 * Minor version ushort 00051 * 00052 */ 00053 00054 /* 00055 * -- String pool -- 00056 * 00057 * N strings ushort 00058 * Strings: [N strings] 00059 * String char[] null terminated 00060 * 00061 */ 00062 00063 /* Optional */ 00064 00065 /* 00066 * -- Uniform set -- 00067 * 00068 * Prefix uint "unif" 00069 * N entries ushort 00070 * Uniform values: [N entries] 00071 * Name (String ID) ushort 00072 * Flags uchar Bit 0-1: 0 = uint32, 1 = float32, 00073 * 2 = texture, 3 = cubemap 00074 * Bit 2-3: 0 = scalar, 1 = vector, 00075 * 2 = matrix 00076 * Bit 4-5: 0 = dim2, 1 = dim3, 2 = dim4 00077 * Texture/CubeMap: 00078 * String ID ushort 00079 * uint32/float32: 00080 * N values uchar 00081 * Value(s) varies if scalar: N values 00082 * else if vector: N values * dim 00083 * else if matrix: N values * dim * dim 00084 * 00085 */ 00086 00087 /* 00088 * -- Vertex Array -- 00089 * 00090 * Prefix uint "vtxa" 00091 * Name (string ID) ushort 00092 * N attributes ushort 00093 * Attributes: [N attributes] 00094 * Name (string ID) ushort 00095 * Type size char 00096 * N components char 00097 * N vertices uint 00098 * Attributes char[] read "pad4(stride * N vertices)" 00099 * N indices uint no index array if this equals 0 00100 * Indices uint/ ...if N indices > 65535 00101 * ushort/ ...else if N indices > 255 00102 * uchar ...else 00103 * 00104 */ 00105 00106 /* 00107 * -- Texture -- 00108 * 00109 * Prefix uint "texr" 00110 * Name (string ID) ushort 00111 * File (string ID) ushort 00112 * 00113 */ 00114 00115 /* 00116 * -- Shader Program -- 00117 * 00118 * Prefix uint "shpr" 00119 * Name (string ID) ushort 00120 * Descr. (string ID) ushort Typically "Phong" or "Lambert" or such 00121 * Uniform set index short -1 for no Uniform set 00122 * 00123 */ 00124 00125 /* 00126 * -- Geometry -- 00127 * 00128 * Prefix uint "geom" 00129 * Name (string ID) ushort 00130 * V.Array (string ID) ushort 00131 * S.Prog. (string ID) ushort 00132 * Uniform set index short -1 for no Uniform set 00133 * 00134 */ 00135 00136 /* 00137 * -- Group -- 00138 * 00139 * Prefix uint "grou" 00140 * Name (string ID) ushort 00141 * 00142 */ 00143 00144 /* 00145 * -- Camera -- 00146 * 00147 * Prefix uint "cmra" 00148 * Name (string ID) ushort 00149 * V.FOV float radians 00150 * Aspect ratio float 00151 * Near plane float 00152 * Far plane float 00153 * 00154 */ 00155 00156 /* 00157 * -- Light -- 00158 * 00159 * Prefix uint "lght" 00160 * Name (string ID) ushort 00161 * Color float[3] RGB 00162 * Intensity float 00163 * Falloff radius float 00164 * 00165 */ 00166 00167 /* 00168 * -- Node hierarchy -- 00169 * 00170 * Repeated: 00171 * Flags ushort Bit 0: Translation 00172 * Bit 1: Rotation 00173 * Bit 2: Scale 00174 * Translation float[3] if Flags & (1 << 0) 00175 * Rotation (quat.) float[4] if Flags & (1 << 1) 00176 * Scale float[3] if Flags & (1 << 2) 00177 * N children ushort At least N Node hierarchy tables follow 00178 * 00179 */ 00180 00181 /*===========================================================================*/ 00182 00183 #define PWN_HEADER_MAJOR_VERSION 0 00184 #define PWN_HEADER_MINOR_VERSION 3 00185 00186 #define PWN_HEADER_PREFIX "pwnd" 00187 00188 #define PWN_STRING_POOL_PREFIX "strp" 00189 #define PWN_UNIFORM_PREFIX "unif" 00190 00191 #define PWN_VARRAY_PREFIX "vtxa" 00192 #define PWN_TEXTURE_PREFIX "texr" 00193 #define PWN_SHADER_PROGRAM_PREFIX "shpr" 00194 00195 #define PWN_GEOMETRY_PREFIX "geom" 00196 #define PWN_GROUP_PREFIX "grou" 00197 #define PWN_CAMERA_PREFIX "cmra" 00198 #define PWN_LIGHT_PREFIX "lght" 00199 00200 #define PWN_END_FILE "xxxx" 00201 00202 #define PWN_FLAG_TRANSLATION (1<<0) 00203 #define PWN_FLAG_ROTATION (1<<1) 00204 #define PWN_FLAG_SCALE (1<<2) 00205 00206 /*---------------------------------------------------------------------------*/ 00207 00208 #endif /* PWN_H */ 00209