zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lib3ds_mesh.c
Go to the documentation of this file.
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 
34 lib3ds_mesh_new(const char *name) {
35  Lib3dsMesh *mesh;
36 
37  assert(name);
38  assert(strlen(name) < 64);
39 
40  mesh = (Lib3dsMesh*) calloc(sizeof(Lib3dsMesh), 1);
41  if (!mesh) {
42  return (0);
43  }
44  strcpy(mesh->name, name);
46  mesh->map_type = LIB3DS_MAP_NONE;
47  return (mesh);
48 }
49 
50 
56 void
58  lib3ds_mesh_resize_vertices(mesh, 0, 0, 0);
59  lib3ds_mesh_resize_faces(mesh, 0);
60  memset(mesh, 0, sizeof(Lib3dsMesh));
61  free(mesh);
62 }
63 
64 
65 void
66 lib3ds_mesh_resize_vertices(Lib3dsMesh *mesh, int nvertices, int use_texcos, int use_flags) {
67  assert(mesh);
68  mesh->vertices = lib3ds_util_realloc_array(mesh->vertices, mesh->nvertices, nvertices, 3 * sizeof(float));
70  mesh->texcos,
71  mesh->texcos? mesh->nvertices : 0,
72  use_texcos? nvertices : 0,
73  2 * sizeof(float)
74  );
76  mesh->vflags,
77  mesh->vflags? mesh->nvertices : 0,
78  use_flags? nvertices : 0,
79  2 * sizeof(float)
80  );
81  mesh->nvertices = nvertices;
82 }
83 
84 
85 void
87  int i;
88  assert(mesh);
89  mesh->faces = lib3ds_util_realloc_array(mesh->faces, mesh->nfaces, nfaces, sizeof(Lib3dsFace));
90  for (i = mesh->nfaces; i < nfaces; ++i) {
91  mesh->faces[i].material = -1;
92  }
93  mesh->nfaces = nfaces;
94 }
95 
96 
104 void
105 lib3ds_mesh_bounding_box(Lib3dsMesh *mesh, float bmin[3], float bmax[3]) {
106  int i;
107  bmin[0] = bmin[1] = bmin[2] = FLT_MAX;
108  bmax[0] = bmax[1] = bmax[2] = -FLT_MAX;
109 
110  for (i = 0; i < mesh->nvertices; ++i) {
111  lib3ds_vector_min(bmin, mesh->vertices[i]);
112  lib3ds_vector_max(bmax, mesh->vertices[i]);
113  }
114 }
115 
116 
117 void
118 lib3ds_mesh_calculate_face_normals(Lib3dsMesh *mesh, float (*face_normals)[3]) {
119  int i;
120 
121  if (!mesh->nfaces) {
122  return;
123  }
124  for (i = 0; i < mesh->nfaces; ++i) {
126  face_normals[i],
127  mesh->vertices[mesh->faces[i].index[0]],
128  mesh->vertices[mesh->faces[i].index[1]],
129  mesh->vertices[mesh->faces[i].index[2]]
130  );
131  }
132 }
133 
134 
135 typedef struct Lib3dsFaces {
136  struct Lib3dsFaces *next;
137  int index;
138  float normal[3];
139 } Lib3dsFaces;
140 
141 
162 void
164  Lib3dsFaces **fl;
165  Lib3dsFaces *fa;
166  int i, j;
167 
168  if (!mesh->nfaces) {
169  return;
170  }
171 
172  fl = calloc(sizeof(Lib3dsFaces*), mesh->nvertices);
173  fa = malloc(sizeof(Lib3dsFaces) * 3 * mesh->nfaces);
174 
175  for (i = 0; i < mesh->nfaces; ++i) {
176  for (j = 0; j < 3; ++j) {
177  Lib3dsFaces* l = &fa[3*i+j];
178  float p[3], q[3], n[3];
179  float len, weight;
180 
181  l->index = i;
182  l->next = fl[mesh->faces[i].index[j]];
183  fl[mesh->faces[i].index[j]] = l;
184 
185  lib3ds_vector_sub(p, mesh->vertices[mesh->faces[i].index[j<2? j + 1 : 0]], mesh->vertices[mesh->faces[i].index[j]]);
186  lib3ds_vector_sub(q, mesh->vertices[mesh->faces[i].index[j>0? j - 1 : 2]], mesh->vertices[mesh->faces[i].index[j]]);
187  lib3ds_vector_cross(n, p, q);
188  len = lib3ds_vector_length(n);
189  if (len > 0) {
190  weight = (float)atan2(len, lib3ds_vector_dot(p, q));
191  lib3ds_vector_scalar_mul(l->normal, n, weight / len);
192  } else {
193  lib3ds_vector_zero(l->normal);
194  }
195  }
196  }
197 
198  for (i = 0; i < mesh->nfaces; ++i) {
199  Lib3dsFace *f = &mesh->faces[i];
200  for (j = 0; j < 3; ++j) {
201  float n[3];
202  Lib3dsFaces *p;
203  Lib3dsFace *pf;
204 
205  assert(mesh->faces[i].index[j] < mesh->nvertices);
206 
207  if (f->smoothing_group) {
208  unsigned smoothing_group = f->smoothing_group;
209 
211  for (p = fl[mesh->faces[i].index[j]]; p; p = p->next) {
212  pf = &mesh->faces[p->index];
213  if (pf->smoothing_group & f->smoothing_group)
214  smoothing_group |= pf->smoothing_group;
215  }
216 
217  for (p = fl[mesh->faces[i].index[j]]; p; p = p->next) {
218  pf = &mesh->faces[p->index];
219  if (smoothing_group & pf->smoothing_group) {
220  lib3ds_vector_add(n, n, p->normal);
221  }
222  }
223  } else {
224  lib3ds_vector_copy(n, fa[3*i+j].normal);
225  }
226 
228  lib3ds_vector_copy(normals[3*i+j], n);
229  }
230  }
231 
232  free(fa);
233  free(fl);
234 }
235 
236 
237 static void
239  Lib3dsChunk c;
240  uint16_t chunk;
241  int i;
242  uint16_t nfaces;
243 
245 
246  lib3ds_mesh_resize_faces(mesh, 0);
247  nfaces = lib3ds_io_read_word(io);
248  if (nfaces) {
249  lib3ds_mesh_resize_faces(mesh, nfaces);
250  for (i = 0; i < nfaces; ++i) {
251  mesh->faces[i].index[0] = lib3ds_io_read_word(io);
252  mesh->faces[i].index[1] = lib3ds_io_read_word(io);
253  mesh->faces[i].index[2] = lib3ds_io_read_word(io);
254  mesh->faces[i].flags = lib3ds_io_read_word(io);
255  }
256  lib3ds_chunk_read_tell(&c, io);
257 
258  while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) {
259  switch (chunk) {
260  case CHK_MSH_MAT_GROUP: {
261  char name[64];
262  unsigned n;
263  unsigned i;
264  int index;
265  int material;
266 
267  lib3ds_io_read_string(io, name, 64);
268  material = lib3ds_file_material_by_name(file, name);
269 
270  n = lib3ds_io_read_word(io);
271  for (i = 0; i < n; ++i) {
272  index = lib3ds_io_read_word(io);
273  if (index < mesh->nfaces) {
274  mesh->faces[index].material = material;
275  } else {
276  // TODO warning
277  }
278  }
279  break;
280  }
281 
282  case CHK_SMOOTH_GROUP: {
283  int i;
284  for (i = 0; i < mesh->nfaces; ++i) {
286  }
287  break;
288  }
289 
290  case CHK_MSH_BOXMAP: {
291  lib3ds_io_read_string(io, mesh->box_front, 64);
292  lib3ds_io_read_string(io, mesh->box_back, 64);
293  lib3ds_io_read_string(io, mesh->box_left, 64);
294  lib3ds_io_read_string(io, mesh->box_right, 64);
295  lib3ds_io_read_string(io, mesh->box_top, 64);
296  lib3ds_io_read_string(io, mesh->box_bottom, 64);
297  break;
298  }
299 
300  default:
301  lib3ds_chunk_unknown(chunk,io);
302  }
303  }
304 
305  }
306  lib3ds_chunk_read_end(&c, io);
307 }
308 
309 
310 void
312  Lib3dsChunk c;
313  uint16_t chunk;
314 
316 
317  while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) {
318  switch (chunk) {
319  case CHK_MESH_MATRIX: {
320  int i, j;
321 
323  for (i = 0; i < 4; i++) {
324  for (j = 0; j < 3; j++) {
325  mesh->matrix[i][j] = lib3ds_io_read_float(io);
326  }
327  }
328  break;
329  }
330 
331  case CHK_MESH_COLOR: {
332  mesh->color = lib3ds_io_read_byte(io);
333  break;
334  }
335 
336  case CHK_POINT_ARRAY: {
337  int i;
338  uint16_t nvertices = lib3ds_io_read_word(io);
339  lib3ds_mesh_resize_vertices(mesh, nvertices, mesh->texcos != NULL, mesh->vflags != NULL);
340  for (i = 0; i < mesh->nvertices; ++i) {
341  lib3ds_io_read_vector(io, mesh->vertices[i]);
342  }
343  break;
344  }
345 
346  case CHK_POINT_FLAG_ARRAY: {
347  int i;
348  uint16_t nflags = lib3ds_io_read_word(io);
349  uint16_t nvertices = (mesh->nvertices >= nflags)? mesh->nvertices : nflags;
350  lib3ds_mesh_resize_vertices(mesh, nvertices, mesh->texcos != NULL, 1);
351  for (i = 0; i < nflags; ++i) {
352  mesh->vflags[i] = lib3ds_io_read_word(io);
353  }
354  break;
355  }
356 
357  case CHK_FACE_ARRAY: {
358  lib3ds_chunk_read_reset(&c, io);
359  face_array_read(file, mesh, io);
360  break;
361  }
362 
363  case CHK_MESH_TEXTURE_INFO: {
364  int i, j;
365 
366  //FIXME: mesh->map_type = lib3ds_io_read_word(io);
367 
368  for (i = 0; i < 2; ++i) {
369  mesh->map_tile[i] = lib3ds_io_read_float(io);
370  }
371  for (i = 0; i < 3; ++i) {
372  mesh->map_pos[i] = lib3ds_io_read_float(io);
373  }
374  mesh->map_scale = lib3ds_io_read_float(io);
375 
377  for (i = 0; i < 4; i++) {
378  for (j = 0; j < 3; j++) {
379  mesh->map_matrix[i][j] = lib3ds_io_read_float(io);
380  }
381  }
382  for (i = 0; i < 2; ++i) {
384  }
386  break;
387  }
388 
389  case CHK_TEX_VERTS: {
390  int i;
391  uint16_t ntexcos = lib3ds_io_read_word(io);
392  uint16_t nvertices = (mesh->nvertices >= ntexcos)? mesh->nvertices : ntexcos;;
393  if (!mesh->texcos) {
394  lib3ds_mesh_resize_vertices(mesh, nvertices, 1, mesh->vflags != NULL);
395  }
396  for (i = 0; i < ntexcos; ++i) {
397  mesh->texcos[i][0] = lib3ds_io_read_float(io);
398  mesh->texcos[i][1] = lib3ds_io_read_float(io);
399  }
400  break;
401  }
402 
403  default:
404  lib3ds_chunk_unknown(chunk, io);
405  }
406  }
407 
408  if (lib3ds_matrix_det(mesh->matrix) < 0.0) {
409  /* Flip X coordinate of vertices if mesh matrix
410  has negative determinant */
411  float inv_matrix[4][4], M[4][4];
412  float tmp[3];
413  int i;
414 
415  lib3ds_matrix_copy(inv_matrix, mesh->matrix);
416  lib3ds_matrix_inv(inv_matrix);
417 
418  lib3ds_matrix_copy(M, mesh->matrix);
419  lib3ds_matrix_scale(M, -1.0f, 1.0f, 1.0f);
420  lib3ds_matrix_mult(M, M, inv_matrix);
421 
422  for (i = 0; i < mesh->nvertices; ++i) {
423  lib3ds_vector_transform(tmp, M, mesh->vertices[i]);
424  lib3ds_vector_copy(mesh->vertices[i], tmp);
425  }
426  }
427 
428  lib3ds_chunk_read_end(&c, io);
429 }
430 
431 
432 static void
434  Lib3dsChunk c;
435  int i;
436 
438  c.size = 8 + 12 * mesh->nvertices;
439  lib3ds_chunk_write(&c, io);
440 
442 
443  if (lib3ds_matrix_det(mesh->matrix) >= 0.0f) {
444  for (i = 0; i < mesh->nvertices; ++i) {
445  lib3ds_io_write_vector(io, mesh->vertices[i]);
446  }
447  } else {
448  /* Flip X coordinate of vertices if mesh matrix
449  has negative determinant */
450  float inv_matrix[4][4], M[4][4];
451  float tmp[3];
452 
453  lib3ds_matrix_copy(inv_matrix, mesh->matrix);
454  lib3ds_matrix_inv(inv_matrix);
455  lib3ds_matrix_copy(M, mesh->matrix);
456  lib3ds_matrix_scale(M, -1.0f, 1.0f, 1.0f);
457  lib3ds_matrix_mult(M, M, inv_matrix);
458 
459  for (i = 0; i < mesh->nvertices; ++i) {
460  lib3ds_vector_transform(tmp, M, mesh->vertices[i]);
461  lib3ds_io_write_vector(io, tmp);
462  }
463  }
464 }
465 
466 
467 static void
469  Lib3dsChunk c;
470  int i;
471 
472  if (!mesh->vflags) {
473  return;
474  }
475 
477  c.size = 8 + 2 * mesh->nvertices;
478  lib3ds_chunk_write(&c, io);
479 
481  for (i = 0; i < mesh->nvertices; ++i) {
482  lib3ds_io_write_word(io, mesh->vflags[i]);
483  }
484 }
485 
486 
487 static void
489  Lib3dsChunk c;
490 
491  if (mesh->nfaces == 0) {
492  return;
493  }
494  c.chunk = CHK_FACE_ARRAY;
495  lib3ds_chunk_write_start(&c, io);
496 
497  {
498  int i;
499 
500  lib3ds_io_write_word(io, (uint16_t) mesh->nfaces);
501  for (i = 0; i < mesh->nfaces; ++i) {
502  lib3ds_io_write_word(io, mesh->faces[i].index[0]);
503  lib3ds_io_write_word(io, mesh->faces[i].index[1]);
504  lib3ds_io_write_word(io, mesh->faces[i].index[2]);
505  lib3ds_io_write_word(io, mesh->faces[i].flags);
506  }
507  }
508 
509  {
510  /*---- MSH_CHK_MAT_GROUP ----*/
511  Lib3dsChunk c;
512  int i, j;
513  uint16_t num;
514  char *matf = ((Lib3dsIoImpl*)io->impl)->tmp_mem = calloc(sizeof(char), mesh->nfaces);
515  assert(matf);
516 
517  for (i = 0; i < mesh->nfaces; ++i) {
518  if (!matf[i] && (mesh->faces[i].material >= 0) && (mesh->faces[i].material < file->nmaterials)) {
519  matf[i] = 1;
520  num = 1;
521 
522  for (j = i + 1; j < mesh->nfaces; ++j) {
523  if (mesh->faces[i].material == mesh->faces[j].material) ++num;
524  }
525 
527  c.size = 6 + (uint32_t)strlen(file->materials[mesh->faces[i].material]->name) + 1 + 2 + 2 * num;
528  lib3ds_chunk_write(&c, io);
529  lib3ds_io_write_string(io, file->materials[mesh->faces[i].material]->name);
530  lib3ds_io_write_word(io, num);
532 
533  for (j = i + 1; j < mesh->nfaces; ++j) {
534  if (mesh->faces[i].material == mesh->faces[j].material) {
536  matf[j] = 1;
537  }
538  }
539  }
540  }
541  ((Lib3dsIoImpl*)io->impl)->tmp_mem = NULL;
542  free(matf);
543  }
544 
545  {
546  /*---- SMOOTH_GROUP ----*/
547  Lib3dsChunk c;
548  int i;
549 
551  c.size = 6 + 4 * mesh->nfaces;
552  lib3ds_chunk_write(&c, io);
553 
554  for (i = 0; i < mesh->nfaces; ++i) {
556  }
557  }
558 
559  {
560  /*---- MSH_BOXMAP ----*/
561  Lib3dsChunk c;
562 
563  if (strlen(mesh->box_front) ||
564  strlen(mesh->box_back) ||
565  strlen(mesh->box_left) ||
566  strlen(mesh->box_right) ||
567  strlen(mesh->box_top) ||
568  strlen(mesh->box_bottom)) {
569 
570  c.chunk = CHK_MSH_BOXMAP;
571  lib3ds_chunk_write_start(&c, io);
572 
574  lib3ds_io_write_string(io, mesh->box_back);
575  lib3ds_io_write_string(io, mesh->box_left);
577  lib3ds_io_write_string(io, mesh->box_top);
579 
580  lib3ds_chunk_write_end(&c, io);
581  }
582  }
583 
584  lib3ds_chunk_write_end(&c, io);
585 }
586 
587 
588 static void
590  Lib3dsChunk c;
591  int i;
592 
593  if (!mesh->texcos) {
594  return;
595  }
596 
597  c.chunk = CHK_TEX_VERTS;
598  c.size = 8 + 8 * mesh->nvertices;
599  lib3ds_chunk_write(&c, io);
600 
601  lib3ds_io_write_word(io, mesh->nvertices);
602  for (i = 0; i < mesh->nvertices; ++i) {
603  lib3ds_io_write_float(io, mesh->texcos[i][0]);
604  lib3ds_io_write_float(io, mesh->texcos[i][1]);
605  }
606 }
607 
608 
609 void
611  Lib3dsChunk c;
612 
614  lib3ds_chunk_write_start(&c, io);
615 
616  point_array_write(mesh, io);
617  texco_array_write(mesh, io);
618 
619  if (mesh->map_type != LIB3DS_MAP_NONE) { /*---- LIB3DS_MESH_TEXTURE_INFO ----*/
620  Lib3dsChunk c;
621  int i, j;
622 
624  c.size = 92;
625  lib3ds_chunk_write(&c, io);
626 
627  lib3ds_io_write_word(io, mesh->map_type);
628 
629  for (i = 0; i < 2; ++i) {
630  lib3ds_io_write_float(io, mesh->map_tile[i]);
631  }
632  lib3ds_io_write_vector(io, mesh->map_pos);
633  lib3ds_io_write_float(io, mesh->map_scale);
634 
635  for (i = 0; i < 4; i++) {
636  for (j = 0; j < 3; j++) {
637  lib3ds_io_write_float(io, mesh->map_matrix[i][j]);
638  }
639  }
640  for (i = 0; i < 2; ++i) {
642  }
644  }
645 
646  flag_array_write(mesh, io);
647 
648  {
649  /*---- LIB3DS_MESH_MATRIX ----*/
650  Lib3dsChunk c;
651  int i, j;
652 
654  c.size = 54;
655  lib3ds_chunk_write(&c, io);
656  for (i = 0; i < 4; i++) {
657  for (j = 0; j < 3; j++) {
658  lib3ds_io_write_float(io, mesh->matrix[i][j]);
659  }
660  }
661  }
662 
663  if (mesh->color) { /*---- LIB3DS_MESH_COLOR ----*/
664  Lib3dsChunk c;
665 
666  c.chunk = CHK_MESH_COLOR;
667  c.size = 7;
668  lib3ds_chunk_write(&c, io);
669  lib3ds_io_write_byte(io, mesh->color);
670  }
671 
672  face_array_write(file, mesh, io);
673 
674  lib3ds_chunk_write_end(&c, io);
675 }
676 
unsigned short flags
Definition: lib3ds.h:353
unsigned short * vflags
Definition: lib3ds.h:369
LIB3DSAPI void lib3ds_vector_transform(float c[3], float m[4][4], float a[3])
unsigned short nfaces
Definition: lib3ds.h:370
unsigned short nvertices
Definition: lib3ds.h:366
float map_cylinder_height
Definition: lib3ds.h:384
static void face_array_read(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:238
else Out of place iCCP chunk
Definition: pngrutil.c:1260
float map_pos[3]
Definition: lib3ds.h:379
static void point_array_write(Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:433
#define NULL
Definition: ftobjs.h:61
GLclampf f
Definition: glew.h:3390
static void face_array_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:488
int color
Definition: lib3ds.h:364
unsigned short uint16_t
GLclampd n
Definition: glew.h:7287
float map_tile[2]
Definition: lib3ds.h:382
void lib3ds_io_write_byte(Lib3dsIo *io, uint8_t b)
Definition: lib3ds_io.c:310
float map_scale
Definition: lib3ds.h:381
char name[64]
Definition: lib3ds.h:362
SDL_EventEntry * free
Definition: SDL_events.c:80
float(* vertices)[3]
Definition: lib3ds.h:367
void lib3ds_io_read_vector(Lib3dsIo *io, float v[3])
Definition: lib3ds_io.c:258
int32_t j
Definition: e_log.c:102
#define memset
Definition: SDL_malloc.c:633
FILE * file
Definition: visualinfo.c:88
char name[64]
Definition: lib3ds.h:227
void lib3ds_chunk_unknown(uint16_t chunk, Lib3dsIo *io)
Definition: lib3ds_chunk.c:140
EGLImageKHR EGLint * name
Definition: eglext.h:284
LIB3DSAPI void lib3ds_matrix_scale(float m[4][4], float x, float y, float z)
Lib3dsFace * faces
Definition: lib3ds.h:371
#define assert(x)
Definition: SDL_malloc.c:1234
GLenum GLsizei len
Definition: glew.h:7035
LIB3DSAPI void lib3ds_matrix_identity(float m[4][4])
Definition: lib3ds_matrix.c:42
unsigned short index[3]
Definition: lib3ds.h:352
uint32_t lib3ds_io_read_dword(Lib3dsIo *io)
Definition: lib3ds_io.c:172
GLuint GLuint GLfloat weight
Definition: glew.h:12401
if(!yyg->yy_init)
float map_matrix[4][4]
Definition: lib3ds.h:380
LIB3DSAPI void lib3ds_mesh_calculate_face_normals(Lib3dsMesh *mesh, float(*face_normals)[3])
Definition: lib3ds_mesh.c:118
#define calloc
Definition: SDL_malloc.c:636
uint32_t size
Definition: lib3ds_impl.h:297
LIB3DSAPI void lib3ds_matrix_mult(float m[4][4], float a[4][4], float b[4][4])
uint16_t lib3ds_chunk_read_next(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:68
void lib3ds_mesh_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:610
LIB3DSAPI void lib3ds_vector_max(float c[3], float a[3])
void lib3ds_io_write_string(Lib3dsIo *io, const char *s)
Definition: lib3ds_io.c:443
char box_back[64]
Definition: lib3ds.h:373
void lib3ds_chunk_write_start(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:119
void lib3ds_io_write_vector(Lib3dsIo *io, float v[3])
Definition: lib3ds_io.c:422
uint8_t lib3ds_io_read_byte(Lib3dsIo *io)
Definition: lib3ds_io.c:143
LIB3DSAPI void lib3ds_vector_min(float c[3], float a[3])
LIB3DSAPI void lib3ds_vector_copy(float dst[3], float src[3])
Definition: lib3ds_vector.c:39
void lib3ds_io_write_float(Lib3dsIo *io, float l)
Definition: lib3ds_io.c:402
int nmaterials
Definition: lib3ds.h:543
void lib3ds_chunk_read_reset(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:90
LIB3DSAPI void lib3ds_mesh_free(Lib3dsMesh *mesh)
Definition: lib3ds_mesh.c:57
char box_right[64]
Definition: lib3ds.h:375
char box_front[64]
Definition: lib3ds.h:372
int map_type
Definition: lib3ds.h:378
GLfloat GLfloat p
Definition: glew.h:14938
LIB3DSAPI void lib3ds_vector_zero(float c[3])
Definition: lib3ds_vector.c:30
const GLfloat * c
Definition: glew.h:14913
static void texco_array_write(Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:589
LIB3DSAPI Lib3dsMesh * lib3ds_mesh_new(const char *name)
Definition: lib3ds_mesh.c:34
LIB3DSAPI int lib3ds_file_material_by_name(Lib3dsFile *file, const char *name)
Definition: lib3ds_file.c:949
LIB3DSAPI void lib3ds_vector_normalize(float c[3])
void * lib3ds_util_realloc_array(void *ptr, int old_size, int new_size, int element_size)
Definition: lib3ds_util.c:21
uint16_t lib3ds_io_read_word(Lib3dsIo *io)
Definition: lib3ds_io.c:156
LIB3DSAPI void lib3ds_vector_normal(float n[3], float a[3], float b[3], float c[3])
GLuint index
Definition: glew.h:1800
float lib3ds_io_read_float(Lib3dsIo *io)
Definition: lib3ds_io.c:237
struct Lib3dsFaces Lib3dsFaces
LIB3DSAPI void lib3ds_mesh_resize_vertices(Lib3dsMesh *mesh, int nvertices, int use_texcos, int use_flags)
Definition: lib3ds_mesh.c:66
GLuint num
Definition: glew.h:2631
LIB3DSAPI void lib3ds_vector_add(float c[3], float a[3], float b[3])
Definition: lib3ds_vector.c:55
void lib3ds_chunk_read_end(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:96
void lib3ds_chunk_read_tell(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:62
float(* texcos)[2]
Definition: lib3ds.h:368
unsigned int uint32_t
GLdouble l
Definition: glew.h:8383
#define malloc
Definition: SDL_malloc.c:635
LIB3DSAPI void lib3ds_mesh_bounding_box(Lib3dsMesh *mesh, float bmin[3], float bmax[3])
Definition: lib3ds_mesh.c:105
LIB3DSAPI void lib3ds_vector_scalar_mul(float c[3], float a[3], float k)
Definition: lib3ds_vector.c:86
static void flag_array_write(Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:468
LIB3DSAPI void lib3ds_vector_sub(float c[3], float a[3], float b[3])
Definition: lib3ds_vector.c:71
void lib3ds_io_read_string(Lib3dsIo *io, char *s, int buflen)
Definition: lib3ds_io.c:285
LIB3DSAPI void lib3ds_mesh_calculate_vertex_normals(Lib3dsMesh *mesh, float(*normals)[3])
Definition: lib3ds_mesh.c:163
char box_left[64]
Definition: lib3ds.h:374
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1400
char box_top[64]
Definition: lib3ds.h:376
void lib3ds_chunk_write(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:111
void lib3ds_chunk_read_start(Lib3dsChunk *c, uint16_t chunk, Lib3dsIo *io)
Definition: lib3ds_chunk.c:50
float map_planar_size[2]
Definition: lib3ds.h:383
LIB3DSAPI void lib3ds_vector_cross(float c[3], float a[3], float b[3])
LIB3DSAPI void lib3ds_mesh_resize_faces(Lib3dsMesh *mesh, int nfaces)
Definition: lib3ds_mesh.c:86
void * impl
Definition: lib3ds.h:57
LIB3DSAPI int lib3ds_matrix_inv(float m[4][4])
int material
Definition: lib3ds.h:354
LIB3DSAPI float lib3ds_vector_dot(float a[3], float b[3])
LIB3DSAPI float lib3ds_matrix_det(float m[4][4])
unsigned smoothing_group
Definition: lib3ds.h:355
uint16_t chunk
Definition: lib3ds_impl.h:296
int i
Definition: pngrutil.c:1377
LIB3DSAPI float lib3ds_vector_length(float c[3])
void lib3ds_io_write_dword(Lib3dsIo *io, uint32_t d)
Definition: lib3ds_io.c:338
float matrix[4][4]
Definition: lib3ds.h:365
void lib3ds_mesh_read(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:311
char box_bottom[64]
Definition: lib3ds.h:377
void lib3ds_chunk_write_end(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:129
Lib3dsMaterial ** materials
Definition: lib3ds.h:544
LIB3DSAPI void lib3ds_matrix_copy(float dest[4][4], float src[4][4])
Definition: lib3ds_matrix.c:56
void lib3ds_io_write_word(Lib3dsIo *io, uint16_t w)
Definition: lib3ds_io.c:322