[evas/evas_3D] Some fixes in evas-3d-shadows example
authorOleksandr Shcherbina <o.shcherbina@samsung.com>
Fri, 10 Apr 2015 05:20:34 +0000 (14:20 +0900)
committerChunEon Park <chuneon.park@samsung.com>
Fri, 10 Apr 2015 05:20:35 +0000 (14:20 +0900)
Summary:
Regard to this https://phab.enlightenment.org/D2250 improve view of 3D objects
Improve bug with incorect changing shade mode for billboard

Reviewers: Hermet, cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2299

src/examples/evas/evas-3d-shadows.c

index 701a474..5177043 100644 (file)
@@ -42,7 +42,7 @@ static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_MODEL_FOLDER "/sonic.m
 static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png";
 static const char *b_image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/billboard.png";
 static const vec2 tex_scale = {1, 1};
-static const vec2 fence_tex_scale = {80, 6};
+static const vec2 fence_tex_scale = {160, 12};
 
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
@@ -50,11 +50,42 @@ Eo *background = NULL;
 Eo *image = NULL;
 Evas_3D_Node *choosed_node = NULL;
 
+typedef struct _Body_3D
+{
+   Eo     *material;
+   Eo     *mesh;
+   Eo     *node;
+   Eo     *texture;
+} Body_3D;
+
+typedef struct _Scene_Data
+{
+   Eo     *scene;
+   Eo     *root_node;
+   Eo     *camera_node;
+   Eo     *camera;
+   Eo     *light_node;
+   Eo     *light;
+   Eo     *mediator;
+
+   Body_3D     sphere;
+   Body_3D     cube;
+   Body_3D     square;
+   Body_3D     cylinder;
+   Body_3D     model;
+   Body_3D     cone;
+   Body_3D     fence;
+   Body_3D     billboard;
+
+   Eina_Bool   init;
+} Scene_Data;
+
 Eina_Bool
 _cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
 {
    Eina_List *meshes = NULL, *l;
    Evas_3D_Mesh *m;
+   Evas_3D_Node *billboard = NULL;
    eo_do((Evas_3D_Node *)event_info, meshes = (Eina_List *)evas_3d_node_mesh_list_get());
    EINA_LIST_FOREACH(meshes, l, m)
      {
@@ -62,10 +93,14 @@ _cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Descript
      }
    if (choosed_node != (Evas_3D_Node *)event_info)
      {
-        eo_do(choosed_node, meshes = (Eina_List *)evas_3d_node_mesh_list_get());
-        EINA_LIST_FOREACH(meshes, l, m)
+        eo_do(choosed_node, billboard = evas_3d_node_billboard_target_get());
+        if (!billboard)
           {
-             eo_do(m, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
+             eo_do(choosed_node, meshes = (Eina_List *)evas_3d_node_mesh_list_get());
+             EINA_LIST_FOREACH(meshes, l, m)
+               {
+                  eo_do(m, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
+               }
           }
         choosed_node = (Evas_3D_Node *)event_info;
      }
@@ -87,36 +122,6 @@ _cb_collision(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Descri
    return EINA_TRUE;
 }
 
-typedef struct _Body_3D
-{
-   Eo     *material;
-   Eo     *mesh;
-   Eo     *node;
-   Eo     *texture;
-} Body_3D;
-
-typedef struct _Scene_Data
-{
-   Eo     *scene;
-   Eo     *root_node;
-   Eo     *camera_node;
-   Eo     *camera;
-   Eo     *light_node;
-   Eo     *light;
-   Eo     *mediator;
-
-   Body_3D     sphere;
-   Body_3D     cube;
-   Body_3D     square;
-   Body_3D     cylinder;
-   Body_3D     model;
-   Body_3D     cone;
-   Body_3D     fence;
-   Body_3D     billboard;
-
-   Eina_Bool   init;
-} Scene_Data;
-
 static void
 _show_help()
 {
@@ -218,7 +223,8 @@ _cone_setup(Body_3D *cone)
       eo_add(EVAS_3D_NODE_CLASS, evas,
                     evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
    eo_do(cone->node, evas_3d_node_mesh_add(cone->mesh),
-         evas_3d_node_position_set(-5.0, -1.0, -3.0));
+         evas_3d_node_orientation_angle_axis_set(-90.0, 1.0, 0.0, 0.0),
+         evas_3d_node_position_set(-4.0, 0.0, -3.0));
 }
 
 static void
@@ -232,6 +238,7 @@ _cylinder_setup(Body_3D *cylinder)
       eo_add(EVAS_3D_NODE_CLASS, evas,
                     evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
    eo_do(cylinder->node, evas_3d_node_mesh_add(cylinder->mesh),
+         evas_3d_node_orientation_angle_axis_set(-90.0, 1.0, 0.0, 0.0),
          evas_3d_node_position_set(-2.0, 3.0, 1.0));
 }
 
@@ -279,8 +286,9 @@ _fence_setup(Body_3D *fence)
       eo_add(EVAS_3D_NODE_CLASS, evas,
                     evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
    eo_do(fence->node, evas_3d_node_mesh_add(fence->mesh),
-         evas_3d_node_scale_set(7.0, 3.0, 7.0),
-         evas_3d_node_position_set(0.0, 0.5, -5.0));
+          evas_3d_node_orientation_angle_axis_set(-90.0, 1.0, 0.0, 0.0),
+          evas_3d_node_scale_set(10.0, 10.0, 5.0),
+          evas_3d_node_position_set(0.0, -1.0, -2.0));
 }
 
 static void
@@ -311,7 +319,7 @@ _box_setup(Body_3D *box)
    box->node = eo_add(EVAS_3D_NODE_CLASS, evas,
                       evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
    eo_do(box->node, evas_3d_node_mesh_add(box->mesh),
-         evas_3d_node_position_set(5.0, 0.0, -3.0));
+         evas_3d_node_position_set(3.0, 0.0, -3.0));
 }
 
 static void