summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Walter Seikel <won_fang@yahoo.com.au>2014-05-08 05:18:59 +1000
committerDavid Walter Seikel <won_fang@yahoo.com.au>2014-05-08 05:18:59 +1000
commit56f2409465d4684c0b1e28df8533877d43c6fbc2 (patch)
tree89926b666f0da61caa396fc9cf4e031a94947672
parent533e9519293801bfc6e76aefaebeef5371403688 (diff)
Just pass evas to the 3d setup functions.
-rw-r--r--evas-3d-elm.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/evas-3d-elm.c b/evas-3d-elm.c
index 9fd8b0e..d2f23ff 100644
--- a/evas-3d-elm.c
+++ b/evas-3d-elm.c
@@ -375,13 +375,13 @@ _animate_scene(void *data)
375 375
376 376
377static void 377static void
378_camera_setup(globals *ourGlobals, Scene_Data *scene) 378_camera_setup(Evas *evas, Scene_Data *scene)
379{ 379{
380 scene->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas, 380 scene->camera = eo_add(EVAS_3D_CAMERA_CLASS, evas,
381 evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0) 381 evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0)
382 ); 382 );
383 383
384 scene->camera_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA), 384 scene->camera_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA),
385 evas_3d_node_camera_set(scene->camera), 385 evas_3d_node_camera_set(scene->camera),
386 evas_3d_node_position_set(50.0, 0.0, 20.0), 386 evas_3d_node_position_set(50.0, 0.0, 20.0),
387 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) 387 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)
@@ -392,15 +392,15 @@ _camera_setup(globals *ourGlobals, Scene_Data *scene)
392} 392}
393 393
394static void 394static void
395_light_setup(globals *ourGlobals, Scene_Data *scene) 395_light_setup(Evas *evas, Scene_Data *scene)
396{ 396{
397 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas, 397 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, evas,
398 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 398 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0),
399 evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 399 evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0),
400 evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0), 400 evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0),
401 evas_3d_light_directional_set(EINA_TRUE) 401 evas_3d_light_directional_set(EINA_TRUE)
402 ); 402 );
403 scene->light_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_LIGHT), 403 scene->light_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_LIGHT),
404 evas_3d_node_light_set(scene->light), 404 evas_3d_node_light_set(scene->light),
405 evas_3d_node_position_set(1000.0, 0.0, 1000.0), 405 evas_3d_node_position_set(1000.0, 0.0, 1000.0),
406 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) 406 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)
@@ -409,22 +409,22 @@ _light_setup(globals *ourGlobals, Scene_Data *scene)
409} 409}
410 410
411static void 411static void
412_cube_setup(globals *ourGlobals, Scene_Data *scene) 412_cube_setup(Evas *evas, Scene_Data *scene)
413{ 413{
414 // Setup cube materials. 414 // Setup cube materials.
415 scene->texture0 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, 415 scene->texture0 = eo_add(EVAS_3D_TEXTURE_CLASS, evas,
416 evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels0[0]) 416 evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels0[0])
417 ); 417 );
418 418
419 scene->texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, 419 scene->texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, evas,
420 evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) 420 evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0])
421 ); 421 );
422 422
423 scene->texture_normal = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, 423 scene->texture_normal = eo_add(EVAS_3D_TEXTURE_CLASS, evas,
424 evas_3d_texture_file_set("media/normal_lego.png", NULL) 424 evas_3d_texture_file_set("media/normal_lego.png", NULL)
425 ); 425 );
426 426
427 scene->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, 427 scene->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, evas,
428 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 428 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
429 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 429 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
430 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), 430 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
@@ -437,7 +437,7 @@ _cube_setup(globals *ourGlobals, Scene_Data *scene)
437 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture0) 437 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture0)
438 ); 438 );
439 439
440 scene->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, 440 scene->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, evas,
441 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 441 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
442 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 442 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
443 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), 443 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
@@ -453,7 +453,7 @@ _cube_setup(globals *ourGlobals, Scene_Data *scene)
453 ); 453 );
454 454
455 // Setup CUBE mesh. 455 // Setup CUBE mesh.
456 scene->mesh = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, 456 scene->mesh = eo_add(EVAS_3D_MESH_CLASS, evas,
457 evas_3d_mesh_vertex_count_set(24), 457 evas_3d_mesh_vertex_count_set(24),
458 evas_3d_mesh_frame_add(0), 458 evas_3d_mesh_frame_add(0),
459 459
@@ -473,7 +473,7 @@ _cube_setup(globals *ourGlobals, Scene_Data *scene)
473 evas_3d_mesh_frame_material_set(20, scene->material1) 473 evas_3d_mesh_frame_material_set(20, scene->material1)
474 ); 474 );
475 475
476 scene->mesh_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH), 476 scene->mesh_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH),
477 eo_key_data_set("Name", "cube", NULL), 477 eo_key_data_set("Name", "cube", NULL),
478 evas_3d_node_position_set(40.0, 3.5, 23.0), 478 evas_3d_node_position_set(40.0, 3.5, 23.0),
479 evas_3d_node_mesh_add(scene->mesh) 479 evas_3d_node_mesh_add(scene->mesh)
@@ -483,16 +483,16 @@ _cube_setup(globals *ourGlobals, Scene_Data *scene)
483} 483}
484 484
485static void 485static void
486_sonic_setup(globals *ourGlobals, Scene_Data *scene) 486_sonic_setup(Evas *evas, Scene_Data *scene)
487{ 487{
488 // Setup an MD2 mesh. 488 // Setup an MD2 mesh.
489 scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, 489 scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, evas,
490 evas_3d_texture_file_set("media/sonic.png", NULL), 490 evas_3d_texture_file_set("media/sonic.png", NULL),
491 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), 491 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST),
492 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT) 492 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT)
493 ); 493 );
494 494
495 scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, 495 scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, evas,
496 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture2), 496 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture2),
497 497
498 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 498 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
@@ -506,13 +506,13 @@ _sonic_setup(globals *ourGlobals, Scene_Data *scene)
506 evas_3d_material_shininess_set(50.0) 506 evas_3d_material_shininess_set(50.0)
507 ); 507 );
508 508
509 scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, 509 scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, evas,
510 evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "media/sonic.md2", NULL), 510 evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "media/sonic.md2", NULL),
511 evas_3d_mesh_frame_material_set(0, scene->material2), 511 evas_3d_mesh_frame_material_set(0, scene->material2),
512 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG) 512 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG)
513 ); 513 );
514 514
515 scene->mesh2_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH), 515 scene->mesh2_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH),
516 eo_key_data_set("Name", "sonic", NULL), 516 eo_key_data_set("Name", "sonic", NULL),
517 evas_3d_node_mesh_add(scene->mesh2) 517 evas_3d_node_mesh_add(scene->mesh2)
518 ); 518 );
@@ -521,15 +521,15 @@ _sonic_setup(globals *ourGlobals, Scene_Data *scene)
521} 521}
522 522
523static void 523static void
524_earth_setup(globals *ourGlobals, Scene_Data *scene) 524_earth_setup(Evas *evas, Scene_Data *scene)
525{ 525{
526 // Setup earth material. 526 // Setup earth material.
527 scene->texture_diffuse = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, 527 scene->texture_diffuse = eo_add(EVAS_3D_TEXTURE_CLASS, evas,
528 evas_3d_texture_file_set("media/EarthDiffuse.png", NULL), 528 evas_3d_texture_file_set("media/EarthDiffuse.png", NULL),
529 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR) 529 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR)
530 ); 530 );
531 531
532 scene->material3 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, 532 scene->material3 = eo_add(EVAS_3D_MATERIAL_CLASS, evas,
533 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture_diffuse), 533 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture_diffuse),
534 534
535 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 535 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
@@ -545,7 +545,7 @@ _earth_setup(globals *ourGlobals, Scene_Data *scene)
545 // Setup earth mesh. 545 // Setup earth mesh.
546 _sphere_init(100); 546 _sphere_init(100);
547 547
548 scene->mesh3 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, 548 scene->mesh3 = eo_add(EVAS_3D_MESH_CLASS, evas,
549 evas_3d_mesh_vertex_count_set(vertex_count), 549 evas_3d_mesh_vertex_count_set(vertex_count),
550 evas_3d_mesh_frame_add(0), 550 evas_3d_mesh_frame_add(0),
551 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, sizeof(vertex), &sphere_vertices[0].position), 551 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, sizeof(vertex), &sphere_vertices[0].position),
@@ -561,7 +561,7 @@ _earth_setup(globals *ourGlobals, Scene_Data *scene)
561 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_DIFFUSE) 561 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_DIFFUSE)
562 ); 562 );
563 563
564 scene->mesh3_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH), 564 scene->mesh3_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH),
565 eo_key_data_set("Name", "earth", NULL), 565 eo_key_data_set("Name", "earth", NULL),
566 evas_3d_node_position_set(40.0, -3.5, 23.0), 566 evas_3d_node_position_set(40.0, -3.5, 23.0),
567 evas_3d_node_mesh_add(scene->mesh3) 567 evas_3d_node_mesh_add(scene->mesh3)
@@ -571,22 +571,22 @@ _earth_setup(globals *ourGlobals, Scene_Data *scene)
571} 571}
572 572
573static void 573static void
574_scene_setup(globals *ourGlobals, Scene_Data *scene) 574_scene_setup(Evas *evas, Scene_Data *scene)
575{ 575{
576 scene->root_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_NODE)); 576 scene->root_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_NODE));
577 577
578 // -TODO - set the size based on the size of the enclosing window. 578 // -TODO - set the size based on the size of the enclosing window.
579 scene->scene = eo_add(EVAS_3D_SCENE_CLASS, ourGlobals->evas, 579 scene->scene = eo_add(EVAS_3D_SCENE_CLASS, evas,
580 evas_3d_scene_root_node_set(scene->root_node), 580 evas_3d_scene_root_node_set(scene->root_node),
581 evas_3d_scene_size_set(512, 512), 581 evas_3d_scene_size_set(512, 512),
582 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0) 582 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0)
583 ); 583 );
584 584
585 _camera_setup(ourGlobals, scene); 585 _camera_setup(evas, scene);
586 _light_setup(ourGlobals, scene); 586 _light_setup(evas, scene);
587 _cube_setup(ourGlobals, scene); 587 _cube_setup(evas, scene);
588 _sonic_setup(ourGlobals, scene); 588 _sonic_setup(evas, scene);
589 _earth_setup(ourGlobals, scene); 589 _earth_setup(evas, scene);
590} 590}
591 591
592static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) 592static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
@@ -706,7 +706,7 @@ static void open_window(globals *ourGlobals)
706 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm. 706 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm.
707 ourGlobals->evas = evas_object_evas_get(ourGlobals->win); 707 ourGlobals->evas = evas_object_evas_get(ourGlobals->win);
708 708
709 _scene_setup(ourGlobals, &ourScene); 709 _scene_setup(ourGlobals->evas, &ourScene);
710 710
711 // Add a background image object. 711 // Add a background image object.
712 obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win); 712 obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win);