summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2014-11-14 07:11:09 +0100
committerCedric BAIL <cedric@osg.samsung.com>2014-11-14 07:11:15 +0100
commitd896dfb34233ac6bb0b1cb226f50180783dc5961 (patch)
treed3fd7c4c0632ff4105abac97b8c5e978f6a87a26 /src/lib/evas/canvas
parentc59fba68de29dc106471e11b205e34b12954ec7b (diff)
evas: Evas_3D - add .ply export/import.
Summary: .ply format is important for relation blender and EFl, because in blender exist only two mesh export API: bpy.ops.import_mesh.ply and bpy.ops.import_mesh.stl. One of them is necessary for .edc 3D generator. Which I writing now. Sorry, it isn't like image loader. Refactoring of import/export will be soon. Reviewers: Oleksander, artem.popov, Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1544 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/evas/canvas')
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh.c46
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh.eo4
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh_loader_ply.c401
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh_saver_ply.c56
4 files changed, 478 insertions, 29 deletions
diff --git a/src/lib/evas/canvas/evas_3d_mesh.c b/src/lib/evas/canvas/evas_3d_mesh.c
index 350967a514..f72d959dd2 100644
--- a/src/lib/evas/canvas/evas_3d_mesh.c
+++ b/src/lib/evas/canvas/evas_3d_mesh.c
@@ -27,9 +27,7 @@ evas_3d_mesh_frame_free(Evas_3D_Mesh_Frame *frame)
27 int i; 27 int i;
28 28
29 if (frame->material) 29 if (frame->material)
30 { 30 evas_3d_material_mesh_del(frame->material, frame->mesh);
31 evas_3d_material_mesh_del(frame->material, frame->mesh);
32 }
33 31
34 for (i = 0; i < EVAS_3D_VERTEX_ATTRIB_COUNT; i++) 32 for (i = 0; i < EVAS_3D_VERTEX_ATTRIB_COUNT; i++)
35 { 33 {
@@ -790,6 +788,9 @@ _evas_3d_mesh_file_set(Eo *obj, Evas_3D_Mesh_Data *pd, Evas_3D_Mesh_File_Type ty
790 case EVAS_3D_MESH_FILE_TYPE_EET: 788 case EVAS_3D_MESH_FILE_TYPE_EET:
791 evas_3d_mesh_file_eet_set(obj, file); 789 evas_3d_mesh_file_eet_set(obj, file);
792 break; 790 break;
791 case EVAS_3D_MESH_FILE_TYPE_PLY:
792 evas_3d_mesh_file_ply_set(obj, file);
793 break;
793 default: 794 default:
794 ERR("Invalid mesh file type."); 795 ERR("Invalid mesh file type.");
795 break; 796 break;
@@ -802,34 +803,25 @@ _evas_3d_mesh_save(Eo *obj, Evas_3D_Mesh_Data *pd, Evas_3D_Mesh_File_Type type,
802{ 803{
803 if ((file == NULL) || (obj == NULL) || (pd == NULL)) return; 804 if ((file == NULL) || (obj == NULL) || (pd == NULL)) return;
804 805
806 Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, 0);
807
808 if (f == NULL)
809 {
810 ERR("Not existing mesh frame.");
811 return;
812 }
813
805 switch (type) 814 switch (type)
806 { 815 {
807 case EVAS_3D_MESH_FILE_TYPE_OBJ: 816 case EVAS_3D_MESH_FILE_TYPE_OBJ:
808 { 817 evas_3d_mesh_save_obj(obj, file, f);//file without extension!
809 Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, 0); 818 break;
810
811 if (f == NULL)
812 {
813 ERR("Not existing mesh frame.");
814 return;
815 }
816
817 evas_3d_mesh_save_obj(obj, file, f);//file without extension!
818 break;
819 }
820 case EVAS_3D_MESH_FILE_TYPE_EET: 819 case EVAS_3D_MESH_FILE_TYPE_EET:
821 { 820 evas_3d_mesh_save_eet(obj, file, f);
822 Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, 0); 821 break;
823 822 case EVAS_3D_MESH_FILE_TYPE_PLY:
824 if (f == NULL) 823 evas_3d_mesh_save_ply(obj, file, f);
825 { 824 break;
826 ERR("Not existing mesh frame.");
827 return;
828 }
829
830 evas_3d_mesh_save_eet(obj, file, f);
831 break;
832 }
833 default: 825 default:
834 ERR("Invalid mesh file type."); 826 ERR("Invalid mesh file type.");
835 break; 827 break;
diff --git a/src/lib/evas/canvas/evas_3d_mesh.eo b/src/lib/evas/canvas/evas_3d_mesh.eo
index 3a0b29c448..66d4f69fa8 100644
--- a/src/lib/evas/canvas/evas_3d_mesh.eo
+++ b/src/lib/evas/canvas/evas_3d_mesh.eo
@@ -8,7 +8,7 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface)
8 /** 8 /**
9 * Load mesh data from file. 9 * Load mesh data from file.
10 * 10 *
11 * Loading a mesh from existing file is supported. Currently, only MD2, OBJ and EET file 11 * Loading a mesh from existing file is supported. Currently, only MD2, OBJ, PLY and EET file
12 * formats are supported. 12 * formats are supported.
13 * 13 *
14 * @ingroup Evas_3D_Mesh 14 * @ingroup Evas_3D_Mesh
@@ -24,7 +24,7 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface)
24 /** 24 /**
25 * Save mesh data to file. 25 * Save mesh data to file.
26 * 26 *
27 * Saving a mesh to file is supported. Currently, only OBJ and EET file 27 * Saving a mesh to file is supported. Currently, only OBJ, PLY and EET file
28 * format are supported. 28 * format are supported.
29 * 29 *
30 * @ingroup Evas_3D_Mesh 30 * @ingroup Evas_3D_Mesh
diff --git a/src/lib/evas/canvas/evas_3d_mesh_loader_ply.c b/src/lib/evas/canvas/evas_3d_mesh_loader_ply.c
new file mode 100644
index 0000000000..b4bbe18c28
--- /dev/null
+++ b/src/lib/evas/canvas/evas_3d_mesh_loader_ply.c
@@ -0,0 +1,401 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdlib.h>
6#include "stdio.h"
7#include "evas_common_private.h"
8#include "evas_private.h"
9#include <Eina.h>
10
11/* set value to position [x][y] to array name which have. */
12#define ARRAY_2D(name, x, y, count_y) (*(name + x * count_y + y))
13
14/* Structures for reading data from file. */
15typedef struct _PLY_Header PLY_Header;
16
17struct _PLY_Header
18{
19 int vertices_count;
20 int triangles_count;
21 Eina_Bool existence_of_geometries;
22 Eina_Bool existence_of_normals;
23 Eina_Bool existence_of_texcoords;
24 Eina_Bool existence_of_colors;
25};
26
27static inline char*
28_file_to_buf(const char *file, long *length)//prepare text file for reading
29{
30 FILE *file_for_print;
31 char *buf;
32 int unused __attribute__((unused));//this variable fixes warning "ignoring return value of fread"
33
34 *length = 0;
35 file_for_print = fopen(file, "rb");
36 if (!file_for_print) return NULL;
37 fseek(file_for_print, 0, SEEK_END);//set file_for_print to the end of file
38 *length = ftell(file_for_print);//set current position of file_for_print
39 buf = malloc(*length + 1);
40 fseek(file_for_print, 0, SEEK_SET);//set file_for_print to the begining of file
41 unused = fread(buf, *length, 1, file_for_print);
42 fclose(file_for_print);
43 buf[*length] = '\0';
44 return buf;
45}
46
47/* create new header */
48static inline PLY_Header
49_new_ply_header()
50{
51 PLY_Header header;
52
53 header.vertices_count = 0;
54 header.triangles_count = 0;
55 header.existence_of_geometries = EINA_FALSE;
56 header.existence_of_normals = EINA_FALSE;
57 header.existence_of_texcoords = EINA_FALSE;
58 header.existence_of_colors = EINA_FALSE;
59
60 return header;
61}
62
63static inline char *
64_to_next_line(char *current)
65{
66 while (*current != '\n') current++;
67 current++;
68 return current;
69}
70
71static inline char *
72_to_begin_of_line(char *current)
73{
74 while (*current != '\n') current--;
75 current++;
76 return current;
77}
78
79static inline char *
80_to_next_number(char *current, int count)
81{
82 int i;
83 for (i = 0; i < count; i++)
84 {
85 while (*current != ' ') current++;
86 current++;
87 }
88 return current;
89}
90
91static inline char *
92_read_data(float *array, int place, int count, char *current, float divider)
93{
94 int i;
95 for (i = 0; i < count; i++)
96 {
97 sscanf (current,"%f", &ARRAY_2D(array, place, i, count));
98 ARRAY_2D(array, place, i, count) /= divider;
99 current = _to_next_number(current, 1);
100 }
101 return current;
102}
103
104static inline PLY_Header
105_read_header(char *start)//Check properties of mesh in .ply file.
106{
107 eina_init();
108
109 Eina_Bool reading_vertices = EINA_TRUE, check_next_char = EINA_FALSE;
110 int vertex_lines, triangles = 0, vertices_in_current_face = 0;
111 char **helping_pointer;
112 char *current;
113 PLY_Header header;
114
115 header = _new_ply_header();
116 helping_pointer = eina_str_split(start, "vertex ", 0);
117
118 if (helping_pointer == NULL)
119 {
120 ERR("File have not kayword vertex. It is necessary.");
121 return header;
122 }
123
124 sscanf(helping_pointer[1], "%d", &header.vertices_count);
125
126 free(helping_pointer);
127 helping_pointer = eina_str_split(start, "end_header\n", 0);
128
129 if (helping_pointer == NULL)
130 {
131 ERR("File have not kayword end_header. It is necessary.");
132 return header;
133 }
134
135 current = helping_pointer[1];
136
137 vertex_lines = header.vertices_count;
138 while (*current != '\0')
139 {
140 if (vertex_lines == 1)
141 reading_vertices = EINA_FALSE;
142 if (*current == '\n')
143 {
144 if (reading_vertices)
145 vertex_lines--;
146 else
147 check_next_char = EINA_TRUE;
148 }
149 if (check_next_char)
150 {
151 if ((*current <= '9') && (*current >= '0'))
152 vertices_in_current_face = (vertices_in_current_face * 10) + (*current - '0');
153 else if (*current >= ' ')
154 {
155 triangles += (vertices_in_current_face - 2);
156 vertices_in_current_face = 0;
157 check_next_char = EINA_FALSE;
158 }
159 }
160 current++;
161 }
162
163 header.triangles_count = triangles;
164 free(helping_pointer);
165
166 /* analyse flags used when file was saved in blender */
167 helping_pointer = eina_str_split(start, "property float ", 0);
168
169 if ((helping_pointer[1] != NULL) && (*helping_pointer[1] == 'x') &&
170 (helping_pointer[2] != NULL) && (*helping_pointer[2] == 'y') &&
171 (helping_pointer[3] != NULL) && (*helping_pointer[3] == 'z'))
172 header.existence_of_geometries = EINA_TRUE;
173 else return header;
174
175 if ((helping_pointer[4] != NULL) && (*helping_pointer[4] == 'n') &&
176 (helping_pointer[5] != NULL) && (*helping_pointer[5] == 'n') &&
177 (helping_pointer[6] != NULL) && (*helping_pointer[6] == 'n'))
178 header.existence_of_normals = EINA_TRUE;
179
180 if ((header.existence_of_normals &&
181 ((helping_pointer[7] != NULL) && (*helping_pointer[7] == 's') &&
182 (helping_pointer[8] != NULL) && (*helping_pointer[8] == 't'))) ||
183 (!header.existence_of_normals &&
184 ((helping_pointer[4] != NULL) && (*helping_pointer[4] == 's') &&
185 (helping_pointer[5] != NULL) && (*helping_pointer[5] == 't'))))
186 header.existence_of_texcoords = EINA_TRUE;
187
188 helping_pointer = eina_str_split(start, "property uchar ", 0);
189
190 if ((helping_pointer[1] != NULL) && (*helping_pointer[1] == 'r') &&
191 (helping_pointer[2] != NULL) && (*helping_pointer[2] == 'g') &&
192 (helping_pointer[3] != NULL) && (*helping_pointer[3] == 'b'))
193 header.existence_of_colors = EINA_TRUE;
194
195 free(helping_pointer);
196
197 return header;
198}
199
200void
201evas_3d_mesh_file_ply_set(Evas_3D_Mesh *mesh, const char *file)
202{
203 long length;
204 Evas_3D_Mesh_Data *pd;
205 int i = 0, j = 0, k = 0, count_of_triangles_in_line = 0;
206 float *pos, *nor, *tex, *col;
207 int stride_pos, stride_nor, stride_tex, stride_col;
208 char *start, *current;
209 PLY_Header header;
210 float *_vertices_ply = NULL, *_normals_ply = NULL, *_tex_coords_ply = NULL, *_colors_ply = NULL;
211 char **helping_pointer;
212
213 start = _file_to_buf(file, &length);
214
215 if (start == NULL)
216 {
217 ERR("Buffer is empty after preparation file for reading.");
218 return;
219 }
220
221 header = _read_header(start);
222
223 if (!header.existence_of_geometries)
224 {
225 ERR("File have not x, y, or z field as the first 3 float fields. They are necessary.");
226 return;
227 }
228
229 helping_pointer = eina_str_split(start, "end_header\n", 0);
230
231 if (helping_pointer == NULL)
232 {
233 ERR("File have not kayword end_header. It is necessary.");
234 return;
235 }
236
237 current = helping_pointer[1];
238
239 _vertices_ply = malloc(header.vertices_count * 3 * sizeof(float));
240 if (header.existence_of_normals)
241 _normals_ply = malloc(header.vertices_count * 3 * sizeof(float));
242 if (header.existence_of_texcoords)
243 _tex_coords_ply = malloc(header.vertices_count * 2 * sizeof(float));
244 if (header.existence_of_colors)
245 _colors_ply = malloc(header.vertices_count * 3 * sizeof(float));
246 int *_triangles = malloc(header.triangles_count * 3 * sizeof(int));
247
248 if ((header.existence_of_geometries && (_vertices_ply == NULL)) ||
249 (header.existence_of_normals && (_normals_ply == NULL)) ||
250 (header.existence_of_texcoords && (_tex_coords_ply == NULL)) ||
251 (header.existence_of_colors && (_colors_ply == NULL)) ||
252 (_triangles == NULL))
253 {
254 ERR("Allocate memory is failed.");
255 free(start);
256 free(_vertices_ply);
257 free(_normals_ply);
258 free(_tex_coords_ply);
259 free(_colors_ply);
260 free(_triangles);
261 return;
262 }
263
264 for (i = 0; i < header.vertices_count; i++)
265 {
266 current = _read_data(_vertices_ply, i, 3, current, 1.0);
267 if (header.existence_of_normals)
268 current = _read_data(_normals_ply, i, 3, current, 1.0);
269 if (header.existence_of_texcoords)
270 current = _read_data(_tex_coords_ply, i, 2, current, 1.0);
271 if (header.existence_of_colors)
272 current = _read_data(_colors_ply, i, 3, current, 255.0);
273 current = _to_begin_of_line(current);
274 }
275
276 for (i = 0; i < header.triangles_count;)
277 {
278 sscanf (current,"%d", &count_of_triangles_in_line);
279 count_of_triangles_in_line -= 2;
280 current = _to_next_number(current, 1);
281
282 sscanf (current,"%i", &ARRAY_2D(_triangles, i, 0, 3));
283
284 for (j = 0; j < count_of_triangles_in_line; j++)
285 {
286 if (j > 0)
287 ARRAY_2D(_triangles, i, 0, 3) = ARRAY_2D(_triangles, (i - 1), 0, 3);
288 current = _to_next_number(current, 1);
289 sscanf (current,"%i %i",
290 &ARRAY_2D(_triangles, i, 1, 3),
291 &ARRAY_2D(_triangles, i, 2, 3));
292 i++;
293 }
294 current = _to_next_line(current);
295 }
296
297 /* prepare of mesh and take pointers to data which must be read */
298 eo_do(mesh,
299 evas_3d_mesh_vertex_count_set(header.triangles_count * 3),
300 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
301 evas_3d_mesh_frame_add(0),
302 evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_POSITION, 0, NULL),
303 evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_NORMAL, 0, NULL),
304 evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_TEXCOORD, 0, NULL),
305 evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_COLOR, 0, NULL),
306
307 pos = (float *)evas_3d_mesh_frame_vertex_data_map(0, EVAS_3D_VERTEX_POSITION),
308 nor = (float *)evas_3d_mesh_frame_vertex_data_map(0, EVAS_3D_VERTEX_NORMAL),
309 tex = (float *)evas_3d_mesh_frame_vertex_data_map(0, EVAS_3D_VERTEX_TEXCOORD),
310 col = (float *)evas_3d_mesh_frame_vertex_data_map(0, EVAS_3D_VERTEX_COLOR),
311
312 stride_pos = evas_3d_mesh_frame_vertex_stride_get(0, EVAS_3D_VERTEX_POSITION),
313 stride_nor = evas_3d_mesh_frame_vertex_stride_get(0, EVAS_3D_VERTEX_NORMAL),
314 stride_tex = evas_3d_mesh_frame_vertex_stride_get(0, EVAS_3D_VERTEX_TEXCOORD),
315 stride_col = evas_3d_mesh_frame_vertex_stride_get(0, EVAS_3D_VERTEX_COLOR));
316
317 if (stride_pos == 0) stride_pos = sizeof(float) * 3;
318 if (stride_nor == 0) stride_nor = sizeof(float) * 3;
319 if (stride_tex == 0) stride_tex = sizeof(float) * 2;
320 if (stride_col == 0) stride_col = sizeof(float) * 4;
321
322 for (j = 0; j < header.triangles_count; j++)
323 {
324 for (k = 0; k < 3; k++)
325 {
326 float *p, *n, *t, *c;
327
328 p = (float *)((char *)pos + stride_pos * (j * 3 + k));
329 n = (float *)((char *)nor + stride_nor * (j * 3 + k));
330 t = (float *)((char *)tex + stride_tex * (j * 3 + k));
331 c = (float *)((char *)col + stride_col * (j * 3 + k));
332
333 p[0] = ARRAY_2D(_vertices_ply, ARRAY_2D(_triangles, j, k, 3), 0, 3);
334 p[1] = ARRAY_2D(_vertices_ply, ARRAY_2D(_triangles, j, k, 3), 1, 3);
335 p[2] = ARRAY_2D(_vertices_ply, ARRAY_2D(_triangles, j, k, 3), 2, 3);
336
337 if (header.existence_of_normals)
338 {
339 n[0] = ARRAY_2D(_normals_ply, ARRAY_2D(_triangles, j, k, 3), 0, 3);
340 n[1] = ARRAY_2D(_normals_ply, ARRAY_2D(_triangles, j, k, 3), 1, 3);
341 n[2] = ARRAY_2D(_normals_ply, ARRAY_2D(_triangles, j, k, 3), 2, 3);
342 }
343 else
344 {
345 n[0] = 0.0;
346 n[1] = 0.0;
347 n[2] = 0.0;
348 }
349
350 if (header.existence_of_texcoords)
351 {
352 t[0] = ARRAY_2D(_tex_coords_ply, ARRAY_2D(_triangles, j, k, 3), 0, 2);
353 t[1] = ARRAY_2D(_tex_coords_ply, ARRAY_2D(_triangles, j, k, 3), 1, 2);
354 }
355 else
356 {
357 t[0] = 0.0;
358 t[1] = 0.0;
359 }
360
361 if (header.existence_of_colors)
362 {
363 c[0] = ARRAY_2D(_colors_ply, ARRAY_2D(_triangles, j, k, 3), 0, 3);
364 c[1] = ARRAY_2D(_colors_ply, ARRAY_2D(_triangles, j, k, 3), 1, 3);
365 c[2] = ARRAY_2D(_colors_ply, ARRAY_2D(_triangles, j, k, 3), 2, 3);
366 c[3] = 1.0;
367 }
368 else
369 {
370 c[0] = 0.0;
371 c[1] = 0.0;
372 c[2] = 0.0;
373 c[3] = 1.0;
374 }
375 }
376 }
377
378 free(helping_pointer);
379 free(_vertices_ply);
380 if (header.existence_of_normals)
381 free(_normals_ply);
382 if (header.existence_of_texcoords)
383 free(_tex_coords_ply);
384 if (header.existence_of_colors)
385 free(_colors_ply);
386 free(_triangles);
387
388 /* Unmap vertex buffer. */
389 eo_do(mesh,
390 evas_3d_mesh_frame_vertex_data_unmap(0, EVAS_3D_VERTEX_POSITION),
391 evas_3d_mesh_frame_vertex_data_unmap(0, EVAS_3D_VERTEX_NORMAL),
392 evas_3d_mesh_frame_vertex_data_unmap(0, EVAS_3D_VERTEX_TEXCOORD),
393 evas_3d_mesh_frame_vertex_data_unmap(0, EVAS_3D_VERTEX_COLOR));
394
395 pd = eo_data_scope_get(mesh, EVAS_3D_MESH_CLASS);
396
397 if (!evas_3d_mesh_aabb_add_to_frame(pd, 0, stride_pos))
398 {
399 ERR("Axis-Aligned Bounding Box wan't added in frame %d ", 0);
400 }
401}
diff --git a/src/lib/evas/canvas/evas_3d_mesh_saver_ply.c b/src/lib/evas/canvas/evas_3d_mesh_saver_ply.c
new file mode 100644
index 0000000000..f2376a33bb
--- /dev/null
+++ b/src/lib/evas/canvas/evas_3d_mesh_saver_ply.c
@@ -0,0 +1,56 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdlib.h>
6#include <time.h>
7#include "stdio.h"
8#include "math.h"
9#include "evas_common_private.h"
10#include "evas_private.h"
11
12void
13evas_3d_mesh_save_ply(Evas_3D_Mesh *mesh, const char *file, Evas_3D_Mesh_Frame *f)
14{
15 float *src_pos, *src_nor, *src_tex, *src_col;
16 int i;
17
18 Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, EVAS_3D_MESH_CLASS);
19 FILE *_ply_file = fopen(file, "w+");
20
21 fprintf(_ply_file,"ply\nformat ascii 1.0\ncomment Created by EFL evas_3d_mesh_saver_ply.c" \
22 "version 1 (sub 0) - www.enlightenment.org, source file: ''\n");
23 fprintf(_ply_file,"element vertex %d\n", pd->vertex_count);
24 fprintf(_ply_file,"property float x\nproperty float y\nproperty float z\n" \
25 "property float nx\nproperty float ny\nproperty float nz\n" \
26 "property float s\nproperty float t\n" \
27 "property uchar red\nproperty uchar green\nproperty uchar blue\n");
28 fprintf(_ply_file,"element face %d\nproperty list uchar uint vertex_indices\nend_header\n",
29 pd->vertex_count / 3);
30
31 src_pos = (float*)(&f->vertices[EVAS_3D_VERTEX_POSITION])->data;
32 src_nor = (float*)(&f->vertices[EVAS_3D_VERTEX_NORMAL])->data;
33 src_tex = (float*)(&f->vertices[EVAS_3D_VERTEX_TEXCOORD])->data;
34 src_col = (float*)(&f->vertices[EVAS_3D_VERTEX_COLOR])->data;
35
36 for (i = 0; i < pd->vertex_count; i++)
37 {
38 fprintf(_ply_file,"%f %f %f %f %f %f %f %f %.0f %.0f %.0f\n",
39 src_pos[0], src_pos[1], src_pos[2],
40 src_nor[0], src_nor[1], src_nor[2],
41 src_tex[0], src_tex[1],
42 round(src_col[0] * 255), round(src_col[1] * 255), round(src_col[2] * 255));
43 src_pos += 3;
44 src_nor += 3;
45 src_tex += 2;
46 src_col += 4;
47 }
48
49 for (i = 0; i < pd->vertex_count;)
50 {
51 fprintf(_ply_file,"3 %d %d %d\n", i, i + 1, i + 2);
52 i += 3;
53 }
54
55 fclose(_ply_file);
56}