evas: Evas_3D - add creation of folder for saving and usage of PACKAGE_DATA_DIR to every example of Evas_3D.
Reviewers: cedric, Hermet, raster Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2003 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
2ae90fd1ff
commit
175c8cbd63
|
@ -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 \
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
*/
|
||||
//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
|
||||
|
||||
|
@ -27,6 +33,10 @@
|
|||
#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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
* 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));
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
* @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.
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
* 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
|
||||
|
||||
|
@ -30,6 +36,10 @@
|
|||
#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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -37,27 +43,28 @@
|
|||
#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(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) \
|
||||
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_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); \
|
||||
|
@ -83,6 +90,10 @@
|
|||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -26,6 +32,18 @@
|
|||
|
||||
#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)
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue