summaryrefslogtreecommitdiff
path: root/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
diff options
context:
space:
mode:
authorHermet Park <chuneon.park@samsung.com>2020-03-25 19:14:02 +0900
committerHermet Park <chuneon.park@samsung.com>2020-03-25 19:14:02 +0900
commit476e2b0521df500776ef0e88f3f28bb5f6b26e78 (patch)
tree8b455b1e731c16efca7f4a4352e7b369e3cc1349 /src/modules/evas/model_loaders/eet/evas_model_load_eet.c
parentd4e6303d9e14c38f2d901b571261f27fe544b1de (diff)
canvas 3d: remove all canvas3d features across efl.
Reviewers: jsuya, kimcinoo, bu5hm4n, raster Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11552
Diffstat (limited to '')
-rw-r--r--src/modules/evas/model_loaders/eet/evas_model_load_eet.c111
1 files changed, 0 insertions, 111 deletions
diff --git a/src/modules/evas/model_loaders/eet/evas_model_load_eet.c b/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
deleted file mode 100644
index 7ff40b9b25..0000000000
--- a/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
+++ /dev/null
@@ -1,111 +0,0 @@
1#ifdef HAVE_CONFIG_H
2 #include "config.h"
3#endif
4
5#include <Eo.h>
6#include <Eet.h>
7#include <stdio.h>
8#include "evas_common_private.h"
9#include "evas_private.h"
10
11static void
12_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
13 Evas_Canvas3D_Mesh_Eet *eet_mesh)
14{
15 float *pos, *nor, *tex;
16 int stride_pos, stride_nor, stride_tex, j;
17
18 evas_canvas3d_mesh_vertex_count_set(mesh, eet_mesh->geometries->vertices_count);
19 evas_canvas3d_mesh_vertex_assembly_set(mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
20 evas_canvas3d_mesh_frame_add(mesh, 0);
21 evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 0, NULL);
22 evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 0, NULL);
23 evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 0, NULL);
24 pos = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
25 nor = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
26 tex = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
27 stride_pos = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
28 stride_nor = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
29 stride_tex = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
30
31 if (stride_pos == 0) stride_pos = sizeof(float) * 3;
32 if (stride_nor == 0) stride_nor = sizeof(float) * 3;
33 if (stride_tex == 0) stride_tex = sizeof(float) * 2;
34
35 /* set data to vertex buffer */
36 for (j = 0; j < eet_mesh->geometries->vertices_count; j++)
37 {
38 float *p, *n, *t;
39
40 p = (float *)((char *)pos + stride_pos * j);
41 n = (float *)((char *)nor + stride_nor * j);
42 t = (float *)((char *)tex + stride_tex * j);
43
44 p[0] = eet_mesh->geometries->vertices[j].position.x;
45 p[1] = eet_mesh->geometries->vertices[j].position.y;
46 p[2] = eet_mesh->geometries->vertices[j].position.z;
47
48 n[0] = eet_mesh->geometries->vertices[j].normal.x;
49 n[1] = eet_mesh->geometries->vertices[j].normal.y;
50 n[2] = eet_mesh->geometries->vertices[j].normal.z;
51
52 t[0] = eet_mesh->geometries->vertices[j].texcoord.x;
53 t[1] = eet_mesh->geometries->vertices[j].texcoord.y;
54 }
55
56 /* unmap vertex buffer */
57 evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
58 evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
59 evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
60}
61
62static void
63_set_material_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
64 Evas_Canvas3D_Mesh_Eet *eet_mesh)
65{
66 Evas_Canvas3D_Object_Data *pd = efl_data_scope_get(mesh, EVAS_CANVAS3D_OBJECT_CLASS);
67 Eo *material = NULL;
68 material = efl_add(EVAS_CANVAS3D_MATERIAL_CLASS, pd->evas);
69
70 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, !!(eet_mesh->materials->colors[0].a > 0));
71 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, !!(eet_mesh->materials->colors[1].a > 0));
72 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, !!(eet_mesh->materials->colors[2].a > 0));
73 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
74 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, eet_mesh->materials->colors[0].r, eet_mesh->materials->colors[0].g, eet_mesh->materials->colors[0].b, eet_mesh->materials->colors[0].a);
75 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, eet_mesh->materials->colors[1].r, eet_mesh->materials->colors[1].g, eet_mesh->materials->colors[1].b, eet_mesh->materials->colors[1].a);
76 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, eet_mesh->materials->colors[2].r, eet_mesh->materials->colors[2].g, eet_mesh->materials->colors[2].b, eet_mesh->materials->colors[2].a);
77 evas_canvas3d_material_shininess_set(material, eet_mesh->materials->shininess);
78
79 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
80}
81
82void
83evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
84{
85 Eet_File *ef;
86 Evas_Canvas3D_File_Eet* eet_file;
87 Eet_Data_Descriptor *_file_descriptor;
88
89 eet_init();
90
91 _file_descriptor = _evas_canvas3d_eet_file_get();
92 ef = eet_mmap(file);
93 eet_file = eet_data_read(ef,
94 _file_descriptor,
95 EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY);
96
97 eet_close(ef);
98
99 if (!eet_file || !eet_file->mesh || !eet_file->header)
100 {
101 ERR("Failed to read model file");
102 goto on_error;
103 }
104
105 _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh);
106 _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh);
107
108 on_error:
109 _evas_canvas3d_eet_file_free(eet_file);
110 eet_shutdown();
111}