evas: Evas_3D - add creation of folder for saving and usage of PACKAGE_DATA_DIR to...
authorBogdan Devichev <b.devichev@samsung.com>
Fri, 20 Feb 2015 11:02:08 +0000 (12:02 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 20 Feb 2015 11:19:30 +0000 (12:19 +0100)
Reviewers: cedric, Hermet, raster

Subscribers: cedric

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
14 files changed:
src/examples/evas/Makefile.am
src/examples/evas/evas-3d-aabb.c
src/examples/evas/evas-3d-colorpick.c
src/examples/evas/evas-3d-common.h
src/examples/evas/evas-3d-cube2.c
src/examples/evas/evas-3d-eet.c
src/examples/evas/evas-3d-frustum.c
src/examples/evas/evas-3d-md2.c
src/examples/evas/evas-3d-mmap-set.c
src/examples/evas/evas-3d-moon-space.c
src/examples/evas/evas-3d-obj.c
src/examples/evas/evas-3d-pick.c
src/examples/evas/evas-3d-ply.c
src/examples/evas/evas-3d-shadows.c

index b6700a1fb6b5cbbdc4b462b377ebef00e3646da7..9cb42842619ed38f03eeeb6888f9dc932c13c5e2 100644 (file)
@@ -32,6 +32,7 @@ ECORE_EVAS_COMMON_CPPFLAGS = \
 -I$(top_srcdir)/src/lib/eo \
 -I$(top_srcdir)/src/lib/evas \
 -I$(top_srcdir)/src/lib/ecore \
+-I$(top_srcdir)/src/lib/ecore_file \
 -I$(top_srcdir)/src/lib/ecore_input \
 -I$(top_srcdir)/src/lib/ecore_evas \
 -I$(top_builddir)/src/lib/efl \
@@ -39,6 +40,7 @@ ECORE_EVAS_COMMON_CPPFLAGS = \
 -I$(top_builddir)/src/lib/eo \
 -I$(top_builddir)/src/lib/evas \
 -I$(top_builddir)/src/lib/ecore \
+-I$(top_builddir)/src/lib/ecore_file \
 -I$(top_srcdir)/src/lib/ecore_input \
 -I$(top_builddir)/src/lib/ecore_evas \
 -DPACKAGE_EXAMPLES_DIR=\".\" \
@@ -49,6 +51,7 @@ $(top_builddir)/src/lib/efl/libefl.la \
 $(top_builddir)/src/lib/eina/libeina.la \
 $(top_builddir)/src/lib/eo/libeo.la \
 $(top_builddir)/src/lib/ecore/libecore.la \
+$(top_builddir)/src/lib/ecore_file/libecore_file.la \
 $(top_builddir)/src/lib/ecore_input/libecore_input.la \
 $(top_builddir)/src/lib/ecore_evas/libecore_evas.la \
 $(top_builddir)/src/lib/evas/libevas.la \
index 722796c1b349d98987fdcdc057212421054a7682..ef3e0793f7cf8970474f8dd3e1f52a4fe05eb0e0 100644 (file)
@@ -6,6 +6,12 @@
  * Compile with "gcc -o evas-3d-aabb evas-3d-aabb.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`"
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -18,6 +24,9 @@
 #define  WIDTH 400
 #define  HEIGHT 400
 
+static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/sonic.md2";
+static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/sonic.png";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Eo *background = NULL;
@@ -228,13 +237,13 @@ main(void)
    material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
 
    eo_do(mesh,
-         efl_file_set(EVAS_3D_MODEL_FOLDER"sonic.md2", NULL),
+         efl_file_set(model_path, NULL),
          evas_3d_mesh_frame_material_set(0, material),
          evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
 
    texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
    eo_do(texture,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"sonic.png", NULL),
+         evas_3d_texture_file_set(image_path, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
                                     EVAS_3D_TEXTURE_FILTER_NEAREST),
          evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
index 2dce99977c2a18a620fded720ba2f5a9ad75ea3a..6ca3376dbe55ee3f5259bd0468ca99116e10615b 100644 (file)
  */
 //TODO new resources
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
 #define ANIMATION_COUNT 3
 #define MAX_PATH 128
 
+static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/M15.obj";
+static const char *image1_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/M15.png";
+static const char *image2_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/M15_1.png";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Evas_Object *image = NULL, *bg = NULL;
@@ -444,9 +454,9 @@ int main(int argc, char **argv)
 
    if (!row) row = 2;
    if (!col) col = 5;
-   if (!model) model = EVAS_3D_MODEL_FOLDER"M15.obj";
-   if (!texture1) texture1 = EVAS_3D_IMAGE_FOLDER"M15.png";
-   if (!texture2) texture2 = EVAS_3D_IMAGE_FOLDER"M15_1.png";
+   if (!model) model = (char *)model_path;
+   if (!texture1) texture1 = (char *)image1_path;
+   if (!texture2) texture2 = (char *)image2_path;
 
    fprintf(stdout, "row - %d, col - %d, model - %s, texture1 - %s, texture2 - %s\n",
            row, col, model, texture1, texture2);
index 065b544c724d2b92fbf6bdd0d73cec6ee729d78b..4304b3d7f78b94a63f14f390076d8231f9ad1ba4 100644 (file)
@@ -1,3 +1,3 @@
-#define EVAS_3D_IMAGE_FOLDER "resources/images/"
-#define EVAS_3D_MODEL_FOLDER "resources/models/"
-#define EVAS_3D_SAVED_FILES "saved_files/"
+#define EVAS_3D_IMAGE_FOLDER "/resources/images"
+#define EVAS_3D_MODEL_FOLDER "/resources/models"
+#define EVAS_3D_SAVED_FILES "/saved_files"
index 38a2d4e25ab930efb7135bc58190c51785f6a6c0..30095209093aced37ed50a23e0628939ac2541ff 100644 (file)
@@ -1,3 +1,9 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -10,6 +16,8 @@
 #define  WIDTH          400
 #define  HEIGHT         400
 
+static const char *normal_map_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/normal_lego.png";
+
 typedef struct _Scene_Data
 {
    Eo *scene;
@@ -231,7 +239,7 @@ _mesh_setup(Scene_Data *data)
          evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA,
                                   EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]));
    eo_do(data->texture_normal,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"normal_lego.png", NULL));
