summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorDmytro Dadyka <d.dadyka@samsung.com>2015-03-18 14:40:05 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-18 15:22:20 +0100
commit31651a88424744054c41b3544937991488f032ef (patch)
tree4391532eea416054aa65f0f021ffcfedd6c979de /src/examples
parent0f86d692e701397d3813015c4dc7118305f7c049 (diff)
evas: Evas_3D - add alpha testing.
Reviewers: Hermet, cedric Reviewed By: cedric Subscribers: Ievgen, cedric Differential Revision: https://phab.enlightenment.org/D2046
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/Makefile.am2
-rw-r--r--src/examples/evas/evas-3d-shadows.c123
-rw-r--r--src/examples/evas/resources/images/grid.pngbin0 -> 45870 bytes
-rw-r--r--src/examples/evas/resources/images/grid_n.pngbin0 -> 51868 bytes
4 files changed, 89 insertions, 36 deletions
diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am
index 98a4a7f..5e27afa 100644
--- a/src/examples/evas/Makefile.am
+++ b/src/examples/evas/Makefile.am
@@ -338,6 +338,8 @@ resources/images/wood.jpg \
338resources/images/rocks.jpg \ 338resources/images/rocks.jpg \
339resources/images/four_NM_height.tga \ 339resources/images/four_NM_height.tga \
340resources/images/rocks_NM_height.tga \ 340resources/images/rocks_NM_height.tga \
341resources/images/grid.png \
342resources/images/grid_n.png \
341resources/models/mesh_for_mmap.eet \ 343resources/models/mesh_for_mmap.eet \
342resources/models/mesh_for_mmap.md2 \ 344resources/models/mesh_for_mmap.md2 \
343resources/models/mesh_for_mmap.obj \ 345resources/models/mesh_for_mmap.obj \
diff --git a/src/examples/evas/evas-3d-shadows.c b/src/examples/evas/evas-3d-shadows.c
index f58e8b8..d53f435 100644
--- a/src/examples/evas/evas-3d-shadows.c
+++ b/src/examples/evas/evas-3d-shadows.c
@@ -6,7 +6,7 @@
6 * @see evas_3d_object_callback_register 6 * @see evas_3d_object_callback_register
7 * 7 *
8 * @verbatim 8 * @verbatim
9 * gcc -o gcc -o evas-3d-shadows evas-3d-shadows.c evas-3d-primitives.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo eina` -lm 9 * gcc -o evas-3d-shadows evas-3d-shadows.c evas-3d-primitives.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo eina` -lm
10 * @endverbatim 10 * @endverbatim
11 */ 11 */
12 12
@@ -37,8 +37,9 @@
37#define SPECULAR_LIGHT 1.0, 1.0, 1.0 37#define SPECULAR_LIGHT 1.0, 1.0, 1.0
38 38
39static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_MODEL_FOLDER "/sonic.md2"; 39static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_MODEL_FOLDER "/sonic.md2";
40static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png"; 40
41static const vec2 tex_scale = {1, 1}; 41static const vec2 tex_scale = {1, 1};
42static const vec2 fence_tex_scale = {80, 6};
42 43
43Ecore_Evas *ecore_evas = NULL; 44Ecore_Evas *ecore_evas = NULL;
44Evas *evas = NULL; 45Evas *evas = NULL;
@@ -46,30 +47,6 @@ Eo *background = NULL;
46Eo *image = NULL; 47Eo *image = NULL;
47Evas_3D_Node *choosed_node = NULL; 48Evas_3D_Node *choosed_node = NULL;
48 49
49typedef struct _Body_3D
50{
51 Eo *material;
52 Eo *mesh;
53 Eo *node;
54} Body_3D;
55
56typedef struct _Scene_Data
57{
58 Eo *scene;
59 Eo *root_node;
60 Eo *camera_node;
61 Eo *camera;
62 Eo *light_node;
63 Eo *light;
64
65 Body_3D sphere;
66 Body_3D cube;
67 Body_3D square;
68 Body_3D cylinder;
69 Body_3D model;
70 Body_3D cone;
71} Scene_Data;
72
73Eina_Bool 50Eina_Bool
74_cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) 51_cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
75{ 52{
@@ -107,6 +84,31 @@ _cb_collision(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Descri
107 return EINA_TRUE; 84 return EINA_TRUE;
108} 85}
109 86
87typedef struct _Body_3D
88{
89 Eo *material;
90 Eo *mesh;
91 Eo *node;
92} Body_3D;
93
94typedef struct _Scene_Data
95{
96 Eo *scene;
97 Eo *root_node;
98 Eo *camera_node;
99 Eo *camera;
100 Eo *light_node;
101 Eo *light;
102
103 Body_3D sphere;
104 Body_3D cube;
105 Body_3D square;
106 Body_3D cylinder;
107 Body_3D model;
108 Body_3D cone;
109 Body_3D fence;
110} Scene_Data;
111
110static void 112static void
111_show_help() 113_show_help()
112{ 114{
@@ -212,6 +214,51 @@ _cylinder_setup(Body_3D *cylinder)
212} 214}
213 215
214static void 216static void
217_fence_setup(Body_3D *fence)
218{
219
220 Eo *texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
221 eo_do(texture,
222 evas_3d_texture_file_set(PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/grid.png", NULL),
223 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
224 EVAS_3D_TEXTURE_FILTER_NEAREST),
225 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
226 EVAS_3D_WRAP_MODE_REPEAT));
227 Eo *texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
228 eo_do(texture1,
229 evas_3d_texture_file_set(PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/grid_n.png", NULL),
230 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
231 EVAS_3D_TEXTURE_FILTER_NEAREST),
232 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
233 EVAS_3D_WRAP_MODE_REPEAT));
234 fence->material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
235
236 eo_do(fence->material,
237 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, texture),
238 evas_3d_material_texture_set(EVAS_3D_MATERIAL_AMBIENT, texture),
239 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
240 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
241 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
242 evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE),
243 evas_3d_material_texture_set(EVAS_3D_MATERIAL_NORMAL, texture1),
244 evas_3d_material_shininess_set(100.0));
245 fence->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
246 evas_3d_add_cylinder_frame(fence->mesh, 0, 50, fence_tex_scale);
247
248 eo_do(fence->mesh,
249 evas_3d_mesh_frame_material_set(0, fence->material),
250 evas_3d_mesh_alpha_func_set(EVAS_3D_COMPARISON_GREATER, 0),
251 evas_3d_mesh_alpha_test_enable_set(EINA_TRUE),
252 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP));
253 fence->node =
254 eo_add(EVAS_3D_NODE_CLASS, evas,
255 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
256 eo_do(fence->node, evas_3d_node_mesh_add(fence->mesh),
257 evas_3d_node_scale_set(7.0, 3.0, 7.0),
258 evas_3d_node_position_set(0.0, 0.5, -5.0));
259}
260
261static void
215_square_setup(Body_3D *square) 262_square_setup(Body_3D *square)
216{ 263{
217 square->mesh = eo_add(EVAS_3D_MESH_CLASS, evas); 264 square->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
@@ -247,7 +294,7 @@ _model_setup(Body_3D *model)
247{ 294{
248 Eo *texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas); 295 Eo *texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
249 eo_do(texture, 296 eo_do(texture,
250 evas_3d_texture_file_set(image_path, NULL), 297 evas_3d_texture_file_set(PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png", NULL),
251 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, 298 evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
252 EVAS_3D_TEXTURE_FILTER_NEAREST), 299 EVAS_3D_TEXTURE_FILTER_NEAREST),
253 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, 300 evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
@@ -307,7 +354,8 @@ _light_setup(Scene_Data *data)
307 evas_3d_light_ambient_set(AMBIENT_LIGHT, 1.0), 354 evas_3d_light_ambient_set(AMBIENT_LIGHT, 1.0),
308 evas_3d_light_diffuse_set(DIFFUSE_LIGHT, 1.0), 355 evas_3d_light_diffuse_set(DIFFUSE_LIGHT, 1.0),
309 evas_3d_light_specular_set(SPECULAR_LIGHT, 1.0), 356 evas_3d_light_specular_set(SPECULAR_LIGHT, 1.0),
310 evas_3d_light_projection_perspective_set(45.0, 1.0, 2.0, 1000.0)); 357 evas_3d_light_spot_cutoff_set(20),
358 evas_3d_light_projection_perspective_set(40.0, 1.0, 2.0, 1000.0));
311 359
312 data->light_node = 360 data->light_node =
313 eo_add(EVAS_3D_NODE_CLASS, evas, 361 eo_add(EVAS_3D_NODE_CLASS, evas,
@@ -315,7 +363,7 @@ _light_setup(Scene_Data *data)
315 eo_do(data->light_node, 363 eo_do(data->light_node,
316 evas_3d_node_light_set(data->light), 364 evas_3d_node_light_set(data->light),
317 evas_3d_node_position_set(50.0, 50.0, 20.0), 365 evas_3d_node_position_set(50.0, 50.0, 20.0),
318 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 20.0, 366 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 15.0, 0.0, -5.0,
319 EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0)); 367 EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0));
320 eo_do(data->root_node, evas_3d_node_member_add(data->light_node)); 368 eo_do(data->root_node, evas_3d_node_member_add(data->light_node));
321} 369}
@@ -343,13 +391,16 @@ _scene_setup(Scene_Data *data)
343 _square_setup(&data->square); 391 _square_setup(&data->square);
344 _model_setup(&data->model); 392 _model_setup(&data->model);
345 _cone_setup(&data->cone); 393 _cone_setup(&data->cone);
346 394 _fence_setup(&data->fence);
347 eo_do(data->root_node, evas_3d_node_member_add(data->sphere.node)); 395
348 eo_do(data->root_node, evas_3d_node_member_add(data->cube.node)); 396 eo_do(data->root_node,
349 eo_do(data->root_node, evas_3d_node_member_add(data->cylinder.node)); 397 evas_3d_node_member_add(data->sphere.node),
350 eo_do(data->root_node, evas_3d_node_member_add(data->square.node)); 398 evas_3d_node_member_add(data->cube.node),
351 eo_do(data->root_node, evas_3d_node_member_add(data->model.node)); 399 evas_3d_node_member_add(data->cylinder.node),
352 eo_do(data->root_node, evas_3d_node_member_add(data->cone.node)); 400 evas_3d_node_member_add(data->square.node),
401 evas_3d_node_member_add(data->model.node),
402 evas_3d_node_member_add(data->cone.node),
403 evas_3d_node_member_add(data->fence.node));
353 404
354 eo_do(data->scene, 405 eo_do(data->scene,
355 evas_3d_scene_root_node_set(data->root_node), 406 evas_3d_scene_root_node_set(data->root_node),
diff --git a/src/examples/evas/resources/images/grid.png b/src/examples/evas/resources/images/grid.png
new file mode 100644
index 0000000..60d1036
--- /dev/null
+++ b/src/examples/evas/resources/images/grid.png
Binary files differ
diff --git a/src/examples/evas/resources/images/grid_n.png b/src/examples/evas/resources/images/grid_n.png
new file mode 100644
index 0000000..7b9236e
--- /dev/null
+++ b/src/examples/evas/resources/images/grid_n.png
Binary files differ