root/OpenSceneGraph/trunk/src/osgPlugins/3ds/lib3ds/lib3ds_chunktable.c @ 10853

Revision 10853, 9.9 kB (checked in by robert, 5 years ago)

From Sukender,
"Here is our freshly baked 3DS reader/writer (named 'v0.5' to differentiate from previous one). Changes are against trunk rev. 10819.
Short changelog (from rev 10819):
- Added 3DS writer
- Sync'd with latest lib3DS
- Added options, especially "flattenMatrixTransforms" to get the "old" behaviour (else the reader correctly maps to OSG the transforms from the 3DS file).

What should be done:
- Check with pivot points, with and without "flattenMatrixTransforms" option.
- We ran tests on it, but we can never be 100% sure there is no bug. Testing from the community would of course be helpful."

RevLine 
[10853]1/*
2    Copyright (C) 1996-2008 by Jan Eric Kyprianidis <www.kyprianidis.com>
3    All rights reserved.
4   
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
7    by the Free Software Foundation, either version 2.1 of the License, or
8    (at your option) any later version.
9
10    Thisprogram  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.
14   
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/>.
17*/
18#include "lib3ds_impl.h"
19
20
21typedef struct Lib3dsChunkTable {
22    uint32_t chunk;
23    const char* name;
24} Lib3dsChunkTable;
25
26
27static Lib3dsChunkTable lib3ds_chunk_table[] = {
28    {CHK_NULL_CHUNK, "NULL_CHUNK"},
29    {CHK_M3DMAGIC, "M3DMAGIC"},
30    {CHK_SMAGIC, "SMAGIC"},
31    {CHK_LMAGIC, "LMAGIC"},
32    {CHK_MLIBMAGIC, "MLIBMAGIC"},
33    {CHK_MATMAGIC, "MATMAGIC"},
34    {CHK_CMAGIC, "CMAGIC"},
35    {CHK_M3D_VERSION, "M3D_VERSION"},
36    {CHK_M3D_KFVERSION, "M3D_KFVERSION"},
37    {CHK_COLOR_F, "COLOR_F"},
38    {CHK_COLOR_24, "COLOR_24"},
39    {CHK_LIN_COLOR_24, "LIN_COLOR_24"},
40    {CHK_LIN_COLOR_F, "LIN_COLOR_F"},
41    {CHK_INT_PERCENTAGE, "INT_PERCENTAGE"},
42    {CHK_FLOAT_PERCENTAGE, "FLOAT_PERCENTAGE"},
43    {CHK_MDATA, "MDATA"},
44    {CHK_MESH_VERSION, "MESH_VERSION"},
45    {CHK_MASTER_SCALE, "MASTER_SCALE"},
46    {CHK_LO_SHADOW_BIAS, "LO_SHADOW_BIAS"},
47    {CHK_HI_SHADOW_BIAS, "HI_SHADOW_BIAS"},
48    {CHK_SHADOW_MAP_SIZE, "SHADOW_MAP_SIZE"},
49    {CHK_SHADOW_SAMPLES, "SHADOW_SAMPLES"},
50    {CHK_SHADOW_RANGE, "SHADOW_RANGE"},
51    {CHK_SHADOW_FILTER, "SHADOW_FILTER"},
52    {CHK_RAY_BIAS, "RAY_BIAS"},
53    {CHK_O_CONSTS, "O_CONSTS"},
54    {CHK_AMBIENT_LIGHT, "AMBIENT_LIGHT"},
55    {CHK_BIT_MAP, "BIT_MAP"},
56    {CHK_SOLID_BGND, "SOLID_BGND"},
57    {CHK_V_GRADIENT, "V_GRADIENT"},
58    {CHK_USE_BIT_MAP, "USE_BIT_MAP"},
59    {CHK_USE_SOLID_BGND, "USE_SOLID_BGND"},
60    {CHK_USE_V_GRADIENT, "USE_V_GRADIENT"},
61    {CHK_FOG, "FOG"},
62    {CHK_FOG_BGND, "FOG_BGND"},
63    {CHK_LAYER_FOG, "LAYER_FOG"},
64    {CHK_DISTANCE_CUE, "DISTANCE_CUE"},
65    {CHK_DCUE_BGND, "DCUE_BGND"},
66    {CHK_USE_FOG, "USE_FOG"},
67    {CHK_USE_LAYER_FOG, "USE_LAYER_FOG"},
68    {CHK_USE_DISTANCE_CUE, "USE_DISTANCE_CUE"},
69    {CHK_MAT_ENTRY, "MAT_ENTRY"},
70    {CHK_MAT_NAME, "MAT_NAME"},
71    {CHK_MAT_AMBIENT, "MAT_AMBIENT"},
72    {CHK_MAT_DIFFUSE, "MAT_DIFFUSE"},
73    {CHK_MAT_SPECULAR, "MAT_SPECULAR"},
74    {CHK_MAT_SHININESS, "MAT_SHININESS"},
75    {CHK_MAT_SHIN2PCT, "MAT_SHIN2PCT"},
76    {CHK_MAT_TRANSPARENCY, "MAT_TRANSPARENCY"},
77    {CHK_MAT_XPFALL, "MAT_XPFALL"},
78    {CHK_MAT_USE_XPFALL, "MAT_USE_XPFALL"},
79    {CHK_MAT_REFBLUR, "MAT_REFBLUR"},
80    {CHK_MAT_SHADING, "MAT_SHADING"},
81    {CHK_MAT_USE_REFBLUR, "MAT_USE_REFBLUR"},
82    {CHK_MAT_SELF_ILLUM, "MAT_SELF_ILLUM"},
83    {CHK_MAT_TWO_SIDE, "MAT_TWO_SIDE"},
84    {CHK_MAT_DECAL, "MAT_DECAL"},
85    {CHK_MAT_ADDITIVE, "MAT_ADDITIVE"},
86    {CHK_MAT_SELF_ILPCT, "MAT_SELF_ILPCT"},
87    {CHK_MAT_WIRE, "MAT_WIRE"},
88    {CHK_MAT_FACEMAP, "MAT_FACEMAP"},
89    {CHK_MAT_PHONGSOFT, "MAT_PHONGSOFT"},
90    {CHK_MAT_WIREABS, "MAT_WIREABS"},
91    {CHK_MAT_WIRE_SIZE, "MAT_WIRE_SIZE"},
92    {CHK_MAT_TEXMAP, "MAT_TEXMAP"},
93    {CHK_MAT_SXP_TEXT_DATA, "MAT_SXP_TEXT_DATA"},
94    {CHK_MAT_TEXMASK, "MAT_TEXMASK"},
95    {CHK_MAT_SXP_TEXTMASK_DATA, "MAT_SXP_TEXTMASK_DATA"},
96    {CHK_MAT_TEX2MAP, "MAT_TEX2MAP"},
97    {CHK_MAT_SXP_TEXT2_DATA, "MAT_SXP_TEXT2_DATA"},
98    {CHK_MAT_TEX2MASK, "MAT_TEX2MASK"},
99    {CHK_MAT_SXP_TEXT2MASK_DATA, "MAT_SXP_TEXT2MASK_DATA"},
100    {CHK_MAT_OPACMAP, "MAT_OPACMAP"},
101    {CHK_MAT_SXP_OPAC_DATA, "MAT_SXP_OPAC_DATA"},
102    {CHK_MAT_OPACMASK, "MAT_OPACMASK"},
103    {CHK_MAT_SXP_OPACMASK_DATA, "MAT_SXP_OPACMASK_DATA"},
104    {CHK_MAT_BUMPMAP, "MAT_BUMPMAP"},
105    {CHK_MAT_SXP_BUMP_DATA, "MAT_SXP_BUMP_DATA"},
106    {CHK_MAT_BUMPMASK, "MAT_BUMPMASK"},
107    {CHK_MAT_SXP_BUMPMASK_DATA, "MAT_SXP_BUMPMASK_DATA"},
108    {CHK_MAT_SPECMAP, "MAT_SPECMAP"},
109    {CHK_MAT_SXP_SPEC_DATA, "MAT_SXP_SPEC_DATA"},
110    {CHK_MAT_SPECMASK, "MAT_SPECMASK"},
111    {CHK_MAT_SXP_SPECMASK_DATA, "MAT_SXP_SPECMASK_DATA"},
112    {CHK_MAT_SHINMAP, "MAT_SHINMAP"},
113    {CHK_MAT_SXP_SHIN_DATA, "MAT_SXP_SHIN_DATA"},
114    {CHK_MAT_SHINMASK, "MAT_SHINMASK"},
115    {CHK_MAT_SXP_SHINMASK_DATA, "MAT_SXP_SHINMASK_DATA"},
116    {CHK_MAT_SELFIMAP, "MAT_SELFIMAP"},
117    {CHK_MAT_SXP_SELFI_DATA, "MAT_SXP_SELFI_DATA"},
118    {CHK_MAT_SELFIMASK, "MAT_SELFIMASK"},
119    {CHK_MAT_SXP_SELFIMASK_DATA, "MAT_SXP_SELFIMASK_DATA"},
120    {CHK_MAT_REFLMAP, "MAT_REFLMAP"},
121    {CHK_MAT_REFLMASK, "MAT_REFLMASK"},
122    {CHK_MAT_SXP_REFLMASK_DATA, "MAT_SXP_REFLMASK_DATA"},
123    {CHK_MAT_ACUBIC, "MAT_ACUBIC"},
124    {CHK_MAT_MAPNAME, "MAT_MAPNAME"},
125    {CHK_MAT_MAP_TILING, "MAT_MAP_TILING"},
126    {CHK_MAT_MAP_TEXBLUR, "MAT_MAP_TEXBLUR"},
127    {CHK_MAT_MAP_USCALE, "MAT_MAP_USCALE"},
128    {CHK_MAT_MAP_VSCALE, "MAT_MAP_VSCALE"},
129    {CHK_MAT_MAP_UOFFSET, "MAT_MAP_UOFFSET"},
130    {CHK_MAT_MAP_VOFFSET, "MAT_MAP_VOFFSET"},
131    {CHK_MAT_MAP_ANG, "MAT_MAP_ANG"},
132    {CHK_MAT_MAP_COL1, "MAT_MAP_COL1"},
133    {CHK_MAT_MAP_COL2, "MAT_MAP_COL2"},
134    {CHK_MAT_MAP_RCOL, "MAT_MAP_RCOL"},
135    {CHK_MAT_MAP_GCOL, "MAT_MAP_GCOL"},
136    {CHK_MAT_MAP_BCOL, "MAT_MAP_BCOL"},
137    {CHK_NAMED_OBJECT, "NAMED_OBJECT"},
138    {CHK_N_DIRECT_LIGHT, "N_DIRECT_LIGHT"},
139    {CHK_DL_OFF, "DL_OFF"},
140    {CHK_DL_OUTER_RANGE, "DL_OUTER_RANGE"},
141    {CHK_DL_INNER_RANGE, "DL_INNER_RANGE"},
142    {CHK_DL_MULTIPLIER, "DL_MULTIPLIER"},
143    {CHK_DL_EXCLUDE, "DL_EXCLUDE"},
144    {CHK_DL_ATTENUATE, "DL_ATTENUATE"},
145    {CHK_DL_SPOTLIGHT, "DL_SPOTLIGHT"},
146    {CHK_DL_SPOT_ROLL, "DL_SPOT_ROLL"},
147    {CHK_DL_SHADOWED, "DL_SHADOWED"},
148    {CHK_DL_LOCAL_SHADOW2, "DL_LOCAL_SHADOW2"},
149    {CHK_DL_SEE_CONE, "DL_SEE_CONE"},
150    {CHK_DL_SPOT_RECTANGULAR, "DL_SPOT_RECTANGULAR"},
151    {CHK_DL_SPOT_ASPECT, "DL_SPOT_ASPECT"},
152    {CHK_DL_SPOT_PROJECTOR, "DL_SPOT_PROJECTOR"},
153    {CHK_DL_SPOT_OVERSHOOT, "DL_SPOT_OVERSHOOT"},
154    {CHK_DL_RAY_BIAS, "DL_RAY_BIAS"},
155    {CHK_DL_RAYSHAD, "DL_RAYSHAD"},
156    {CHK_N_CAMERA, "N_CAMERA"},
157    {CHK_CAM_SEE_CONE, "CAM_SEE_CONE"},
158    {CHK_CAM_RANGES, "CAM_RANGES"},
159    {CHK_OBJ_HIDDEN, "OBJ_HIDDEN"},
160    {CHK_OBJ_VIS_LOFTER, "OBJ_VIS_LOFTER"},
161    {CHK_OBJ_DOESNT_CAST, "OBJ_DOESNT_CAST"},
162    {CHK_OBJ_DONT_RCVSHADOW, "OBJ_DONT_RCVSHADOW"},
163    {CHK_OBJ_MATTE, "OBJ_MATTE"},
164    {CHK_OBJ_FAST, "OBJ_FAST"},
165    {CHK_OBJ_PROCEDURAL, "OBJ_PROCEDURAL"},
166    {CHK_OBJ_FROZEN, "OBJ_FROZEN"},
167    {CHK_N_TRI_OBJECT, "N_TRI_OBJECT"},
168    {CHK_POINT_ARRAY, "POINT_ARRAY"},
169    {CHK_POINT_FLAG_ARRAY, "POINT_FLAG_ARRAY"},
170    {CHK_FACE_ARRAY, "FACE_ARRAY"},
171    {CHK_MSH_MAT_GROUP, "MSH_MAT_GROUP"},
172    {CHK_SMOOTH_GROUP, "SMOOTH_GROUP"},
173    {CHK_MSH_BOXMAP, "MSH_BOXMAP"},
174    {CHK_TEX_VERTS, "TEX_VERTS"},
175    {CHK_MESH_MATRIX, "MESH_MATRIX"},
176    {CHK_MESH_COLOR, "MESH_COLOR"},
177    {CHK_MESH_TEXTURE_INFO, "MESH_TEXTURE_INFO"},
178    {CHK_KFDATA, "KFDATA"},
179    {CHK_KFHDR, "KFHDR"},
180    {CHK_KFSEG, "KFSEG"},
181    {CHK_KFCURTIME, "KFCURTIME"},
182    {CHK_AMBIENT_NODE_TAG, "AMBIENT_NODE_TAG"},
183    {CHK_OBJECT_NODE_TAG, "OBJECT_NODE_TAG"},
184    {CHK_CAMERA_NODE_TAG, "CAMERA_NODE_TAG"},
185    {CHK_TARGET_NODE_TAG, "TARGET_NODE_TAG"},
186    {CHK_LIGHT_NODE_TAG, "LIGHT_NODE_TAG"},
187    {CHK_L_TARGET_NODE_TAG, "L_TARGET_NODE_TAG"},
188    {CHK_SPOTLIGHT_NODE_TAG, "SPOTLIGHT_NODE_TAG"},
189    {CHK_NODE_ID, "NODE_ID"},
190    {CHK_NODE_HDR, "NODE_HDR"},
191    {CHK_PIVOT, "PIVOT"},
192    {CHK_INSTANCE_NAME, "INSTANCE_NAME"},
193    {CHK_MORPH_SMOOTH, "MORPH_SMOOTH"},
194    {CHK_BOUNDBOX, "BOUNDBOX"},
195    {CHK_POS_TRACK_TAG, "POS_TRACK_TAG"},
196    {CHK_COL_TRACK_TAG, "COL_TRACK_TAG"},
197    {CHK_ROT_TRACK_TAG, "ROT_TRACK_TAG"},
198    {CHK_SCL_TRACK_TAG, "SCL_TRACK_TAG"},
199    {CHK_MORPH_TRACK_TAG, "MORPH_TRACK_TAG"},
200    {CHK_FOV_TRACK_TAG, "FOV_TRACK_TAG"},
201    {CHK_ROLL_TRACK_TAG, "ROLL_TRACK_TAG"},
202    {CHK_HOT_TRACK_TAG, "HOT_TRACK_TAG"},
203    {CHK_FALL_TRACK_TAG, "FALL_TRACK_TAG"},
204    {CHK_HIDE_TRACK_TAG, "HIDE_TRACK_TAG"},
205    {CHK_POLY_2D, "POLY_2D"},
206    {CHK_SHAPE_OK, "SHAPE_OK"},
207    {CHK_SHAPE_NOT_OK, "SHAPE_NOT_OK"},
208    {CHK_SHAPE_HOOK, "SHAPE_HOOK"},
209    {CHK_PATH_3D, "PATH_3D"},
210    {CHK_PATH_MATRIX, "PATH_MATRIX"},
211    {CHK_SHAPE_2D, "SHAPE_2D"},
212    {CHK_M_SCALE, "M_SCALE"},
213    {CHK_M_TWIST, "M_TWIST"},
214    {CHK_M_TEETER, "M_TEETER"},
215    {CHK_M_FIT, "M_FIT"},
216    {CHK_M_BEVEL, "M_BEVEL"},
217    {CHK_XZ_CURVE, "XZ_CURVE"},
218    {CHK_YZ_CURVE, "YZ_CURVE"},
219    {CHK_INTERPCT, "INTERPCT"},
220    {CHK_DEFORM_LIMIT, "DEFORM_LIMIT"},
221    {CHK_USE_CONTOUR, "USE_CONTOUR"},
222    {CHK_USE_TWEEN, "USE_TWEEN"},
223    {CHK_USE_SCALE, "USE_SCALE"},
224    {CHK_USE_TWIST, "USE_TWIST"},
225    {CHK_USE_TEETER, "USE_TEETER"},
226    {CHK_USE_FIT, "USE_FIT"},
227    {CHK_USE_BEVEL, "USE_BEVEL"},
228    {CHK_DEFAULT_VIEW, "DEFAULT_VIEW"},
229    {CHK_VIEW_TOP, "VIEW_TOP"},
230    {CHK_VIEW_BOTTOM, "VIEW_BOTTOM"},
231    {CHK_VIEW_LEFT, "VIEW_LEFT"},
232    {CHK_VIEW_RIGHT, "VIEW_RIGHT"},
233    {CHK_VIEW_FRONT, "VIEW_FRONT"},
234    {CHK_VIEW_BACK, "VIEW_BACK"},
235    {CHK_VIEW_USER, "VIEW_USER"},
236    {CHK_VIEW_CAMERA, "VIEW_CAMERA"},
237    {CHK_VIEW_WINDOW, "VIEW_WINDOW"},
238    {CHK_VIEWPORT_LAYOUT_OLD, "VIEWPORT_LAYOUT_OLD"},
239    {CHK_VIEWPORT_DATA_OLD, "VIEWPORT_DATA_OLD"},
240    {CHK_VIEWPORT_LAYOUT, "VIEWPORT_LAYOUT"},
241    {CHK_VIEWPORT_DATA, "VIEWPORT_DATA"},
242    {CHK_VIEWPORT_DATA_3, "VIEWPORT_DATA_3"},
243    {CHK_VIEWPORT_SIZE, "VIEWPORT_SIZE"},
244    {CHK_NETWORK_VIEW, "NETWORK_VIEW"},
245    {0, 0}
246};
247
248
249const char*
250lib3ds_chunk_name(uint16_t chunk) {
251    Lib3dsChunkTable *p;
252
253    for (p = lib3ds_chunk_table; p->name != 0; ++p) {
254        if (p->chunk == chunk) {
255            return(p->name);
256        }
257    }
258    return("***UNKNOWN***");
259}
Note: See TracBrowser for help on using the browser.