+         evas_3d_texture_file_set(normal_map_path, NULL));
 
    eo_do(data->material0,
          evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, data->texture0));
index b6966bb410c97361debde124b913b0e02bd2eba8..c7139a89059803b26e7f146c969ef640bca9e38a 100644 (file)
@@ -9,10 +9,16 @@
 * Show it in right side.
 *
 * @verbatim
-* gcc -o evas-3d-eet evas-3d-eet.c `pkg-config --libs --cflags efl eina evas ecore ecore-evas eo`
+* gcc -o evas-3d-eet evas-3d-eet.c `pkg-config --libs --cflags efl eina evas ecore ecore-evas ecore-file eo`
 * @endverbatim
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -25,6 +31,9 @@
 #define  WIDTH 1024
 #define  HEIGHT 1024
 
+static const char *input_model_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/sonic.md2";
+static const char *output_model_path = PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES "/saved_Sonic_EET.eet";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Eo *background = NULL;
@@ -152,7 +161,7 @@ main(void)
    material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
 
    eo_do(mesh,
-         efl_file_set(EVAS_3D_MODEL_FOLDER"sonic.md2", NULL),
+         efl_file_set(input_model_path, NULL),
          evas_3d_mesh_frame_material_set(0, material),
          evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
 
@@ -169,10 +178,14 @@ main(void)
                                     0.50, 0.00, 0.50, 0.30),
          evas_3d_material_shininess_set(50.0));
 
