aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/GuiLua/GuiLua.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/GuiLua/GuiLua.c121
1 files changed, 60 insertions, 61 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index a21ccfa..acad2e6 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -230,7 +230,7 @@ globals ourGlobals;
230static const char *globName = "ourGlobals"; 230static const char *globName = "ourGlobals";
231 231
232 232
233static Scene_Data data; 233static Scene_Data ourScene;
234 234
235static Eina_Bool 235static Eina_Bool
236_animate_scene(void *data) 236_animate_scene(void *data)
@@ -264,10 +264,10 @@ _animate_scene(void *data)
264#define DO_CUBE 1 264#define DO_CUBE 1
265 265
266static void 266static void
267_camera_setup(globals *ourGlobals, Scene_Data *data) 267_camera_setup(globals *ourGlobals, Scene_Data *scene)
268{ 268{
269 data->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas); 269 scene->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas);
270 eo_do(data->camera, 270 eo_do(scene->camera,
271#if DO_CUBE 271#if DO_CUBE
272 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 273#else
@@ -275,14 +275,14 @@ _camera_setup(globals *ourGlobals, Scene_Data *data)
275#endif 275#endif
276 ); 276 );
277 277
278 data->camera_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA); 278 scene->camera_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA);
279 eo_do(data->camera_node, 279 eo_do(scene->camera_node,
280 evas_3d_node_camera_set(data->camera) 280 evas_3d_node_camera_set(scene->camera)
281 ); 281 );
282 eo_do(data->root_node, 282 eo_do(scene->root_node,
283 evas_3d_node_member_add(data->camera_node) 283 evas_3d_node_member_add(scene->camera_node)
284 ); 284 );
285 eo_do(data->camera_node, 285 eo_do(scene->camera_node,
286#if DO_CUBE 286#if DO_CUBE
287 evas_3d_node_position_set(0.0, 0.0, 10.0), 287 evas_3d_node_position_set(0.0, 0.0, 10.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) 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)
@@ -294,10 +294,10 @@ _camera_setup(globals *ourGlobals, Scene_Data *data)
294} 294}
295 295
296static void 296static void
297_light_setup(globals *ourGlobals, Scene_Data *data) 297_light_setup(globals *ourGlobals, Scene_Data *scene)
298{ 298{
299 data->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas); 299 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas);
300 eo_do(data->light, 300 eo_do(scene->light,
301#if DO_CUBE 301#if DO_CUBE
302 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 303#else
@@ -308,14 +308,14 @@ _light_setup(globals *ourGlobals, Scene_Data *data)
308 evas_3d_light_directional_set(EINA_TRUE) 308 evas_3d_light_directional_set(EINA_TRUE)
309 ); 309 );
310 310
311 data->light_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_LIGHT); 311 scene->light_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_LIGHT);
312 eo_do(data->light_node, 312 eo_do(scene->light_node,
313 evas_3d_node_light_set(data->light) 313 evas_3d_node_light_set(scene->light)
314 ); 314 );
315 eo_do(data->root_node, 315 eo_do(scene->root_node,
316 evas_3d_node_member_add(data->light_node) 316 evas_3d_node_member_add(scene->light_node)
317 ); 317 );
318 eo_do(data->light_node, 318 eo_do(scene->light_node,
319#if DO_CUBE 319#if DO_CUBE
320 evas_3d_node_position_set(0.0, 0.0, 10.0), 320 evas_3d_node_position_set(0.0, 0.0, 10.0),
321#else 321#else
@@ -326,11 +326,11 @@ _light_setup(globals *ourGlobals, Scene_Data *data)
326} 326}
327 327
328static void 328static void
329_mesh_setup(globals *ourGlobals, Scene_Data *data) 329_mesh_setup(globals *ourGlobals, Scene_Data *scene)
330{ 330{
331 /* Setup material. */ 331 /* Setup material. */
332 data->material = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); 332 scene->material = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas);
333 eo_do(data->material, 333 eo_do(scene->material,
334 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 334 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
335 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 335 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
336 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), 336 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
@@ -342,8 +342,8 @@ _mesh_setup(globals *ourGlobals, Scene_Data *data)
342 ); 342 );
343 343
344 /* Setup mesh. */ 344 /* Setup mesh. */
345 data->mesh = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); 345 scene->mesh = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas);
346 eo_do(data->mesh, 346 eo_do(scene->mesh,
347 evas_3d_mesh_vertex_count_set(24), 347 evas_3d_mesh_vertex_count_set(24),
348 evas_3d_mesh_frame_add(0), 348 evas_3d_mesh_frame_add(0),
349 349
@@ -357,37 +357,37 @@ _mesh_setup(globals *ourGlobals, Scene_Data *data)
357 357
358 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), 358 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG),
359 359
360 evas_3d_mesh_frame_material_set(0, data->material) 360 evas_3d_mesh_frame_material_set(0, scene->material)
361 361
362 ); 362 );
363 data->mesh_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); 363 scene->mesh_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH);
364 eo_do(data->root_node, 364 eo_do(scene->root_node,
365 evas_3d_node_member_add(data->mesh_node) 365 evas_3d_node_member_add(scene->mesh_node)
366 ); 366 );
367 eo_do(data->mesh_node, 367 eo_do(scene->mesh_node,
368 evas_3d_node_mesh_add(data->mesh) 368 evas_3d_node_mesh_add(scene->mesh)
369 ); 369 );
370 370
371 // Setup an MD2 mesh. 371 // Setup an MD2 mesh.
372 data->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); 372 scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas);
373 eo_do(data->mesh2, 373 eo_do(scene->mesh2,
374 evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "../../media/sonic.md2", NULL) 374 evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "../../media/sonic.md2", NULL)
375 ); 375 );
376 376
377 data->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); 377 scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas);
378 eo_do(data->mesh2, 378 eo_do(scene->mesh2,
379 evas_3d_mesh_frame_material_set(0, data->material2) 379 evas_3d_mesh_frame_material_set(0, scene->material2)
380 ); 380 );
381 381
382 data->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); 382 scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas);
383 eo_do(data->texture2, 383 eo_do(scene->texture2,
384// evas_3d_texture_file_set("../../media/sonic.png", NULL) 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), 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) 386// evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT)
387 ); 387 );
388 388
389 eo_do(data->material2, 389 eo_do(scene->material2,
390// evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, data->texture2), 390// evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture2),
391 391
392 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 392 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
393 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 393 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
@@ -401,41 +401,41 @@ _mesh_setup(globals *ourGlobals, Scene_Data *data)
401 ); 401 );
402 402
403 403
404 data->mesh2_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); 404 scene->mesh2_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH);
405 eo_do(data->root_node, 405 eo_do(scene->root_node,
406 evas_3d_node_member_add(data->mesh2_node) 406 evas_3d_node_member_add(scene->mesh2_node)
407 ); 407 );
408 eo_do(data->mesh2_node, 408 eo_do(scene->mesh2_node,
409 evas_3d_node_mesh_add(data->mesh2) 409 evas_3d_node_mesh_add(scene->mesh2)
410 ); 410 );
411 411
412 eo_do(data->mesh2, 412 eo_do(scene->mesh2,
413 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG)
413 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG); 414 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG);
414 ); 415 );
415
416} 416}
417 417
418 418
419static void 419static void
420_scene_setup(globals *ourGlobals, Scene_Data *data) 420_scene_setup(globals *ourGlobals, Scene_Data *scene)
421{ 421{
422 data->scene = eo_add(EVAS_3D_SCENE_CLASS, ourGlobals->evas); 422 scene->scene = eo_add(EVAS_3D_SCENE_CLASS, ourGlobals->evas);
423 eo_do(data->scene, 423 eo_do(scene->scene,
424 evas_3d_scene_size_set(WIDTH, HEIGHT), 424 evas_3d_scene_size_set(WIDTH, HEIGHT),
425 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0) 425 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0)
426 ); 426 );
427 427
428 // TODO - I have no idea how this should work. 428 // TODO - I have no idea how this should work.
429// data->root_node = eo_add(EVAS_3D_NODE_CLASS, ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE); 429// scene->root_node = eo_add(EVAS_3D_NODE_CLASS, ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE);
430 data->root_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE); 430 scene->root_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE);
431 431
432 _camera_setup(ourGlobals, data); 432 _camera_setup(ourGlobals, scene);
433 _light_setup(ourGlobals, data); 433 _light_setup(ourGlobals, scene);
434 _mesh_setup(ourGlobals, data); 434 _mesh_setup(ourGlobals, scene);
435 435
436 eo_do(data->scene, 436 eo_do(scene->scene,
437 evas_3d_scene_root_node_set(data->root_node), 437 evas_3d_scene_root_node_set(scene->root_node),
438 evas_3d_scene_camera_node_set(data->camera_node), 438 evas_3d_scene_camera_node_set(scene->camera_node),
439 evas_3d_scene_size_set(1024, 1024) 439 evas_3d_scene_size_set(1024, 1024)
440 ); 440 );
441} 441}
@@ -592,7 +592,7 @@ static int window(lua_State *L)
592 592
593 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas. 593 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas.
594 ourGlobals->evas = evas_object_evas_get(ourGlobals->win); 594 ourGlobals->evas = evas_object_evas_get(ourGlobals->win);
595 _scene_setup(ourGlobals, &data); 595 _scene_setup(ourGlobals, &ourScene);
596 596
597 /* Add a background rectangle objects. */ 597 /* Add a background rectangle objects. */
598 background = evas_object_rectangle_add(ourGlobals->evas); 598 background = evas_object_rectangle_add(ourGlobals->evas);
@@ -617,9 +617,8 @@ static int window(lua_State *L)
617 ); 617 );
618// evas_object_resize(wid->obj, w, h); 618// evas_object_resize(wid->obj, w, h);
619// evas_object_move(wid->obj, 0, 0); 619// evas_object_move(wid->obj, 0, 0);
620
621 // Add animation timer callback. 620 // Add animation timer callback.
622 ecore_timer_add(0.016, _animate_scene, &data); 621 ecore_timer_add(0.016, _animate_scene, &ourScene);
623 622
624 lua_pushlightuserdata(L, &ourGlobals->win); 623 lua_pushlightuserdata(L, &ourGlobals->win);
625 return 1; 624 return 1;