diff options
author | Bogdan Devichev <b.devichev@samsung.com> | 2015-01-29 17:39:59 +0200 |
---|---|---|
committer | Bogdan Devichev <b.devichev@samsung.com> | 2015-01-29 17:39:59 +0200 |
commit | d69e06183c089e354820fc766080ee3dc8804096 (patch) | |
tree | b4732bebd7009ea0caf8e59fb184f28e418fc8ff | |
parent | 23c3cd9489c32093226124aa0efb5f4853230302 (diff) | |
download | efl-d69e06183c089e354820fc766080ee3dc8804096.tar.gz |
Obj_io. Step 5. Example to see fix on step 4. (warning with memory in loader will be fixed ASAP)
7 files changed, 273 insertions, 23 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 index e07ff287a1..35bdc5385b 100644 --- a/src/examples/evas/Obj_fixes/example_to_explain_fixes.c +++ b/src/examples/evas/Obj_fixes/example_to_explain_fixes.c @@ -17,6 +17,21 @@ #define WIDTH 1900 #define HEIGHT 1080 +#define ADD_OBJ_MESH(mesh_name, Y, Z) \ + mesh_name = eo_add(EVAS_3D_MESH_CLASS, evas); \ + eo_do(mesh_name, \ + efl_file_set("sweet_"#mesh_name".obj", NULL), \ + evas_3d_mesh_frame_material_set(0, material), \ + evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG)); \ + eo_do(mesh_name, efl_file_save("saved_"#mesh_name".obj", NULL, NULL)); \ + mesh_name##_node = eo_add(EVAS_3D_NODE_CLASS, evas, \ + evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); \ + eo_do(root_node, \ + evas_3d_node_member_add(mesh_name##_node)); \ + eo_do(mesh_name##_node, \ + evas_3d_node_mesh_add(mesh_name), \ + evas_3d_node_position_set(0, Y, Z)); + Ecore_Evas *ecore_evas = NULL; Evas *evas = NULL; Eo *background = NULL; @@ -27,8 +42,14 @@ Eo *root_node = NULL; Eo *camera_node = NULL; Eo *light_node = NULL; Eo *camera = NULL; -Eo *mesh_node = NULL; -Eo *mesh = NULL; +Eo *home_node = NULL; +Eo *home = NULL; +Eo *home_without_normals_node = NULL; +Eo *home_without_normals = NULL;; +Eo *home_without_tex_coords_node = NULL; +Eo *home_without_tex_coords = NULL; +Eo *home_only_vertex_coords_node = NULL; +Eo *home_only_vertex_coords = NULL; Eo *material = NULL; Eo *texture = NULL; Eo *light = NULL; @@ -38,7 +59,7 @@ static float angle = 0; static Eina_Bool _animate_scene(void *data) { - angle += 0.5; + angle += 0.2; eo_do((Evas_3D_Node *)data, evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, -1.0)); @@ -92,7 +113,7 @@ main(void) /* Add the camera. */ camera = eo_add(EVAS_3D_CAMERA_CLASS, evas); eo_do(camera, - evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0)); + evas_3d_camera_projection_perspective_set(100.0, 1.0, 1.0, 500.0)); camera_node = eo_add(EVAS_3D_NODE_CLASS, evas, @@ -102,8 +123,8 @@ main(void) eo_do(root_node, evas_3d_node_member_add(camera_node)); eo_do(camera_node, - evas_3d_node_position_set(10.0, 0.0, 2.0), - evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 2.0, + evas_3d_node_position_set(10.0, 0.0, 0.0), + evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0)); /* Add the light. */ light = eo_add(EVAS_3D_LIGHT_CLASS, evas); @@ -124,16 +145,14 @@ main(void) eo_do(root_node, evas_3d_node_member_add(light_node)); - /* Add the mesh. */ - mesh = eo_add(EVAS_3D_MESH_CLASS, evas); + texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas); material = eo_add(EVAS_3D_MATERIAL_CLASS, evas); - eo_do(mesh, - efl_file_set("sweet_home.obj", NULL), - evas_3d_mesh_frame_material_set(0, material), - evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG)); + ADD_OBJ_MESH(home, -3, -3) + ADD_OBJ_MESH(home_without_normals, -3, 3) + ADD_OBJ_MESH(home_without_tex_coords, 3, -3) + ADD_OBJ_MESH(home_only_vertex_coords, 3, 3) - texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas); eo_do(texture, evas_3d_texture_file_set("sweet_home_temp.png", NULL), evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, @@ -154,15 +173,6 @@ main(void) 1.0, 1.0, 1.0, 1.0), evas_3d_material_shininess_set(50.0)); - eo_do(mesh, efl_file_save("saved_home.obj", NULL, NULL)); - - mesh_node = eo_add(EVAS_3D_NODE_CLASS, evas, - evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); - eo_do(root_node, - evas_3d_node_member_add(mesh_node)); - eo_do(mesh_node, - evas_3d_node_mesh_add(mesh)); - /* Set up scene. */ eo_do(scene, evas_3d_scene_root_node_set(root_node), @@ -185,7 +195,10 @@ main(void) /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(scene)); - ecore_timer_add(0.01, _animate_scene, mesh_node); + ecore_timer_add(0.01, _animate_scene, home_node); + ecore_timer_add(0.01, _animate_scene, home_without_normals_node); + ecore_timer_add(0.01, _animate_scene, home_without_tex_coords_node); + ecore_timer_add(0.01, _animate_scene, home_only_vertex_coords_node); /* Enter main loop. */ ecore_main_loop_begin(); diff --git a/src/examples/evas/Obj_fixes/sweet_home_only_vertex_coords.mtl b/src/examples/evas/Obj_fixes/sweet_home_only_vertex_coords.mtl new file mode 100644 index 0000000000..19d1272a1e --- /dev/null +++ b/src/examples/evas/Obj_fixes/sweet_home_only_vertex_coords.mtl @@ -0,0 +1,12 @@ +# Blender MTL File: 'sweet_home.blend' +# Material Count: 1 + +newmtl Material +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd /home/bdevichev/Desktop/rect.png diff --git a/src/examples/evas/Obj_fixes/sweet_home_only_vertex_coords.obj b/src/examples/evas/Obj_fixes/sweet_home_only_vertex_coords.obj new file mode 100644 index 0000000000..675b032db0 --- /dev/null +++ b/src/examples/evas/Obj_fixes/sweet_home_only_vertex_coords.obj @@ -0,0 +1,40 @@ +# Blender v2.69 (sub 0) OBJ File: 'sweet_home.blend' +# www.blender.org +mtllib sweet_home_only_vertex_coords.mtl +o Cube +v 1.000003 -0.999997 0.000002 +v -0.999997 -1.000003 0.000002 +v -1.000002 0.999998 0.000002 +v 0.999998 1.000002 0.000002 +v 1.000002 -0.999998 2.000002 +v -0.999998 -1.000002 2.000002 +v -1.000002 0.999998 2.000002 +v 0.999997 1.000003 2.000002 +v 0.000002 -1.000000 3.075149 +v -0.000002 1.000000 3.075149 +v 0.666668 -0.644449 2.358384 +v 0.333335 -0.644450 2.716766 +v 0.666667 -0.293067 2.358384 +v 0.333334 -0.293068 2.716766 +v 0.662209 -0.629904 2.991038 +v 0.337794 -0.629904 2.980731 +v 0.662208 -0.307612 2.991038 +v 0.337793 -0.307613 2.980731 +usemtl Material +s off +f 4 8 5 1 +f 6 2 1 5 9 +f 7 10 8 4 3 +f 11 12 14 13 +f 15 17 18 16 +f 2 3 4 1 +f 6 7 3 2 +f 6 9 10 7 +f 14 12 16 18 +f 11 13 17 15 +f 13 14 18 17 +f 12 11 15 16 +f 5 11 12 9 +f 9 12 14 10 +f 13 8 10 14 +f 11 5 8 13 diff --git a/src/examples/evas/Obj_fixes/sweet_home_without_normals.mtl b/src/examples/evas/Obj_fixes/sweet_home_without_normals.mtl new file mode 100644 index 0000000000..c3342d4c8b --- /dev/null +++ b/src/examples/evas/Obj_fixes/sweet_home_without_normals.mtl @@ -0,0 +1,22 @@ +# Blender MTL File: 'sweet_home.blend' +# Material Count: 2 + +newmtl Material +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd /home/bdevichev/Desktop/rect.png + +newmtl Material_Untitled +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd /home/bdevichev/Desktop/sweet_home.png diff --git a/src/examples/evas/Obj_fixes/sweet_home_without_normals.obj b/src/examples/evas/Obj_fixes/sweet_home_without_normals.obj new file mode 100644 index 0000000000..a535ece5a4 --- /dev/null +++ b/src/examples/evas/Obj_fixes/sweet_home_without_normals.obj @@ -0,0 +1,96 @@ +# Blender v2.69 (sub 0) OBJ File: 'sweet_home.blend' +# www.blender.org +mtllib sweet_home_without_normals.mtl +o Cube +v 1.000003 -0.999997 0.000002 +v -0.999997 -1.000003 0.000002 +v -1.000002 0.999998 0.000002 +v 0.999998 1.000002 0.000002 +v 1.000002 -0.999998 2.000002 +v -0.999998 -1.000002 2.000002 +v -1.000002 0.999998 2.000002 +v 0.999997 1.000003 2.000002 +v 0.000002 -1.000000 3.075149 +v -0.000002 1.000000 3.075149 +v 0.666668 -0.644449 2.358384 +v 0.333335 -0.644450 2.716766 +v 0.666667 -0.293067 2.358384 +v 0.333334 -0.293068 2.716766 +v 0.662209 -0.629904 2.991038 +v 0.337794 -0.629904 2.980731 +v 0.662208 -0.307612 2.991038 +v 0.337793 -0.307613 2.980731 +vt 0.013689 0.608350 +vt 0.285640 0.608350 +vt 0.285640 0.978776 +vt 0.013689 0.978776 +vt 0.564957 0.983606 +vt 0.293719 0.983606 +vt 0.293719 0.613180 +vt 0.564957 0.613180 +vt 0.646856 0.021326 +vt 0.083404 0.021326 +vt 0.083369 0.584801 +vt 0.646820 0.584801 +vt 0.949735 0.303064 +vt 0.654355 0.022016 +vt 0.957234 0.303753 +vt 0.654320 0.585490 +vt 0.090869 0.585491 +vt 0.090904 0.022016 +vt 0.820337 0.692442 +vt 0.820337 0.803140 +vt 0.740863 0.803140 +vt 0.740863 0.692442 +vt 0.695284 0.903159 +vt 0.695284 0.830265 +vt 0.768687 0.830265 +vt 0.768687 0.903159 +vt 0.874667 0.789013 +vt 0.874667 0.893367 +vt 0.979009 0.893367 +vt 0.979009 0.789013 +vt 0.567834 0.981515 +vt 0.567834 0.611089 +vt 0.768686 0.903159 +vt 0.768687 0.823686 +vt 0.811715 0.826975 +vt 0.811715 0.899870 +vt 0.591196 0.903159 +vt 0.591196 0.823686 +vt 0.695284 0.826975 +vt 0.695284 0.899870 +vt 0.666035 0.721564 +vt 0.667476 0.661838 +vt 0.740863 0.660019 +vt 0.591196 0.741571 +vt 0.666035 0.660015 +vt 0.666035 0.803140 +vt 0.592658 0.801339 +vt 0.013481 0.981515 +vt 0.104078 0.915663 +vt 0.194676 0.915663 +vt 0.285274 0.981515 +vt 0.194676 0.850582 +vt 0.285274 0.611089 +vt 0.104078 0.850582 +vt 0.013481 0.611089 +usemtl Material +s off +f 6/1 9/2 10/3 7/4 +usemtl Material_Untitled +f 4/5 8/6 5/7 1/8 +f 6/9 2/10 1/11 5/12 9/13 +f 7/14 10/15 8/16 4/17 3/18 +f 11/19 12/20 14/21 13/22 +f 15/23 17/24 18/25 16/26 +f 2/27 3/28 4/29 1/30 +f 6/2 7/3 3/31 2/32 +f 14/33 12/34 16/35 18/36 +f 11/37 13/38 17/39 15/40 +f 13/21 14/41 18/42 17/43 +f 12/44 11/45 15/46 16/47 +f 5/48 11/49 12/50 9/51 +f 9/51 12/50 14/52 10/53 +f 13/54 8/55 10/53 14/52 +f 11/49 5/48 8/55 13/54 diff --git a/src/examples/evas/Obj_fixes/sweet_home_without_tex_coords.mtl b/src/examples/evas/Obj_fixes/sweet_home_without_tex_coords.mtl new file mode 100644 index 0000000000..19d1272a1e --- /dev/null +++ b/src/examples/evas/Obj_fixes/sweet_home_without_tex_coords.mtl @@ -0,0 +1,12 @@ +# Blender MTL File: 'sweet_home.blend' +# Material Count: 1 + +newmtl Material +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd /home/bdevichev/Desktop/rect.png diff --git a/src/examples/evas/Obj_fixes/sweet_home_without_tex_coords.obj b/src/examples/evas/Obj_fixes/sweet_home_without_tex_coords.obj new file mode 100644 index 0000000000..50339a28b7 --- /dev/null +++ b/src/examples/evas/Obj_fixes/sweet_home_without_tex_coords.obj @@ -0,0 +1,55 @@ +# Blender v2.69 (sub 0) OBJ File: 'sweet_home.blend' +# www.blender.org +mtllib sweet_home_without_tex_coords.mtl +o Cube +v 1.000003 -0.999997 0.000002 +v -0.999997 -1.000003 0.000002 +v -1.000002 0.999998 0.000002 +v 0.999998 1.000002 0.000002 +v 1.000002 -0.999998 2.000002 +v -0.999998 -1.000002 2.000002 +v -1.000002 0.999998 2.000002 +v 0.999997 1.000003 2.000002 +v 0.000002 -1.000000 3.075149 +v -0.000002 1.000000 3.075149 +v 0.666668 -0.644449 2.358384 +v 0.333335 -0.644450 2.716766 +v 0.666667 -0.293067 2.358384 +v 0.333334 -0.293068 2.716766 +v 0.662209 -0.629904 2.991038 +v 0.337794 -0.629904 2.980731 +v 0.662208 -0.307612 2.991038 +v 0.337793 -0.307613 2.980731 +vn 1.000000 0.000002 0.000000 +vn 0.000002 -1.000000 0.000000 +vn -0.000002 1.000000 -0.000000 +vn -0.732233 -0.000001 -0.681054 +vn -0.031755 -0.000000 0.999496 +vn -0.000000 0.000000 -1.000000 +vn -1.000000 -0.000002 -0.000000 +vn -0.732233 -0.000002 0.681054 +vn -0.999857 -0.000002 0.016891 +vn 0.999975 0.000002 0.007049 +vn 0.017155 0.999327 0.032422 +vn 0.017160 -0.999327 0.032422 +vn 0.732233 0.000001 0.681054 +vn 0.732233 0.000002 0.681054 +vn 0.732234 0.000002 0.681053 +usemtl Material +s off +f 4//1 8//1 5//1 1//1 +f 6//2 2//2 1//2 5//2 9//2 +f 7//3 10//3 8//3 4//3 3//3 +f 11//4 12//4 14//4 13//4 +f 15//5 17//5 18//5 16//5 +f 2//6 3//6 4//6 1//6 +f 6//7 7//7 3//7 2//7 +f 6//8 9//8 10//8 7//8 +f 14//9 12//9 16//9 18//9 +f 11//10 13//10 17//10 15//10 +f 13//11 14//11 18//11 17//11 +f 12//12 11//12 15//12 16//12 +f 5//13 11//13 12//13 9//13 +f 9//14 12//14 14//14 10//14 +f 13//14 8//14 10//14 14//14 +f 11//15 5//15 8//15 13//15 |