-   eo_do(mesh, efl_file_save(EVAS_3D_SAVED_FILES"saved_Sonic_EET.eet", NULL, NULL));
+   if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES))
+     fprintf(stderr, "Failed to create folder %s\n\n",
+             PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES);
+
+   eo_do(mesh, efl_file_save(output_model_path, NULL, NULL));
 
    eo_do(mesh2,
-         efl_file_set(EVAS_3D_SAVED_FILES"saved_Sonic_EET.eet", NULL),
+         efl_file_set(output_model_path, NULL),
          evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
 
    mesh_node = eo_add(EVAS_3D_NODE_CLASS, evas,
index 75c936afa5fc55e0fc10ab2d6f05c88ae387760a..90b8a6a00601d27adb2d06acadb17251fc3d1a61 100644 (file)
  * Compile with "gcc -o evas-3d-frustum evas-3d-frustum.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo` -lm"
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -24,6 +30,9 @@
 #define  WIDTH          800
 #define  HEIGHT         600
 
+static const char *image_eagle_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/eagle.png";
+static const char *eagle_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/eagle.md2";
+
 typedef struct _Scene_Data
 {
    Eo *root_node;
@@ -453,7 +462,7 @@ _mesh_setup_model(Scene_Data *data)
    data->texture_model = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
 
    eo_do(data->texture_model,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"eagle.png", NULL),
+         evas_3d_texture_file_set(image_eagle_path, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST),
          evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT));
 
@@ -470,7 +479,7 @@ _mesh_setup_model(Scene_Data *data)
          evas_3d_material_shininess_set(100.0));
 
    eo_do(data->mesh_model,
-         efl_file_set(EVAS_3D_MODEL_FOLDER"eagle.md2", NULL),
+         efl_file_set(eagle_path, NULL),
          evas_3d_mesh_frame_material_set(0, data->material_model),
          evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_DIFFUSE));
 }
index 76546cd921ac4656d60589bafb7841e834e1e227..5a9309e148fea4ebf4b4fe922c460f6a89d29334 100644 (file)
@@ -1,3 +1,9 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -10,6 +16,9 @@
 #define  WIDTH 400
 #define  HEIGHT 400
 
