summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-hull.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-hull.c')
-rw-r--r--src/examples/evas/evas-3d-hull.c242
1 files changed, 102 insertions, 140 deletions
diff --git a/src/examples/evas/evas-3d-hull.c b/src/examples/evas/evas-3d-hull.c
index 31748dc..4877884 100644
--- a/src/examples/evas/evas-3d-hull.c
+++ b/src/examples/evas/evas-3d-hull.c
@@ -85,58 +85,52 @@ int rr;
85 85
86#define MODEL_MESH_INIT(name, model, shade) \ 86#define MODEL_MESH_INIT(name, model, shade) \
87 data->mesh_##name = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); \ 87 data->mesh_##name = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); \
88 eo_do(data->mesh_##name, \ 88 efl_file_set(data->mesh_##name, model, NULL); \
89 efl_file_set(model, NULL), \ 89 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_##name, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES); \
90 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), \ 90 evas_canvas3d_mesh_shade_mode_set(data->mesh_##name, EVAS_CANVAS3D_SHADE_MODE_##shade); \
91 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_##shade), \ 91 evas_canvas3d_mesh_frame_material_set(data->mesh_##name, 0, data->material);
92 evas_canvas3d_mesh_frame_material_set(0, data->material));
93 92
94#define CONVEX_HULL_MESH_INIT(name) \ 93#define CONVEX_HULL_MESH_INIT(name) \
95 vert = eina_inarray_new(sizeof(float), 1); \ 94 vert = eina_inarray_new(sizeof(float), 1); \
96 ind = eina_inarray_new(sizeof(unsigned short int), 1);\ 95 ind = eina_inarray_new(sizeof(unsigned short int), 1);\
97 eo_do(data->mesh_##name, \ 96 evas_canvas3d_mesh_convex_hull_data_get(data->mesh_##name, 0, vert, ind); \
98 evas_canvas3d_mesh_convex_hull_data_get(0, vert, ind)); \
99 vertex = (float*) vert->members;\ 97 vertex = (float*) vert->members;\
100 index = ind->members;\ 98 index = ind->members;\
101 data->mesh_##name##_ch = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); \ 99 data->mesh_##name##_ch = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); \
102 eo_do(data->mesh_##name##_ch, \ 100 evas_canvas3d_mesh_vertex_count_set(data->mesh_##name##_ch, (vert->len / 10)); \
103 evas_canvas3d_mesh_vertex_count_set((vert->len / 10)), \ 101 evas_canvas3d_mesh_frame_add(data->mesh_##name##_ch, 0); \
104 evas_canvas3d_mesh_frame_add(0), \ 102 evas_canvas3d_mesh_frame_vertex_data_copy_set(data->mesh_##name##_ch, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, \
105 evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, \ 103 10 * sizeof(float), &vertex[ 0]); \
106 10 * sizeof(float), &vertex[ 0]), \ 104 evas_canvas3d_mesh_frame_vertex_data_copy_set(data->mesh_##name##_ch, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, \
107 evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, \ 105 10 * sizeof(float), &vertex[ 3]); \
108 10 * sizeof(float), &vertex[ 3]), \ 106 evas_canvas3d_mesh_frame_vertex_data_copy_set(data->mesh_##name##_ch, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, \
109 evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, \ 107 10 * sizeof(float), &vertex[ 6]); \
110 10 * sizeof(float), &vertex[ 6]), \ 108 evas_canvas3d_mesh_index_data_copy_set(data->mesh_##name##_ch, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
111 evas_canvas3d_mesh_index_data_copy_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \ 109 ind->len, &index[0]); \
112 ind->len, &index[0]), \ 110 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_##name##_ch, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES); \
113 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), \ 111 evas_canvas3d_mesh_shade_mode_set(data->mesh_##name##_ch, EVAS_CANVAS3D_SHADE_MODE_VERTEX_COLOR); \
114 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_VERTEX_COLOR), \ 112 evas_canvas3d_mesh_frame_material_set(data->mesh_##name##_ch, 0, data->material); \
115 evas_canvas3d_mesh_frame_material_set(0, data->material)); \
116 free(vert); \ 113 free(vert); \
117 free(ind); 114 free(ind);
118 115
119#define SWITCH_MESH(index, name, scale) \ 116#define SWITCH_MESH(index, name, scale) \
120 case index: \ 117 case index: \
121 { \ 118 { \
122 eo_do(scene->mesh_node, list = evas_canvas3d_node_mesh_list_get()); \ 119 list = evas_canvas3d_node_mesh_list_get(scene->mesh_node); \
123 mesh = eina_list_nth(list, 0); \ 120 mesh = eina_list_nth(list, 0); \
124 eo_do(scene->mesh_node, \ 121 evas_canvas3d_node_mesh_del(scene->mesh_node, mesh); \
125 evas_canvas3d_node_mesh_del(mesh), \ 122 evas_canvas3d_node_mesh_add(scene->mesh_node, scene->mesh_##name); \
126 evas_canvas3d_node_mesh_add(scene->mesh_##name), \ 123 evas_canvas3d_node_scale_set(scene->mesh_node, scale, scale, scale); \
127 evas_canvas3d_node_scale_set(scale, scale, scale)); \ 124 list = evas_canvas3d_node_mesh_list_get(scene->mesh_node_convex_hull); \
128 eo_do(scene->mesh_node_convex_hull, list = evas_canvas3d_node_mesh_list_get()); \
129 mesh = eina_list_nth(list, 0); \ 125 mesh = eina_list_nth(list, 0); \
130 eo_do(scene->mesh_node_convex_hull, \ 126 evas_canvas3d_node_mesh_del(scene->mesh_node_convex_hull, mesh); \
131 evas_canvas3d_node_mesh_del(mesh), \ 127 evas_canvas3d_node_mesh_add(scene->mesh_node_convex_hull, scene->mesh_##name##_ch); \
132 evas_canvas3d_node_mesh_add(scene->mesh_##name##_ch), \ 128 evas_canvas3d_node_scale_set(scene->mesh_node_convex_hull, scale, scale, scale); \
133 evas_canvas3d_node_scale_set(scale, scale, scale)); \ 129 list = evas_canvas3d_node_mesh_list_get(scene->mesh_node_blender); \
134 eo_do(scene->mesh_node_blender, list = evas_canvas3d_node_mesh_list_get()); \
135 mesh = eina_list_nth(list, 0); \ 130 mesh = eina_list_nth(list, 0); \
136 eo_do(scene->mesh_node_blender, \ 131 evas_canvas3d_node_mesh_del(scene->mesh_node_blender, mesh); \
137 evas_canvas3d_node_mesh_del(mesh), \ 132 evas_canvas3d_node_mesh_add(scene->mesh_node_blender, scene->mesh_blender_##name); \
138 evas_canvas3d_node_mesh_add(scene->mesh_blender_##name), \ 133 evas_canvas3d_node_scale_set(scene->mesh_node_blender, scale, scale, scale); \
139 evas_canvas3d_node_scale_set(scale, scale, scale)); \
140 _print_result(scene->mesh_##name##_ch, scene->mesh_blender_test_##name); \ 134 _print_result(scene->mesh_##name##_ch, scene->mesh_blender_test_##name); \
141 break; \ 135 break; \
142 } 136 }
@@ -174,12 +168,12 @@ static void
174_print_result(Evas_Canvas3D_Mesh *mesh, Evas_Canvas3D_Mesh *convex_mesh) 168_print_result(Evas_Canvas3D_Mesh *mesh, Evas_Canvas3D_Mesh *convex_mesh)
175{ 169{
176 int v_count = 0; 170 int v_count = 0;
177 eo_do(mesh, v_count = evas_canvas3d_mesh_vertex_count_get()); 171 v_count = evas_canvas3d_mesh_vertex_count_get(mesh);
178 172
179 printf("Vertex count is %d for convex hull\n", 173 printf("Vertex count is %d for convex hull\n",
180 v_count); 174 v_count);
181 175
182 eo_do(convex_mesh, v_count = evas_canvas3d_mesh_vertex_count_get()); 176 v_count = evas_canvas3d_mesh_vertex_count_get(convex_mesh);
183 177
184 printf("Vertex count is %d for blender convex hull\n\n", 178 printf("Vertex count is %d for blender convex hull\n\n",
185 v_count); 179 v_count);
@@ -199,8 +193,8 @@ _on_canvas_resize(Ecore_Evas *ee)
199 int w, h; 193 int w, h;
200 194
201 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 195 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
202 eo_do(background, efl_gfx_size_set(w, h)); 196 efl_gfx_size_set(background, w, h);
203 eo_do(image, efl_gfx_size_set(w, h)); 197 efl_gfx_size_set(image, w, h);
204} 198}
205 199
206static Eina_Bool 200static Eina_Bool
@@ -213,14 +207,11 @@ _animate_scene(void *data)
213 if (angle >= 360.0) 207 if (angle >= 360.0)
214 angle = 0.0; 208 angle = 0.0;
215 209
216 eo_do(scene->mesh_node, 210 evas_canvas3d_node_orientation_angle_axis_set(scene->mesh_node, angle, 1.0, 1.0, 1.0);
217 evas_canvas3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0));
218 211
219 eo_do(scene->mesh_node_convex_hull, 212 evas_canvas3d_node_orientation_angle_axis_set(scene->mesh_node_convex_hull, angle, 1.0, 1.0, 1.0);
220 evas_canvas3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0));
221 213
222 eo_do(scene->mesh_node_blender, 214 evas_canvas3d_node_orientation_angle_axis_set(scene->mesh_node_blender, angle, 1.0, 1.0, 1.0);
223 evas_canvas3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0));
224 215
225 return EINA_TRUE; 216 return EINA_TRUE;
226} 217}
@@ -266,38 +257,30 @@ _camera_setup(Scene_Data *data)
266{ 257{
267 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 258 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
268 259
269 eo_do(data->camera, 260 evas_canvas3d_camera_projection_perspective_set(data->camera, 60.0, 1.0, 2.0, 50.0);
270 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0));
271 261
272 data->camera_node = 262 data->camera_node =
273 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 263 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
274 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 264 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
275 eo_do(data->camera_node, 265 evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 10.0);
276 evas_canvas3d_node_camera_set(data->camera), 266 evas_canvas3d_node_look_at_set(data->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
277 evas_canvas3d_node_position_set(0.0, 0.0, 10.0), 267 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
278 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
279 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
280 eo_do(data->root_node, evas_canvas3d_node_member_add(data->camera_node));
281} 268}
282 269
283static void 270static void
284_light_setup(Scene_Data *data) 271_light_setup(Scene_Data *data)
285{ 272{
286 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 273 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
287 eo_do(data->light, 274 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
288 evas_canvas3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), 275 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
289 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 276 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
290 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0));
291 277
292 data->light_node = 278 data->light_node =
293 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 279 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
294 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 280 evas_canvas3d_node_light_set(data->light_node, data->light);
295 eo_do(data->light_node, 281 evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
296 evas_canvas3d_node_light_set(data->light), 282 evas_canvas3d_node_look_at_set(data->light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
297 evas_canvas3d_node_position_set(0.0, 0.0, 10.0), 283 evas_canvas3d_node_member_add(data->root_node, data->light_node);
298 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
299 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
300 eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node));
301} 284}
302 285
303static void 286static void
@@ -311,51 +294,41 @@ _mesh_setup(Scene_Data *data)
311 /* Setup material. */ 294 /* Setup material. */
312 295
313 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 296 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
314 eo_do(data->material, 297 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
315 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 298 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
316 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 299 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
317 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 300 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0);
318 301 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
319 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0), 302 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
320 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0), 303 evas_canvas3d_material_shininess_set(data->material, 100.0);
321 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0),
322 evas_canvas3d_material_shininess_set(100.0));
323 304
324 /* Setup mesh sphere */ 305 /* Setup mesh sphere */
325 primitive = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 306 primitive = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
326 eo_do(primitive, 307 evas_canvas3d_primitive_form_set(primitive, EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE);
327 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE), 308 evas_canvas3d_primitive_precision_set(primitive, 10);
328 evas_canvas3d_primitive_precision_set(10));
329 data->mesh_sphere = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 309 data->mesh_sphere = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
330 eo_do(data->mesh_sphere, evas_canvas3d_mesh_from_primitive_set(0, primitive)); 310 evas_canvas3d_mesh_from_primitive_set(data->mesh_sphere, 0, primitive);
331 eo_do(data->mesh_sphere, 311 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_sphere, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
332 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), 312 evas_canvas3d_mesh_shade_mode_set(data->mesh_sphere, EVAS_CANVAS3D_SHADE_MODE_PHONG);
333 313 evas_canvas3d_mesh_frame_material_set(data->mesh_sphere, 0, data->material);
334 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG),
335
336 evas_canvas3d_mesh_frame_material_set(0, data->material));
337 314
338 /* Setup mesh torus */ 315 /* Setup mesh torus */
339 data->mesh_torus = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 316 data->mesh_torus = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
340 eo_do(primitive, 317 evas_canvas3d_primitive_form_set(primitive, EVAS_CANVAS3D_MESH_PRIMITIVE_TORUS);
341 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_TORUS), 318 evas_canvas3d_primitive_precision_set(primitive, 50);
342 evas_canvas3d_primitive_precision_set(50)); 319 evas_canvas3d_mesh_from_primitive_set(data->mesh_torus, 0, primitive);
343 eo_do(data->mesh_torus, evas_canvas3d_mesh_from_primitive_set(0, primitive)); 320 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_torus, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
344 eo_do(data->mesh_torus, 321 evas_canvas3d_mesh_shade_mode_set(data->mesh_torus, EVAS_CANVAS3D_SHADE_MODE_PHONG);
345 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), 322 evas_canvas3d_mesh_frame_material_set(data->mesh_torus, 0, data->material);
346 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG),
347 evas_canvas3d_mesh_frame_material_set(0, data->material));
348 323
349 /* Setup mesh cube */ 324 /* Setup mesh cube */
350 data->mesh_cube = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 325 data->mesh_cube = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
351 eo_do(primitive, 326 evas_canvas3d_primitive_form_set(primitive, EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE);
352 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE), 327 evas_canvas3d_primitive_precision_set(primitive, 50);
353 evas_canvas3d_primitive_precision_set(50)); 328 evas_canvas3d_mesh_from_primitive_set(data->mesh_cube, 0, primitive);
354 eo_do(data->mesh_cube, evas_canvas3d_mesh_from_primitive_set(0, primitive)); 329 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_cube, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
355 eo_do(data->mesh_cube, 330 evas_canvas3d_mesh_shade_mode_set(data->mesh_cube, EVAS_CANVAS3D_SHADE_MODE_PHONG);
356 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), 331 evas_canvas3d_mesh_frame_material_set(data->mesh_cube, 0, data->material);
357 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG),
358 evas_canvas3d_mesh_frame_material_set(0, data->material));
359 332
360 MODEL_MESH_INIT(plain, plain, PHONG) 333 MODEL_MESH_INIT(plain, plain, PHONG)
361 MODEL_MESH_INIT(column, column, PHONG) 334 MODEL_MESH_INIT(column, column, PHONG)
@@ -382,13 +355,11 @@ _mesh_setup(Scene_Data *data)
382 MODEL_MESH_INIT(blender_test_sonic, sonic_test, DIFFUSE) 355 MODEL_MESH_INIT(blender_test_sonic, sonic_test, DIFFUSE)
383 356
384 data->mesh_node = 357 data->mesh_node =
385 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 358 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
386 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 359 evas_canvas3d_node_member_add(data->root_node, data->mesh_node);
387 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node)); 360 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh_sphere);
388 eo_do(data->mesh_node, 361 evas_canvas3d_node_scale_set(data->mesh_node, SCALE_SPHERE, SCALE_SPHERE, SCALE_SPHERE);
389 evas_canvas3d_node_mesh_add(data->mesh_sphere), 362 evas_canvas3d_node_position_set(data->mesh_node, 3.0, 0.0, 0.0);
390 evas_canvas3d_node_scale_set(SCALE_SPHERE, SCALE_SPHERE, SCALE_SPHERE),
391 evas_canvas3d_node_position_set(3.0, 0.0, 0.0));
392 363
393 CONVEX_HULL_MESH_INIT(sphere) 364 CONVEX_HULL_MESH_INIT(sphere)
394 CONVEX_HULL_MESH_INIT(torus) 365 CONVEX_HULL_MESH_INIT(torus)
@@ -402,43 +373,36 @@ _mesh_setup(Scene_Data *data)
402 _print_result(data->mesh_sphere_ch, data->mesh_blender_test_sphere); 373 _print_result(data->mesh_sphere_ch, data->mesh_blender_test_sphere);
403 374
404 data->mesh_node_convex_hull = 375 data->mesh_node_convex_hull =
405 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 376 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
406 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 377 evas_canvas3d_node_member_add(data->root_node, data->mesh_node_convex_hull);
407 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node_convex_hull)); 378 evas_canvas3d_node_position_set(data->mesh_node_convex_hull, 0.0, 0.0, 0.0);
408 eo_do(data->mesh_node_convex_hull, 379 evas_canvas3d_node_scale_set(data->mesh_node_convex_hull, SCALE_SPHERE, SCALE_SPHERE, SCALE_SPHERE);
409 evas_canvas3d_node_position_set(0.0, 0.0, 0.0), 380 evas_canvas3d_node_mesh_add(data->mesh_node_convex_hull, data->mesh_sphere_ch);
410 evas_canvas3d_node_scale_set(SCALE_SPHERE, SCALE_SPHERE, SCALE_SPHERE),
411 evas_canvas3d_node_mesh_add(data->mesh_sphere_ch));
412 381
413 data->mesh_node_blender = 382 data->mesh_node_blender =
414 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 383 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
415 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 384 evas_canvas3d_node_member_add(data->root_node, data->mesh_node_blender);
416 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node_blender)); 385 evas_canvas3d_node_position_set(data->mesh_node_blender, -3.0, 0.0, 0.0);
417 eo_do(data->mesh_node_blender, 386 evas_canvas3d_node_scale_set(data->mesh_node_blender, SCALE_SPHERE, SCALE_SPHERE, SCALE_SPHERE);
418 evas_canvas3d_node_position_set(-3.0, 0.0, 0.0), 387 evas_canvas3d_node_mesh_add(data->mesh_node_blender, data->mesh_blender_sphere);
419 evas_canvas3d_node_scale_set(SCALE_SPHERE, SCALE_SPHERE, SCALE_SPHERE),
420 evas_canvas3d_node_mesh_add(data->mesh_blender_sphere));
421} 388}
422 389
423static void 390static void
424_scene_setup(Scene_Data *data) 391_scene_setup(Scene_Data *data)
425{ 392{
426 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 393 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
427 eo_do(data->scene, 394 evas_canvas3d_scene_size_set(data->scene, WIDTH, HEIGHT);
428 evas_canvas3d_scene_size_set(WIDTH, HEIGHT); 395 evas_canvas3d_scene_background_color_set(data->scene, 0.0, 0.0, 0.0, 0.0);
429 evas_canvas3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0));
430 396
431 data->root_node = 397 data->root_node =
432 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 398 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
433 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
434 399
435 _camera_setup(data); 400 _camera_setup(data);
436 _light_setup(data); 401 _light_setup(data);
437 _mesh_setup(data); 402 _mesh_setup(data);
438 403
439 eo_do(data->scene, 404 evas_canvas3d_scene_root_node_set(data->scene, data->root_node);
440 evas_canvas3d_scene_root_node_set(data->root_node), 405 evas_canvas3d_scene_camera_node_set(data->scene, data->camera_node);
441 evas_canvas3d_scene_camera_node_set(data->camera_node));
442} 406}
443 407
444int 408int
@@ -468,22 +432,20 @@ main(void)
468 432
469 /* Add a background rectangle objects. */ 433 /* Add a background rectangle objects. */
470 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 434 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
471 eo_do(background, 435 efl_gfx_color_set(background, 0, 0, 0, 255);
472 efl_gfx_color_set(0, 0, 0, 255), 436 efl_gfx_size_set(background, WIDTH, HEIGHT);
473 efl_gfx_size_set(WIDTH, HEIGHT), 437 efl_gfx_visible_set(background, EINA_TRUE);
474 efl_gfx_visible_set(EINA_TRUE));
475 438
476 /* Add an image object for 3D scene rendering. */ 439 /* Add an image object for 3D scene rendering. */
477 image = evas_object_image_filled_add(evas); 440 image = evas_object_image_filled_add(evas);
478 eo_do(image, 441 efl_gfx_size_set(image, WIDTH, HEIGHT);
479 efl_gfx_size_set(WIDTH, HEIGHT), 442 efl_gfx_visible_set(image, EINA_TRUE);
480 efl_gfx_visible_set(EINA_TRUE));
481 443
482 evas_object_show(image), 444 evas_object_show(image),
483 evas_object_focus_set(image, EINA_TRUE); 445 evas_object_focus_set(image, EINA_TRUE);
484 446
485 /* Set the image object as render target for 3D scene. */ 447 /* Set the image object as render target for 3D scene. */
486 eo_do(image, evas_obj_image_scene_set(data.scene)); 448 evas_obj_image_scene_set(image, data.scene);
487 449
488 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _key_down, &data); 450 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _key_down, &data);
489 451