evas: Evas_3D - callbacks for Evas 3D.
Summary: Add class and type Evas_3D_Callback like wrapper under smart object Incapsulate Evas_3D_Callback in Evas_3D_Object Add virtual function register and unregister in Evas_3D_Object Add function evas_3d_callback_call Add callbacks clicked and collision for Evas_3D_Node @feature Reviewers: raster, Hermet, cedric Reviewed By: cedric Subscribers: artem.popov, cedric Differential Revision: https://phab.enlightenment.org/D1914 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
b9b5ced501
commit
d28b82be45
|
@ -188,7 +188,7 @@ lib/evas/canvas/evas_3d_camera.c \
|
|||
lib/evas/canvas/evas_3d_light.c \
|
||||
lib/evas/canvas/evas_3d_mesh.c \
|
||||
lib/evas/canvas/evas_3d_texture.c \
|
||||
lib/evas/canvas/evas_3d_material.c
|
||||
lib/evas/canvas/evas_3d_material.c
|
||||
|
||||
# Model savers/loaders (will be replaced to modules in next commits)
|
||||
lib_evas_libevas_la_SOURCES += \
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* This example illustrating use of shadows in the scene.
|
||||
*
|
||||
/*
|
||||
* This example illustrating use of shadows in the scene and callbacks(clicked, collision).
|
||||
* Model and cube are clickable. Model detects collision with sphere.
|
||||
* Cube detects collision with sphere, model and cone.
|
||||
* @see evas_3d_scene_shadows_enable_set(Eina_Bool _shadows_enabled)
|
||||
* @see evas_3d_object_callback_register
|
||||
*
|
||||
* Compile with "gcc -o evas-3d-shadows evas-3d-shadows.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo` -lm"
|
||||
* Compile with gcc -o evas-3d-shadows evas-3d-shadows.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo eina` -lm
|
||||
*/
|
||||
|
||||
#define EFL_EO_API_SUPPORT
|
||||
|
@ -13,12 +15,14 @@
|
|||
#include <Evas.h>
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_Evas.h>
|
||||
#include <Eina.h>
|
||||
#include <math.h>
|
||||
#include "evas-3d-primitives.c"
|
||||
|
||||
#define WIDTH 1024
|
||||
#define HEIGHT 1024
|
||||
|
||||
#define STEP 0.1
|
||||
#define BG_COLOR 0.2, 0.2, 0.2
|
||||
#define AMBIENT_LIGHT 0.2, 0.2, 0.2
|
||||
#define DIFFUSE_LIGHT 1.0, 1.0, 1.0
|
||||
|
@ -28,6 +32,7 @@ Ecore_Evas *ecore_evas = NULL;
|
|||
Evas *evas = NULL;
|
||||
Eo *background = NULL;
|
||||
Eo *image = NULL;
|
||||
Evas_3D_Node *choosed_node = NULL;
|
||||
|
||||
typedef struct _Body_3D
|
||||
{
|
||||
|
@ -53,6 +58,51 @@ typedef struct _Scene_Data
|
|||
Body_3D cone;
|
||||
} Scene_Data;
|
||||
|
||||
Eina_Bool
|
||||
_cb_clicked(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
Eina_List *meshes = NULL, *l;
|
||||
Evas_3D_Mesh *m;
|
||||
eo_do((Evas_3D_Node *)event_info, 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_DIFFUSE));
|
||||
}
|
||||
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(m, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
|
||||
}
|
||||
choosed_node = (Evas_3D_Node *)event_info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_cb_collision(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
Eina_List *meshes = NULL, *l;
|
||||
Evas_3D_Mesh *m;
|
||||
eo_do((Evas_3D_Node *)event_info, 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_DIFFUSE));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_show_help()
|
||||
{
|
||||
fprintf(stdout, "Press 'w'/'s' key to move up/down object\n");
|
||||
fprintf(stdout, "Press 'a'/'d' key to move left/right object\n");
|
||||
fprintf(stdout, "Press 'q'/'e' key to to move near/far object\n");
|
||||
fprintf(stdout, "Cude and model can be moved.\n");
|
||||
fprintf(stdout, "Cube detects intersection with model, sphere, cone\n");
|
||||
fprintf(stdout, "Model detects intersection with sphere\n");
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_animate_scene(void *data)
|
||||
{
|
||||
|
@ -61,9 +111,9 @@ _animate_scene(void *data)
|
|||
|
||||
eo_do(body->node, evas_3d_node_mesh_frame_set(body->mesh, frame));
|
||||
|
||||
frame += 32;
|
||||
/*frame += 32;*/
|
||||
|
||||
if (frame > 256 * 50) frame = 0;
|
||||
if (frame > 256 * 20) frame = 0;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -114,7 +164,7 @@ _sphere_setup(Body_3D *sphere)
|
|||
sphere->node =
|
||||
eo_add(EVAS_3D_NODE_CLASS, evas,
|
||||
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH),
|
||||
evas_3d_node_position_set(2.0, 3.0, 1.0));
|
||||
evas_3d_node_position_set(3.0, 3.0, 0.0));
|
||||
eo_do(sphere->node, evas_3d_node_mesh_add(sphere->mesh));
|
||||
}
|
||||
|
||||
|
@ -293,12 +343,106 @@ _scene_setup(Scene_Data *data)
|
|||
evas_3d_scene_shadows_enable_set(EINA_TRUE));
|
||||
}
|
||||
|
||||
static void
|
||||
_on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Scene_Data *scene = (Scene_Data *)data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
if (!strcmp("w", ev->key))
|
||||
{
|
||||
Evas_Real x, y, z;
|
||||
eo_do(choosed_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
|
||||
eo_do(choosed_node, evas_3d_node_position_set(x, y + STEP, z));
|
||||
}
|
||||
else if(!strcmp("s", ev->key))
|
||||
{
|
||||
Evas_Real x, y, z;
|
||||
eo_do(choosed_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
|
||||
eo_do(choosed_node, evas_3d_node_position_set(x, y - STEP, z));
|
||||
}
|
||||
else if(!strcmp("a", ev->key))
|
||||
{
|
||||
Evas_Real x, y, z;
|
||||
eo_do(choosed_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
|
||||
eo_do(choosed_node, evas_3d_node_position_set(x - STEP, y, z));
|
||||
}
|
||||
else if(!strcmp("d", ev->key))
|
||||
{
|
||||
Evas_Real x, y, z;
|
||||
eo_do(choosed_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
|
||||
eo_do(choosed_node, evas_3d_node_position_set(x + STEP, y, z));
|
||||
}
|
||||
else if(!strcmp("q", ev->key))
|
||||
{
|
||||
Evas_Real x, y, z;
|
||||
eo_do(choosed_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
|
||||
eo_do(choosed_node, evas_3d_node_position_set(x, y, z - STEP));
|
||||
}
|
||||
else if(!strcmp("e", ev->key))
|
||||
{
|
||||
Evas_Real x, y, z;
|
||||
eo_do(choosed_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
|
||||
eo_do(choosed_node, evas_3d_node_position_set(x, y, z + STEP));
|
||||
}
|
||||
else
|
||||
{
|
||||
_show_help();
|
||||
}
|
||||
}
|
||||
|
||||
static void _init(Scene_Data *data)
|
||||
{
|
||||
Eina_List *meshes = NULL, *l;
|
||||
Evas_3D_Mesh *m;
|
||||
eo_do(data->sphere.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));
|
||||
}
|
||||
eo_do(data->cube.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));
|
||||
}
|
||||
eo_do(data->cylinder.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));
|
||||
}
|
||||
eo_do(data->model.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));
|
||||
}
|
||||
eo_do(data->cone.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));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Scene_Data *d = (Scene_Data *)data;
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
Evas_3D_Node *n = NULL;
|
||||
Evas_3D_Mesh *m = NULL;
|
||||
Evas_Real s, t;
|
||||
if (ev->button == 3)
|
||||
{
|
||||
_init(d);
|
||||
return;
|
||||
}
|
||||
eo_do(d->scene, evas_3d_scene_pick(ev->canvas.x, ev->canvas.y, &n, &m, &s, &t));
|
||||
|
||||
}
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
Scene_Data data;
|
||||
Ecore_Animator *anim;
|
||||
|
||||
Eina_List *nodes1 = NULL, *nodes2 = NULL;
|
||||
//Unless Evas 3D supports Software renderer, we set gl backened forcely.
|
||||
setenv("ECORE_EVAS_ENGINE", "opengl_x11", 1);
|
||||
if (!ecore_evas_init()) return 0;
|
||||
|
@ -327,9 +471,25 @@ main(void)
|
|||
evas_obj_size_set(WIDTH, HEIGHT),
|
||||
evas_obj_visibility_set(EINA_TRUE));
|
||||
|
||||
evas_object_focus_set(image, EINA_TRUE);
|
||||
/* Set the image object as render target for 3D scene. */
|
||||
eo_do(image, evas_obj_image_scene_set(data.scene));
|
||||
|
||||
nodes1 = eina_list_append(nodes1, data.sphere.node);
|
||||
nodes2 = eina_list_append(nodes2, data.sphere.node);
|
||||
nodes2 = eina_list_append(nodes2, data.model.node);
|
||||
nodes2 = eina_list_append(nodes2, data.cone.node);
|
||||
|
||||
/*Set callbacks*/
|
||||
eo_do(data.cube.node, eo_event_callback_add(EVAS_3D_OBJECT_EVENT_CLICKED, _cb_clicked, NULL));
|
||||
eo_do(data.cube.node, eo_event_callback_add(EVAS_3D_OBJECT_EVENT_COLLISION, _cb_collision, nodes2));
|
||||
|
||||
eo_do(data.model.node, eo_event_callback_add(EVAS_3D_OBJECT_EVENT_CLICKED, _cb_clicked, NULL));
|
||||
eo_do(data.model.node, eo_event_callback_add(EVAS_3D_OBJECT_EVENT_COLLISION, _cb_collision, nodes1));
|
||||
|
||||
evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, &data);
|
||||
evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_key_down, &data);
|
||||
|
||||
/* Add animator. */
|
||||
ecore_animator_frametime_set(0.008);
|
||||
anim = ecore_animator_add(_animate_scene, &data.model);
|
||||
|
@ -337,7 +497,8 @@ main(void)
|
|||
/* Enter main loop. */
|
||||
ecore_main_loop_begin();
|
||||
ecore_animator_del(anim);
|
||||
|
||||
eina_list_free(nodes1);
|
||||
eina_list_free(nodes2);
|
||||
ecore_evas_free(ecore_evas);
|
||||
ecore_evas_shutdown();
|
||||
|
||||
|
|
|
@ -815,3 +815,4 @@ typedef enum _Evas_3D_Material_Attrib
|
|||
#include "canvas/evas_3d_scene.eo.h"
|
||||
|
||||
#include "canvas/evas_3d_object.eo.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "evas_common_private.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_3d_node_callback.h"
|
||||
|
||||
#define MY_CLASS EVAS_3D_NODE_CLASS
|
||||
#define MY_CLASS_NAME "Evas_3D_Node"
|
||||
|
@ -27,6 +28,46 @@ _generate_unic_color_key(Evas_Color *color, Evas_Color *bg_color, Evas_3D_Node *
|
|||
return eina_stringshare_printf("%p %p", node, mesh);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_evas_3d_node_private_callback_collision(void *data, Eo *obj EINA_UNUSED,
|
||||
const Eo_Event_Description *desc EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Eina_List *collision_list = NULL, *l = NULL;
|
||||
Evas_3D_Node *target_node = NULL, *n = NULL;
|
||||
Evas_3D_Node_Data *pd_target = NULL, *pd = NULL;
|
||||
const Eo_Event_Description *eo_desc = NULL;
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
|
||||
target_node = (Evas_3D_Node *)event_info;
|
||||
pd_target = eo_data_scope_get(target_node, EVAS_3D_NODE_CLASS);
|
||||
collision_list = (Eina_List *)data;
|
||||
eo_desc = eo_base_legacy_only_event_description_get("collision");
|
||||
|
||||
if (collision_list)
|
||||
{
|
||||
EINA_LIST_FOREACH(collision_list, l, n)
|
||||
{
|
||||
pd = eo_data_scope_get(n, EVAS_3D_NODE_CLASS);
|
||||
if (box_intersection_box(&pd_target->aabb, &pd->aabb))
|
||||
eo_do(target_node, ret = eo_event_callback_call(eo_desc, n));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static Eina_Bool
|
||||
_evas_3d_node_private_callback_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
|
||||
const Eo_Event_Description *desc EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
const Eo_Event_Description *eo_desc = eo_base_legacy_only_event_description_get("clicked");
|
||||
eo_do((Eo *)event_info, ret = eo_event_callback_call(eo_desc, event_info));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline Evas_3D_Node_Mesh *
|
||||
_node_mesh_new(Evas_3D_Node *node, Evas_3D_Mesh *mesh)
|
||||
{
|
||||
|
@ -127,6 +168,33 @@ _evas_3d_node_evas_3d_object_change_notify(Eo *obj, Evas_3D_Node_Data *pd, Evas_
|
|||
}
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_3d_node_evas_3d_object_callback_register(Eo *obj, Evas_3D_Node_Data *pd EINA_UNUSED,
|
||||
const char *event, const void *data)
|
||||
{
|
||||
Evas_3D_Node_Private_Callback_Type tcb;
|
||||
|
||||
GET_CALLBACK_TYPE(tcb, event)
|
||||
|
||||
if (tcb != PRIVATE_CALLBACK_NONE)
|
||||
eo_do(obj, eo_event_callback_add(&evas_3d_node_private_event_desc[tcb],
|
||||
evas_3d_node_private_callback_functions[tcb], data));
|
||||
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_3d_node_evas_3d_object_callback_unregister(Eo *obj, Evas_3D_Node_Data *pd EINA_UNUSED,
|
||||
const char *event)
|
||||
{
|
||||
Evas_3D_Node_Private_Callback_Type tcb;
|
||||
|
||||
GET_CALLBACK_TYPE(tcb, event)
|
||||
|
||||
if (tcb != PRIVATE_CALLBACK_NONE)
|
||||
eo_do(obj, eo_event_callback_del(&evas_3d_node_private_event_desc[tcb],
|
||||
evas_3d_node_private_callback_functions[tcb], NULL));
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_node_transform_update(Evas_3D_Node *node, void *data EINA_UNUSED)
|
||||
{
|
||||
|
@ -257,6 +325,7 @@ _rotate_vertices(Evas_Vec4* orientation, int vertex_count, Evas_Vec3* vertex_pos
|
|||
evas_vec3_quaternion_rotate(&vertex_position[i], &vertex_position[i], orientation);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_scale_vertices(Evas_Vec3* scale, int vertex_count, Evas_Vec3* vertex_position)
|
||||
{
|
||||
|
@ -471,6 +540,7 @@ _node_aabb_update(Evas_3D_Node *node, void *data EINA_UNUSED)
|
|||
Eina_Bool need_recalc;
|
||||
Eina_List *current;
|
||||
Evas_3D_Node *datanode;
|
||||
const Eo_Event_Description *eo_desc = NULL;
|
||||
|
||||
eo_do(node,
|
||||
need_recalc = evas_3d_object_dirty_get(EVAS_3D_STATE_NODE_TRANSFORM_ORIENTATION),
|
||||
|
@ -495,6 +565,9 @@ _node_aabb_update(Evas_3D_Node *node, void *data EINA_UNUSED)
|
|||
evas_build_sphere(&pd->aabb, &pd->bsphere);
|
||||
}
|
||||
|
||||
eo_desc = eo_base_legacy_only_event_description_get("collision,private");
|
||||
eo_do(node, eo_event_callback_call(eo_desc, (void *)node));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -580,6 +580,8 @@ class Evas_3D_Node (Evas_3D_Object, Evas.Common_Interface)
|
|||
implements {
|
||||
Evas_3D_Object.update_notify;
|
||||
Evas_3D_Object.change_notify;
|
||||
Evas_3D_Object.callback_register;
|
||||
Evas_3D_Object.callback_unregister;
|
||||
}
|
||||
constructors {
|
||||
.constructor;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*Type of events and callbacks for object Evas_3D_Node*/
|
||||
|
||||
#define GET_CALLBACK_TYPE(check, type) \
|
||||
if (!(strcmp(type, "clicked"))) \
|
||||
check = PRIVATE_CALLBACK_CLICKED; \
|
||||
else if (!(strcmp(type, "collision"))) \
|
||||
check = PRIVATE_CALLBACK_COLLISION; \
|
||||
else \
|
||||
check = PRIVATE_CALLBACK_NONE;
|
||||
|
||||
typedef enum _Evas_3D_Node_Private_Callback_Type
|
||||
{
|
||||
PRIVATE_CALLBACK_CLICKED = 0,
|
||||
PRIVATE_CALLBACK_COLLISION,
|
||||
/*Insert here new type of callback*/
|
||||
PRIVATE_CALLBACK_NONE
|
||||
} Evas_3D_Node_Private_Callback_Type;
|
||||
|
||||
const Eo_Event_Description evas_3d_node_private_event_desc[] =
|
||||
{
|
||||
{"clicked,private", "private event clicked", EINA_FALSE},
|
||||
{"collision,private", "private event collision", EINA_FALSE}
|
||||
};
|
||||
|
||||
/*Private callbacks */
|
||||
static Eina_Bool
|
||||
_evas_3d_node_private_callback_clicked(void *data, Eo *obj, const Eo_Event_Description *desc,
|
||||
void *event_info);
|
||||
static Eina_Bool
|
||||
_evas_3d_node_private_callback_collision(void *data, Eo *obj, const Eo_Event_Description *desc,
|
||||
void *event_info);
|
||||
|
||||
Eo_Event_Cb evas_3d_node_private_callback_functions[] =
|
||||
{
|
||||
_evas_3d_node_private_callback_clicked,
|
||||
_evas_3d_node_private_callback_collision,
|
||||
};
|
||||
|
|
@ -14,7 +14,6 @@ _evas_3d_object_eo_base_constructor(Eo *obj, Evas_3D_Object_Data *pd)
|
|||
memset(&pd->dirty[0], 0x00, sizeof(Eina_Bool) * EVAS_3D_STATE_MAX);
|
||||
}
|
||||
|
||||
|
||||
EOLIAN static Evas *
|
||||
_evas_3d_object_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Object_Data *pd)
|
||||
{
|
||||
|
@ -63,4 +62,26 @@ _evas_3d_object_update(Eo *obj, Evas_3D_Object_Data *pd)
|
|||
memset(&pd->dirty[0], 0x00, sizeof(Eina_Bool) * EVAS_3D_STATE_MAX);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_3d_object_eo_base_event_callback_priority_add(Eo *obj,
|
||||
Evas_3D_Object_Data *pd EINA_UNUSED,
|
||||
const Eo_Event_Description *desc,
|
||||
Eo_Callback_Priority priority,
|
||||
Eo_Event_Cb func,
|
||||
const void *user_data)
|
||||
{
|
||||
eo_do_super(obj, MY_CLASS, eo_event_callback_priority_add(desc, priority, func, user_data));
|
||||
eo_do(obj, evas_3d_object_callback_register(desc->name, user_data));
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_3d_object_eo_base_event_callback_del(Eo *obj, Evas_3D_Object_Data *pd EINA_UNUSED,
|
||||
const Eo_Event_Description *desc,
|
||||
Eo_Event_Cb func,
|
||||
const void *user_data)
|
||||
{
|
||||
eo_do_super(obj, MY_CLASS, eo_event_callback_del(desc, func, user_data));
|
||||
eo_do(obj, evas_3d_object_callback_unregister(desc->name));
|
||||
}
|
||||
|
||||
#include "canvas/evas_3d_object.eo.c"
|
||||
|
|
|
@ -60,13 +60,37 @@ class Evas_3D_Object (Eo.Base, Evas.Common_Interface)
|
|||
@in Evas_3D_Object *ref; /*@ The Object that caused the change */
|
||||
}
|
||||
}
|
||||
callback_register {
|
||||
/*@
|
||||
Pure virtual register samrt callback function.
|
||||
*/
|
||||
params {
|
||||
@in const(char)* event; /*@ Event type */
|
||||
@in const(void)* data; /*@ User data*/
|
||||
}
|
||||
}
|
||||
callback_unregister {
|
||||
/*@
|
||||
Pure virtual unregister smart callback function.
|
||||
*/
|
||||
params {
|
||||
@in const(char)* event; /*@ Event type */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
implements {
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.event_callback_priority_add;
|
||||
Eo.Base.event_callback_del;
|
||||
Evas.Common_Interface.evas.get;
|
||||
@virtual .update_notify;
|
||||
@virtual .change_notify;
|
||||
@virtual .callback_register;
|
||||
@virtual .callback_unregister;
|
||||
}
|
||||
events {
|
||||
clicked; /*@ Clicked Event */
|
||||
collision; /*@ Collision Event */
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ evas_3d_scene_data_fini(Evas_3D_Scene_Public_Data *data)
|
|||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_3d_scene_evas_3d_object_change_notify(Eo *eo_obj EINA_UNUSED, Evas_3D_Scene_Data *pd, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED)
|
||||
_evas_3d_scene_evas_3d_object_change_notify(Eo *eo_obj EINA_UNUSED, Evas_3D_Scene_Data *pd,
|
||||
Evas_3D_State state EINA_UNUSED,
|
||||
Evas_3D_Object *ref EINA_UNUSED)
|
||||
{
|
||||
Eina_List *l;
|
||||
Evas_Object *eo;
|
||||
|
@ -635,6 +637,8 @@ _evas_3d_scene_pick(Eo *obj, Evas_3D_Scene_Data *pd, Evas_Real x, Evas_Real y,
|
|||
Eina_Stringshare *tmp;
|
||||
Eina_Array *arr = NULL;
|
||||
Eina_Bool update_scene = EINA_FALSE;
|
||||
Evas_3D_Node *picked_node = NULL;
|
||||
const Eo_Event_Description *eo_desc = NULL;
|
||||
|
||||
pd_parent = eo_data_scope_get(obj, EVAS_3D_OBJECT_CLASS);
|
||||
e = eo_data_scope_get(pd_parent->evas, EVAS_CANVAS_CLASS);
|
||||
|
@ -693,10 +697,15 @@ _evas_3d_scene_pick(Eo *obj, Evas_3D_Scene_Data *pd, Evas_Real x, Evas_Real y,
|
|||
arr = (Eina_Array *)eina_hash_find(pd->colors_node_mesh, tmp);
|
||||
if (arr)
|
||||
{
|
||||
picked_node = (Evas_3D_Node *)eina_array_data_get(arr, 0);
|
||||
if (mesh) *mesh = (Evas_3D_Mesh *)eina_array_data_get(arr, 1);
|
||||
if (node) *node = (Evas_3D_Node *)eina_array_data_get(arr, 0);
|
||||
if (node) *node = picked_node;
|
||||
eina_stringshare_del(tmp);
|
||||
|
||||
/*Calling callback clicked*/
|
||||
eo_desc = eo_base_legacy_only_event_description_get("clicked,private");
|
||||
eo_do(picked_node, eo_event_callback_call(eo_desc, picked_node));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -732,6 +741,10 @@ _evas_3d_scene_pick(Eo *obj, Evas_3D_Scene_Data *pd, Evas_Real x, Evas_Real y,
|
|||
if (node) *node = data.node;
|
||||
if (mesh) *mesh = data.mesh;
|
||||
|
||||
/*Calling callback clicked*/
|
||||
eo_desc = eo_base_legacy_only_event_description_get("clicked,private");
|
||||
eo_do(data.node, eo_event_callback_call(eo_desc, data.node));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2000,3 +2000,15 @@ evas_frustum_calculate(Evas_Vec4 *planes, Evas_Mat4 *matrix_vp)
|
|||
evas_plane_normalize(&planes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
box_intersection_box(Evas_Box3 *v1, Evas_Box3 *v2)
|
||||
{
|
||||
if ((v1->p1.x < v2->p0.x) || (v1->p0.x > v2->p1.x)
|
||||
|| (v1->p1.y < v2->p0.y) || (v1->p0.y > v2->p1.y)
|
||||
|| (v1->p1.z < v2->p0.z) || (v1->p0.z > v2->p1.z))
|
||||
return EINA_FALSE;
|
||||
else
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,6 @@ typedef enum _Evas_3D_Tree_Traverse_Type
|
|||
struct _Evas_3D_Object
|
||||
{
|
||||
Evas *evas;
|
||||
|
||||
Evas_3D_Object_Type type;
|
||||
|
||||
Eina_Bool dirty[EVAS_3D_STATE_MAX];
|
||||
|
|
Loading…
Reference in New Issue