+static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/sonic.md2";
+static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/sonic.png";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Eo *background = NULL;
@@ -121,13 +130,13 @@ main(void)
    material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
 
    eo_do(mesh,
-         efl_file_set(EVAS_3D_MODEL_FOLDER"sonic.md2", NULL),
+         efl_file_set(model_path, NULL),
          evas_3d_mesh_frame_material_set(0, material),
          evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
 
    texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
    eo_do(texture,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"sonic.png", NULL),
+         evas_3d_texture_file_set(image_path, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
                                     EVAS_3D_TEXTURE_FILTER_NEAREST),
          evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
index 501046d5d044639fca0f586e03b5e96901186728..923654ef2c7530cd37a45c1c8a6a3ed8611b45e2 100644 (file)
 * @endverbatim
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -25,8 +31,8 @@
 #define  HEIGHT 1000
 
 #define LOAD_AND_ADD_MESH(extention, number)                                          \
-   extention##_file =                                                                 \
-      eina_file_open(EVAS_3D_MODEL_FOLDER"mesh_for_mmap."#extention, 0);              \
+   snprintf(buffer, PATH_MAX, "%s%s", template_path, #extention);                     \
+   extention##_file = eina_file_open(buffer , 0);                                     \
    mesh_##extention = eo_add(EVAS_3D_MESH_CLASS, evas);                               \
    eo_do(mesh_##extention,                                                            \
          evas_3d_mesh_mmap_set(extention##_file, NULL),                               \
@@ -48,6 +54,8 @@
                                                  initial_node_data[number * 10 + 9]));\
    ecore_timer_add(0.01, _animate_##extention, node_##extention);
 
+static const char *template_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/mesh_for_mmap.";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Eo *background = NULL;
@@ -160,6 +168,7 @@ _on_canvas_resize(Ecore_Evas *ee)
 int
 main(void)
 {
+   char buffer[PATH_MAX];
    Eina_File *obj_file, *ply_file, *eet_file, *md2_file;
 
    //Unless Evas 3D supports Software renderer, we set gl backened forcely.
index 87d8bb11e1aa4d7b6faf7dbdfc21c144c38453d3..cbe4a925697962cc6a5d4021a90a788e9cb9cb2e 100644 (file)
 * gcc -o evas-3d-moon-space evas-3d-moon-space.c -g `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
 #define  WIDTH          1024
 #define  HEIGHT         1024
 
+static const char *bg_image = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/bg_space.jpg";
+static const char *moon_image = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/moon.png";
+static const char *earth_image = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/EarthDiffuse.png";
+
 typedef struct _Scene_Data
 {
    Eo   *texture_diffuse_moon;
@@ -448,7 +458,7 @@ _mesh_setup(Scene_Data *data)
 
    /* Setup material and texture for planet. */
    eo_do(data->texture_diffuse_planet,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"EarthDiffuse.png", NULL),
+         evas_3d_texture_file_set(earth_image, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR));
 
    eo_do(data->material_planet,
@@ -463,7 +473,7 @@ _mesh_setup(Scene_Data *data)
 
    /* Setup material and texture for moon. */
    eo_do(data->texture_diffuse_moon,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"moon.png", NULL),
+         evas_3d_texture_file_set(moon_image, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR));
 
    eo_do(data->material_moon,
@@ -733,7 +743,7 @@ main(void)
 
    /* Add evas objects. */
    background = evas_object_image_filled_add(evas);
-   evas_object_image_file_set(background, EVAS_3D_IMAGE_FOLDER"bg_space.jpg", NULL),
+   evas_object_image_file_set(background, bg_image, NULL),
    evas_object_resize(background, WIDTH, HEIGHT),
    evas_object_show(background);
 
index b0203d3dd31f1178518e81aa8c6232802cea537c..bccbea22ea29f6da66a1aa7bbbc38feb97036040 100644 (file)
@@ -9,10 +9,16 @@
 * If material was not set it will be not saved.
 *
 * @verbatim
-* gcc -o evas-3d-obj evas-3d-obj.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`
+* gcc -o evas-3d-obj evas-3d-obj.c `pkg-config --libs --cflags efl evas ecore ecore-evas ecore-file eo`
 * @endverbatim
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
 #define GRID_SIZE 6
 #define NUMBER_OF_MESHES 8
 
-#define ADD_OBJ_MESH(path, Y, Z, num, shade_mode, name_of_material)                 \
-   mesh[num] = eo_add(EVAS_3D_MESH_CLASS, evas);                                    \
-   eo_do(mesh[num],                                                                 \
-         efl_file_set(path".obj", NULL),                                            \
-         evas_3d_mesh_frame_material_set(0, name_of_material),                      \
-         evas_3d_mesh_shade_mode_set(shade_mode));                                  \
-   mesh_node[num] = 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[num]));                                  \
-   eo_do(mesh_node[num],                                                            \
-         evas_3d_node_mesh_add(mesh[num]),                                          \
-         evas_3d_node_position_set(0, Y, Z));                                       \
-
-#define ADD_OBJ_MESH_AND_SAVED_COPY(path, Y, Z, num, shade_mode, name_of_material)  \
-   ADD_OBJ_MESH(EVAS_3D_MODEL_FOLDER"sweet_"#path,                                  \
-                Y, Z, num, shade_mode, name_of_material)                            \
-   eo_do(mesh[num], efl_file_save(EVAS_3D_SAVED_FILES"saved_"#path".obj",           \
-                                  NULL, NULL));                                     \
-   ADD_OBJ_MESH(EVAS_3D_SAVED_FILES"saved_"#path,                                   \
-                Y + COPY_OFFSET, Z, num + 4, shade_mode, name_of_material)
+#define ADD_OBJ_MESH(path, Y, Z, num, shade_mode, name_of_material)               \
+   mesh[num] = eo_add(EVAS_3D_MESH_CLASS, evas);                                  \
+   snprintf(full_file_path, PATH_MAX, "%s%s", path, ".obj");                      \
+   eo_do(mesh[num],                                                               \
+         efl_file_set(full_file_path, NULL),                                      \
+         evas_3d_mesh_frame_material_set(0, name_of_material),                    \
+         evas_3d_mesh_shade_mode_set(shade_mode));                                \
+   mesh_node[num] = 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[num]));                                \
+   eo_do(mesh_node[num],                                                          \
+         evas_3d_node_mesh_add(mesh[num]),                                        \
+         evas_3d_node_position_set(0, Y, Z));                                     \
+
+#define ADD_OBJ_MESH_AND_SAVED_COPY(path, Y, Z, num, shade_mode, name_of_material)\
+   snprintf(buffer, PATH_MAX, "%s%s", input_template, #path);                     \
+   ADD_OBJ_MESH(buffer, Y, Z, num, shade_mode, name_of_material)                  \
+   snprintf(buffer, PATH_MAX, "%s%s%s", output_template, #path, ".obj");          \
+   eo_do(mesh[num], efl_file_save(buffer, NULL, NULL));                           \
+   snprintf(buffer, PATH_MAX, "%s%s", output_template, #path);                    \
+   ADD_OBJ_MESH(buffer, Y + COPY_OFFSET, Z, num + 4, shade_mode, name_of_material)
 
 #define ADD_TEXTURE(name, path)                                       \
    name = eo_add(EVAS_3D_TEXTURE_CLASS, evas);                        \
                                     COL_BLUE, 0.5),                        \
          evas_3d_material_shininess_set(100.0));
 
+static const char *texture_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/sweet_home_reversed.png";
+static const char *output_template = PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES "/saved_";
+static const char *input_template = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/sweet_";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Eo *background = NULL;
@@ -136,6 +147,7 @@ int
 main(void)
 {
    int i;
+   char buffer[PATH_MAX], full_file_path[PATH_MAX];
    //Unless Evas 3D supports Software renderer, we set gl backened forcely.
    setenv("ECORE_EVAS_ENGINE", "opengl_x11", 1);
 
@@ -193,7 +205,7 @@ main(void)
    eo_do(root_node,
          evas_3d_node_member_add(light_node));
 
-   ADD_TEXTURE(texture, EVAS_3D_IMAGE_FOLDER"sweet_home_reversed.png")
+   ADD_TEXTURE(texture, texture_path)
 
    ADD_MATERIAL(material)
 
@@ -201,6 +213,10 @@ main(void)
    eo_do(material_with_tex,
          evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, texture));
 
+   if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES))
+     fprintf(stderr, "Failed to create folder %s\n\n",
+             PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES);
+
    ADD_OBJ_MESH_AND_SAVED_COPY(home, -GRID_SIZE, -GRID_SIZE, 0,
                                EVAS_3D_SHADE_MODE_PHONG, material_with_tex)
    ADD_OBJ_MESH_AND_SAVED_COPY(home_without_normals, -GRID_SIZE, GRID_SIZE, 1,
index f983146a368343b6f13a3194603473e958ae2e46..3d7c235e94794cbd1e641746228ddbe35ce6b064 100644 (file)
@@ -1,3 +1,9 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -11,6 +17,8 @@
 #define  WIDTH          400
 #define  HEIGHT         400
 
+static const char *earth_image = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/EarthDiffuse.png";
+
 typedef struct _vec4
 {
     float   x;
@@ -344,7 +352,7 @@ main(void)
 
    texture_diffuse = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
    eo_do(texture_diffuse,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"EarthDiffuse.png", NULL),
+         evas_3d_texture_file_set(earth_image, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR,
                                     EVAS_3D_TEXTURE_FILTER_LINEAR));
    eo_do(material,
index d6102f94add8f674f2c5d82857ad8ffce819320f..8e010fc99886645ce09ca0fbe3772b32c003a918 100644 (file)
@@ -7,11 +7,17 @@
 * and geometry to "saved_man_all_with_mods.ply", "saved_man_only_geometry.ply" and "saved_man_without_UVs.ply".
 *
 * @verbatim
-* gcc -o evas-3d-ply evas-3d-ply.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`
+* gcc -o evas-3d-ply evas-3d-ply.c `pkg-config --libs --cflags efl evas ecore ecore-evas ecore-file eo`
 * @endverbatim
 */
 //TODO new resources
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
 
 #define NUMBER_OF_MESHES 32
 
+static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/normal_lego.png";
+static const char *input_template = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/";
+static const char *output_template = PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES "/";
+static const char *file_name[8] = {"Normal_UVs_Colors.ply",
+                                   "Normal_UVs_NoColors.ply",
+                                   "Normal_NoUVs_Colors.ply",
+                                   "Normal_NoUVs_NoColors.ply",
+                                   "NoNormal_UVs_Colors.ply",
+                                   "NoNormal_UVs_NoColors.ply",
+                                   "NoNormal_NoUVs_Colors.ply",
+                                   "NoNormal_NoUVs_NoColors.ply"};
+
 int draw_mode[2] = {EVAS_3D_SHADE_MODE_PHONG, EVAS_3D_SHADE_MODE_VERTEX_COLOR};
 
 Ecore_Evas *ecore_evas = NULL;
@@ -47,15 +65,6 @@ Eo *texture = NULL;
 Eo *light = NULL;
 Ecore_Animator *anim = NULL;
 
-char *file_name[8] = {"Normal_UVs_Colors.ply",
-                      "Normal_UVs_NoColors.ply",
-                      "Normal_NoUVs_Colors.ply",
-                      "Normal_NoUVs_NoColors.ply",
-                      "NoNormal_UVs_Colors.ply",
-                      "NoNormal_UVs_NoColors.ply",
-                      "NoNormal_NoUVs_Colors.ply",
-                      "NoNormal_NoUVs_NoColors.ply"};
-
 static float angle = 0;
 
 static Eina_Bool
@@ -157,7 +166,7 @@ main(void)
    material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
    texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
    eo_do(texture,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"normal_lego.png", NULL),
+         evas_3d_texture_file_set(image_path, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
                                     EVAS_3D_TEXTURE_FILTER_NEAREST),
          evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
@@ -176,18 +185,22 @@ main(void)
                                     1.0, 1.0, 1.0, 1.0),
          evas_3d_material_shininess_set(50.0));
 
+   if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES))
+     fprintf(stderr, "Failed to create folder %s\n\n",
+             PACKAGE_EXAMPLES_DIR EVAS_3D_SAVED_FILES);
+
    /* Add the meshes. */
    for (i = 0; i < NUMBER_OF_MESHES; i++)
      {
         mesh[i] = eo_add(EVAS_3D_MESH_CLASS, evas);
 
-        snprintf(buffer, PATH_MAX, "%s%s", EVAS_3D_MODEL_FOLDER, file_name[i % 8]);
+        snprintf(buffer, PATH_MAX, "%s%s", input_template, file_name[i % 8]);
         eo_do(mesh[i],
               efl_file_set(buffer, NULL),
               evas_3d_mesh_frame_material_set(0, material),
               evas_3d_mesh_shade_mode_set(draw_mode[(i % 16) / 8]));
 
-        snprintf(buffer, PATH_MAX, "%s%s", EVAS_3D_SAVED_FILES, file_name[i % 8]);
+        snprintf(buffer, PATH_MAX, "%s%s", output_template, file_name[i % 8]);
         eo_do(mesh[i], efl_file_save(buffer, NULL, NULL));
 
         if (i > 15)
index df5184bbfa2a3c1fdea2ff059c4b9b82b5828a0b..86903f62ec57eecffd07c6598058e0440681f197 100644 (file)
@@ -8,6 +8,12 @@
  * Compile with gcc -o evas-3d-shadows evas-3d-shadows.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo eina` -lm
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
 #define EFL_EO_API_SUPPORT
 #define EFL_BETA_API_SUPPORT
 
@@ -29,6 +35,9 @@
 #define DIFFUSE_LIGHT 1.0, 1.0, 1.0
 #define SPECULAR_LIGHT 1.0, 1.0, 1.0
 
+static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_3D_MODEL_FOLDER "/sonic.md2";
+static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_3D_IMAGE_FOLDER "/sonic.png";
+
 Ecore_Evas *ecore_evas = NULL;
 Evas *evas = NULL;
 Eo *background = NULL;
@@ -237,7 +246,7 @@ _model_setup(Body_3D *model)
 {
    Eo *texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
    eo_do(texture,
-         evas_3d_texture_file_set(EVAS_3D_IMAGE_FOLDER"sonic.png", NULL),
+         evas_3d_texture_file_set(image_path, NULL),
          evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST,
                                     EVAS_3D_TEXTURE_FILTER_NEAREST),
          evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT,
@@ -256,7 +265,7 @@ _model_setup(Body_3D *model)
    model->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
 
    eo_do(model->mesh,
-         efl_file_set(EVAS_3D_MODEL_FOLDER"sonic.md2", NULL),
+         efl_file_set(model_path, NULL),
          evas_3d_mesh_frame_material_set(0, model->material),
          evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));