1 /* -*- c -*- */
2 #ifndef INCLUDED_LIB3DS_H
3 #define INCLUDED_LIB3DS_H
4 /*
5     Copyright (C) 1996-2008 by Jan Eric Kyprianidis <www.kyprianidis.com>
6     All rights reserved.
7 
8     This program is free  software: you can redistribute it and/or modify
9     it under the terms of the GNU Lesser General Public License as published
10     by the Free Software Foundation, either version 2.1 of the License, or
11     (at your option) any later version.
12 
13     Thisprogram  is  distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     GNU Lesser General Public License for more details.
17 
18     You should  have received a copy of the GNU Lesser General Public License
19     along with  this program; If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <stddef.h>
23 
24 #ifndef LIB3DSAPI
25     //#ifdef _MSC_VER
26     //    #ifdef LIB3DS_EXPORTS
27     //        #define LIB3DSAPI __declspec(dllexport)
28     //    #else
29     //        #define LIB3DSAPI __declspec(dllimport)
30     //    #endif
31     //#else
32         #define LIB3DSAPI
33     //#endif
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /** @defgroup api API */
41 /** @{ */
42 
43 typedef enum Lib3dsIoSeek {
44     LIB3DS_SEEK_SET     = 0,
45     LIB3DS_SEEK_CUR     = 1,
46     LIB3DS_SEEK_END     = 2
47 } Lib3dsIoSeek;
48 
49 typedef enum Lib3dsLogLevel {
50     LIB3DS_LOG_ERROR    = 0,
51     LIB3DS_LOG_WARN     = 1,
52     LIB3DS_LOG_INFO     = 2,
53     LIB3DS_LOG_DEBUG    = 3
54 } Lib3dsLogLevel;
55 
56 typedef struct Lib3dsIo {
57     void*   impl;
58     void*   self;
59     long    (*seek_func) (void *self, long offset, Lib3dsIoSeek origin);
60     long    (*tell_func) (void *self);
61     size_t  (*read_func) (void *self, void *buffer, size_t size);
62     size_t  (*write_func)(void *self, const void *buffer, size_t size);
63     void    (*log_func)  (void *self, Lib3dsLogLevel level, int indent, const char *msg);
64 } Lib3dsIo;
65 
66 /* Atmosphere settings */
67 typedef struct Lib3dsAtmosphere {
68     int         use_fog;
69     float       fog_color[3];
70     int         fog_background;
71     float       fog_near_plane;
72     float       fog_near_density;
73     float       fog_far_plane;
74     float       fog_far_density;
75     int         use_layer_fog;
76     unsigned    layer_fog_flags;
77     float       layer_fog_color[3];
78     float       layer_fog_near_y;
79     float       layer_fog_far_y;
80     float       layer_fog_density;
81     int         use_dist_cue;
82     int         dist_cue_background;     /* bool */
83     float       dist_cue_near_plane;
84     float       dist_cue_near_dimming;
85     float       dist_cue_far_plane;
86     float       dist_cue_far_dimming;
87 } Lib3dsAtmosphere;
88 
89 /* Background settings */
90 typedef struct Lib3dsBackground {
91     int         use_bitmap;
92     char        bitmap_name[64];
93     int         use_solid;
94     float       solid_color[3];
95     int         use_gradient;
96     float       gradient_percent;
97     float       gradient_top[3];
98     float       gradient_middle[3];
99     float       gradient_bottom[3];
100 } Lib3dsBackground;
101 
102 /* Shadow settings */
103 typedef struct Lib3dsShadow {
104     short       map_size;           /* Global shadow map size that ranges from 10 to 4096 */
105     float       low_bias;           /* Global shadow low bias */
106     float       hi_bias;            /* Global shadow hi bias */
107     float       filter;             /* Global shadow filter that ranges from 1 (lowest) to 10 (highest) */
108     float       ray_bias;           /* Global raytraced shadow bias */
109 } Lib3dsShadow;
110 
111 /* Layout view types */
112 typedef enum Lib3dsViewType {
113     LIB3DS_VIEW_NOT_USED   = 0,
114     LIB3DS_VIEW_TOP        = 1,
115     LIB3DS_VIEW_BOTTOM     = 2,
116     LIB3DS_VIEW_LEFT       = 3,
117     LIB3DS_VIEW_RIGHT      = 4,
118     LIB3DS_VIEW_FRONT      = 5,
119     LIB3DS_VIEW_BACK       = 6,
120     LIB3DS_VIEW_USER       = 7,
121     LIB3DS_VIEW_SPOTLIGHT  = 18,
122     LIB3DS_VIEW_CAMERA     = 65535
123 } Lib3dsViewType;
124 
125 /* Layout styles */
126 typedef enum Lib3dsLayoutStyle {
127     LIB3DS_LAYOUT_SINGLE                    = 0,
128     LIB3DS_LAYOUT_TWO_PANE_VERT_SPLIT       = 1,
129     LIB3DS_LAYOUT_TWO_PANE_HORIZ_SPLIT      = 2,
130     LIB3DS_LAYOUT_FOUR_PANE                 = 3,
131     LIB3DS_LAYOUT_THREE_PANE_LEFT_SPLIT     = 4,
132     LIB3DS_LAYOUT_THREE_PANE_BOTTOM_SPLIT   = 5,
133     LIB3DS_LAYOUT_THREE_PANE_RIGHT_SPLIT    = 6,
134     LIB3DS_LAYOUT_THREE_PANE_TOP_SPLIT      = 7,
135     LIB3DS_LAYOUT_THREE_PANE_VERT_SPLIT     = 8,
136     LIB3DS_LAYOUT_THREE_PANE_HORIZ_SPLIT    = 9,
137     LIB3DS_LAYOUT_FOUR_PANE_LEFT_SPLIT      = 10,
138     LIB3DS_LAYOUT_FOUR_PANE_RIGHT_SPLIT     = 11
139 } Lib3dsLayoutStyle;
140 
141 /* Layout view settings */
142 typedef struct Lib3dsView {
143     int         type;
144     unsigned    axis_lock;
145     short       position[2];
146     short       size[2];
147     float       zoom;
148     float       center[3];
149     float       horiz_angle;
150     float       vert_angle;
151     char        camera[11];
152 } Lib3dsView;
153 
154 #define LIB3DS_LAYOUT_MAX_VIEWS 32
155 
156 /* Viewport and default view settings */
157 typedef struct Lib3dsViewport {
158     int             layout_style;
159     int             layout_active;
160     int             layout_swap;
161     int             layout_swap_prior;
162     int             layout_swap_view;
163     unsigned short  layout_position[2];
164     unsigned short  layout_size[2];
165     int             layout_nviews;
166     Lib3dsView      layout_views[LIB3DS_LAYOUT_MAX_VIEWS];
167     int             default_type;
168     float           default_position[3];
169     float           default_width;
170     float           default_horiz_angle;
171     float           default_vert_angle;
172     float           default_roll_angle;
173     char            default_camera[64];
174 } Lib3dsViewport;
175 
176 /* Material texture map flags */
177 typedef enum Lib3dsTextureMapFlags {
178     LIB3DS_TEXTURE_DECALE       = 0x0001,
179     LIB3DS_TEXTURE_MIRROR       = 0x0002,
180     LIB3DS_TEXTURE_NEGATE       = 0x0008,
181     LIB3DS_TEXTURE_NO_TILE      = 0x0010,
182     LIB3DS_TEXTURE_SUMMED_AREA  = 0x0020,
183     LIB3DS_TEXTURE_ALPHA_SOURCE = 0x0040,
184     LIB3DS_TEXTURE_TINT         = 0x0080,
185     LIB3DS_TEXTURE_IGNORE_ALPHA = 0x0100,
186     LIB3DS_TEXTURE_RGB_TINT     = 0x0200
187 } Lib3dsTextureMapFlags;
188 
189 /* Material texture map */
190 typedef struct Lib3dsTextureMap {
191     unsigned    user_id;
192     void*       user_ptr;
193     char        name[64];
194     unsigned    flags;
195     float       percent;
196     float       blur;
197     float       scale[2];
198     float       offset[2];
199     float       rotation;
200     float       tint_1[3];
201     float       tint_2[3];
202     float       tint_r[3];
203     float       tint_g[3];
204     float       tint_b[3];
205 } Lib3dsTextureMap;
206 
207 /* Auto reflection texture map flags */
208 typedef enum Lib3dsAutoReflMapFlags {
209     LIB3DS_AUTOREFL_USE                     = 0x0001,
210     LIB3DS_AUTOREFL_READ_FIRST_FRAME_ONLY   = 0x0004,
211     LIB3DS_AUTOREFL_FLAT_MIRROR             = 0x0008
212 } Lib3dsAutoReflMapFlags;
213 
214 /* Material shading type */
215 typedef enum Lib3dsShading {
216     LIB3DS_SHADING_WIRE_FRAME = 0,
217     LIB3DS_SHADING_FLAT       = 1,
218     LIB3DS_SHADING_GOURAUD    = 2,
219     LIB3DS_SHADING_PHONG      = 3,
220     LIB3DS_SHADING_METAL      = 4
221 } Lib3dsShading;
222 
223 /** Material */
224 typedef struct Lib3dsMaterial {
225     unsigned            user_id;
226     void*               user_ptr;
227     char                name[64];           /* Material name */
228     float               ambient[3];         /* Material ambient reflectivity */
229     float               diffuse[3];         /* Material diffuse reflectivity */
230     float               specular[3];        /* Material specular reflectivity */
231     float               shininess;          /* Material specular exponent */
232     float               shin_strength;
233     int                 use_blur;
234     float               blur;
235     float               transparency;
236     float               falloff;
237     int                 is_additive;
238     int                 self_illum_flag; /* bool */
239     float               self_illum;
240     int                 use_falloff;
241     int                 shading;
242     int                 soften;         /* bool */
243     int                 face_map;       /* bool */
244     int                 two_sided;      /* Material visible from back */
245     int                 map_decal;      /* bool */
246     int                 use_wire;
247     int                 use_wire_abs;
248     float               wire_size;
249     Lib3dsTextureMap    texture1_map;
250     Lib3dsTextureMap    texture1_mask;
251     Lib3dsTextureMap    texture2_map;
252     Lib3dsTextureMap    texture2_mask;
253     Lib3dsTextureMap    opacity_map;
254     Lib3dsTextureMap    opacity_mask;
255     Lib3dsTextureMap    bump_map;
256     Lib3dsTextureMap    bump_mask;
257     Lib3dsTextureMap    specular_map;
258     Lib3dsTextureMap    specular_mask;
259     Lib3dsTextureMap    shininess_map;
260     Lib3dsTextureMap    shininess_mask;
261     Lib3dsTextureMap    self_illum_map;
262     Lib3dsTextureMap    self_illum_mask;
263     Lib3dsTextureMap    reflection_map;
264     Lib3dsTextureMap    reflection_mask;
265     unsigned            autorefl_map_flags;
266     int                 autorefl_map_anti_alias;  /* 0=None, 1=Low, 2=Medium, 3=High */
267     int                 autorefl_map_size;
268     int                 autorefl_map_frame_step;
269 } Lib3dsMaterial;
270 
271 /** Object flags for cameras, lights and meshes */
272 typedef enum Lib3dsObjectFlags {
273     LIB3DS_OBJECT_HIDDEN          = 0x01,
274     LIB3DS_OBJECT_VIS_LOFTER      = 0x02,
275     LIB3DS_OBJECT_DOESNT_CAST     = 0x04,
276     LIB3DS_OBJECT_MATTE           = 0x08,
277     LIB3DS_OBJECT_DONT_RCVSHADOW  = 0x10,
278     LIB3DS_OBJECT_FAST            = 0x20,
279     LIB3DS_OBJECT_FROZEN          = 0x40
280 } Lib3dsObjectFlags;
281 
282 /** Camera object */
283 typedef struct Lib3dsCamera {
284     unsigned    user_id;
285     void*       user_ptr;
286     char        name[64];
287     unsigned    object_flags; /*< @see Lib3dsObjectFlags */
288     float       position[3];
289     float       target[3];
290     float       roll;
291     float       fov;
292     int         see_cone;
293     float       near_range;
294     float       far_range;
295 } Lib3dsCamera;
296 
297 /** Light object */
298 typedef struct Lib3dsLight {
299     unsigned    user_id;
300     void*       user_ptr;
301     char        name[64];
302     unsigned    object_flags;
303     int         spot_light;     /* bool */
304     int         see_cone;
305     float       color[3];
306     float       position[3];
307     float       target[3];
308     float       roll;
309     int         off;              /* bool */
310     float       outer_range;
311     float       inner_range;
312     float       multiplier;
313     /*const char**  excludes;*/
314     float       attenuation;
315     int         rectangular_spot;   /* bool */
316     int         shadowed;           /* bool */
317     float       shadow_bias;
318     float       shadow_filter;
319     int         shadow_size;
320     float       spot_aspect;
321     int         use_projector;
322     char        projector[64];
323     int         spot_overshoot;      /* bool */
324     int         ray_shadows;         /* bool */
325     float       ray_bias;
326     float       hotspot;
327     float       falloff;
328 } Lib3dsLight;
329 
330 /* Texture map projection */
331 typedef enum {
332   LIB3DS_MAP_NONE           = -1,
333   LIB3DS_MAP_PLANAR         = 0,
334   LIB3DS_MAP_CYLINDRICAL    = 1,
335   LIB3DS_MAP_SPHERICAL      = 2
336 } Lib3dsMapType;
337 
338 /**  Meaning of Lib3dsFace::flags. ABC are points of the current face
339     (A: is 1st vertex, B is 2nd vertex, C is 3rd vertex) */
340 typedef enum Lib3dsFaceFlags {
341   LIB3DS_FACE_VIS_AC    = 0x01,       /**< Bit 0: Edge visibility AC */
342   LIB3DS_FACE_VIS_BC    = 0x02,       /**< Bit 1: Edge visibility BC */
343   LIB3DS_FACE_VIS_AB    = 0x04,       /**< Bit 2: Edge visibility AB */
344   LIB3DS_FACE_WRAP_U    = 0x08,       /**< Bit 3: Face is at tex U wrap seam */
345   LIB3DS_FACE_WRAP_V    = 0x10,       /**< Bit 4: Face is at tex V wrap seam */
346   LIB3DS_FACE_SELECT_3  = (1<<13),    /**< Bit 13: Selection of the face in selection 3*/
347   LIB3DS_FACE_SELECT_2  = (1<<14),    /**< Bit 14: Selection of the face in selection 2*/
348   LIB3DS_FACE_SELECT_1  = (1<<15),    /**< Bit 15: Selection of the face in selection 1*/
349 } Lib3dsFaceFlags;
350 
351 typedef struct Lib3dsFace {
352     unsigned short  index[3];
353     unsigned short  flags;
354     int             material;
355     unsigned        smoothing_group;
356 } Lib3dsFace;
357 
358 /* Triangular mesh object */
359 typedef struct Lib3dsMesh {
360     unsigned        user_id;
361     void*           user_ptr;
362     char            name[64];            /**< Mesh name. Don't use more than 8 characters  */
363     unsigned        object_flags;        /**< @see Lib3dsObjectFlags */
364     int             color;               /**< Index to editor palette [0..255] */
365     float           matrix[4][4];        /**< Transformation matrix for mesh data */
366     unsigned short  nvertices;           /**< Number of vertices in vertex array (max. 65535) */
367     float           (*vertices)[3];
368     float           (*texcos)[2];
369     unsigned short* vflags;
370     unsigned short  nfaces;              /**< Number of faces in face array (max. 65535) */
371     Lib3dsFace*     faces;
372     char            box_front[64];
373     char            box_back[64];
374     char            box_left[64];
375     char            box_right[64];
376     char            box_top[64];
377     char            box_bottom[64];
378     int             map_type;
379     float           map_pos[3];
380     float           map_matrix[4][4];
381     float           map_scale;
382     float           map_tile[2];
383     float           map_planar_size[2];
384     float           map_cylinder_height;
385 } Lib3dsMesh;
386 
387 typedef enum Lib3dsNodeType {
388     LIB3DS_NODE_AMBIENT_COLOR   = 0,
389     LIB3DS_NODE_MESH_INSTANCE   = 1,
390     LIB3DS_NODE_CAMERA          = 2,
391     LIB3DS_NODE_CAMERA_TARGET   = 3,
392     LIB3DS_NODE_OMNILIGHT       = 4,
393     LIB3DS_NODE_SPOTLIGHT       = 5,
394     LIB3DS_NODE_SPOTLIGHT_TARGET= 6
395 } Lib3dsNodeType;
396 
397 typedef enum Lib3dsNodeFlags{
398     LIB3DS_NODE_HIDDEN           = 0x000800,
399     LIB3DS_NODE_SHOW_PATH        = 0x010000,
400     LIB3DS_NODE_SMOOTHING        = 0x020000,
401     LIB3DS_NODE_MOTION_BLUR      = 0x100000,
402     LIB3DS_NODE_MORPH_MATERIALS  = 0x400000
403 } Lib3dsNodeFlags;
404 
405 typedef struct Lib3dsNode {
406     unsigned            user_id;
407     void*               user_ptr;
408     struct Lib3dsNode*  next;
409     struct Lib3dsNode*  childs;
410     struct Lib3dsNode*  parent;
411     Lib3dsNodeType      type;
412     unsigned short      node_id;            /**< 0..65535 */
413     char                name[64];
414     unsigned            flags;
415     float               matrix[4][4];
416 } Lib3dsNode;
417 
418 typedef enum Lib3dsKeyFlags {
419     LIB3DS_KEY_USE_TENS         = 0x01,
420     LIB3DS_KEY_USE_CONT         = 0x02,
421     LIB3DS_KEY_USE_BIAS         = 0x04,
422     LIB3DS_KEY_USE_EASE_TO      = 0x08,
423     LIB3DS_KEY_USE_EASE_FROM    = 0x10
424 } Lib3dsKeyFlags;
425 
426 typedef struct Lib3dsKey {
427     int         frame;
428     unsigned    flags;
429     float       tens;
430     float       cont;
431     float       bias;
432     float       ease_to;
433     float       ease_from;
434     float       value[4];
435 } Lib3dsKey;
436 
437 typedef enum Lib3dsTrackType {
438     LIB3DS_TRACK_BOOL   = 0,
439     LIB3DS_TRACK_FLOAT  = 1,
440     LIB3DS_TRACK_VECTOR = 3,
441     LIB3DS_TRACK_QUAT   = 4
442 } Lib3dsTrackType;
443 
444 typedef enum {
445     LIB3DS_TRACK_REPEAT   = 0x0001,
446     LIB3DS_TRACK_SMOOTH   = 0x0002,
447     LIB3DS_TRACK_LOCK_X   = 0x0008,
448     LIB3DS_TRACK_LOCK_Y   = 0x0010,
449     LIB3DS_TRACK_LOCK_Z   = 0x0020,
450     LIB3DS_TRACK_UNLINK_X = 0x0100,
451     LIB3DS_TRACK_UNLINK_Y = 0x0200,
452     LIB3DS_TRACK_UNLINK_Z = 0x0400
453 } Lib3dsTrackFlags;
454 
455 typedef struct Lib3dsTrack {
456     unsigned        flags;
457     Lib3dsTrackType type;
458     int             nkeys;
459     Lib3dsKey*      keys;
460 } Lib3dsTrack;
461 
462 typedef struct Lib3dsAmbientColorNode {
463     Lib3dsNode      base;
464     float           color[3];
465     Lib3dsTrack     color_track;
466 } Lib3dsAmbientColorNode;
467 
468 typedef struct Lib3dsMeshInstanceNode {
469     Lib3dsNode      base;
470     float           pivot[3];
471     char            instance_name[64];
472     float           bbox_min[3];
473     float           bbox_max[3];
474     int             hide;
475     float           pos[3];
476     float           rot[4];
477     float           scl[3];
478     float           morph_smooth;
479     char            morph[64];
480     Lib3dsTrack     pos_track;
481     Lib3dsTrack     rot_track;
482     Lib3dsTrack     scl_track;
483     Lib3dsTrack     hide_track;
484 } Lib3dsMeshInstanceNode;
485 
486 typedef struct Lib3dsCameraNode {
487     Lib3dsNode      base;
488     float           pos[3];
489     float           fov;
490     float           roll;
491     Lib3dsTrack     pos_track;
492     Lib3dsTrack     fov_track;
493     Lib3dsTrack     roll_track;
494 } Lib3dsCameraNode;
495 
496 typedef struct Lib3dsTargetNode {
497     Lib3dsNode      base;
498     float           pos[3];
499     Lib3dsTrack     pos_track;
500 } Lib3dsTargetNode;
501 
502 typedef struct Lib3dsOmnilightNode {
503     Lib3dsNode      base;
504     float           pos[3];
505     float           color[3];
506     Lib3dsTrack     pos_track;
507     Lib3dsTrack     color_track;
508 } Lib3dsOmnilightNode;
509 
510 typedef struct Lib3dsSpotlightNode {
511     Lib3dsNode      base;
512     float           pos[3];
513     float           color[3];
514     float           hotspot;
515     float           falloff;
516     float           roll;
517     Lib3dsTrack     pos_track;
518     Lib3dsTrack     color_track;
519     Lib3dsTrack     hotspot_track;
520     Lib3dsTrack     falloff_track;
521     Lib3dsTrack     roll_track;
522 } Lib3dsSpotlightNode;
523 
524 typedef struct Lib3dsFile {
525     unsigned            user_id;
526     void*               user_ptr;
527     unsigned            mesh_version;
528     unsigned            keyf_revision;
529     char                name[12+1];
530     float               master_scale;
531     float               construction_plane[3];
532     float               ambient[3];
533     Lib3dsShadow        shadow;
534     Lib3dsBackground    background;
535     Lib3dsAtmosphere    atmosphere;
536     Lib3dsViewport      viewport;
537     Lib3dsViewport      viewport_keyf;
538     int                 frames;
539     int                 segment_from;
540     int                 segment_to;
541     int                 current_frame;
542     int                 materials_size;
543     int                 nmaterials;
544     Lib3dsMaterial**    materials;
545     int                 cameras_size;
546     int                 ncameras;
547     Lib3dsCamera**      cameras;
548     int                 lights_size;
549     int                 nlights;
550     Lib3dsLight**       lights;
551     int                 meshes_size;
552     int                 nmeshes;
553     Lib3dsMesh**        meshes;
554     Lib3dsNode*         nodes;
555 } Lib3dsFile;
556 
557 extern LIB3DSAPI Lib3dsFile* lib3ds_file_open(const char *filename);
558 extern LIB3DSAPI int lib3ds_file_save(Lib3dsFile *file, const char *filename);
559 extern LIB3DSAPI Lib3dsFile* lib3ds_file_new();
560 extern LIB3DSAPI void lib3ds_file_free(Lib3dsFile *file);
561 extern LIB3DSAPI void lib3ds_file_eval(Lib3dsFile *file, float t);
562 extern LIB3DSAPI int lib3ds_file_read(Lib3dsFile *file, Lib3dsIo *io);
563 extern LIB3DSAPI int lib3ds_file_write(Lib3dsFile *file, Lib3dsIo *io);
564 extern LIB3DSAPI void lib3ds_file_reserve_materials(Lib3dsFile *file, int size, int force);
565 extern LIB3DSAPI void lib3ds_file_insert_material(Lib3dsFile *file, Lib3dsMaterial *material, int index);
566 extern LIB3DSAPI void lib3ds_file_remove_material(Lib3dsFile *file, int index);
567 extern LIB3DSAPI int lib3ds_file_material_by_name(Lib3dsFile *file, const char *name);
568 extern LIB3DSAPI void lib3ds_file_reserve_cameras(Lib3dsFile *file, int size, int force);
569 extern LIB3DSAPI void lib3ds_file_insert_camera(Lib3dsFile *file, Lib3dsCamera *camera, int index);
570 extern LIB3DSAPI void lib3ds_file_remove_camera(Lib3dsFile *file, int index);
571 extern LIB3DSAPI int lib3ds_file_camera_by_name(Lib3dsFile *file, const char *name);
572 extern LIB3DSAPI void lib3ds_file_reserve_lights(Lib3dsFile *file, int size, int force);
573 extern LIB3DSAPI void lib3ds_file_insert_light(Lib3dsFile *file, Lib3dsLight *light, int index);
574 extern LIB3DSAPI void lib3ds_file_remove_light(Lib3dsFile *file, int index);
575 extern LIB3DSAPI int lib3ds_file_light_by_name(Lib3dsFile *file, const char *name);
576 extern LIB3DSAPI void lib3ds_file_reserve_meshes(Lib3dsFile *file, int size, int force);
577 extern LIB3DSAPI void lib3ds_file_insert_mesh(Lib3dsFile *file, Lib3dsMesh *mesh, int index);
578 extern LIB3DSAPI void lib3ds_file_remove_mesh(Lib3dsFile *file, int index);
579 extern LIB3DSAPI int lib3ds_file_mesh_by_name(Lib3dsFile *file, const char *name);
580 extern LIB3DSAPI Lib3dsMesh* lib3ds_file_mesh_for_node(Lib3dsFile *file, Lib3dsNode *node);
581 extern LIB3DSAPI Lib3dsNode* lib3ds_file_node_by_name(Lib3dsFile *file, const char* name, Lib3dsNodeType type);
582 extern LIB3DSAPI Lib3dsNode* lib3ds_file_node_by_id(Lib3dsFile *file, unsigned short node_id);
583 extern LIB3DSAPI void lib3ds_file_append_node(Lib3dsFile *file, Lib3dsNode *node, Lib3dsNode *parent);
584 extern LIB3DSAPI void lib3ds_file_insert_node(Lib3dsFile *file, Lib3dsNode *node, Lib3dsNode *at);
585 extern LIB3DSAPI void lib3ds_file_remove_node(Lib3dsFile *file, Lib3dsNode *node);
586 extern LIB3DSAPI void lib3ds_file_minmax_node_id(Lib3dsFile *file, unsigned short *min_id, unsigned short *max_id);
587 extern LIB3DSAPI void lib3ds_file_create_nodes_for_meshes(Lib3dsFile *file);
588 
589 
590 /**
591     This function computes the bounding box of meshes, cameras
592     and lights defined in the 3D editor.
593 
594     \param file             The Lib3dsFile object to be examined.
595     \param include_meshes   Include meshes in bounding box calculation.
596     \param include_cameras  Include cameras in bounding box calculation.
597     \param include_lights   Include lights in bounding box calculation.
598     \param bmin             Returned minimum x,y,z values.
599     \param bmax             Returned maximum x,y,z values.
600  */
601 extern LIB3DSAPI void lib3ds_file_bounding_box_of_objects(
602     Lib3dsFile *file,
603     int include_meshes,
604     int include_cameras,
605     int include_lights,
606     float bmin[3],
607     float bmax[3]);
608 
609 /**
610     This function computes the bounding box of mesh, camera
611     and light instances defined in the Keyframer.
612 
613     \param file             The Lib3dsFile object to be examined.
614     \param include_meshes   Include meshes in bounding box calculation.
615     \param include_cameras  Include cameras in bounding box calculation.
616     \param include_lights   Include lights in bounding box calculation.
617     \param bmin             Returned minimum x,y,z values.
618     \param bmax             Returned maximum x,y,z values.
619     \param matrix           A matrix describing the coordinate system to
620                             calculate the bounding box in.
621  */
622 extern LIB3DSAPI void lib3ds_file_bounding_box_of_nodes(
623     Lib3dsFile *file,
624     int include_meshes,
625     int include_cameras,
626     int include_lights,
627     float bmin[3],
628     float bmax[3],
629     float matrix[4][4]);
630 
631 extern LIB3DSAPI Lib3dsMaterial* lib3ds_material_new(const char *name);
632 extern LIB3DSAPI void lib3ds_material_free(Lib3dsMaterial *material);
633 extern LIB3DSAPI Lib3dsCamera* lib3ds_camera_new(const char *name);
634 extern LIB3DSAPI void lib3ds_camera_free(Lib3dsCamera *mesh);
635 extern LIB3DSAPI Lib3dsLight* lib3ds_light_new(const char *name);
636 extern LIB3DSAPI void lib3ds_light_free(Lib3dsLight *mesh);
637 extern LIB3DSAPI Lib3dsMesh* lib3ds_mesh_new(const char *name);
638 extern LIB3DSAPI void lib3ds_mesh_free(Lib3dsMesh *mesh);
639 extern LIB3DSAPI void lib3ds_mesh_resize_vertices(Lib3dsMesh *mesh, int nvertices, int use_texcos, int use_flags);
640 extern LIB3DSAPI void lib3ds_mesh_resize_faces(Lib3dsMesh *mesh, int nfaces);
641 extern LIB3DSAPI void lib3ds_mesh_bounding_box(Lib3dsMesh *mesh, float bmin[3], float bmax[3]);
642 extern LIB3DSAPI void lib3ds_mesh_calculate_face_normals(Lib3dsMesh *mesh, float (*face_normals)[3]);
643 extern LIB3DSAPI void lib3ds_mesh_calculate_vertex_normals(Lib3dsMesh *mesh, float (*normals)[3]);
644 
645 extern LIB3DSAPI Lib3dsNode* lib3ds_node_new(Lib3dsNodeType type);
646 extern LIB3DSAPI Lib3dsAmbientColorNode* lib3ds_node_new_ambient_color(float color0[3]);
647 extern LIB3DSAPI Lib3dsMeshInstanceNode* lib3ds_node_new_mesh_instance(Lib3dsMesh *mesh, const char* instance_name, float pos0[3], float scl0[3], float rot0[4]);
648 extern LIB3DSAPI Lib3dsCameraNode* lib3ds_node_new_camera(Lib3dsCamera *camera);
649 extern LIB3DSAPI Lib3dsTargetNode* lib3ds_node_new_camera_target(Lib3dsCamera *camera);
650 extern LIB3DSAPI Lib3dsOmnilightNode* lib3ds_node_new_omnilight(Lib3dsLight *light);
651 extern LIB3DSAPI Lib3dsSpotlightNode* lib3ds_node_new_spotlight(Lib3dsLight *light);
652 extern LIB3DSAPI Lib3dsTargetNode* lib3ds_node_new_spotlight_target(Lib3dsLight *light);
653 extern LIB3DSAPI void lib3ds_node_free(Lib3dsNode *node);
654 extern LIB3DSAPI void lib3ds_node_eval(Lib3dsNode *node, float t);
655 extern LIB3DSAPI Lib3dsNode* lib3ds_node_by_name(Lib3dsNode *node, const char* name, Lib3dsNodeType type);
656 extern LIB3DSAPI Lib3dsNode* lib3ds_node_by_id(Lib3dsNode *node, unsigned short node_id);
657 
658 extern LIB3DSAPI Lib3dsTrack* lib3ds_track_new(Lib3dsTrackType type, int nkeys);
659 extern LIB3DSAPI void lib3ds_track_free(Lib3dsTrack *track);
660 extern LIB3DSAPI void lib3ds_track_resize(Lib3dsTrack *track, int nkeys);
661 extern LIB3DSAPI void lib3ds_track_eval_bool(Lib3dsTrack *track, int *b, float t);
662 extern LIB3DSAPI void lib3ds_track_eval_float(Lib3dsTrack *track, float *f, float t);
663 extern LIB3DSAPI void lib3ds_track_eval_vector(Lib3dsTrack *track, float v[3], float t);
664 extern LIB3DSAPI void lib3ds_track_eval_quat(Lib3dsTrack *track, float q[4], float t);
665 
666 /**
667     Calculates the ease in/out function. See Lib3dsKey for details.
668 
669     \param fp           Previous frame number.
670     \param fc           Current frame number.
671     \param fn           Next frame number.
672     \param ease_from    Ease in value [0, 1.0]
673     \param ease_to      Ease out value [0, 1.0]
674 */
675 extern LIB3DSAPI float lib3ds_math_ease(
676     float fp,
677     float fc,
678     float fn,
679     float ease_from,
680     float ease_to);
681 
682 /**
683     Computes a point on a n-dimensional cubic hermite spline.
684     \param v
685         [out] Result
686     \param a
687         [in] First point of the spline.
688     \param p
689         [in] Tangent at the first point of the spline.
690     \param q
691         [in] Tangent at the second point of the spline.
692     \param b
693         [in] Second point of the spline.
694     \param n
695         [in] Dimension
696     \param t
697         [in] Parameter value [0...1]
698 */
699 extern LIB3DSAPI void lib3ds_math_cubic_interp(
700     float *v,
701     float *a,
702     float *p,
703     float *q,
704     float *b,
705     int n,
706     float t);
707 
708 extern LIB3DSAPI void lib3ds_vector_make(
709     float c[3],
710     float x,
711     float y,
712     float z);
713 
714 /**
715     Sets all components of a vector to zero.
716     \param c
717         The Pointer to the vector.
718 */
719 extern LIB3DSAPI void lib3ds_vector_zero(
720     float c[3]);
721 
722 /**
723     Copies all components of a vector to another vector.
724     \param dst
725         [out] The destination vector.
726     \param src
727         [in] The source vector.
728 */
729 extern LIB3DSAPI void lib3ds_vector_copy(
730     float dst[3],
731     float src[3]);
732 
733 /**
734     Negates all components of a vector.
735     \param c
736         The Pointer to the vector.
737 */
738 extern LIB3DSAPI void lib3ds_vector_neg(
739     float c[3]);
740 
741 extern LIB3DSAPI void lib3ds_vector_make(float c[3], float x, float y, float z);
742 extern LIB3DSAPI void lib3ds_vector_zero(float c[3]);
743 extern LIB3DSAPI void lib3ds_vector_add(float c[3], float a[3], float b[3]);
744 extern LIB3DSAPI void lib3ds_vector_sub(float c[3], float a[3], float b[3]);
745 extern LIB3DSAPI void lib3ds_vector_scalar_mul(float c[3], float a[3], float k);
746 extern LIB3DSAPI void lib3ds_vector_cross(float c[3], float a[3], float b[3]);
747 extern LIB3DSAPI float lib3ds_vector_dot(float a[3], float b[3]);
748 extern LIB3DSAPI float lib3ds_vector_length(float c[3]);
749 extern LIB3DSAPI void lib3ds_vector_normalize(float c[3]);
750 extern LIB3DSAPI void lib3ds_vector_normal(float n[3], float a[3], float b[3], float c[3]);
751 extern LIB3DSAPI void lib3ds_vector_min(float c[3], float a[3]);
752 extern LIB3DSAPI void lib3ds_vector_max(float c[3], float a[3]);
753 extern LIB3DSAPI void lib3ds_vector_transform(float c[3], float m[4][4], float a[3]);
754 
755 extern LIB3DSAPI void lib3ds_quat_identity(float c[4]);
756 extern LIB3DSAPI void lib3ds_quat_copy(float dest[4], float src[4]);
757 extern LIB3DSAPI void lib3ds_quat_axis_angle(float c[4], float axis[3], float angle);
758 extern LIB3DSAPI void lib3ds_quat_neg(float c[4]);
759 extern LIB3DSAPI void lib3ds_quat_cnj(float c[4]);
760 extern LIB3DSAPI void lib3ds_quat_mul(float c[4], float a[4], float b[4]);
761 extern LIB3DSAPI void lib3ds_quat_scalar(float c[4], float k);
762 extern LIB3DSAPI void lib3ds_quat_normalize(float c[4]);
763 extern LIB3DSAPI void lib3ds_quat_inv(float c[4]);
764 extern LIB3DSAPI float lib3ds_quat_dot(float a[4], float b[4]);
765 extern LIB3DSAPI float lib3ds_quat_norm(float c[4]);
766 extern LIB3DSAPI void lib3ds_quat_ln(float c[4]);
767 extern LIB3DSAPI void lib3ds_quat_ln_dif(float c[4], float a[4], float b[4]);
768 extern LIB3DSAPI void lib3ds_quat_exp(float c[4]);
769 extern LIB3DSAPI void lib3ds_quat_slerp(float c[4], float a[4], float b[4], float t);
770 extern LIB3DSAPI void lib3ds_quat_squad(float c[4], float a[4], float p[4], float q[4], float b[4], float t);
771 extern LIB3DSAPI void lib3ds_quat_tangent(float c[4], float p[4], float q[4], float n[4]);
772 
773 extern LIB3DSAPI void lib3ds_matrix_zero(float m[4][4]);
774 extern LIB3DSAPI void lib3ds_matrix_identity(float  m[4][4]);
775 extern LIB3DSAPI void lib3ds_matrix_copy(float dest[4][4], float src[4][4]);
776 extern LIB3DSAPI void lib3ds_matrix_neg(float m[4][4]);
777 extern LIB3DSAPI void lib3ds_matrix_transpose(float m[4][4]);
778 extern LIB3DSAPI void lib3ds_matrix_add(float m[4][4], float a[4][4], float b[4][4]);
779 extern LIB3DSAPI void lib3ds_matrix_sub(float m[4][4], float a[4][4], float b[4][4]);
780 extern LIB3DSAPI void lib3ds_matrix_mult(float m[4][4], float a[4][4], float b[4][4]);
781 extern LIB3DSAPI void lib3ds_matrix_scalar(float m[4][4], float k);
782 extern LIB3DSAPI float lib3ds_matrix_det(float m[4][4]);
783 extern LIB3DSAPI int lib3ds_matrix_inv(float m[4][4]);
784 extern LIB3DSAPI void lib3ds_matrix_translate(float m[4][4], float x, float y, float z);
785 extern LIB3DSAPI void lib3ds_matrix_scale(float m[4][4], float x, float y, float z);
786 extern LIB3DSAPI void lib3ds_matrix_rotate_quat(float m[4][4], float q[4]);
787 extern LIB3DSAPI void lib3ds_matrix_rotate(float m[4][4], float angle, float ax, float ay, float az);
788 extern LIB3DSAPI void lib3ds_matrix_camera(float m[4][4], float pos[3], float tgt[3], float roll);
789 
790 /** @} */
791 #ifdef __cplusplus
792 }
793 #endif
794 #endif
795 
796