diff options
Diffstat (limited to '')
-rw-r--r-- | media/sonic.md2 | bin | 0 -> 660576 bytes | |||
-rw-r--r-- | media/sonic.png | bin | 0 -> 309072 bytes | |||
-rw-r--r-- | src/GuiLua/GuiLua.c | 97 |
3 files changed, 91 insertions, 6 deletions
diff --git a/media/sonic.md2 b/media/sonic.md2 new file mode 100644 index 0000000..228edb9 --- /dev/null +++ b/media/sonic.md2 | |||
Binary files differ | |||
diff --git a/media/sonic.png b/media/sonic.png new file mode 100644 index 0000000..01cb2ed --- /dev/null +++ b/media/sonic.png | |||
Binary files differ | |||
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 1318ba2..a21ccfa 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c | |||
@@ -154,11 +154,15 @@ typedef struct _Scene_Data | |||
154 | Evas_3D_Node *camera_node; | 154 | Evas_3D_Node *camera_node; |
155 | Evas_3D_Node *light_node; | 155 | Evas_3D_Node *light_node; |
156 | Evas_3D_Node *mesh_node; | 156 | Evas_3D_Node *mesh_node; |
157 | Evas_3D_Node *mesh2_node; | ||
157 | 158 | ||
158 | Evas_3D_Camera *camera; | 159 | Evas_3D_Camera *camera; |
159 | Evas_3D_Light *light; | 160 | Evas_3D_Light *light; |
160 | Evas_3D_Mesh *mesh; | 161 | Evas_3D_Mesh *mesh; |
161 | Evas_3D_Material *material; | 162 | Evas_3D_Material *material; |
163 | Evas_3D_Mesh *mesh2; | ||
164 | Evas_3D_Material *material2; | ||
165 | Evas_3D_Texture *texture2; | ||
162 | } Scene_Data; | 166 | } Scene_Data; |
163 | 167 | ||
164 | static const float cube_vertices[] = | 168 | static const float cube_vertices[] = |
@@ -232,6 +236,7 @@ static Eina_Bool | |||
232 | _animate_scene(void *data) | 236 | _animate_scene(void *data) |
233 | { | 237 | { |
234 | static float angle = 0.0f; | 238 | static float angle = 0.0f; |
239 | static int frame = 0; | ||
235 | 240 | ||
236 | Scene_Data *scene = (Scene_Data *)data; | 241 | Scene_Data *scene = (Scene_Data *)data; |
237 | 242 | ||
@@ -241,18 +246,33 @@ _animate_scene(void *data) | |||
241 | evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0) | 246 | evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0) |
242 | ); | 247 | ); |
243 | 248 | ||
249 | eo_do(scene->mesh2_node, | ||
250 | evas_3d_node_mesh_frame_set(scene->mesh2, frame); | ||
251 | ); | ||
252 | |||
244 | /* Rotate */ | 253 | /* Rotate */ |
245 | if (angle > 360.0) | 254 | if (angle > 360.0) |
246 | angle -= 360.0f; | 255 | angle -= 360.0f; |
256 | |||
257 | frame += 32; | ||
258 | if (frame > 256 * 50) | ||
259 | frame = 0; | ||
260 | |||
247 | return EINA_TRUE; | 261 | return EINA_TRUE; |
248 | } | 262 | } |
249 | 263 | ||
264 | #define DO_CUBE 1 | ||
265 | |||
250 | static void | 266 | static void |
251 | _camera_setup(globals *ourGlobals, Scene_Data *data) | 267 | _camera_setup(globals *ourGlobals, Scene_Data *data) |
252 | { | 268 | { |
253 | data->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas); | 269 | data->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas); |
254 | eo_do(data->camera, | 270 | eo_do(data->camera, |
271 | #if DO_CUBE | ||
255 | evas_3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0) | 272 | evas_3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0) |
273 | #else | ||
274 | evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0) | ||
275 | #endif | ||
256 | ); | 276 | ); |
257 | 277 | ||
258 | data->camera_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA); | 278 | data->camera_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA); |
@@ -263,8 +283,13 @@ _camera_setup(globals *ourGlobals, Scene_Data *data) | |||
263 | evas_3d_node_member_add(data->camera_node) | 283 | evas_3d_node_member_add(data->camera_node) |
264 | ); | 284 | ); |
265 | eo_do(data->camera_node, | 285 | eo_do(data->camera_node, |
286 | #if DO_CUBE | ||
266 | evas_3d_node_position_set(0.0, 0.0, 10.0), | 287 | evas_3d_node_position_set(0.0, 0.0, 10.0), |
267 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0) | 288 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0) |
289 | #else | ||
290 | evas_3d_node_position_set(100.0, 0.0, 20.0), | ||
291 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 20.0, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0) | ||
292 | #endif | ||
268 | ); | 293 | ); |
269 | } | 294 | } |
270 | 295 | ||
@@ -273,9 +298,14 @@ _light_setup(globals *ourGlobals, Scene_Data *data) | |||
273 | { | 298 | { |
274 | data->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas); | 299 | data->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas); |
275 | eo_do(data->light, | 300 | eo_do(data->light, |
301 | #if DO_CUBE | ||
276 | evas_3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), | 302 | evas_3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), |
303 | #else | ||
304 | evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), | ||
305 | #endif | ||
277 | evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), | 306 | evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), |
278 | evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0) | 307 | evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0), |
308 | evas_3d_light_directional_set(EINA_TRUE) | ||
279 | ); | 309 | ); |
280 | 310 | ||
281 | data->light_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_LIGHT); | 311 | data->light_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_LIGHT); |
@@ -286,8 +316,12 @@ _light_setup(globals *ourGlobals, Scene_Data *data) | |||
286 | evas_3d_node_member_add(data->light_node) | 316 | evas_3d_node_member_add(data->light_node) |
287 | ); | 317 | ); |
288 | eo_do(data->light_node, | 318 | eo_do(data->light_node, |
289 | evas_3d_node_position_set(0.0, 0.0, 10.0); | 319 | #if DO_CUBE |
290 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0); | 320 | evas_3d_node_position_set(0.0, 0.0, 10.0), |
321 | #else | ||
322 | evas_3d_node_position_set(1000.0, 0.0, 1000.0), | ||
323 | #endif | ||
324 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0) | ||
291 | ); | 325 | ); |
292 | } | 326 | } |
293 | 327 | ||
@@ -319,7 +353,7 @@ _mesh_setup(globals *ourGlobals, Scene_Data *data) | |||
319 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, 12 * sizeof(float), &cube_vertices[10]), | 353 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, 12 * sizeof(float), &cube_vertices[10]), |
320 | 354 | ||
321 | evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]), | 355 | evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]), |
322 | evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES); | 356 | evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES), |
323 | 357 | ||
324 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), | 358 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), |
325 | 359 | ||
@@ -333,6 +367,52 @@ _mesh_setup(globals *ourGlobals, Scene_Data *data) | |||
333 | eo_do(data->mesh_node, | 367 | eo_do(data->mesh_node, |
334 | evas_3d_node_mesh_add(data->mesh) | 368 | evas_3d_node_mesh_add(data->mesh) |
335 | ); | 369 | ); |
370 | |||
371 | // Setup an MD2 mesh. | ||
372 | data->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); | ||
373 | eo_do(data->mesh2, | ||
374 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "../../media/sonic.md2", NULL) | ||
375 | ); | ||
376 | |||
377 | data->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | ||
378 | eo_do(data->mesh2, | ||
379 | evas_3d_mesh_frame_material_set(0, data->material2) | ||
380 | ); | ||
381 | |||
382 | data->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); | ||
383 | eo_do(data->texture2, | ||
384 | // evas_3d_texture_file_set("../../media/sonic.png", NULL) | ||
385 | // evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), | ||
386 | // evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT) | ||
387 | ); | ||
388 | |||
389 | eo_do(data->material2, | ||
390 | // evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, data->texture2), | ||
391 | |||
392 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | ||
393 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | ||
394 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), | ||
395 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), | ||
396 | |||
397 | evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.01, 0.01, 0.01, 1.0), | ||
398 | evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 1.0, 1.0, 1.0, 1.0), | ||
399 | evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), | ||
400 | evas_3d_material_shininess_set(50.0) | ||
401 | ); | ||
402 | |||
403 | |||
404 | data->mesh2_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); | ||
405 | eo_do(data->root_node, | ||
406 | evas_3d_node_member_add(data->mesh2_node) | ||
407 | ); | ||
408 | eo_do(data->mesh2_node, | ||
409 | evas_3d_node_mesh_add(data->mesh2) | ||
410 | ); | ||
411 | |||
412 | eo_do(data->mesh2, | ||
413 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG); | ||
414 | ); | ||
415 | |||
336 | } | 416 | } |
337 | 417 | ||
338 | 418 | ||
@@ -354,8 +434,9 @@ _scene_setup(globals *ourGlobals, Scene_Data *data) | |||
354 | _mesh_setup(ourGlobals, data); | 434 | _mesh_setup(ourGlobals, data); |
355 | 435 | ||
356 | eo_do(data->scene, | 436 | eo_do(data->scene, |
357 | evas_3d_scene_root_node_set(data->root_node); | 437 | evas_3d_scene_root_node_set(data->root_node), |
358 | evas_3d_scene_camera_node_set(data->camera_node); | 438 | evas_3d_scene_camera_node_set(data->camera_node), |
439 | evas_3d_scene_size_set(1024, 1024) | ||
359 | ); | 440 | ); |
360 | } | 441 | } |
361 | 442 | ||
@@ -503,6 +584,7 @@ static int window(lua_State *L) | |||
503 | if ((ourGlobals->win = elm_win_util_standard_add(name, title))) | 584 | if ((ourGlobals->win = elm_win_util_standard_add(name, title))) |
504 | { | 585 | { |
505 | eina_clist_init(&ourGlobals->widgets); | 586 | eina_clist_init(&ourGlobals->widgets); |
587 | |||
506 | evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals); | 588 | evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals); |
507 | evas_object_resize(ourGlobals->win, w, h); | 589 | evas_object_resize(ourGlobals->win, w, h); |
508 | evas_object_move(ourGlobals->win, 0, 0); | 590 | evas_object_move(ourGlobals->win, 0, 0); |
@@ -528,10 +610,13 @@ static int window(lua_State *L) | |||
528 | eo_do(wid->obj, | 610 | eo_do(wid->obj, |
529 | evas_obj_image_filled_set(EINA_TRUE), | 611 | evas_obj_image_filled_set(EINA_TRUE), |
530 | evas_obj_image_size_set(w, h), | 612 | evas_obj_image_size_set(w, h), |
613 | // evas_obj_size_set(w, h), | ||
531 | evas_obj_position_set(0, 0), | 614 | evas_obj_position_set(0, 0), |
532 | evas_obj_visibility_set(EINA_TRUE), | 615 | evas_obj_visibility_set(EINA_TRUE), |
533 | evas_obj_image_scene_set(data.scene) | 616 | evas_obj_image_scene_set(data.scene) |
534 | ); | 617 | ); |
618 | // evas_object_resize(wid->obj, w, h); | ||
619 | // evas_object_move(wid->obj, 0, 0); | ||
535 | 620 | ||
536 | // Add animation timer callback. | 621 | // Add animation timer callback. |
537 | ecore_timer_add(0.016, _animate_scene, &data); | 622 | ecore_timer_add(0.016, _animate_scene, &data); |