summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorOleksandr Shcherbina <o.shcherbina@samsung.com>2015-04-10 14:20:34 +0900
committerChunEon Park <chuneon.park@samsung.com>2015-04-10 14:20:35 +0900
commit499e546ee9a193eae2a09d1b3784142c79b04d42 (patch)
tree5090b52fdbfd156a72899011ac76f5687321c24a /src/examples
parentdbf56936dc21e861cb50f0d3b34edbd2dd37cd6a (diff)
[evas/evas_3D] Some fixes in evas-3d-shadows example
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
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/evas-3d-shadows.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/src/examples/evas/evas-3d-shadows.c b/src/examples/evas/evas-3d-shadows.c
index 701a474..5177043 100644
--- a/src/examples/evas/evas-3d-shadows.c
+++ b/src/examples/evas/evas-3d-shadows.c
@@ -42,7 +42,7 @@ static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_MODEL_FOLDER "/sonic.m
42static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png"; 42static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png";
43static const char *b_image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/billboard.png"; 43static const char *b_image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/billboard.png";
44static const vec2 tex_scale = {1, 1}; 44static const vec2 tex_scale = {1, 1};
45static const vec2 fence_tex_scale = {80, 6}; 45static const vec2 fence_tex_scale = {160, 12};
46 46
47Ecore_Evas *ecore_evas = NULL; 47Ecore_Evas *ecore_evas = NULL;
48Evas *evas = NULL; 48Evas *evas = NULL;
@@ -50,11 +50,42 @@ Eo *background = NULL;
50Eo *image = NULL; 50Eo *image = NULL;
51Evas_3D_Node *choosed_node = NULL; 51Evas_3D_Node *choosed_node = NULL;
52 52
53typedef struct _Body_3D
54{
55 Eo *material;
56 Eo *mesh;
57 Eo *node;
58 Eo *texture;
59} Body_3D;
60
61typedef struct _Scene_Data
62{
63 Eo *scene;
64 Eo *root_node;
65 Eo *camera_node;
66 Eo *camera;
67 Eo *light_node;
68 Eo *light;
69 Eo *mediator;
70
71 Body_3D sphere;
72 Body_3D cube;
73 Body_3D square;
74 Body_3D cylinder;
75 Body_3D model;
76 Body_3D cone;
77 Body_3D fence;
78 Body_3D billboard;
79
80 Eina_Bool init;
81} Scene_Data;
82
53Eina_Bool 83Eina_Bool
54_cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) 84_cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
55{ 85{
56 Eina_List *meshes = NULL, *l; 86 Eina_List *meshes = NULL, *l;
57 Evas_3D_Mesh *m; 87 Evas_3D_Mesh *m;
88 Evas_3D_Node *billboard = NULL;
58 eo_do((Evas_3D_Node *)event_info, meshes = (Eina_List *)evas_3d_node_mesh_list_get()); 89 eo_do((Evas_3D_Node *)event_info, meshes = (Eina_List *)evas_3d_node_mesh_list_get());
59 EINA_LIST_FOREACH(meshes, l, m) 90 EINA_LIST_FOREACH(meshes, l, m)
60 { 91 {
@@ -62,10 +93,14 @@ _cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Descript
62 } 93 }
63 if (choosed_node != (Evas_3D_Node *)event_info) 94 if (choosed_node != (Evas_3D_Node *)event_info)
64 { 95 {
65 eo_do(choosed_node, meshes = (Eina_List *)evas_3d_node_mesh_list_get()); 96 eo_do(choosed_node, billboard = evas_3d_node_billboard_target_get());
66 EINA_LIST_FOREACH(meshes, l, m) 97 if (!billboard)
67 { 98 {
68 eo_do(m, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG)); 99 eo_do(choosed_node, meshes = (Eina_List *)evas_3d_node_mesh_list_get());
100 EINA_LIST_FOREACH(meshes, l, m)
101 {
102 eo_do(m, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
103 }
69 } 104 }
70 choosed_node = (Evas_3D_Node *)event_info; 105 choosed_node = (Evas_3D_Node *)event_info;
71 } 106 }
@@ -87,36 +122,6 @@ _cb_collision(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Descri
87 return EINA_TRUE; 122 return EINA_TRUE;
88} 123}
89 124
90typedef struct _Body_3D
91{
92 Eo *material;
93 Eo *mesh;
94 Eo *node;
95 Eo *texture;
96} Body_3D;
97
98typedef struct _Scene_Data
99{
100 Eo *scene;
101 Eo *root_node;
102 Eo *camera_node;
103 Eo *camera;
104 Eo *light_node;
105 Eo *light;
106 Eo *mediator;
107
108 Body_3D sphere;
109 Body_3D cube;
110 Body_3D square;
111 Body_3D cylinder;
112 Body_3D model;
113 Body_3D cone;
114 Body_3D fence;
115 Body_3D billboard;
116
117 Eina_Bool init;
118} Scene_Data;
119
120static void 125static void
121_show_help() 126_show_help()
122{ 127{
@@ -218,7 +223,8 @@ _cone_setup(Body_3D *cone)
218 eo_add(EVAS_3D_NODE_CLASS, evas, 223 eo_add(EVAS_3D_NODE_CLASS, evas,
219 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); 224 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
220 eo_do(cone->node, evas_3d_node_mesh_add(cone->mesh), 225 eo_do(cone->node, evas_3d_node_mesh_add(cone->mesh),
221 evas_3d_node_position_set(-5.0, -1.0, -3.0)); 226 evas_3d_node_orientation_angle_axis_set(-90.0, 1.0, 0.0, 0.0),
227 evas_3d_node_position_set(-4.0, 0.0, -3.0));
222} 228}
223 229
224static void 230static void
@@ -232,6 +238,7 @@ _cylinder_setup(Body_3D *cylinder)
232 eo_add(EVAS_3D_NODE_CLASS, evas, 238 eo_add(EVAS_3D_NODE_CLASS, evas,
233 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); 239 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
234 eo_do(cylinder->node, evas_3d_node_mesh_add(cylinder->mesh), 240 eo_do(cylinder->node, evas_3d_node_mesh_add(cylinder->mesh),
241 evas_3d_node_orientation_angle_axis_set(-90.0, 1.0, 0.0, 0.0),
235 evas_3d_node_position_set(-2.0, 3.0, 1.0)); 242 evas_3d_node_position_set(-2.0, 3.0, 1.0));
236} 243}
237 244
@@ -279,8 +286,9 @@ _fence_setup(Body_3D *fence)
279 eo_add(EVAS_3D_NODE_CLASS, evas, 286 eo_add(EVAS_3D_NODE_CLASS, evas,
280 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); 287 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
281 eo_do(fence->node, evas_3d_node_mesh_add(fence->mesh), 288 eo_do(fence->node, evas_3d_node_mesh_add(fence->mesh),
282 evas_3d_node_scale_set(7.0, 3.0, 7.0), 289 evas_3d_node_orientation_angle_axis_set(-90.0, 1.0, 0.0, 0.0),
283 evas_3d_node_position_set(0.0, 0.5, -5.0)); 290 evas_3d_node_scale_set(10.0, 10.0, 5.0),
291 evas_3d_node_position_set(0.0, -1.0, -2.0));
284} 292}
285 293
286static void 294static void
@@ -311,7 +319,7 @@ _box_setup(Body_3D *box)
311 box->node = eo_add(EVAS_3D_NODE_CLASS, evas, 319 box->node = eo_add(EVAS_3D_NODE_CLASS, evas,
312 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); 320 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
313 eo_do(box->node, evas_3d_node_mesh_add(box->mesh), 321 eo_do(box->node, evas_3d_node_mesh_add(box->mesh),
314 evas_3d_node_position_set(5.0, 0.0, -3.0)); 322 evas_3d_node_position_set(3.0, 0.0, -3.0));
315} 323}
316 324
317static void 325static void