summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-01-28 18:49:03 +0200
committerBogdan Devichev <b.devichev@samsung.com>2015-01-28 18:49:03 +0200
commit6053e67310fdcc8bd067ca1729b6c6cda3ea3bb7 (patch)
treefb6de8fa6a0e95d58b9490aa70ae0f683cd77339
parent199ea77b4e719fb174ba442f622270953d4a7383 (diff)
Obj_io. Step 2. Example to see fix on step 1.
-rw-r--r--src/examples/evas/Obj_fixes/example_to_explain_fixes.c197
-rw-r--r--src/examples/evas/Obj_fixes/sweet_home.mtl22
-rw-r--r--src/examples/evas/Obj_fixes/sweet_home.obj111
-rw-r--r--src/examples/evas/Obj_fixes/sweet_home_temp.pngbin0 -> 570854 bytes
4 files changed, 330 insertions, 0 deletions
diff --git a/src/examples/evas/Obj_fixes/example_to_explain_fixes.c b/src/examples/evas/Obj_fixes/example_to_explain_fixes.c
new file mode 100644
index 0000000000..e07ff287a1
--- /dev/null
+++ b/src/examples/evas/Obj_fixes/example_to_explain_fixes.c
@@ -0,0 +1,197 @@
1/**
2* Temporary example to explain what changed in obj.
3*
4* @verbatim
5* gcc -o example_to_explain_fixes example_to_explain_fixes.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`
6* @endverbatim
7*/
8
9#define EFL_EO_API_SUPPORT
10#define EFL_BETA_API_SUPPORT
11
12#include <Eo.h>
13#include <Evas.h>
14#include <Ecore.h>
15#include <Ecore_Evas.h>
16
17#define WIDTH 1900
18#define HEIGHT 1080
19
20Ecore_Evas *ecore_evas = NULL;
21Evas *evas = NULL;
22Eo *background = NULL;
23Eo *image = NULL;
24
25Eo *scene = NULL;
26Eo *root_node = NULL;
27Eo *camera_node = NULL;
28Eo *light_node = NULL;
29Eo *camera = NULL;
30Eo *mesh_node = NULL;
31Eo *mesh = NULL;
32Eo *material = NULL;
33Eo *texture = NULL;
34Eo *light = NULL;
35
36static float angle = 0;
37
38static Eina_Bool
39_animate_scene(void *data)
40{
41 angle += 0.5;
42
43 eo_do((Evas_3D_Node *)data, evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, -1.0));
44
45 /* Rotate */
46 if (angle > 360.0) angle -= 360.0f;
47
48 return EINA_TRUE;
49}
50
51static void
52_on_delete(Ecore_Evas *ee EINA_UNUSED)
53{
54 ecore_main_loop_quit();
55}
56
57static void
58_on_canvas_resize(Ecore_Evas *ee)
59{
60 int w, h;
61
62 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
63 eo_do(background, evas_obj_size_set(w, h));
64 eo_do(image, evas_obj_size_set(w, h));
65}
66
67int
68main(void)
69{
70 //Unless Evas 3D supports Software renderer, we set gl backened forcely.
71 setenv("ECORE_EVAS_ENGINE", "opengl_x11", 1);
72
73 if (!ecore_evas_init()) return 0;
74
75 ecore_evas = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
76
77 if (!ecore_evas) return 0;
78
79 ecore_evas_callback_delete_request_set(ecore_evas, _on_delete);
80 ecore_evas_callback_resize_set(ecore_evas, _on_canvas_resize);
81 ecore_evas_show(ecore_evas);
82
83 evas = ecore_evas_get(ecore_evas);
84
85 /* Add a scene object .*/
86 scene = eo_add(EVAS_3D_SCENE_CLASS, evas);
87
88 /* Add the root node for the scene. */
89 root_node = eo_add(EVAS_3D_NODE_CLASS, evas,
90 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_NODE));
91
92 /* Add the camera. */
93 camera = eo_add(EVAS_3D_CAMERA_CLASS, evas);
94 eo_do(camera,
95 evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0));
96
97 camera_node =
98 eo_add(EVAS_3D_NODE_CLASS, evas,
99 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA));
100 eo_do(camera_node,
101 evas_3d_node_camera_set(camera));
102 eo_do(root_node,
103 evas_3d_node_member_add(camera_node));
104 eo_do(camera_node,
105 evas_3d_node_position_set(10.0, 0.0, 2.0),
106 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 2.0,
107 EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0));
108 /* Add the light. */
109 light = eo_add(EVAS_3D_LIGHT_CLASS, evas);
110 eo_do(light,
111 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0),
112 evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0),
113 evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0),
114 evas_3d_light_directional_set(EINA_TRUE));
115
116 light_node =
117 eo_add(EVAS_3D_NODE_CLASS, evas,
118 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_LIGHT));
119 eo_do(light_node,
120 evas_3d_node_light_set(light),
121 evas_3d_node_position_set(10.0, 0.0, 2.0),
122 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
123 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
124 eo_do(root_node,
125 evas_3d_node_member_add(light_node));
126
127 /* Add the mesh. */
128 mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
129 material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
130
131 eo_do(mesh,
132 efl_file_set("sweet_home.obj", NULL),
133 evas_3d_mesh_frame_material_set(0, material),
134 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
135
136 texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
137 eo_do(texture,
138 evas_3d_texture_file_set("sweet_home_temp.png", NULL),
139 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
140 EVAS_3D_TEXTURE_FILTER_NEAREST),
141 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
142 EVAS_3D_WRAP_MODE_REPEAT));
143 eo_do(material,
144 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, texture),
145 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
146 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
147 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
148 evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE),
149 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT,
150 0.01, 0.01, 0.01, 1.0),
151 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE,
152 1.0, 1.0, 1.0, 1.0),
153 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR,
154 1.0, 1.0, 1.0, 1.0),
155 evas_3d_material_shininess_set(50.0));
156
157 eo_do(mesh, efl_file_save("saved_home.obj", NULL, NULL));
158
159 mesh_node = eo_add(EVAS_3D_NODE_CLASS, evas,
160 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
161 eo_do(root_node,
162 evas_3d_node_member_add(mesh_node));
163 eo_do(mesh_node,
164 evas_3d_node_mesh_add(mesh));
165
166 /* Set up scene. */
167 eo_do(scene,
168 evas_3d_scene_root_node_set(root_node),
169 evas_3d_scene_camera_node_set(camera_node),
170 evas_3d_scene_size_set(WIDTH, HEIGHT));
171
172 /* Add a background rectangle objects. */
173 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
174 eo_do(background,
175 evas_obj_color_set(0, 0, 0, 255),
176 evas_obj_size_set(WIDTH, HEIGHT),
177 evas_obj_visibility_set(EINA_TRUE));
178
179 /* Add an image object for 3D scene rendering. */
180 image = evas_object_image_filled_add(evas);
181 eo_do(image,
182 evas_obj_size_set(WIDTH, HEIGHT),
183 evas_obj_visibility_set(EINA_TRUE));
184
185 /* Set the image object as render target for 3D scene. */
186 eo_do(image, evas_obj_image_scene_set(scene));
187
188 ecore_timer_add(0.01, _animate_scene, mesh_node);
189
190 /* Enter main loop. */
191 ecore_main_loop_begin();
192
193 ecore_evas_free(ecore_evas);
194 ecore_evas_shutdown();
195
196 return 0;
197}
diff --git a/src/examples/evas/Obj_fixes/sweet_home.mtl b/src/examples/evas/Obj_fixes/sweet_home.mtl
new file mode 100644
index 0000000000..c3342d4c8b
--- /dev/null
+++ b/src/examples/evas/Obj_fixes/sweet_home.mtl
@@ -0,0 +1,22 @@
1# Blender MTL File: 'sweet_home.blend'
2# Material Count: 2
3
4newmtl Material
5Ns 96.078431
6Ka 0.000000 0.000000 0.000000
7Kd 0.640000 0.640000 0.640000
8Ks 0.500000 0.500000 0.500000
9Ni 1.000000
10d 1.000000
11illum 2
12map_Kd /home/bdevichev/Desktop/rect.png
13
14newmtl Material_Untitled
15Ns 96.078431
16Ka 0.000000 0.000000 0.000000
17Kd 0.640000 0.640000 0.640000
18Ks 0.500000 0.500000 0.500000
19Ni 1.000000
20d 1.000000
21illum 2
22map_Kd /home/bdevichev/Desktop/sweet_home.png
diff --git a/src/examples/evas/Obj_fixes/sweet_home.obj b/src/examples/evas/Obj_fixes/sweet_home.obj
new file mode 100644
index 0000000000..a98175f125
--- /dev/null
+++ b/src/examples/evas/Obj_fixes/sweet_home.obj
@@ -0,0 +1,111 @@
1# Blender v2.69 (sub 0) OBJ File: 'sweet_home.blend'
2# www.blender.org
3mtllib sweet_home.mtl
4o Cube
5v 1.000003 -0.999997 0.000002
6v -0.999997 -1.000003 0.000002
7v -1.000002 0.999998 0.000002
8v 0.999998 1.000002 0.000002
9v 1.000002 -0.999998 2.000002
10v -0.999998 -1.000002 2.000002
11v -1.000002 0.999998 2.000002
12v 0.999997 1.000003 2.000002
13v 0.000002 -1.000000 3.075149
14v -0.000002 1.000000 3.075149
15v 0.666668 -0.644449 2.358384
16v 0.333335 -0.644450 2.716766
17v 0.666667 -0.293067 2.358384
18v 0.333334 -0.293068 2.716766
19v 0.662209 -0.629904 2.991038
20v 0.337794 -0.629904 2.980731
21v 0.662208 -0.307612 2.991038
22v 0.337793 -0.307613 2.980731
23vt 0.013689 0.608350
24vt 0.285640 0.608350
25vt 0.285640 0.978776
26vt 0.013689 0.978776
27vt 0.564957 0.983606
28vt 0.293719 0.983606
29vt 0.293719 0.613180
30vt 0.564957 0.613180
31vt 0.646856 0.021326
32vt 0.083404 0.021326
33vt 0.083369 0.584801
34vt 0.646820 0.584801
35vt 0.949735 0.303064
36vt 0.654355 0.022016
37vt 0.957234 0.303753
38vt 0.654320 0.585490
39vt 0.090869 0.585491
40vt 0.090904 0.022016
41vt 0.820337 0.692442
42vt 0.820337 0.803140
43vt 0.740863 0.803140
44vt 0.740863 0.692442
45vt 0.695284 0.903159
46vt 0.695284 0.830265
47vt 0.768687 0.830265
48vt 0.768687 0.903159
49vt 0.874667 0.789013
50vt 0.874667 0.893367
51vt 0.979009 0.893367
52vt 0.979009 0.789013
53vt 0.567834 0.981515
54vt 0.567834 0.611089
55vt 0.768686 0.903159
56vt 0.768687 0.823686
57vt 0.811715 0.826975
58vt 0.811715 0.899870
59vt 0.591196 0.903159
60vt 0.591196 0.823686
61vt 0.695284 0.826975
62vt 0.695284 0.899870
63vt 0.666035 0.721564
64vt 0.667476 0.661838
65vt 0.740863 0.660019
66vt 0.591196 0.741571
67vt 0.666035 0.660015
68vt 0.666035 0.803140
69vt 0.592658 0.801339
70vt 0.013481 0.981515
71vt 0.104078 0.915663
72vt 0.194676 0.915663
73vt 0.285274 0.981515
74vt 0.194676 0.850582
75vt 0.285274 0.611089
76vt 0.104078 0.850582
77vt 0.013481 0.611089
78vn -0.732233 -0.000002 0.681054
79vn 1.000000 0.000002 0.000000
80vn 0.000002 -1.000000 0.000000
81vn -0.000002 1.000000 -0.000000
82vn -0.732233 -0.000001 -0.681054
83vn -0.031755 -0.000000 0.999496
84vn -0.000000 0.000000 -1.000000
85vn -1.000000 -0.000002 -0.000000
86vn -0.999857 -0.000002 0.016891
87vn 0.999975 0.000002 0.007049
88vn 0.017155 0.999327 0.032422
89vn 0.017160 -0.999327 0.032422
90vn 0.732233 0.000001 0.681054
91vn 0.732233 0.000002 0.681054
92vn 0.732234 0.000002 0.681053
93usemtl Material
94s off
95f 6/1/1 9/2/1 10/3/1 7/4/1
96usemtl Material_Untitled
97f 4/5/2 8/6/2 5/7/2 1/8/2
98f 6/9/3 2/10/3 1/11/3 5/12/3 9/13/3
99f 7/14/4 10/15/4 8/16/4 4/17/4 3/18/4
100f 11/19/5 12/20/5 14/21/5 13/22/5
101f 15/23/6 17/24/6 18/25/6 16/26/6
102f 2/27/7 3/28/7 4/29/7 1/30/7
103f 6/2/8 7/3/8 3/31/8 2/32/8
104f 14/33/9 12/34/9 16/35/9 18/36/9
105f 11/37/10 13/38/10 17/39/10 15/40/10
106f 13/21/11 14/41/11 18/42/11 17/43/11
107f 12/44/12 11/45/12 15/46/12 16/47/12
108f 5/48/13 11/49/13 12/50/13 9/51/13
109f 9/51/14 12/50/14 14/52/14 10/53/14
110f 13/54/14 8/55/14 10/53/14 14/52/14
111f 11/49/15 5/48/15 8/55/15 13/54/15
diff --git a/src/examples/evas/Obj_fixes/sweet_home_temp.png b/src/examples/evas/Obj_fixes/sweet_home_temp.png
new file mode 100644
index 0000000000..1e79861dd4
--- /dev/null
+++ b/src/examples/evas/Obj_fixes/sweet_home_temp.png
Binary files differ