zenilib: zenilib/jni/external/lib3ds/src/lib3ds_mesh.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
33 Lib3dsMesh*
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);
45 lib3ds_matrix_identity(mesh->matrix);
46 mesh->map_type = LIB3DS_MAP_NONE;
47 return (mesh);
48 }
49
50
56 void
57 lib3ds_mesh_free(Lib3dsMesh *mesh) {
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));
69 mesh->texcos = lib3ds_util_realloc_array(
70 mesh->texcos,
71 mesh->texcos? mesh->nvertices : 0,
72 use_texcos? nvertices : 0,
73 2 * sizeof(float)
74 );
75 mesh->vflags = lib3ds_util_realloc_array(
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
86 lib3ds_mesh_resize_faces(Lib3dsMesh *mesh, int nfaces) {
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) {
125 lib3ds_vector_normal(
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
163 lib3ds_mesh_calculate_vertex_normals(Lib3dsMesh *mesh, float (*normals)[3]) {
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
210 lib3ds_vector_zero(n);
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
227 lib3ds_vector_normalize(n);
228 lib3ds_vector_copy(normals[3*i+j], n);
229 }
230 }
231
232 free(fa);
233 free(fl);
234 }
235
236
237 static void
238 face_array_read(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io) {
239 Lib3dsChunk c;
240 uint16_t chunk;
241 int i;
242 uint16_t nfaces;
243
244 lib3ds_chunk_read_start(&c, CHK_FACE_ARRAY, io);
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) {
285 mesh->faces[i].smoothing_group = lib3ds_io_read_dword(io);
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
311 lib3ds_mesh_read(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io) {
312 Lib3dsChunk c;
313 uint16_t chunk;
314
315 lib3ds_chunk_read_start(&c, CHK_N_TRI_OBJECT, io);
316
317 while ((chunk = lib3ds_chunk_read_next(&c, io)) != 0) {
318 switch (chunk) {
319 case CHK_MESH_MATRIX: {
320 int i, j;
321
322 lib3ds_matrix_identity(mesh->matrix);
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
376 lib3ds_matrix_identity(mesh->map_matrix);
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) {
383 mesh->map_planar_size[i] = lib3ds_io_read_float(io);
384 }
385 mesh->map_cylinder_height = lib3ds_io_read_float(io);
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
433 point_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) {
434 Lib3dsChunk c;
435 int i;
436
437 c.chunk = CHK_POINT_ARRAY;
438 c.size = 8 + 12 * mesh->nvertices;
439 lib3ds_chunk_write(&c, io);
440
441 lib3ds_io_write_word(io, (uint16_t) mesh->nvertices);
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
468 flag_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) {
469 Lib3dsChunk c;
470 int i;
471
472 if (!mesh->vflags) {
473 return;
474 }
475
476 c.chunk = CHK_POINT_FLAG_ARRAY;
477 c.size = 8 + 2 * mesh->nvertices;
478 lib3ds_chunk_write(&c, io);
479
480 lib3ds_io_write_word(io, (uint16_t) mesh->nvertices);
481 for (i = 0; i < mesh->nvertices; ++i) {
482 lib3ds_io_write_word(io, mesh->vflags[i]);
483 }
484 }
485
486
487 static void
488 face_array_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io) {
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
526 c.chunk = CHK_MSH_MAT_GROUP;
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);
531 lib3ds_io_write_word(io, (uint16_t) i);
532
533 for (j = i + 1; j < mesh->nfaces; ++j) {
534 if (mesh->faces[i].material == mesh->faces[j].material) {
535 lib3ds_io_write_word(io, (uint16_t) j);
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
550 c.chunk = CHK_SMOOTH_GROUP;
551 c.size = 6 + 4 * mesh->nfaces;
552 lib3ds_chunk_write(&c, io);
553
554 for (i = 0; i < mesh->nfaces; ++i) {
555 lib3ds_io_write_dword(io, mesh->faces[i].smoothing_group);
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
573 lib3ds_io_write_string(io, mesh->box_front);
574 lib3ds_io_write_string(io, mesh->box_back);
575 lib3ds_io_write_string(io, mesh->box_left);
576 lib3ds_io_write_string(io, mesh->box_right);
577 lib3ds_io_write_string(io, mesh->box_top);
578 lib3ds_io_write_string(io, mesh->box_bottom);
579
580 lib3ds_chunk_write_end(&c, io);
581 }
582 }
583
584 lib3ds_chunk_write_end(&c, io);
585 }
586
587
588 static void
589 texco_array_write(Lib3dsMesh *mesh, Lib3dsIo *io) {
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
610 lib3ds_mesh_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io) {
611 Lib3dsChunk c;
612
613 c.chunk = CHK_N_TRI_OBJECT;
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
623 c.chunk = CHK_MESH_TEXTURE_INFO;
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) {
641 lib3ds_io_write_float(io, mesh->map_planar_size[i]);
642 }
643 lib3ds_io_write_float(io, mesh->map_cylinder_height);
644 }
645
646 flag_array_write(mesh, io);
647
648 {
649 /*---- LIB3DS_MESH_MATRIX ----*/
650 Lib3dsChunk c;
651 int i, j;
652
653 c.chunk = CHK_MESH_MATRIX;
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
Lib3dsFace::flags
unsigned short flags
Definition: lib3ds.h:353
Lib3dsMesh::vflags
unsigned short * vflags
Definition: lib3ds.h:369
lib3ds_vector_transform
LIB3DSAPI void lib3ds_vector_transform(float c[3], float m[4][4], float a[3])
Definition: lib3ds_vector.c:203
Lib3dsMesh::nfaces
unsigned short nfaces
Definition: lib3ds.h:370
Lib3dsMesh::nvertices
unsigned short nvertices
Definition: lib3ds.h:366
Lib3dsMesh::map_cylinder_height
float map_cylinder_height
Definition: lib3ds.h:384
face_array_read
static void face_array_read(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:238
chunk
else Out of place iCCP chunk
Definition: pngrutil.c:1260
Lib3dsChunk
Definition: lib3ds_impl.h:295
Lib3dsMesh::map_pos
float map_pos[3]
Definition: lib3ds.h:379
point_array_write
static void point_array_write(Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:433
NULL
#define NULL
Definition: ftobjs.h:61
f
GLclampf f
Definition: glew.h:3390
face_array_write
static void face_array_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:488
Lib3dsMesh::color
int color
Definition: lib3ds.h:364
uint16_t
unsigned short uint16_t
Definition: SDL_config_windows.h:60
n
GLclampd n
Definition: glew.h:7287
Lib3dsMesh::map_tile
float map_tile[2]
Definition: lib3ds.h:382
CHK_TEX_VERTS
Definition: lib3ds_impl.h:217
lib3ds_io_write_byte
void lib3ds_io_write_byte(Lib3dsIo *io, uint8_t b)
Definition: lib3ds_io.c:310
Lib3dsMesh::map_scale
float map_scale
Definition: lib3ds.h:381
Lib3dsMesh::name
char name[64]
Definition: lib3ds.h:362
free
SDL_EventEntry * free
Definition: SDL_events.c:80
Lib3dsMesh::vertices
float(* vertices)[3]
Definition: lib3ds.h:367
lib3ds_io_read_vector
void lib3ds_io_read_vector(Lib3dsIo *io, float v[3])
Definition: lib3ds_io.c:258
j
int32_t j
Definition: e_log.c:102
memset
#define memset
Definition: SDL_malloc.c:633
file
FILE * file
Definition: visualinfo.c:88
LIB3DS_MAP_NONE
Definition: lib3ds.h:332
Lib3dsMaterial::name
char name[64]
Definition: lib3ds.h:227
lib3ds_chunk_unknown
void lib3ds_chunk_unknown(uint16_t chunk, Lib3dsIo *io)
Definition: lib3ds_chunk.c:140
name
EGLImageKHR EGLint * name
Definition: eglext.h:284
lib3ds_matrix_scale
LIB3DSAPI void lib3ds_matrix_scale(float m[4][4], float x, float y, float z)
Definition: lib3ds_matrix.c:341
Lib3dsMesh::faces
Lib3dsFace * faces
Definition: lib3ds.h:371
assert
#define assert(x)
Definition: SDL_malloc.c:1234
len
GLenum GLsizei len
Definition: glew.h:7035
lib3ds_matrix_identity
LIB3DSAPI void lib3ds_matrix_identity(float m[4][4])
Definition: lib3ds_matrix.c:42
Lib3dsFace::index
unsigned short index[3]
Definition: lib3ds.h:352
lib3ds_io_read_dword
uint32_t lib3ds_io_read_dword(Lib3dsIo *io)
Definition: lib3ds_io.c:172
weight
GLuint GLuint GLfloat weight
Definition: glew.h:12401
if
if(!yyg->yy_init)
Definition: glslang_lex.cpp:1037
Lib3dsMesh::map_matrix
float map_matrix[4][4]
Definition: lib3ds.h:380
lib3ds_mesh_calculate_face_normals
LIB3DSAPI void lib3ds_mesh_calculate_face_normals(Lib3dsMesh *mesh, float(*face_normals)[3])
Definition: lib3ds_mesh.c:118
calloc
#define calloc
Definition: SDL_malloc.c:636
CHK_MSH_BOXMAP
Definition: lib3ds_impl.h:216
Lib3dsChunk::size
uint32_t size
Definition: lib3ds_impl.h:297
lib3ds_matrix_mult
LIB3DSAPI void lib3ds_matrix_mult(float m[4][4], float a[4][4], float b[4][4])
Definition: lib3ds_matrix.c:132
Lib3dsMesh
Definition: lib3ds.h:359
lib3ds_chunk_read_next
uint16_t lib3ds_chunk_read_next(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:68
lib3ds_mesh_write
void lib3ds_mesh_write(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:610
lib3ds_vector_max
LIB3DSAPI void lib3ds_vector_max(float c[3], float a[3])
Definition: lib3ds_vector.c:232
CHK_MESH_MATRIX
Definition: lib3ds_impl.h:218
lib3ds_io_write_string
void lib3ds_io_write_string(Lib3dsIo *io, const char *s)
Definition: lib3ds_io.c:443
Lib3dsMesh::box_back
char box_back[64]
Definition: lib3ds.h:373
lib3ds_chunk_write_start
void lib3ds_chunk_write_start(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:119
lib3ds_io_write_vector
void lib3ds_io_write_vector(Lib3dsIo *io, float v[3])
Definition: lib3ds_io.c:422
lib3ds_io_read_byte
uint8_t lib3ds_io_read_byte(Lib3dsIo *io)
Definition: lib3ds_io.c:143
Lib3dsFile
Definition: lib3ds.h:524
CHK_MSH_MAT_GROUP
Definition: lib3ds_impl.h:214
lib3ds_vector_min
LIB3DSAPI void lib3ds_vector_min(float c[3], float a[3])
Definition: lib3ds_vector.c:216
lib3ds_vector_copy
LIB3DSAPI void lib3ds_vector_copy(float dst[3], float src[3])
Definition: lib3ds_vector.c:39
lib3ds_io_write_float
void lib3ds_io_write_float(Lib3dsIo *io, float l)
Definition: lib3ds_io.c:402
CHK_N_TRI_OBJECT
Definition: lib3ds_impl.h:210
Lib3dsFace
Definition: lib3ds.h:351
Lib3dsFile::nmaterials
int nmaterials
Definition: lib3ds.h:543
lib3ds_chunk_read_reset
void lib3ds_chunk_read_reset(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:90
lib3ds_mesh_free
LIB3DSAPI void lib3ds_mesh_free(Lib3dsMesh *mesh)
Definition: lib3ds_mesh.c:57
Lib3dsMesh::box_right
char box_right[64]
Definition: lib3ds.h:375
Lib3dsMesh::box_front
char box_front[64]
Definition: lib3ds.h:372
Lib3dsMesh::map_type
int map_type
Definition: lib3ds.h:378
p
GLfloat GLfloat p
Definition: glew.h:14938
lib3ds_vector_zero
LIB3DSAPI void lib3ds_vector_zero(float c[3])
Definition: lib3ds_vector.c:30
c
const GLfloat * c
Definition: glew.h:14913
texco_array_write
static void texco_array_write(Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:589
lib3ds_mesh_new
LIB3DSAPI Lib3dsMesh * lib3ds_mesh_new(const char *name)
Definition: lib3ds_mesh.c:34
lib3ds_file_material_by_name
LIB3DSAPI int lib3ds_file_material_by_name(Lib3dsFile *file, const char *name)
Definition: lib3ds_file.c:949
lib3ds_vector_normalize
LIB3DSAPI void lib3ds_vector_normalize(float c[3])
Definition: lib3ds_vector.c:146
lib3ds_util_realloc_array
void * lib3ds_util_realloc_array(void *ptr, int old_size, int new_size, int element_size)
Definition: lib3ds_util.c:21
lib3ds_io_read_word
uint16_t lib3ds_io_read_word(Lib3dsIo *io)
Definition: lib3ds_io.c:156
lib3ds_vector_normal
LIB3DSAPI void lib3ds_vector_normal(float n[3], float a[3], float b[3], float c[3])
Definition: lib3ds_vector.c:182
index
GLuint index
Definition: glew.h:1800
lib3ds_io_read_float
float lib3ds_io_read_float(Lib3dsIo *io)
Definition: lib3ds_io.c:237
Lib3dsFaces
struct Lib3dsFaces Lib3dsFaces
lib3ds_mesh_resize_vertices
LIB3DSAPI void lib3ds_mesh_resize_vertices(Lib3dsMesh *mesh, int nvertices, int use_texcos, int use_flags)
Definition: lib3ds_mesh.c:66
num
GLuint num
Definition: glew.h:2631
CHK_POINT_FLAG_ARRAY
Definition: lib3ds_impl.h:212
lib3ds_vector_add
LIB3DSAPI void lib3ds_vector_add(float c[3], float a[3], float b[3])
Definition: lib3ds_vector.c:55
lib3ds_chunk_read_end
void lib3ds_chunk_read_end(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:96
lib3ds_chunk_read_tell
void lib3ds_chunk_read_tell(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:62
Lib3dsMesh::texcos
float(* texcos)[2]
Definition: lib3ds.h:368
CHK_FACE_ARRAY
Definition: lib3ds_impl.h:213
uint32_t
unsigned int uint32_t
Definition: SDL_config_windows.h:62
l
GLdouble l
Definition: glew.h:8383
malloc
#define malloc
Definition: SDL_malloc.c:635
lib3ds_mesh_bounding_box
LIB3DSAPI void lib3ds_mesh_bounding_box(Lib3dsMesh *mesh, float bmin[3], float bmax[3])
Definition: lib3ds_mesh.c:105
Lib3dsIo
Definition: lib3ds.h:56
lib3ds_vector_scalar_mul
LIB3DSAPI void lib3ds_vector_scalar_mul(float c[3], float a[3], float k)
Definition: lib3ds_vector.c:86
flag_array_write
static void flag_array_write(Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:468
lib3ds_vector_sub
LIB3DSAPI void lib3ds_vector_sub(float c[3], float a[3], float b[3])
Definition: lib3ds_vector.c:71
lib3ds_io_read_string
void lib3ds_io_read_string(Lib3dsIo *io, char *s, int buflen)
Definition: lib3ds_io.c:285
lib3ds_mesh_calculate_vertex_normals
LIB3DSAPI void lib3ds_mesh_calculate_vertex_normals(Lib3dsMesh *mesh, float(*normals)[3])
Definition: lib3ds_mesh.c:163
Lib3dsMesh::box_left
char box_left[64]
Definition: lib3ds.h:374
q
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1400
Lib3dsMesh::box_top
char box_top[64]
Definition: lib3ds.h:376
CHK_POINT_ARRAY
Definition: lib3ds_impl.h:211
lib3ds_chunk_write
void lib3ds_chunk_write(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:111
lib3ds_chunk_read_start
void lib3ds_chunk_read_start(Lib3dsChunk *c, uint16_t chunk, Lib3dsIo *io)
Definition: lib3ds_chunk.c:50
Lib3dsMesh::map_planar_size
float map_planar_size[2]
Definition: lib3ds.h:383
lib3ds_vector_cross
LIB3DSAPI void lib3ds_vector_cross(float c[3], float a[3], float b[3])
Definition: lib3ds_vector.c:102
lib3ds_mesh_resize_faces
LIB3DSAPI void lib3ds_mesh_resize_faces(Lib3dsMesh *mesh, int nfaces)
Definition: lib3ds_mesh.c:86
Lib3dsIo::impl
void * impl
Definition: lib3ds.h:57
lib3ds_matrix_inv
LIB3DSAPI int lib3ds_matrix_inv(float m[4][4])
Definition: lib3ds_matrix.c:229
Lib3dsFace::material
int material
Definition: lib3ds.h:354
lib3ds_vector_dot
LIB3DSAPI float lib3ds_vector_dot(float a[3], float b[3])
Definition: lib3ds_vector.c:118
Lib3dsIoImpl
Definition: lib3ds_impl.h:314
lib3ds_matrix_det
LIB3DSAPI float lib3ds_matrix_det(float m[4][4])
Definition: lib3ds_matrix.c:191
Lib3dsFace::smoothing_group
unsigned smoothing_group
Definition: lib3ds.h:355
Lib3dsChunk::chunk
uint16_t chunk
Definition: lib3ds_impl.h:296
i
int i
Definition: pngrutil.c:1377
lib3ds_vector_length
LIB3DSAPI float lib3ds_vector_length(float c[3])
Definition: lib3ds_vector.c:133
lib3ds_io_write_dword
void lib3ds_io_write_dword(Lib3dsIo *io, uint32_t d)
Definition: lib3ds_io.c:338
Lib3dsMesh::matrix
float matrix[4][4]
Definition: lib3ds.h:365
CHK_SMOOTH_GROUP
Definition: lib3ds_impl.h:215
CHK_MESH_TEXTURE_INFO
Definition: lib3ds_impl.h:220
lib3ds_mesh_read
void lib3ds_mesh_read(Lib3dsFile *file, Lib3dsMesh *mesh, Lib3dsIo *io)
Definition: lib3ds_mesh.c:311
Lib3dsMesh::box_bottom
char box_bottom[64]
Definition: lib3ds.h:377
lib3ds_impl.h
lib3ds_chunk_write_end
void lib3ds_chunk_write_end(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:129
Lib3dsFile::materials
Lib3dsMaterial ** materials
Definition: lib3ds.h:544
lib3ds_matrix_copy
LIB3DSAPI void lib3ds_matrix_copy(float dest[4][4], float src[4][4])
Definition: lib3ds_matrix.c:56
CHK_MESH_COLOR
Definition: lib3ds_impl.h:219
lib3ds_io_write_word
void lib3ds_io_write_word(Lib3dsIo *io, uint16_t w)
Definition: lib3ds_io.c:322