Evas_3D : Eolian change

Conflicts:

	src/Makefile_Evas.am
	src/lib/evas/Evas_3D.h
	src/lib/evas/Evas_Eo.h
This commit is contained in:
subhransu 2014-04-14 19:03:47 +09:00 committed by ChunEon Park
parent 86ce491a86
commit e84e28fc22
25 changed files with 5790 additions and 3764 deletions

View File

@ -61,7 +61,21 @@ BUILT_SOURCES += \
lib/evas/canvas/evas_zoomable_interface.eo.h \
lib/evas/canvas/evas_box.eo.c \
lib/evas/canvas/evas_box.eo.h \
lib/evas/canvas/evas_box.eo.legacy.h
lib/evas/canvas/evas_box.eo.legacy.h \
lib/evas/canvas/evas_3d_camera.eo.c\
lib/evas/canvas/evas_3d_camera.eo.h\
lib/evas/canvas/evas_3d_texture.eo.c\
lib/evas/canvas/evas_3d_texture.eo.h\
lib/evas/canvas/evas_3d_material.eo.c\
lib/evas/canvas/evas_3d_material.eo.h\
lib/evas/canvas/evas_3d_light.eo.c\
lib/evas/canvas/evas_3d_light.eo.h\
lib/evas/canvas/evas_3d_mesh.eo.c\
lib/evas/canvas/evas_3d_mesh.eo.h\
lib/evas/canvas/evas_3d_node.eo.c\
lib/evas/canvas/evas_3d_node.eo.h\
lib/evas/canvas/evas_3d_scene.eo.c\
lib/evas/canvas/evas_3d_scene.eo.h
evaseolianfilesdir = $(datadir)/eolian/include/evas-@VMAJ@
evaseolianfiles_DATA = \
@ -86,8 +100,15 @@ evaseolianfiles_DATA = \
lib/evas/canvas/evas_scrollable_interface.eo \
lib/evas/canvas/evas_selectable_interface.eo \
lib/evas/canvas/evas_zoomable_interface.eo \
lib/evas/canvas/evas_box.eo
lib/evas/canvas/evas_box.eo\
lib/evas/canvas/evas_3d_camera.eo\
lib/evas/canvas/evas_3d_texture.eo\
lib/evas/canvas/evas_3d_material.eo\
lib/evas/canvas/evas_3d_light.eo\
lib/evas/canvas/evas_3d_mesh.eo\
lib/evas/canvas/evas_3d_node.eo\
lib/evas/canvas/evas_3d_scene.eo
EXTRA_DIST += \
${evaseolianfiles_DATA}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -206,6 +206,20 @@ EAPI extern const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_POST;
#include "canvas/evas_object.eo.h"
#include"canvas/evas_image.eo.h"
#include "canvas/evas_image.eo.h"
#include "canvas/evas_out.eo.h"
#include "canvas/evas_3d_camera.eo.h"
#include "canvas/evas_3d_texture.eo.h"
#include "canvas/evas_3d_material.eo.h"
#include "canvas/evas_3d_light.eo.h"
#include "canvas/evas_3d_mesh.eo.h"
#include "canvas/evas_3d_node.eo.h"
#include "canvas/evas_3d_scene.eo.h"

View File

@ -6,15 +6,19 @@
#include "evas_common_private.h"
#include "evas_private.h"
#include "Eo.h"
#define MY_CLASS EO_EVAS_3D_CAMERA_CLASS
static void
_camera_free(Evas_3D_Object *obj)
{
Evas_3D_Camera *camera = (Evas_3D_Camera *)obj;
Evas_3D_Camera_Data *pd = (Evas_3D_Camera_Data *)obj;
if (camera->nodes)
eina_hash_free(camera->nodes);
if (pd->nodes)
eina_hash_free(pd->nodes);
free(camera);
//free(pd);
}
static Eina_Bool
@ -22,7 +26,8 @@ _camera_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_3D_Node *n = *(Evas_3D_Node **)key;
evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_CAMERA, (Evas_3D_Object *)fdata);
Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_CAMERA, (Evas_3D_Object *)fdata);
return EINA_TRUE;
}
@ -30,10 +35,10 @@ static void
_camera_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED,
Evas_3D_Object *ref EINA_UNUSED)
{
Evas_3D_Camera *camera = (Evas_3D_Camera *)obj;
Evas_3D_Camera_Data *pd = (Evas_3D_Camera_Data *)obj;
if (camera->nodes)
eina_hash_foreach(camera->nodes, _camera_node_change_notify, obj);
if (pd->nodes)
eina_hash_foreach(pd->nodes, _camera_node_change_notify, obj);
}
static const Evas_3D_Object_Func camera_func =
@ -47,92 +52,107 @@ void
evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node)
{
int count = 0;
if (camera->nodes == NULL)
Evas_3D_Camera_Data *pd = eo_data_scope_get(camera, MY_CLASS);
if (pd->nodes == NULL)
{
camera->nodes = eina_hash_pointer_new(NULL);
pd->nodes = eina_hash_pointer_new(NULL);
if (camera->nodes == NULL)
if (pd->nodes == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)eina_hash_find(camera->nodes, &node);
count = (int)eina_hash_find(pd->nodes, &node);
eina_hash_set(camera->nodes, &node, (const void *)(count + 1));
eina_hash_set(pd->nodes, &node, (const void *)(count + 1));
}
void
evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node)
{
int count = 0;
Evas_3D_Camera_Data *pd = eo_data_scope_get(camera, MY_CLASS);
if (camera->nodes == NULL)
if (pd->nodes == NULL)
{
ERR("No node to delete.");
return;
}
count = (int)eina_hash_find(camera->nodes, &node);
count = (int)eina_hash_find(pd->nodes, &node);
if (count == 1)
eina_hash_del(camera->nodes, &node, NULL);
eina_hash_del(pd->nodes, &node, NULL);
else
eina_hash_set(camera->nodes, &node, (const void *)(count - 1));
eina_hash_set(pd->nodes, &node, (const void *)(count - 1));
}
Evas_3D_Camera *
evas_3d_camera_new(Evas *e)
// Evas_3D_Camera *
// evas_3d_camera_new(Evas *e)
// {
// Evas_3D_Camera *camera = NULL;
// camera = (Evas_3D_Camera *)calloc(1, sizeof(Evas_3D_Camera));
// if (camera == NULL)
// {
// ERR("Failed to allocate memory.");
// return NULL;
// }
// evas_3d_object_init(&camera->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &camera_func);
// return camera;
// }
EOLIAN static void
_eo_evas_3d_camera_eo_base_constructor(Eo *obj, Evas_3D_Camera_Data *pd)
{
Evas_3D_Camera *camera = NULL;
Eo *e;
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, e = eo_parent_get());
evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &camera_func);
}
camera = (Evas_3D_Camera *)calloc(1, sizeof(Evas_3D_Camera));
if (camera == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
evas_3d_object_init(&camera->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &camera_func);
return camera;
EOLIAN static void
_eo_evas_3d_camera_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd)
{
evas_3d_object_unreference(&pd->base);
}
EAPI Evas_3D_Camera *
evas_3d_camera_add(Evas *e)
{
return evas_3d_camera_new(e);
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Object *eo_obj = eo_add(MY_CLASS, e);
eo_unref(eo_obj);
return eo_obj;
//return evas_3d_camera_new(e);
}
EAPI void
evas_3d_camera_del(Evas_3D_Camera *camera)
EOLIAN static Evas *
_eo_evas_3d_camera_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd)
{
evas_3d_object_unreference(&camera->base);
return pd->base.evas;
}
EAPI Evas *
evas_3d_camera_evas_get(const Evas_3D_Camera *camera)
EOLIAN static void
_eo_evas_3d_camera_projection_matrix_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, const Evas_Real *matrix)
{
return camera->base.evas;
evas_mat4_array_set(&pd->projection, matrix);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
}
EAPI void
evas_3d_camera_projection_matrix_set(Evas_3D_Camera *camera, const Evas_Real *matrix)
EOLIAN static void
_eo_evas_3d_camera_projection_matrix_get(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real *matrix)
{
evas_mat4_array_set(&camera->projection, matrix);
evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
memcpy(matrix, &pd->projection.m[0], sizeof(Evas_Real) * 16);
}
EAPI void
evas_3d_camera_projection_matrix_get(const Evas_3D_Camera *camera, Evas_Real *matrix)
{
memcpy(matrix, &camera->projection.m[0], sizeof(Evas_Real) * 16);
}
EAPI void
evas_3d_camera_projection_perspective_set(Evas_3D_Camera *camera, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far)
EOLIAN static void
_eo_evas_3d_camera_projection_perspective_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far)
{
Evas_Real xmax;
Evas_Real ymax;
@ -140,20 +160,23 @@ evas_3d_camera_projection_perspective_set(Evas_3D_Camera *camera, Evas_Real fovy
ymax = near * (Evas_Real)tan((double)fovy * M_PI / 360.0);
xmax = ymax * aspect;
evas_mat4_frustum_set(&camera->projection, -xmax, xmax, -ymax, ymax, near, far);
evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
evas_mat4_frustum_set(&pd->projection, -xmax, xmax, -ymax, ymax, near, far);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
}
EAPI void
evas_3d_camera_projection_frustum_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far)
EOLIAN static void
_eo_evas_3d_camera_projection_frustum_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far)
{
evas_mat4_frustum_set(&camera->projection, left, right, bottom, top, near, far);
evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, near, far);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
}
EAPI void
evas_3d_camera_projection_ortho_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far)
EOLIAN static void
_eo_evas_3d_camera_projection_ortho_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far)
{
evas_mat4_ortho_set(&camera->projection, left, right, bottom, top, near, far);
evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
evas_mat4_ortho_set(&pd->projection, left, right, bottom, top, near, far);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL);
}
#include "canvas/evas_3d_camera.eo.c"

View File

@ -0,0 +1,108 @@
class EO_Evas_3D_Camera (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_camera;
data: Evas_3D_Camera_Data;
methods {
projection_matrix_set {
/*@
Set the projection matrix of the given camera.
@param camera The given camera.
@param matrix Pointer to the array of 16 Evas_Real values in column major order.
Default projection matrix is identity matrix.
@see evas_3d_camera_projection_perspective_set()
@see evas_3d_camera_projection_ortho_set()
@see evas_3d_camera_projection_frustum_set()
@ingroup Evas_3D_Camera
*/
params {
@in const Evas_Real *matrix; /*@ Projection Matrix */
}
}
projection_matrix_get {
/*@
Get the projection matrix of the given camera.
@param camera The given camera.
@param matrix Pointer to receive the 16 Evas_Real values in column major order.
@see evas_3d_camera_projection_matrix_set()
@ingroup Evas_3D_Camera
*/
const;
params {
@out Evas_Real matrix; /*@ Projection Matrix */
}
}
projection_perspective_set {
/*@
Set the projection matrix of the given camera with perspective projection.
@param camera The given camera.
@param fovy Field of view angle in Y direction.
@param aspect Aspect ratio.
@param near Distance to near clipping plane.
@param far Distance to far clipping plane.
@see evas_3d_camera_projection_matrix_set()
@ingroup Evas_3D_Camera
*/
params {
Evas_Real fovy; /*@ Field of view angle in Y direction. */
Evas_Real aspect; /*@ Aspect ratio.*/
Evas_Real near; /*@ Distance to near clipping plane. */
Evas_Real far; /*@ Distance to far clipping plane. */
}
}
projection_frustum_set {
/*@
Set the projection matrix of the given camera with frustum projection.
@see evas_3d_camera_projection_matrix_set()
@ingroup Evas_3D_Camera
*/
params {
Evas_Real left; /*@ Left X coordinate of the near clipping plane. */
Evas_Real right; /*@ Right X coordinate of the near clipping plane..*/
Evas_Real bottom; /*@ Bottom Y coordinate of the near clipping plane. */
Evas_Real top; /*@ Top Y coordinate of the near clipping plane */
Evas_Real near; /*@ Distance to near clipping plane. */
Evas_Real far; /*@ Distance to far clipping plane. */
}
}
projection_ortho_set {
/*@
Set the projection matrix of the given camera with orthogonal projection.
@see evas_3d_camera_projection_matrix_set()
@ingroup Evas_3D_Camera
*/
params {
Evas_Real left; /*@ Left X coordinate of the near clipping plane. */
Evas_Real right; /*@ Right X coordinate of the near clipping plane..*/
Evas_Real bottom; /*@ Bottom Y coordinate of the near clipping plane. */
Evas_Real top; /*@ Top Y coordinate of the near clipping plane */
Evas_Real near; /*@ Distance to near clipping plane. */
Evas_Real far; /*@ Distance to far clipping plane. */
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

View File

@ -7,15 +7,19 @@
#include "evas_common_private.h"
#include "evas_private.h"
#include "Eo.h"
#define MY_CLASS EO_EVAS_3D_LIGHT_CLASS
static void
_light_free(Evas_3D_Object *obj)
{
Evas_3D_Light *light = (Evas_3D_Light *)obj;
Evas_3D_Light_Data *light = (Evas_3D_Light_Data *)obj;
if (light->nodes)
eina_hash_free(light->nodes);
free(light);
//free(light);
}
static Eina_Bool
@ -23,7 +27,8 @@ _light_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_3D_Node *n = *(Evas_3D_Node **)key;
evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_LIGHT, (Evas_3D_Object *)fdata);
Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_LIGHT, (Evas_3D_Object *)fdata);
return EINA_TRUE;
}
@ -31,7 +36,7 @@ static void
_light_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED,
Evas_3D_Object *ref EINA_UNUSED)
{
Evas_3D_Light *light = (Evas_3D_Light *)obj;
Evas_3D_Light_Data *light = (Evas_3D_Light_Data *)obj;
if (light->nodes)
eina_hash_foreach(light->nodes, _light_node_change_notify, obj);
@ -48,226 +53,220 @@ void
evas_3d_light_node_add(Evas_3D_Light *light, Evas_3D_Node *node)
{
int count = 0;
if (light->nodes == NULL)
Evas_3D_Light_Data *pd = eo_data_scope_get(light, MY_CLASS);
if (pd->nodes == NULL)
{
light->nodes = eina_hash_pointer_new(NULL);
pd->nodes = eina_hash_pointer_new(NULL);
if (light->nodes == NULL)
if (pd->nodes == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)eina_hash_find(light->nodes, &node);
count = (int)eina_hash_find(pd->nodes, &node);
eina_hash_set(light->nodes, &node, (const void *)(count + 1));
eina_hash_set(pd->nodes, &node, (const void *)(count + 1));
}
void
evas_3d_light_node_del(Evas_3D_Light *light, Evas_3D_Node *node)
{
int count = 0;
if (light->nodes == NULL)
Evas_3D_Light_Data *pd = eo_data_scope_get(light, MY_CLASS);
if (pd->nodes == NULL)
{
ERR("No node to delete.");
return;
}
count = (int)eina_hash_find(light->nodes, &node);
count = (int)eina_hash_find(pd->nodes, &node);
if (count == 1)
eina_hash_del(light->nodes, &node, NULL);
eina_hash_del(pd->nodes, &node, NULL);
else
eina_hash_set(light->nodes, &node, (const void *)(count - 1));
eina_hash_set(pd->nodes, &node, (const void *)(count - 1));
}
Evas_3D_Light *
evas_3d_light_new(Evas *e)
{
Evas_3D_Light *light = NULL;
light = (Evas_3D_Light *)calloc(1, sizeof(Evas_3D_Light));
if (light == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
evas_3d_object_init(&light->base, e, EVAS_3D_OBJECT_TYPE_LIGHT, &light_func);
evas_color_set(&light->ambient, 0.0, 0.0, 0.0, 1.0);
evas_color_set(&light->diffuse, 1.0, 1.0, 1.0, 1.0);
evas_color_set(&light->specular, 1.0, 1.0, 1.0, 1.0);
light->spot_exp = 0.0;
light->spot_cutoff = 180.0;
light->spot_cutoff_cos = -1.0;
light->atten_const = 1.0;
light->atten_linear = 0.0;
light->atten_quad = 0.0;
return light;
}
EAPI Evas_3D_Light *
evas_3d_light_add(Evas *e)
{
return evas_3d_light_new(e);
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Object *eo_obj = eo_add(MY_CLASS, e);
eo_unref(eo_obj);
return eo_obj;
}
EAPI void
evas_3d_light_del(Evas_3D_Light *light)
EOLIAN static void
_eo_evas_3d_light_eo_base_constructor(Eo *obj, Evas_3D_Light_Data *pd)
{
evas_3d_object_unreference(&light->base);
Eo *e;
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, e = eo_parent_get());
evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_LIGHT, &light_func);
evas_color_set(&pd->ambient, 0.0, 0.0, 0.0, 1.0);
evas_color_set(&pd->diffuse, 1.0, 1.0, 1.0, 1.0);
evas_color_set(&pd->specular, 1.0, 1.0, 1.0, 1.0);
pd->spot_exp = 0.0;
pd->spot_cutoff = 180.0;
pd->spot_cutoff_cos = -1.0;
pd->atten_const = 1.0;
pd->atten_linear = 0.0;
pd->atten_quad = 0.0;
}
EAPI Evas *
evas_3d_light_evas_get(const Evas_3D_Light *light)
EOLIAN static void
_eo_evas_3d_light_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd)
{
return light->base.evas;
evas_3d_object_unreference(&pd->base);
}
EAPI void
evas_3d_light_directional_set(Evas_3D_Light *light, Eina_Bool directional)
EOLIAN static Evas *
_eo_evas_3d_light_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd)
{
if (light->directional != directional)
return pd->base.evas;
}
EOLIAN static void
_eo_evas_3d_light_directional_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Eina_Bool directional)
{
if (pd->directional != directional)
{
light->directional = directional;
evas_3d_object_change(&light->base, EVAS_3D_STATE_ANY, NULL);
pd->directional = directional;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_ANY, NULL);
}
}
EAPI Eina_Bool
evas_3d_light_directional_get(const Evas_3D_Light *light)
EOLIAN static Eina_Bool
_eo_evas_3d_light_directional_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd)
{
return light->directional;
return pd->directional;
}
EAPI void
evas_3d_light_ambient_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
EOLIAN static void
_eo_evas_3d_light_ambient_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
light->ambient.r = r;
light->ambient.g = g;
light->ambient.b = b;
light->ambient.a = a;
pd->ambient.r = r;
pd->ambient.g = g;
pd->ambient.b = b;
pd->ambient.a = a;
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_AMBIENT, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_AMBIENT, NULL);
}
EAPI void
evas_3d_light_ambient_get(const Evas_3D_Light *light,
Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
EOLIAN static void
_eo_evas_3d_light_ambient_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
{
if (r) *r = light->ambient.r;
if (g) *g = light->ambient.g;
if (b) *b = light->ambient.b;
if (a) *a = light->ambient.a;
if (r) *r = pd->ambient.r;
if (g) *g = pd->ambient.g;
if (b) *b = pd->ambient.b;
if (a) *a = pd->ambient.a;
}
EAPI void
evas_3d_light_diffuse_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
EOLIAN static void
_eo_evas_3d_light_diffuse_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
light->diffuse.r = r;
light->diffuse.g = g;
light->diffuse.b = b;
light->diffuse.a = a;
pd->diffuse.r = r;
pd->diffuse.g = g;
pd->diffuse.b = b;
pd->diffuse.a = a;
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_DIFFUSE, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_DIFFUSE, NULL);
}
EAPI void
evas_3d_light_diffuse_get(const Evas_3D_Light *light,
Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
EOLIAN static void
_eo_evas_3d_light_diffuse_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
{
if (r) *r = light->diffuse.r;
if (g) *g = light->diffuse.g;
if (b) *b = light->diffuse.b;
if (a) *a = light->diffuse.a;
if (r) *r = pd->diffuse.r;
if (g) *g = pd->diffuse.g;
if (b) *b = pd->diffuse.b;
if (a) *a = pd->diffuse.a;
}
EAPI void
evas_3d_light_specular_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
EOLIAN static void
_eo_evas_3d_light_specular_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
light->specular.r = r;
light->specular.g = g;
light->specular.b = b;
light->specular.a = a;
pd->specular.r = r;
pd->specular.g = g;
pd->specular.b = b;
pd->specular.a = a;
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_SPECULAR, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_SPECULAR, NULL);
}
EAPI void
evas_3d_light_specular_get(const Evas_3D_Light *light,
Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
EOLIAN static void
_eo_evas_3d_light_specular_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
{
if (r) *r = light->specular.r;
if (g) *g = light->specular.g;
if (b) *b = light->specular.b;
if (a) *a = light->specular.a;
if (r) *r = pd->specular.r;
if (g) *g = pd->specular.g;
if (b) *b = pd->specular.b;
if (a) *a = pd->specular.a;
}
EAPI void
evas_3d_light_spot_exponent_set(Evas_3D_Light *light, Evas_Real exponent)
EOLIAN static void
_eo_evas_3d_light_spot_exponent_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real exponent)
{
light->spot_exp = exponent;
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_SPOT_EXP, NULL);
pd->spot_exp = exponent;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_SPOT_EXP, NULL);
}
EAPI Evas_Real
evas_3d_light_spot_exponent_get(const Evas_3D_Light *light)
EOLIAN static Evas_Real
_eo_evas_3d_light_spot_exponent_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd)
{
return light->spot_exp;
return pd->spot_exp;
}
EAPI void
evas_3d_light_spot_cutoff_set(Evas_3D_Light *light, Evas_Real cutoff)
EOLIAN static void
_eo_evas_3d_light_spot_cutoff_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real cutoff)
{
light->spot_cutoff = cutoff;
light->spot_cutoff_cos = cos(cutoff * M_PI / 180.0);
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_SPOT_CUTOFF, NULL);
pd->spot_cutoff = cutoff;
pd->spot_cutoff_cos = cos(cutoff * M_PI / 180.0);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_SPOT_CUTOFF, NULL);
}
EAPI Evas_Real
evas_3d_light_spot_cutoff_get(const Evas_3D_Light *light)
EOLIAN static Evas_Real
_eo_evas_3d_light_spot_cutoff_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd)
{
return light->spot_cutoff;
return pd->spot_cutoff;
}
EAPI void
evas_3d_light_attenuation_set(Evas_3D_Light *light,
Evas_Real constant, Evas_Real linear, Evas_Real quadratic)
EOLIAN static void
_eo_evas_3d_light_attenuation_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real constant, Evas_Real linear, Evas_Real quadratic)
{
light->atten_const = constant;
light->atten_linear = linear;
light->atten_quad = quadratic;
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL);
pd->atten_const = constant;
pd->atten_linear = linear;
pd->atten_quad = quadratic;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL);
}
EAPI void
evas_3d_light_attenuation_get(const Evas_3D_Light *light, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic)
EOLIAN static void
_eo_evas_3d_light_attenuation_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic)
{
if (constant) *constant = light->atten_const;
if (linear) *linear = light->atten_linear;
if (quadratic) *quadratic = light->atten_quad;
if (constant) *constant = pd->atten_const;
if (linear) *linear = pd->atten_linear;
if (quadratic) *quadratic = pd->atten_quad;
}
EAPI void
evas_3d_light_attenuation_enable_set(Evas_3D_Light *light, Eina_Bool enable)
EOLIAN static void
_eo_evas_3d_light_attenuation_enable_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Eina_Bool enable)
{
if (light->enable_attenuation != enable)
if (pd->enable_attenuation != enable)
{
light->enable_attenuation = enable;
evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL);
pd->enable_attenuation = enable;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL);
}
}
EAPI Eina_Bool
evas_3d_light_attenuation_enable_get(const Evas_3D_Light *light)
EOLIAN static Eina_Bool
_eo_evas_3d_light_attenuation_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd)
{
return light->enable_attenuation;
return pd->enable_attenuation;
}
#include "canvas/evas_3d_light.eo.c"

View File

@ -0,0 +1,264 @@
class EO_Evas_3D_LIGHT (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_light;
data: Evas_3D_Light_Data;
properties {
directional {
set {
/*@
Set the directional flag of the given light.
Directional light is a type of light which is infinitely far away with no
attenuation. The light direction is determined by the containing node's
forward vector (negative Z-axis).
By default, directional is not enabled.
@see evas_3d_node_look_at_set()
@ingroup Evas_3D_Light
*/
}
get {
/*@
Get the directional flag of the given light.
@see evas_3d_light_directional_set()
@ingroup Evas_3D_Light
*/
}
values {
Eina_Bool directional; /*@ Whether the light is directional (@c EINA_TRUE), or not (@c EINA_FALSE).*/
}
}
spot_exponent {
set {
/*@
Set the spot exponent of the given light.
Higher spot exponent means intensity at the center of the cone is relatively
stronger. Zero exponent means the light intensity is evenly distibuted. The
spot exponent has no effect when the light is not spot light (spot cutoff
angle is less than 180 degree).
Default spot exponent is 0.
@see evas_3d_light_spot_cutoff_set()
@ingroup Evas_3D_Light
*/
}
get {
/*@
Get the spot exponent of the given light.
@see evas_3d_light_spot_exponent_set()
@ingroup Evas_3D_Light
*/
}
values {
Evas_Real exponent; /*@ Spot exponent value..*/
}
}
spot_cutoff {
set {
/*@
Set the spot cutoff angle of the given light.
Only angle less than 180 degree will make it spot light, so that other spot
light attribute will take effect.
Default spot cutoff angle is 180.
@ingroup Evas_3D_Light
*/
}
get {
/*@
Get the spot cutoff angle of the given light.
@see evas_3d_light_spot_cutoff_set()
@ingroup Evas_3D_Light
*/
}
values {
Evas_Real cutoff; /*@ Cutoff angle in degree..*/
}
}
attenuation_enable {
set {
/*@
Set the attenuation enable flag of the given light.
By default, light attenuation is not enabled.
@see evas_3d_light_attenuation_set()
@ingroup Evas_3D_Light
*/
}
get {
/*@
Get the attenuation enable flag of the given light.
@see evas_3d_light_attenuation_enable_set()
@ingroup Evas_3D_Light
*/
}
values {
Eina_Bool enable; /*@ Whether to enable attenuation (@c EINA_TRUE), or not (@c EINA_FALSE)..*/
}
}
}
methods {
ambient_set {
/*@
Set the ambient color of the given light.
Default ambient color is (0.0, 0.0, 0.0, 1.0).
@ingroup Evas_3D_Light
*/
params {
@in Evas_Real r; /*@ Red component of the ambient color between [0.0, 1.0]. */
@in Evas_Real g; /*@ Green component of the ambient color between [0.0, 1.0]. */
@in Evas_Real b; /*@ Blue component of the ambient color between [0.0, 1.0]. */
@in Evas_Real a; /*@ Alpha component of the ambient color between [0.0, 1.0]. */
}
}
ambient_get {
/*@
Get the ambient color of the given light.
@see evas_3d_light_ambient_set()
@ingroup Evas_3D_Light
*/
const;
params {
@out Evas_Real r; /*@ Red component of the ambient color between [0.0, 1.0]. */
@out Evas_Real g; /*@ Green component of the ambient color between [0.0, 1.0]. */
@out Evas_Real b; /*@ Blue component of the ambient color between [0.0, 1.0]. */
@out Evas_Real a; /*@ Alpha component of the ambient color between [0.0, 1.0]. */
}
}
diffuse_set {
/*@
Set the diffuse color of the given light.
Default diffuse color is (1.0, 1.0, 1.0, 1.0).
@ingroup Evas_3D_Light
*/
params {
@in Evas_Real r; /*@ Red component of the diffuse color between [0.0, 1.0]. */
@in Evas_Real g; /*@ Green component of the diffuse color between [0.0, 1.0]. */
@in Evas_Real b; /*@ Blue component of the diffuse color between [0.0, 1.0]. */
@in Evas_Real a; /*@ Alpha component of the diffuse color between [0.0, 1.0]. */
}
}
diffuse_get {
/*@
Get the diffuse color of the given light.
@see evas_3d_light_diffuse_set()
@ingroup Evas_3D_Light
*/
const;
params {
@out Evas_Real r; /*@ Red component of the diffuse color between [0.0, 1.0]. */
@out Evas_Real g; /*@ Green component of the diffuse color between [0.0, 1.0]. */
@out Evas_Real b; /*@ Blue component of the diffuse color between [0.0, 1.0]. */
@out Evas_Real a; /*@ Alpha component of the diffuse color between [0.0, 1.0]. */
}
}
specular_set {
/*@
Set the specular color of the given light.
Default specular color is (1.0, 1.0, 1.0, 1.0).
@ingroup Evas_3D_Light
*/
params {
@in Evas_Real r; /*@ Red component of the specular color between [0.0, 1.0]. */
@in Evas_Real g; /*@ Green component of the specular color between [0.0, 1.0]. */
@in Evas_Real b; /*@ Blue component of the specular color between [0.0, 1.0]. */
@in Evas_Real a; /*@ Alpha component of the specular color between [0.0, 1.0]. */
}
}
specular_get {
/*@
Get the specular color of the given light.
@see evas_3d_light_specular_set()
@ingroup Evas_3D_Light
*/
const;
params {
@out Evas_Real r; /*@ Red component of the specular color between [0.0, 1.0]. */
@out Evas_Real g; /*@ Green component of the specular color between [0.0, 1.0]. */
@out Evas_Real b; /*@ Blue component of the specular color between [0.0, 1.0]. */
@out Evas_Real a; /*@ Alpha component of the specular color between [0.0, 1.0]. */
}
}
attenuation_set {
/*@
Set the attenuation of the given light.
Light attenuation has no effect with directional light. And the attenuation
should be enabled first to take effect. The attenuation factor is calculated
as follows.
atten = 1.0 / constant + linear * distance + quadratic * distance * distance
Default attenuation is constant = 1.0, linear = 0.0, quadratic = 0.0.
@see evas_3d_light_attenuation_enable_set()
@ingroup Evas_3D_Light
*/
params {
@in Evas_Real constant; /*@ Constant attenuation term..*/
@in Evas_Real linear; /*@ Linear attenuation term..*/
@in Evas_Real quadratic; /*@ Quadratic attenuation term..*/
}
}
attenuation_get {
/*@
Get the attenuation of the given light.
@see evas_3d_light_attenuation_set()
@ingroup Evas_3D_Light
*/
const;
params {
@out Evas_Real constant; /*@ Constant attenuation term..*/
@out Evas_Real linear; /*@ Linear attenuation term..*/
@out Evas_Real quadratic; /*@ Quadratic attenuation term..*/
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

View File

@ -6,11 +6,15 @@
#include "evas_common_private.h"
#include "evas_private.h"
#include "Eo.h"
#define MY_CLASS EO_EVAS_3D_MATERIAL_CLASS
static void
_material_free(Evas_3D_Object *obj)
{
int i;
Evas_3D_Material *material = (Evas_3D_Material *)obj;
Evas_3D_Material_Data *material = (Evas_3D_Material_Data *)obj;
if (material->meshes)
eina_hash_free(material->meshes);
@ -19,12 +23,14 @@ _material_free(Evas_3D_Object *obj)
{
if (material->attribs[i].texture)
{
evas_3d_texture_material_del(material->attribs[i].texture, material);
evas_3d_object_unreference(&material->attribs[i].texture->base);
//@FIXME
//evas_3d_texture_material_del(material->attribs[i].texture, material);
Evas_3D_Texture_Data *pd = eo_data_scope_get(material->attribs[i].texture, EO_EVAS_3D_TEXTURE_CLASS);
evas_3d_object_unreference(&pd->base);
}
}
free(material);
//free(material);
}
static Eina_Bool
@ -32,7 +38,8 @@ _material_mesh_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_3D_Mesh *m = *(Evas_3D_Mesh **)key;
evas_3d_object_change(&m->base, EVAS_3D_STATE_MESH_MATERIAL, (Evas_3D_Object *)fdata);
Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(m, EO_EVAS_3D_MESH_CLASS);
evas_3d_object_change(&pdmesh->base, EVAS_3D_STATE_MESH_MATERIAL, (Evas_3D_Object *)fdata);
return EINA_TRUE;
}
@ -40,7 +47,7 @@ static void
_material_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED,
Evas_3D_Object *ref EINA_UNUSED)
{
Evas_3D_Material *material = (Evas_3D_Material *)obj;
Evas_3D_Material_Data *material = (Evas_3D_Material_Data *)obj;
if (material->meshes)
eina_hash_foreach(material->meshes, _material_mesh_change_notify, obj);
@ -50,14 +57,17 @@ static void
_material_update(Evas_3D_Object *obj)
{
int i;
Evas_3D_Material *material = (Evas_3D_Material *)obj;
Evas_3D_Material_Data *material = (Evas_3D_Material_Data *)obj;
for (i = 0; i < EVAS_3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (material->attribs[i].enable)
{
if (material->attribs[i].texture)
evas_3d_object_update(&material->attribs[i].texture->base);
{
Evas_3D_Texture_Data *pd = eo_data_scope_get(material->attribs[i].texture, EO_EVAS_3D_TEXTURE_CLASS);
evas_3d_object_update(&pd->base);
}
}
}
}
@ -73,149 +83,148 @@ void
evas_3d_material_mesh_add(Evas_3D_Material *material, Evas_3D_Mesh *mesh)
{
int count = 0;
Evas_3D_Material_Data *pd = eo_data_scope_get(material, MY_CLASS);
if (material->meshes == NULL)
if (pd->meshes == NULL)
{
material->meshes = eina_hash_pointer_new(NULL);
pd->meshes = eina_hash_pointer_new(NULL);
if (material->meshes == NULL)
if (pd->meshes == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)eina_hash_find(material->meshes, &mesh);
count = (int)eina_hash_find(pd->meshes, &mesh);
eina_hash_set(material->meshes, &mesh, (const void *)(count + 1));
eina_hash_set(pd->meshes, &mesh, (const void *)(count + 1));
}
void
evas_3d_material_mesh_del(Evas_3D_Material *material, Evas_3D_Mesh *mesh)
{
int count = 0;
Evas_3D_Material_Data *pd = eo_data_scope_get(material, MY_CLASS);
if (material->meshes == NULL)
if (pd->meshes == NULL)
{
ERR("No mesh to delete.");
return;
}
count = (int)eina_hash_find(material->meshes, &mesh);
count = (int)eina_hash_find(pd->meshes, &mesh);
if (count == 1)
eina_hash_del(material->meshes, &mesh, NULL);
eina_hash_del(pd->meshes, &mesh, NULL);
else
eina_hash_set(material->meshes, &mesh, (const void *)(count - 1));
eina_hash_set(pd->meshes, &mesh, (const void *)(count - 1));
}
Evas_3D_Material *
evas_3d_material_new(Evas *e)
{
Evas_3D_Material *material = NULL;
material = (Evas_3D_Material *)calloc(1, sizeof(Evas_3D_Material));
if (material == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
evas_3d_object_init(&material->base, e, EVAS_3D_OBJECT_TYPE_MATERIAL, &material_func);
evas_color_set(&material->attribs[EVAS_3D_MATERIAL_AMBIENT].color, 0.2, 0.2, 0.2, 1.0);
evas_color_set(&material->attribs[EVAS_3D_MATERIAL_DIFFUSE].color, 0.8, 0.8, 0.8, 1.0);
evas_color_set(&material->attribs[EVAS_3D_MATERIAL_SPECULAR].color, 1.0, 1.0, 1.0, 1.0);
evas_color_set(&material->attribs[EVAS_3D_MATERIAL_EMISSION].color, 0.0, 0.0, 0.0, 1.0);
material->shininess = 150.0;
return material;
}
EAPI Evas_3D_Material *
evas_3d_material_add(Evas *e)
{
return evas_3d_material_new(e);
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Object *eo_obj = eo_add(MY_CLASS, e);
eo_unref(eo_obj);
return eo_obj;
}
EAPI void
evas_3d_material_del(Evas_3D_Material *material)
EOLIAN static void
_eo_evas_3d_material_eo_base_constructor(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd)
{
evas_3d_object_unreference(&material->base);
Eo *e;
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, e = eo_parent_get());
evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_MATERIAL, &material_func);
evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_AMBIENT].color, 0.2, 0.2, 0.2, 1.0);
evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_DIFFUSE].color, 0.8, 0.8, 0.8, 1.0);
evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_SPECULAR].color, 1.0, 1.0, 1.0, 1.0);
evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_EMISSION].color, 0.0, 0.0, 0.0, 1.0);
pd->shininess = 150.0;
}
EAPI Evas *
evas_3d_material_evas_get(const Evas_3D_Material *material)
EOLIAN static void
_eo_evas_3d_material_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd)
{
return material->base.evas;
evas_3d_object_unreference(&pd->base);
}
EAPI void
evas_3d_material_enable_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib,
Eina_Bool enable)
EOLIAN static Evas *
_eo_evas_3d_material_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd)
{
material->attribs[attrib].enable = enable;
return pd->base.evas;
}
EAPI Eina_Bool
evas_3d_material_enable_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib)
EOLIAN static void
_eo_evas_3d_material_enable_set(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Eina_Bool enable)
{
return material->attribs[attrib].enable;
pd->attribs[attrib].enable = enable;
}
EAPI void
evas_3d_material_color_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib,
Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
EOLIAN static Eina_Bool
_eo_evas_3d_material_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib)
{
evas_color_set(&material->attribs[attrib].color, r, g, b, a);
evas_3d_object_change(&material->base, EVAS_3D_STATE_MATERIAL_COLOR, NULL);
return pd->attribs[attrib].enable;
}
EAPI void
evas_3d_material_color_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib,
Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
EOLIAN static void
_eo_evas_3d_material_color_set(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
if (r) *r = material->attribs[attrib].color.r;
if (g) *g = material->attribs[attrib].color.g;
if (b) *b = material->attribs[attrib].color.b;
if (a) *a = material->attribs[attrib].color.a;
evas_color_set(&pd->attribs[attrib].color, r, g, b, a);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MATERIAL_COLOR, NULL);
}
EAPI void
evas_3d_material_shininess_set(Evas_3D_Material *material, Evas_Real shininess)
EOLIAN static void
_eo_evas_3d_material_color_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
{
material->shininess = shininess;
if (r) *r = pd->attribs[attrib].color.r;
if (g) *g = pd->attribs[attrib].color.g;
if (b) *b = pd->attribs[attrib].color.b;
if (a) *a = pd->attribs[attrib].color.a;
}
EAPI Evas_Real
evas_3d_material_shininess_get(const Evas_3D_Material *material)
EOLIAN static void
_eo_evas_3d_material_shininess_set(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_Real shininess)
{
return material->shininess;
pd->shininess = shininess;
}
EAPI void
evas_3d_material_texture_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib,
Evas_3D_Texture *texture)
EOLIAN static Evas_Real
_eo_evas_3d_material_shininess_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd)
{
if (material->attribs[attrib].texture != texture)
return pd->shininess;
}
EOLIAN static void
_eo_evas_3d_material_texture_set(Eo *obj, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Evas_3D_Texture *texture)
{
if (pd->attribs[attrib].texture != texture)
{
if (material->attribs[attrib].texture)
if (pd->attribs[attrib].texture)
{
evas_3d_texture_material_del(material->attribs[attrib].texture, material);
evas_3d_object_unreference(&material->attribs[attrib].texture->base);
evas_3d_texture_material_del(pd->attribs[attrib].texture, obj);
Evas_3D_Texture_Data *pdt = eo_data_scope_get(pd->attribs[attrib].texture, EO_EVAS_3D_TEXTURE_CLASS);
evas_3d_object_unreference(&pdt->base);
}
material->attribs[attrib].texture = texture;
evas_3d_texture_material_add(texture, material);
evas_3d_object_reference(&texture->base);
pd->attribs[attrib].texture = texture;
evas_3d_texture_material_add(texture, obj);
Evas_3D_Texture_Data *pdt = eo_data_scope_get(texture, EO_EVAS_3D_TEXTURE_CLASS);
evas_3d_object_reference(&pdt->base);
}
evas_3d_object_change(&material->base, EVAS_3D_STATE_MATERIAL_TEXTURE, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MATERIAL_TEXTURE, NULL);
}
EAPI Evas_3D_Texture *
evas_3d_material_texture_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib)
EOLIAN static Evas_3D_Texture *
_eo_evas_3d_material_texture_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib)
{
return material->attribs[attrib].texture;
return pd->attribs[attrib].texture;
}
#include "canvas/evas_3d_material.eo.c"

View File

@ -0,0 +1,156 @@
class EO_Evas_3D_Material (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_material;
data: Evas_3D_Material_Data;
methods {
color_set {
/*
Set the material attribute color of the given material.
Material color is used also when texture map is enabled. The colors will be
modulated (multiplied). To controll the color contribution of a material
attribute, use gray color. Setting color value for normal attribute has no
effect.
Default color is as follows.
Ambient : (0.2, 0.2, 0.2, 1.0)
Diffuse : (0.8, 0.8, 0.8, 1.0)
Specular : (1.0, 1.0, 1.0, 1.0)
Emission : (0.0, 0.0, 0.0, 1.0)
Normal : Not used
@ingroup Evas_3D_Material
*/
params {
@in Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */
@in Evas_Real r; /*@ Red component of the color. */
@in Evas_Real g; /*@ Green component of the color. */
@in Evas_Real b; /*@ Blue component of the color. */
@in Evas_Real a; /*@ Alpha component of the color. */
}
}
color_get {
/*
Get the material attribute color of the given material.
@see evas_3d_material_color_set()
@ingroup Evas_3D_Material
*/
const;
params {
@in Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */
@out Evas_Real r; /*@ Pointer to receive red component of the color. */
@out Evas_Real g; /*@ Pointer to receive green component of the color. */
@out Evas_Real b; /*@ Pointer to receive blue component of the color. */
@out Evas_Real a; /*@ Pointer to receive alpha component of the color. */
}
}
}
properties {
enable {
set {
/*
Set the material attribute enable flag of the given material.
You might want to disable some material reflection contribution. For
example,Emission attribute is rarely used. Disabling unused attributes
might help the shading less complex so that can get speed up.
By default, diffuse and specular is enabled.
@ingroup Evas_3D_Material
*/
}
get {
/*
Get the material attribute enable flag of the given material.
@see evas_3d_material_enable_set()
@return @c EINA_TRUE if enabled, or @c EINA_FALSE if not.
@ingroup Evas_3D_Material
*/
}
keys {
Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */
}
values {
Eina_Bool enable; /*@ Whether to enable the attribute (@c EINA_TRUE), or not (@c EINA_FALSE). */
}
}
shininess {
set {
/*
Set the shininess of the given material.
Shininess is only used when specular attribute is enabled. Higher shininess
value will make the object more shiny.
Default shininess value is 150.0.
@see evas_3d_material_enable_set()
@ingroup Evas_3D_Material
*/
}
get {
/*
Get the shininess of the given material.
@see evas_3d_material_shininess_set()
@return The shininess value.
@ingroup Evas_3D_Material
*/
}
values {
Evas_Real shininess; /*@ Shininess value. */
}
}
texture {
set {
/*@
Set the texture of the given material.
You have to enable the desired attribute first.
@see evas_3d_material_enable_set()
@ingroup Evas_3D_Material
*/
}
get {
/*
Get the texture of the given material.
@see evas_3d_material_texture_set()
@return The texture that is set to the given material attribute.
@ingroup Evas_3D_Material
*/
}
keys {
@in Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */
}
values {
Evas_3D_Texture *texture;
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

View File

@ -6,11 +6,14 @@
#include "evas_common_private.h"
#include "evas_private.h"
#include "Eo.h"
#define MY_CLASS EO_EVAS_3D_MESH_CLASS
static Evas_3D_Mesh_Frame *
evas_3d_mesh_frame_new(Evas_3D_Mesh *mesh)
{
Evas_3D_Mesh_Frame *frame = NULL;
frame = (Evas_3D_Mesh_Frame *)calloc(1, sizeof(Evas_3D_Mesh_Frame));
if (frame == NULL)
@ -33,7 +36,8 @@ evas_3d_mesh_frame_free(Evas_3D_Mesh_Frame *frame)
if (frame->material)
{
evas_3d_material_mesh_del(frame->material, frame->mesh);
evas_3d_object_unreference(&frame->material->base);
Evas_3D_Material_Data *pd = eo_data_scope_get(frame->material, EO_EVAS_3D_MATERIAL_CLASS);
evas_3d_object_unreference(&pd->base);
}
for (i = 0; i < EVAS_3D_VERTEX_ATTRIB_COUNT; i++)
@ -46,12 +50,12 @@ evas_3d_mesh_frame_free(Evas_3D_Mesh_Frame *frame)
}
static Evas_3D_Mesh_Frame *
evas_3d_mesh_frame_find(Evas_3D_Mesh *mesh, int frame)
evas_3d_mesh_frame_find(Evas_3D_Mesh_Data *pd, int frame)
{
Eina_List *l;
Evas_3D_Mesh_Frame *f;
EINA_LIST_FOREACH(mesh->frames, l, f)
EINA_LIST_FOREACH(pd->frames, l, f)
{
if (f->frame == frame)
return f;
@ -61,50 +65,50 @@ evas_3d_mesh_frame_find(Evas_3D_Mesh *mesh, int frame)
}
static inline void
_mesh_init(Evas_3D_Mesh *mesh)
_mesh_init(Evas_3D_Mesh_Data *pd)
{
mesh->vertex_count = 0;
mesh->frame_count = 0;
mesh->frames = NULL;
pd->vertex_count = 0;
pd->frame_count = 0;
pd->frames = NULL;
mesh->index_format = EVAS_3D_INDEX_FORMAT_NONE;
mesh->index_count = 0;
mesh->indices = NULL;
mesh->owns_indices = EINA_FALSE;
mesh->assembly = EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES;
pd->index_format = EVAS_3D_INDEX_FORMAT_NONE;
pd->index_count = 0;
pd->indices = NULL;
pd->owns_indices = EINA_FALSE;
pd->assembly = EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES;
mesh->nodes = NULL;
pd->nodes = NULL;
}
static inline void
_mesh_fini(Evas_3D_Mesh *mesh)
_mesh_fini(Evas_3D_Mesh_Data *pd)
{
Eina_List *l;
Evas_3D_Mesh_Frame *f;
if (mesh->frames)
if (pd->frames)
{
EINA_LIST_FOREACH(mesh->frames, l, f)
EINA_LIST_FOREACH(pd->frames, l, f)
{
evas_3d_mesh_frame_free(f);
}
eina_list_free(mesh->frames);
eina_list_free(pd->frames);
}
if (mesh->indices && mesh->owns_indices)
free(mesh->indices);
if (pd->indices && pd->owns_indices)
free(pd->indices);
if (mesh->nodes)
eina_hash_free(mesh->nodes);
if (pd->nodes)
eina_hash_free(pd->nodes);
}
static void
_mesh_free(Evas_3D_Object *obj)
{
Evas_3D_Mesh *mesh = (Evas_3D_Mesh *)obj;
Evas_3D_Mesh_Data *mesh = (Evas_3D_Mesh_Data *)obj;
_mesh_fini(mesh);
free(mesh);
//ree(mesh);
}
static Eina_Bool
@ -112,7 +116,8 @@ _mesh_node_geometry_change_notify(const Eina_Hash *hash EINA_UNUSED, const void
void *data EINA_UNUSED, void *fdata)
{
Evas_3D_Node *n = *(Evas_3D_Node **)key;
evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, (Evas_3D_Object *)fdata);
Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, (Evas_3D_Object *)fdata);
return EINA_TRUE;
}
@ -121,14 +126,15 @@ _mesh_node_material_change_notify(const Eina_Hash *hash EINA_UNUSED, const void
void *data EINA_UNUSED, void *fdata)
{
Evas_3D_Node *n = *(Evas_3D_Node **)key;
evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, (Evas_3D_Object *)fdata);
Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, (Evas_3D_Object *)fdata);
return EINA_TRUE;
}
static void
_mesh_change(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref EINA_UNUSED)
{
Evas_3D_Mesh *mesh = (Evas_3D_Mesh *)obj;
Evas_3D_Mesh_Data *mesh = (Evas_3D_Mesh_Data *)obj;
if (state == EVAS_3D_STATE_MESH_MATERIAL)
{
@ -147,12 +153,15 @@ _mesh_update(Evas_3D_Object *obj)
{
Eina_List *l;
Evas_3D_Mesh_Frame *f;
Evas_3D_Mesh *mesh = (Evas_3D_Mesh *)obj;
Evas_3D_Mesh_Data *mesh = (Evas_3D_Mesh_Data *)obj;
EINA_LIST_FOREACH(mesh->frames, l, f)
{
if (f->material)
evas_3d_object_update(&f->material->base);
{
Evas_3D_Material_Data *pdm = eo_data_scope_get(f->material, EO_EVAS_3D_MATERIAL_CLASS);
evas_3d_object_update(&pdm->base);
}
}
}
@ -167,111 +176,109 @@ void
evas_3d_mesh_node_add(Evas_3D_Mesh *mesh, Evas_3D_Node *node)
{
int count = 0;
if (mesh->nodes == NULL)
Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, MY_CLASS);
if (pd->nodes == NULL)
{
mesh->nodes = eina_hash_pointer_new(NULL);
pd->nodes = eina_hash_pointer_new(NULL);
if (mesh->nodes == NULL)
if (pd->nodes == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)eina_hash_find(mesh->nodes, &node);
count = (int)eina_hash_find(pd->nodes, &node);
eina_hash_set(mesh->nodes, &node, (const void *)(count + 1));
eina_hash_set(pd->nodes, &node, (const void *)(count + 1));
}
void
evas_3d_mesh_node_del(Evas_3D_Mesh *mesh, Evas_3D_Node *node)
{
int count = 0;
if (mesh->nodes == NULL)
Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, MY_CLASS);
if (pd->nodes == NULL)
{
ERR("No node to delete.");
return;
}
count = (int)eina_hash_find(mesh->nodes, &node);
count = (int)eina_hash_find(pd->nodes, &node);
if (count == 1)
eina_hash_del(mesh->nodes, &node, NULL);
eina_hash_del(pd->nodes, &node, NULL);
else
eina_hash_set(mesh->nodes, &node, (const void *)(count - 1));
eina_hash_set(pd->nodes, &node, (const void *)(count - 1));
}
Evas_3D_Mesh *
evas_3d_mesh_new(Evas *e)
{
Evas_3D_Mesh *mesh = NULL;
mesh = (Evas_3D_Mesh *)malloc(sizeof(Evas_3D_Mesh));
if (mesh == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
evas_3d_object_init(&mesh->base, e, EVAS_3D_OBJECT_TYPE_MESH, &mesh_func);
_mesh_init(mesh);
return mesh;
}
EAPI Evas_3D_Mesh *
evas_3d_mesh_add(Evas *e)
{
return evas_3d_mesh_new(e);
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Object *eo_obj = eo_add(MY_CLASS, e);
eo_unref(eo_obj);
return eo_obj;
}
EAPI void
evas_3d_mesh_del(Evas_3D_Mesh *mesh)
EOLIAN static void
_eo_evas_3d_mesh_eo_base_constructor(Eo *obj, Evas_3D_Mesh_Data *pd)
{
evas_3d_object_unreference(&mesh->base);
Eo *e;
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, e = eo_parent_get());
evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_MESH, &mesh_func);
_mesh_init(pd);
}
EAPI Evas *
evas_3d_mesh_evas_get(const Evas_3D_Mesh *mesh)
EOLIAN static void
_eo_evas_3d_mesh_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
return mesh->base.evas;
evas_3d_object_unreference(&pd->base);
}
EAPI void
evas_3d_mesh_shade_mode_set(Evas_3D_Mesh *mesh, Evas_3D_Shade_Mode mode)
EOLIAN static Evas *
_eo_evas_3d_mesh_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
if (mesh->shade_mode != mode)
return pd->base.evas;
}
EOLIAN static void
_eo_evas_3d_mesh_shade_mode_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Shade_Mode mode)
{
if (pd->shade_mode != mode)
{
mesh->shade_mode = mode;
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_SHADE_MODE, NULL);
pd->shade_mode = mode;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_SHADE_MODE, NULL);
}
}
EAPI Evas_3D_Shade_Mode
evas_3d_mesh_shade_mode_get(const Evas_3D_Mesh *mesh)
EOLIAN static Evas_3D_Shade_Mode
_eo_evas_3d_mesh_shade_mode_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
return mesh->shade_mode;
return pd->shade_mode;
}
EAPI void
evas_3d_mesh_vertex_count_set(Evas_3D_Mesh *mesh, unsigned int count)
EOLIAN static void
_eo_evas_3d_mesh_vertex_count_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, unsigned int count)
{
mesh->vertex_count = count;
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_COUNT, NULL);
pd->vertex_count = count;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_COUNT, NULL);
}
EAPI int
evas_3d_mesh_vertex_count_get(const Evas_3D_Mesh *mesh)
EOLIAN static int
_eo_evas_3d_mesh_vertex_count_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
return mesh->vertex_count;
return pd->vertex_count;
}
EAPI void
evas_3d_mesh_frame_add(Evas_3D_Mesh *mesh, int frame)
EOLIAN static void
_eo_evas_3d_mesh_frame_add(Eo *obj, Evas_3D_Mesh_Data *pd, int frame)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f != NULL)
{
@ -279,20 +286,20 @@ evas_3d_mesh_frame_add(Evas_3D_Mesh *mesh, int frame)
return;
}
f = evas_3d_mesh_frame_new(mesh);
f = evas_3d_mesh_frame_new(obj);
if (f == NULL)
return;
f->frame = frame;
mesh->frames = eina_list_append(mesh->frames, f);
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_FRAME, NULL);
pd->frames = eina_list_append(pd->frames, f);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_FRAME, NULL);
}
EAPI void
evas_3d_mesh_frame_del(Evas_3D_Mesh *mesh, int frame)
EOLIAN static void
_eo_evas_3d_mesh_frame_del(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f == NULL)
{
@ -300,15 +307,15 @@ evas_3d_mesh_frame_del(Evas_3D_Mesh *mesh, int frame)
return;
}
mesh->frames = eina_list_remove(mesh->frames, f);
pd->frames = eina_list_remove(pd->frames, f);
evas_3d_mesh_frame_free(f);
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_FRAME, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_FRAME, NULL);
}
EAPI void
evas_3d_mesh_frame_material_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Material *material)
EOLIAN static void
_eo_evas_3d_mesh_frame_material_set(Eo *obj, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Material *material)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f == NULL)
{
@ -321,20 +328,22 @@ evas_3d_mesh_frame_material_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Material
if (f->material)
{
evas_3d_material_mesh_del(f->material, mesh);
evas_3d_object_unreference(&f->material->base);
evas_3d_material_mesh_del(f->material, obj);
Evas_3D_Material_Data *pdm = eo_data_scope_get(f->material, EO_EVAS_3D_MATERIAL_CLASS);
evas_3d_object_unreference(&pdm->base);
}
f->material = material;
evas_3d_object_reference(&material->base);
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_MATERIAL, NULL);
evas_3d_material_mesh_add(material, mesh);
Evas_3D_Material_Data *pdm = eo_data_scope_get(material, EO_EVAS_3D_MATERIAL_CLASS);
evas_3d_object_reference(&pdm->base);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_MATERIAL, NULL);
evas_3d_material_mesh_add(material, obj);
}
EAPI Evas_3D_Material *
evas_3d_mesh_frame_material_get(const Evas_3D_Mesh *mesh, int frame)
EOLIAN static Evas_3D_Material *
_eo_evas_3d_mesh_frame_material_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find((Evas_3D_Mesh *)mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f == NULL)
{
@ -345,11 +354,10 @@ evas_3d_mesh_frame_material_get(const Evas_3D_Mesh *mesh, int frame)
return f->material;
}
EAPI void
evas_3d_mesh_frame_vertex_data_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib,
int stride, const void *data)
EOLIAN static void
_eo_evas_3d_mesh_frame_vertex_data_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
int element_count;
if (f == NULL)
@ -393,15 +401,13 @@ evas_3d_mesh_frame_vertex_data_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex
f->vertices[attrib].owns_data = EINA_FALSE;
f->vertices[attrib].element_count = element_count;
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL);
}
EAPI void
evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
Evas_3D_Vertex_Attrib attrib,
int stride, const void *data)
EOLIAN static void
_eo_evas_3d_mesh_frame_vertex_data_copy_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
Evas_3D_Vertex_Buffer *vb;
int size, element_count;
@ -438,7 +444,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
}
vb = &f->vertices[attrib];
size = element_count * sizeof(float) * mesh->vertex_count;
size = element_count * sizeof(float) * pd->vertex_count;
if (!vb->owns_data || vb->size < size)
{
@ -480,7 +486,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
if (element_count == 1)
{
for (i = 0; i <mesh->vertex_count; i++)
for (i = 0; i <pd->vertex_count; i++)
{
*dst++ = src[0];
@ -489,7 +495,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
}
else if (element_count == 2)
{
for (i = 0; i <mesh->vertex_count; i++)
for (i = 0; i <pd->vertex_count; i++)
{
*dst++ = src[0];
*dst++ = src[1];
@ -499,7 +505,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
}
else if (element_count == 3)
{
for (i = 0; i <mesh->vertex_count; i++)
for (i = 0; i <pd->vertex_count; i++)
{
*dst++ = src[0];
*dst++ = src[1];
@ -510,7 +516,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
}
else if (element_count == 4)
{
for (i = 0; i <mesh->vertex_count; i++)
for (i = 0; i <pd->vertex_count; i++)
{
*dst++ = src[0];
*dst++ = src[1];
@ -522,13 +528,13 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame,
}
}
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL);
}
EAPI void *
evas_3d_mesh_frame_vertex_data_map(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib)
EOLIAN static void *
_eo_evas_3d_mesh_frame_vertex_data_map(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f == NULL)
{
@ -546,10 +552,10 @@ evas_3d_mesh_frame_vertex_data_map(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex
return f->vertices[attrib].data;
}
EAPI void
evas_3d_mesh_frame_vertex_data_unmap(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib)
EOLIAN static void
_eo_evas_3d_mesh_frame_vertex_data_unmap(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f == NULL)
{
@ -566,11 +572,10 @@ evas_3d_mesh_frame_vertex_data_unmap(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vert
f->vertices[attrib].mapped = EINA_FALSE;
}
EAPI int
evas_3d_mesh_frame_vertex_stride_get(const Evas_3D_Mesh *mesh, int frame,
Evas_3D_Vertex_Attrib attrib)
EOLIAN static int
_eo_evas_3d_mesh_frame_vertex_stride_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib)
{
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find((Evas_3D_Mesh *)mesh, frame);
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame);
if (f == NULL)
{
@ -581,24 +586,23 @@ evas_3d_mesh_frame_vertex_stride_get(const Evas_3D_Mesh *mesh, int frame,
return f->vertices[attrib].stride;
}
EAPI void
evas_3d_mesh_index_data_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count,
const void *indices)
EOLIAN static void
_eo_evas_3d_mesh_index_data_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Index_Format format, int count, const void *indices)
{
if (mesh->owns_indices && mesh->indices)
free(mesh->indices);
if (pd->owns_indices && pd->indices)
free(pd->indices);
mesh->index_format = format;
mesh->index_count = count;
mesh->index_size = 0;
mesh->indices = (void *)indices;
mesh->owns_indices = EINA_FALSE;
pd->index_format = format;
pd->index_count = count;
pd->index_size = 0;
pd->indices = (void *)indices;
pd->owns_indices = EINA_FALSE;
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_INDEX_DATA, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_INDEX_DATA, NULL);
}
EAPI void
evas_3d_mesh_index_data_copy_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, const void *indices)
EOLIAN static void
_eo_evas_3d_mesh_index_data_copy_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Index_Format format, int count, const void *indices)
{
int size;
@ -616,86 +620,85 @@ evas_3d_mesh_index_data_copy_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format
return;
}
if (!mesh->owns_indices || mesh->index_size < size)
if (!pd->owns_indices || pd->index_size < size)
{
if (mesh->owns_indices && mesh->indices)
free(mesh->indices);
if (pd->owns_indices && pd->indices)
free(pd->indices);
mesh->indices = malloc(size);
pd->indices = malloc(size);
if (mesh->indices == NULL)
if (pd->indices == NULL)
{
ERR("Failed to allocate memory.");
return;
}
mesh->index_size = size;
mesh->owns_indices = EINA_TRUE;
pd->index_size = size;
pd->owns_indices = EINA_TRUE;
}
mesh->index_format = format;
mesh->index_count = count;
pd->index_format = format;
pd->index_count = count;
if (indices)
memcpy(mesh->indices, indices, size);
memcpy(pd->indices, indices, size);
}
EAPI Evas_3D_Index_Format
evas_3d_mesh_index_format_get(const Evas_3D_Mesh *mesh)
EOLIAN static Evas_3D_Index_Format
_eo_evas_3d_mesh_index_format_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
return mesh->index_format;
return pd->index_format;
}
EAPI int
evas_3d_mesh_index_count_get(const Evas_3D_Mesh *mesh)
EOLIAN static int
_eo_evas_3d_mesh_index_count_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
return mesh->index_count;
return pd->index_count;
}
EAPI void *
evas_3d_mesh_index_data_map(Evas_3D_Mesh *mesh)
EOLIAN static void *
_eo_evas_3d_mesh_index_data_map(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
if (mesh->index_mapped)
if (pd->index_mapped)
{
ERR("Try to map alreadly mapped data.");
return NULL;
}
mesh->index_mapped = EINA_TRUE;
return mesh->indices;
pd->index_mapped = EINA_TRUE;
return pd->indices;
}
EAPI void
evas_3d_mesh_index_data_unmap(Evas_3D_Mesh *mesh)
EOLIAN static void
_eo_evas_3d_mesh_index_data_unmap(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
if (!mesh->index_mapped)
if (!pd->index_mapped)
{
ERR("Try to unmap data which is not mapped yet.");
return;
}
mesh->index_mapped = EINA_FALSE;
pd->index_mapped = EINA_FALSE;
}
EAPI void
evas_3d_mesh_vertex_assembly_set(Evas_3D_Mesh *mesh, Evas_3D_Vertex_Assembly assembly)
EOLIAN static void
_eo_evas_3d_mesh_vertex_assembly_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Vertex_Assembly assembly)
{
mesh->assembly = assembly;
evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY, NULL);
pd->assembly = assembly;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY, NULL);
}
EAPI Evas_3D_Vertex_Assembly
evas_3d_mesh_vertex_assembly_get(const Evas_3D_Mesh *mesh)
EOLIAN static Evas_3D_Vertex_Assembly
_eo_evas_3d_mesh_vertex_assembly_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd)
{
return mesh->assembly;
return pd->assembly;
}
EAPI void
evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type,
const char *file, const char *key EINA_UNUSED)
EOLIAN static void
_eo_evas_3d_mesh_file_set(Eo *obj, Evas_3D_Mesh_Data *pd, Evas_3D_Mesh_File_Type type, const char *file, const char *key EINA_UNUSED)
{
_mesh_fini(mesh);
_mesh_init(mesh);
_mesh_fini(pd);
_mesh_init(pd);
if (file == NULL)
return;
@ -703,7 +706,7 @@ evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type,
switch (type)
{
case EVAS_3D_MESH_FILE_TYPE_MD2:
evas_3d_mesh_file_md2_set(mesh, file);
evas_3d_mesh_file_md2_set(obj, file);
break;
default:
ERR("Invalid mesh file type.");
@ -712,7 +715,7 @@ evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type,
}
static inline void
_mesh_frame_find(Evas_3D_Mesh *mesh, int frame,
_mesh_frame_find(Evas_3D_Mesh_Data *mesh, int frame,
Eina_List **l, Eina_List **r)
{
Eina_List *left, *right;
@ -760,8 +763,8 @@ evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame,
{
Eina_List *l, *r;
const Evas_3D_Mesh_Frame *f0 = NULL, *f1 = NULL;
_mesh_frame_find(mesh, frame, &l, &r);
Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, MY_CLASS);
_mesh_frame_find(pd, frame, &l, &r);
while (l)
{
@ -826,3 +829,5 @@ evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame,
*weight = 1.0;
}
}
#include "canvas/evas_3d_mesh.eo.c"

View File

@ -0,0 +1,388 @@
class EO_Evas_3D_Mesh (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_mesh;
data: Evas_3D_Mesh_Data;
methods {
file_set {
/**
* Load mesh data from file.
*
* Loading a mesh from existing file is supported. Currently, only MD2 file
* format is supported.
*
* @ingroup Evas_3D_Mesh
*/
params {
@in Evas_3D_Mesh_File_Type type; /*@ The type of the mesh file. */
@in const char *file; /*@ Path to the mesh file. */
@in const char *key; /*@ Key in the mesh file. */
}
}
frame_vertex_data_set {
/*@
Set the vertex data of the key frame of the given mesh.
This function make evas read from the given buffer whenever it requires.
If you want to release the buffer after calling this functions, use
evas_3d_mesh_frame_vertex_data_copy_set() instead.
After setting the vertex data, further modifications should be protected
by map/unmap pair.
@see evas_3d_mesh_frame_vertex_data_copy_set()
@see evas_3d_mesh_frame_vertex_data_map()
@see evas_3d_mesh_frame_vertex_data_unmap()
@ingroup Evas_3D_Mesh
*/
params {
@in int frame; /*@ The number of the key frame. */
@in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */
@in int stride; /*@ Stride to go to the next vertex (in bytes). */
@in const void *data; /*@ Pointer to the vertex data buffer. */
}
}
frame_vertex_data_copy_set {
/*@
Set the vertex data of the key frame of the given mesh by copying from a buffer.
This function allocates internal vertex buffer and copy from the given
buffer. So you can release the buffer. If you want to modify the vertex data
use evas_3d_mesh_frame_vertex_data_map(). After finishing the modifications,
you should call evas_3d_mesh_frame_vertex_data_unmap().
@see evas_3d_mesh_frame_vertex_data_set()
@see evas_3d_mesh_frame_vertex_data_map()
@see evas_3d_mesh_frame_vertex_data_unmap()
@ingroup Evas_3D_Mesh
*/
params {
@in int frame; /*@ The number of the key frame. */
@in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */
@in int stride; /*@ Stride to go to the next vertex (in bytes). */
@in const void *data; /*@ Pointer to the vertex data buffer. */
}
}
frame_vertex_data_map {
/*@
Map the vertex buffer of the key frame of the given mesh.
After manipulating the mapped buffer, evas_3d_mesh_frame_vertex_data_unmap()
should be called to properly download the data to the engine. If the data
was set using evas_3d_mesh_frame_vertex_data_set(), pointer to the original
buffer will be returned. Otherwise, the returned pointer can differ every
time calling this function.
@see evas_3d_mesh_frame_vertex_data_unmap()
@return Starting address of the mapped vertex buffer.
@ingroup Evas_3D_Mesh
*/
return void *;
params {
@in int frame; /*@ The number of the key frame. */
@in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */
}
}
frame_vertex_data_unmap {
/*
Unmap the vertex buffer of the key frame of the given mesh.
@see evas_3d_mesh_frame_vertex_data_map()
@ingroup Evas_3D_Mesh
*/
params {
@in int frame; /*@ The number of the key frame. */
@in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */
}
}
frame_vertex_stride_get {
/*
Get the vertex buffer stride of the key frame of the given mesh.
This function returns valid stride only when the vertex buffer is mapped.
If the data was set with evas_3d_mesh_frame_vertex_data_set(), the original
stride will be returned unchanged.
@see evas_3d_mesh_frame_vertex_data_map()
@return Stride to go to the next vertex (in bytes).
@ingroup Evas_3D_Mesh
*/
const;
return int ;
params {
@in int frame; /*@ The number of the key frame. */
@in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */
}
}
index_data_set {
/*
Set the vertex index data of the given mesh.
When the index data is set, Evas 3D assembles vertices using the index data.
If you want to free the data buffer, use evas_3d_mesh_index_data_copy_set().
Further modifications should be made within map/unmap pair.
@see evas_3d_mesh_index_data_copy_set()
@see evas_3d_mesh_index_data_map()
@see evas_3d_mesh_index_data_unmap()
@ingroup Evas_3D_Mesh
*/
params {
@in Evas_3D_Index_Format format; /*@ Vertex index data format. */
@in int count; /*@ Vertex index count. */
@in const void *indices; /*@ Pointer to the index data. */
}
}
index_data_copy_set {
/*
Set the vertex index data of the given mesh by copying from a buffer.
This function allocates internal index buffer any copy data from the given
buffer. Futher modifications can be made within map/unmap pair.
@see evas_3d_mesh_index_data_set()
@ingroup Evas_3D_Mesh
*/
return void ;
params {
@in Evas_3D_Index_Format format; /*@ Vertex index data format. */
@in int count; /*@ Vertex index count. */
@in const void *indices; /*@ Pointer to the index data. */
}
}
index_format_get {
/*
Get the format of the index data of the given mesh.
Returns valid format only when the index buffer is mapped. First map the
index buffer and then query the properties of the mapped buffer. If the index
data was set by evas_3d_mesh_index_data_set(), the original format will be
returned. Otherwise the format can differ every time you call the
evas_3d_mesh_index_data_map() function.
@see evas_3d_mesh_index_data_map()
@return Format of the index data.
@ingroup Evas_3D_Mesh
*/
const;
return Evas_3D_Index_Format ;
}
index_count_get {
/*
Get the count of the index data of the given mesh.
This function returns the index count of the last called data_set function.
@see evas_3d_mesh_index_data_set()
@see evas_3d_mesh_index_data_copy_set()
@return Index data count.
@ingroup Evas_3D_Mesh
*/
const;
return int ;
}
index_data_map {
/*
Map the index buffer of the given mesh.
evas_3d_mesh_index_data_unmap() should be called after modifications. If the
data was set using evas_3d_mesh_index_data_set(), the original pointer will
be returned, otherwise, the returned pointer may differ every time you call
this function.
@see evas_3d_mesh_index_data_unmap()
@return Pointer to the mapped buffer.
@ingroup Evas_3D_Mesh
*/
return void * ;
}
index_data_unmap {
/*
Unmap the index buffer of the given mesh.
@see evas_3d_mesh_index_data_map()
@ingroup Evas_3D_Mesh
*/
}
frame_add {
/*
Add a key frame to the given mesh.
@param mesh The given mesh.
@param frame The number of the key frame to be added.
If specified frame is already exist, error message will be generated.
@ingroup Evas_3D_Mesh
*/
params {
@in int frame; /*@ The number of the key frame to be added. */
}
}
frame_del {
/*
Delete a key frame from the given mesh.
@param mesh The given mesh.
@param frame The number of the key frame to be deleted.
@see evas_3d_mesh_frame_add()
@ingroup Evas_3D_Mesh
*/
params {
@in int frame; /*@ The number of the key frame to be added. */
}
}
vertex_count_set {
/*@
Set the vertex count of the given mesh.
Each key frame should have same vertex count to be properly interpolated.
Key frames have their own vertex data and the data should have more vertices
than the mesh's vertex count.
Default vertex count is 0.
@ingroup Evas_3D_Mesh
*/
params {
@in unsigned int count; /*@ Vertex count.*/
}
}
vertex_count_get {
/*@
Get the vertex count of the given mesh.
@see evas_3d_mesh_vertex_count_set()
@ingroup Evas_3D_Mesh
*/
const;
return int;
}
}
properties {
shade_mode {
set {
/**
* Set the shade mode of the given mesh.
*
* Default shade mode is EVAS_3D_SHADE_MODE_VERTEX_COLOR.
*
* @ingroup Evas_3D_Mesh
*/
}
get {
/**
* Get the shade mode of the given mesh.
*
* @see eavs_3d_mesh_shade_mode_set()
*
* @ingroup Evas_3D_Mesh
*/
}
values {
Evas_3D_Shade_Mode mode; /*@ The shade mode.*/
}
}
frame_material {
set {
/**
Set the material of the key frame of the given mesh.
Setting different materials for each key frame is useful for doing animations
like GIF images or color changing animationas.
@ingroup Evas_3D_Mesh
*/
}
get {
/**
Get the material of the key frame of the given mesh.
@see evas_3d_mesh_frame_material_set()
@ingroup Evas_3D_Mesh
*/
}
keys {
int frame; /*@ The number of the key frame.*/
}
values {
Evas_3D_Material *material; /*@ The material to be set to the key frame.*/
}
}
vertex_assembly {
set {
/*
Set the vertex assembly of the given mesh.
Vertex assembly defines how the engine organizes vertices into geometric
primitives.
Default vertex assembly is EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES.
@ingroup Evas_3D_Mesh
*/
}
get {
/*
Get the vertex assembly of the given mesh.
@see evas_3d_mesh_vertex_assembly_set()
@return The vertex assembly.
@ingroup Evas_3D_Mesh
*/
}
values {
Evas_3D_Vertex_Assembly assembly; /*@ Vertex assembly.*/
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,548 @@
class EO_Evas_3D_Node (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_node;
data: Evas_3D_Node_Data;
constructors {
constructor {
/*@ Contructor. */
params {
@in Evas_3D_Node_Type type;
}
}
}
methods {
type_get {
/*
Get the type of the given node.
@return The type of the given node.
@see evas_3d_node_add()
@ingroup Evas_3D_Node
*/
const;
return Evas_3D_Node_Type ;
}
member_add {
/*
Add a member node to the given node.
Nodes can be constructed into N-ary tree structure like other ordinary scene
graph. Basically a node inherit transforms from its parent.
@see evas_3d_node_parent_get()
@ingroup Evas_3D_Node
*/
params {
@in Evas_3D_Node *member; /*@ Node object to be added. */
}
}
member_del {
/*
Delete a member node from the given node.
@see evas_3d_node_member_add()
@ingroup Evas_3D_Node
*/
params {
@in Evas_3D_Node *member; /*@ Member node to be deleted from the given node. */
}
}
parent_get {
/*
Get the parent node of the given node.
@return The parent node of the given node.
@see evas_3d_node_member_add()
@ingroup Evas_3D_Node
*/
const;
return Evas_3D_Node * ;
}
member_list_get {
/*
Get the list of member nodes of the given node.
@return The list of member nodes if any or @c NULL if there are none.
@see evas_3d_node_member_add()
@ingroup Evas_3D_Node
*/
const;
return const Eina_List * ;
}
position_set {
/*
Set the position of the given node.
According to the inheritance flag, (x, y, z) can be a world space position or
parent space position.
Default position is (0.0, 0.0, 0.0).
@see evas_3d_node_position_inherit_set()
@ingroup Evas_3D_Node_Transform
*/
params {
@in Evas_Real x; /*@ X coordinate of the position. */
@in Evas_Real y; /*@ Y coordinate of the position. */
@in Evas_Real z; /*@ Z coordinate of the position. */
}
}
orientation_set {
/*
Set the orientation of the given node using quaternion.
According the the inheritance flag, (w, x, y, z) can be a world space
orientation or parent space orientation.
Default orientation is (1.0, 0.0, 0.0, 0.0) (identity quaternion).
@see evas_3d_node_orientation_inherit_set()
@ingroup Evas_3D_Node_Transform
*/
params {
@in Evas_Real x; /*@ X term of the orientation quaternion (w, x, y, z) */
@in Evas_Real y; /*@ Y term of the orientation quaternion (w, x, y, z) */
@in Evas_Real z; /*@ Z term of the orientation quaternion (w, x, y, z) */
@in Evas_Real w; /*@ W term of the orientation quaternion (w, x, y, z) */
}
}
orientation_angle_axis_set {
/*
Set the orientation of the given node using axis-angle.
@param node The given node.
@param angle Rotation angle.
@param x X term of the rotation axis.
@param y Y term of the rotation axis.
@param z Z term of the rotation axis.
@see evas_3d_node_orientation_set()
@ingroup Evas_3D_Node_Transform
*/
params {
@in Evas_Real angle; /*@ Rotation angle.*/
@in Evas_Real x; /*@ X term of the rotation axis.*/
@in Evas_Real y; /*@ Y term of the rotation axis.*/
@in Evas_Real z; /*@ Z term of the rotation axis.*/
}
}
scale_set {
/*
Set the scale of the given node.
@param node The given node.
@param x Scale factor along X-axis.
@param y Scale factor along Y-axis.
@param z Scale factor along Z-axis.
According to the inheritance flag, (x, y, z) can be a world space scale or
parent space scale. Be careful when using non-uniform scale factor with
inheritance, each transform attributes are not affected by other attributes.
Default scale is (1.0, 1.0, 1.0).
@see evas_3d_node_scale_inherit_set()
@ingroup Evas_3D_Node_Transform
*/
params {
@in Evas_Real x; /*@ Scale factor along X-axis.*/
@in Evas_Real y; /*@ Scale factor along Y-axis.*/
@in Evas_Real z; /*@ Scale factor along Z-axis.*/
}
}
position_get {
/*
Get the position of the given node.
@param node The given node.
@param x Pointer to receive X coordinate of the position.
@param y Pointer to receive Y coordinate of the position.
@param z Pointer to receive Z coordinate of the position.
@see evas_3d_node_position_set()
@ingroup Evas_3D_Node_Transform
*/
const;
params {
@in Evas_3D_Space space; /*@ */
@out Evas_Real x; /*@ Pointer to receive X coordinate of the position.*/
@out Evas_Real y; /*@ Pointer to receive Y coordinate of the position.*/
@out Evas_Real z; /*@ Pointer to receive Z coordinate of the position.*/
}
}
orientation_get {
/*
Get the orientation of the given node as quaternion.
@param node The given node.
@param x Pointer to receive X term of the orientation quaternion.
@param y Pointer to receive Y term of the orientation quaternion.
@param z Pointer to receive Z term of the orientation quaternion.
@param w Pointer to receive W term of the orientation quaternion.
@see evas_3d_node_orientation_set()
@ingroup Evas_3D_Node_Transform
*/
const;
params {
@in Evas_3D_Space space; /*@ */
@out Evas_Real x; /*@ Pointer to receive X term of the orientation quaternion.*/
@out Evas_Real y; /*@ Pointer to receive Y term of the orientation quaternion.*/
@out Evas_Real z; /*@ Pointer to receive Z term of the orientation quaternion.*/
@out Evas_Real w; /*@ Pointer to receive W term of the orientation quaternion.*/
}
}
scale_get {
/*
Get the scale of the given node.
@param node The given node.
@param x Pointer to receive Scale factor along X-axis.
@param y Pointer to receive Scale factor along Y-axis.
@param z Pointer to receive Scale factor along Z-axis.
@see evas_3d_node_scale_get()
@ingroup Evas_3D_Node_Transform
*/
const;
params {
@in Evas_3D_Space space; /*@ */
@out Evas_Real x; /*@ Pointer to receive Scale factor along X-axis.*/
@out Evas_Real y; /*@ Pointer to receive Scale factor along X-axis.*/
@out Evas_Real z; /*@ Pointer to receive Scale factor along X-axis.*/
}
}
look_at_set {
/*
Rotate the given node to look at desired position.
@param node The given node.
@param target_space Space where the target position belongs to.
@param x X coordinate of the target position.
@param y Y coordinate of the target position.
@param z Z coordinate of the target position.
@param up_space Space where the up vector belongs to.
@param ux X term of the up vector.
@param uy Y term of the up vector.
@param uz Z term of the up vector.
This function rotate the given node so that its forward vector (negative
Z-axis) points to the desired position and the up vector coincide with the
given up vector.
@see evas_3d_node_orientation_set()
@ingroup Evas_3D_Node_Transform
*/
params {
@in Evas_3D_Space target_space; /*@ Space where the target position belongs to. */
@in Evas_Real x; /*@ X coordinate of the target position. */
@in Evas_Real y; /*@ Y coordinate of the target position. */
@in Evas_Real z; /*@ Z coordinate of the target position. */
@in Evas_3D_Space up_space; /*@ Space where the up vector belongs to. */
@in Evas_Real ux; /*@ X term of the up vector. */
@in Evas_Real uy; /*@ Y term of the up vector. */
@in Evas_Real uz; /*@ Z term of the up vector. */
}
}
mesh_add {
/*
Add a mesh to the given node.
@param node The given node.
@param mesh The mesh to be added.
If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be
generated and nothing happens.
@see evas_3d_node_add()
@ingroup Evas_3D_Node
*/
params {
@in Evas_3D_Mesh *mesh; /*@ The mesh to be added.*/
}
}
mesh_del {
/*
Delete a mesh from the given node.
@param node The given node.
@param mesh The mesh to be deleted.
If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not
belong to the given node, error message will be gnerated and nothing happens.
@see evas_3d_node_mesh_add()
@ingroup Evas_3D_Node
*/
params {
@in Evas_3D_Mesh *mesh; /*@ The mesh to be deleted.*/
}
}
mesh_list_get {
/*
Get the list of meshes of the given node.
@param node The given node.
@return The list of meshes if any, or @c NULL if there're none.
If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be
generated and @c NULL will be returned. If there're no meshes in the given
node, @c NULL will be returned.
@see evas_3d_node_mesh_add()
@ingroup Evas_3D_Node
*/
const;
return const Eina_List *;
}
}
properties {
position_inherit {
set {
/*
Set the position inheritance flag of the given node.
@param node The given node.
@param inherit Whether to inherit parent position @c EINA_TRUE or not @c EINA_FALSE.
When inheritance is enabled, a node's world space position is determined by
adding the parent node's world position and the node's position, otherwise,
the node's position will be the world space position.
@ingroup Evas_3D_Node_Transform
*/
}
get {
/*
Get the position inheritance flag of the given node.
@param node The given node.
@return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not.
@see evas_3d_node_position_inherit_set()
@ingroup Evas_3D_Node_Transform
*/
}
values {
Eina_Bool inherit; /*@ Whether to inherit parent position*/
}
}
orientation_inherit {
set {
/*
Set the orientation inheritance flag of the given node.
@param node The given node.
@param inherit Whether to inherit parent orientation @c EINA_TRUE or not @c EINA_FALSE.
When inheritance is enabled, a node's world space orientation is determined
by multiplying the parent node's world orientation and the node's
orientation, otherwise, the node's orientation will be the world space
orientation.
@ingroup Evas_3D_Node_Transform
*/
}
get {
/*
Get the orientation inheritance flag of the given node.
@param node The given node.
@return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not.
@see evas_3d_node_orientation_inherit_set()
@ingroup Evas_3D_Node_Transform
*/
}
values {
Eina_Bool inherit; /*@ Whether to inherit parent orientation*/
}
}
scale_inherit {
set {
/*
Set the scale inheritance flag of the given node.
@param node The given node.
@param inherit Whether to inherit parent scale @c EINA_TRUE or not @c EINA_FALSE.
When inheritance is enabled, a node's world space scale is determined by
multiplying the parent node's world scale and the node's scale, otherwise,
the node's scale will be the world space scale.
@ingroup Evas_3D_Node_Transform
*/
}
get {
/*
Get the scale inheritance flag of the given node.
@param node The given node.
@return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not.
@see evas_3d_node_scale_inherit_set()
@ingroup Evas_3D_Node_Transform
*/
}
values {
Eina_Bool inherit; /*@ Whether to inherit parent scale*/
}
}
camera {
set {
/*
Set a camera to the given node.
@param node The given node.
@param camera The camera to be set.
If the node is not of type EVAS_3D_NODE_TYPE_CAMERA, error message will be
generated and nothing happens.
@see evas_3d_node_add()
@ingroup Evas_3D_Node
*/
}
get {
/*
Get the camera of the given node.
@param node The given node.
@return The camera of the given node if any, or @c NULL if there're none.
@see evas_3d_node_camera_set()
@ingroup Evas_3D_Node
*/
}
values {
Evas_3D_Camera *camera; /*@ The camera */
}
}
light {
set {
/*
Set the light of the given node.
@param node The given node.
@param light The light to be set.
If the node is not of type EVAS_3D_NODE_TYPE_LIGHT, error message will be
generated and nothing happens.
@see evas_3d_node_add()
@ingroup Evas_3D_Node
*/
}
get {
/*
Get the light of the given node.
@param node The given node.
@return The light of the given node if any, or @c NULL if there're none.
@see evas_3d_node_light_set()
@ingroup Evas_3D_Node
*/
}
values {
Evas_3D_Light *light; /*@ The light */
}
}
mesh_frame {
set {
/*
Set the animation frame number of the given node for the given mesh.
@param node The given node.
@param mesh The given mesh.
@param frame The animation frame number.
If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not
belong to the given mesh error mesh will be generated and nothing happens.
Default mesh frame is 0.
@see evas_3d_node_mesh_add()
@ingroup Evas_3D_Node
*/
}
get {
/*
Set the animation frame number of the given node for the given mesh.
@param node The given node.
@param mesh The given mesh.
@param frame The animation frame number.
If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not
belong to the given mesh error mesh will be generated and nothing happens.
@see evas_3d_node_mesh_add()
@ingroup Evas_3D_Node
*/
}
keys {
Evas_3D_Mesh *mesh; /*@ The given mesh.*/
}
values {
int frame; /*@ The animation frame number.*/
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

View File

@ -6,8 +6,12 @@
#include "evas_common_private.h"
#include "evas_private.h"
#include "Eo.h"
#define MY_CLASS EO_EVAS_3D_SCENE_CLASS
void
evas_3d_scene_data_init(Evas_3D_Scene_Data *data)
evas_3d_scene_data_init(Evas_3D_Scene_Public_Data *data)
{
data->camera_node = NULL;
data->light_nodes = NULL;
@ -15,7 +19,7 @@ evas_3d_scene_data_init(Evas_3D_Scene_Data *data)
}
void
evas_3d_scene_data_fini(Evas_3D_Scene_Data *data)
evas_3d_scene_data_fini(Evas_3D_Scene_Public_Data *data)
{
if (data->light_nodes)
eina_list_free(data->light_nodes);
@ -27,7 +31,7 @@ evas_3d_scene_data_fini(Evas_3D_Scene_Data *data)
static void
_scene_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED)
{
Evas_3D_Scene *scene = (Evas_3D_Scene *)obj;
Evas_3D_Scene_Data *scene = (Evas_3D_Scene_Data *)obj;
Eina_List *l;
Evas_Object *eo;
@ -41,36 +45,45 @@ _scene_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Obje
static void
_scene_update(Evas_3D_Object *obj)
{
Evas_3D_Scene *scene = (Evas_3D_Scene *)obj;
Evas_3D_Scene_Data *scene = (Evas_3D_Scene_Data *)obj;
if (scene->root_node)
evas_3d_object_update(&scene->root_node->base);
{
Evas_3D_Node_Data *pd_root_node = eo_data_scope_get(scene->root_node, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_update(&pd_root_node->base);
}
if (scene->camera_node)
evas_3d_object_update(&scene->camera_node->base);
{
Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(scene->camera_node, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_update(&pd_camera_node->base);
}
}
static void
_scene_free(Evas_3D_Object *obj)
{
Evas_3D_Scene *scene = (Evas_3D_Scene *)obj;
Evas_3D_Scene_Data *scene = (Evas_3D_Scene_Data *)obj;
if (scene->root_node)
{
evas_3d_node_scene_root_del(scene->root_node, scene);
evas_3d_object_unreference(&scene->root_node->base);
Evas_3D_Node_Data *pd_root_node = eo_data_scope_get(scene->root_node, EO_EVAS_3D_NODE_CLASS);
//@FIXME
evas_3d_node_scene_root_del(scene->root_node, scene->hack_this);
evas_3d_object_unreference(&pd_root_node->base);
}
if (scene->camera_node)
{
evas_3d_node_scene_camera_del(scene->camera_node, scene);
evas_3d_object_unreference(&scene->camera_node->base);
Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(scene->camera_node, EO_EVAS_3D_NODE_CLASS);
evas_3d_node_scene_camera_del(scene->camera_node, scene->hack_this);
evas_3d_object_unreference(&pd_camera_node->base);
}
if (scene->images)
eina_list_free(scene->images);
free(scene);
eo_del(scene->hack_this);
//free(scene);
}
static const Evas_3D_Object_Func scene_func =
@ -80,132 +93,132 @@ static const Evas_3D_Object_Func scene_func =
_scene_update,
};
Evas_3D_Scene *
evas_3d_scene_new(Evas *e)
{
Evas_3D_Scene *scene = NULL;
scene = (Evas_3D_Scene *)calloc(1, sizeof(Evas_3D_Scene));
if (scene == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
evas_3d_object_init(&scene->base, e, EVAS_3D_OBJECT_TYPE_SCENE, &scene_func);
evas_color_set(&scene->bg_color, 0.0, 0.0, 0.0, 0.0);
return scene;
}
EAPI Evas_3D_Scene *
evas_3d_scene_add(Evas *e)
{
return evas_3d_scene_new(e);
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Object *eo_obj = eo_add(MY_CLASS, e);
eo_unref(eo_obj);
return eo_obj;
}
EAPI void
evas_3d_scene_del(Evas_3D_Scene *scene)
EOLIAN static void
_eo_evas_3d_scene_eo_base_constructor(Eo *obj, Evas_3D_Scene_Data *pd)
{
evas_3d_object_unreference(&scene->base);
Eo *e;
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, e = eo_parent_get());
evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_SCENE, &scene_func);
evas_color_set(&pd->bg_color, 0.0, 0.0, 0.0, 0.0);
}
EAPI Evas *
evas_3d_scene_evas_get(const Evas_3D_Scene *scene)
EOLIAN static void
_eo_evas_3d_scene_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd)
{
return scene->base.evas;
//evas_3d_object_unreference(&pd->base);
}
EAPI void
evas_3d_scene_root_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node)
EOLIAN static Evas *
_eo_evas_3d_scene_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd)
{
if (scene->root_node == node)
return pd->base.evas;
}
EOLIAN static void
_eo_evas_3d_scene_root_node_set(Eo *obj, Evas_3D_Scene_Data *pd, Evas_3D_Node *node)
{
if (pd->root_node == node)
return;
if (scene->root_node)
if (pd->root_node)
{
evas_3d_node_scene_root_del(scene->root_node, scene);
evas_3d_object_unreference(&scene->root_node->base);
Evas_3D_Node_Data *pd_root_node = eo_data_scope_get(pd->root_node, EO_EVAS_3D_NODE_CLASS);
evas_3d_node_scene_root_del(pd->root_node, obj);
evas_3d_object_unreference(&pd_root_node->base);
}
scene->root_node = node;
pd->root_node = node;
if (node)
{
evas_3d_object_reference(&node->base);
evas_3d_node_scene_root_add(node, scene);
Evas_3D_Node_Data *pd_node = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_reference(&pd_node->base);
evas_3d_node_scene_root_add(node, obj);
}
evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_ROOT_NODE, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_ROOT_NODE, NULL);
}
EAPI Evas_3D_Node *
evas_3d_scene_root_node_get(const Evas_3D_Scene *scene)
EOLIAN static Evas_3D_Node *
_eo_evas_3d_scene_root_node_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd)
{
return scene->root_node;
return pd->root_node;
}
EAPI void
evas_3d_scene_camera_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node)
EOLIAN static void
_eo_evas_3d_scene_camera_node_set(Eo *obj, Evas_3D_Scene_Data *pd, Evas_3D_Node *node)
{
if (scene->camera_node == node)
if (pd->camera_node == node)
return;
if (scene->camera_node)
if (pd->camera_node)
{
evas_3d_node_scene_camera_del(scene->camera_node, scene);
evas_3d_object_unreference(&scene->camera_node->base);
Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(pd->camera_node, EO_EVAS_3D_NODE_CLASS);
evas_3d_node_scene_camera_del(pd->camera_node, obj);
evas_3d_object_unreference(&pd_camera_node->base);
}
scene->camera_node = node;
pd->camera_node = node;
if (node)
{
evas_3d_object_reference(&node->base);
evas_3d_node_scene_camera_add(node, scene);
Evas_3D_Node_Data *pd_node = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS);
evas_3d_object_reference(&pd_node->base);
evas_3d_node_scene_camera_add(node, obj);
}
evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_CAMERA_NODE, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_CAMERA_NODE, NULL);
}
EAPI Evas_3D_Node *
evas_3d_scene_camera_node_get(const Evas_3D_Scene *scene)
EOLIAN static Evas_3D_Node *
_eo_evas_3d_scene_camera_node_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd)
{
return scene->camera_node;
return pd->camera_node;
}
EAPI void
evas_3d_scene_size_set(Evas_3D_Scene *scene, int w, int h)
EOLIAN static void
_eo_evas_3d_scene_size_set(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, int w, int h)
{
scene->w = w;
scene->h = h;
evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_SIZE, NULL);
pd->w = w;
pd->h = h;
evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_SIZE, NULL);
}
EAPI void
evas_3d_scene_size_get(const Evas_3D_Scene *scene, int *w, int *h)
EOLIAN static void
_eo_evas_3d_scene_size_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, int *w, int *h)
{
if (w) *w = scene->w;
if (h) *h = scene->h;
if (w) *w = pd->w;
if (h) *h = pd->h;
}
EAPI void
evas_3d_scene_background_color_set(Evas_3D_Scene *scene,
EOLIAN static void
_eo_evas_3d_scene_background_color_set(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd,
Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
evas_color_set(&scene->bg_color, r, g, b, a);
evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_BACKGROUND_COLOR, NULL);
evas_color_set(&pd->bg_color, r, g, b, a);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_BACKGROUND_COLOR, NULL);
}
EAPI void
evas_3d_scene_background_color_get(const Evas_3D_Scene *scene,
EOLIAN static void
_eo_evas_3d_scene_background_color_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd,
Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
{
if (r) *r = scene->bg_color.r;
if (g) *g = scene->bg_color.g;
if (b) *b = scene->bg_color.b;
if (a) *a = scene->bg_color.a;
if (r) *r = pd->bg_color.r;
if (g) *g = pd->bg_color.g;
if (b) *b = pd->bg_color.b;
if (a) *a = pd->bg_color.a;
}
static inline Eina_Bool
@ -362,26 +375,26 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray,
evas_3d_mesh_interpolate_vertex_buffer_get(mesh, frame, EVAS_3D_VERTEX_TEXCOORD,
&tex0, &tex1, &tex_weight);
if (mesh->indices)
Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS);
if (pdmesh->indices)
{
unsigned int i0, i1, i2;
if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES)
if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES)
{
for (i = 0; i < mesh->index_count; i += 3)
for (i = 0; i < pdmesh->index_count; i += 3)
{
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i0 = ((unsigned short *)mesh->indices)[i];
i1 = ((unsigned short *)mesh->indices)[i + 1];
i2 = ((unsigned short *)mesh->indices)[i + 2];
i0 = ((unsigned short *)pdmesh->indices)[i];
i1 = ((unsigned short *)pdmesh->indices)[i + 1];
i2 = ((unsigned short *)pdmesh->indices)[i + 2];
}
else
{
i0 = ((unsigned char *)mesh->indices)[i];
i1 = ((unsigned char *)mesh->indices)[i + 1];
i2 = ((unsigned char *)mesh->indices)[i + 2];
i0 = ((unsigned char *)pdmesh->indices)[i];
i1 = ((unsigned char *)pdmesh->indices)[i + 1];
i2 = ((unsigned char *)pdmesh->indices)[i + 2];
}
_position_get(&tri.p0, &pos0, &pos1, pos_weight, i0);
@ -396,45 +409,45 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray,
}
}
}
else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
{
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i1 = ((unsigned short *)mesh->indices)[0];
i2 = ((unsigned short *)mesh->indices)[1];
i1 = ((unsigned short *)pdmesh->indices)[0];
i2 = ((unsigned short *)pdmesh->indices)[1];
}
else
{
i1 = ((unsigned char *)mesh->indices)[0];
i2 = ((unsigned char *)mesh->indices)[1];
i1 = ((unsigned char *)pdmesh->indices)[0];
i2 = ((unsigned char *)pdmesh->indices)[1];
}
_position_get(&tri.p1, &pos0, &pos1, pos_weight, i1);
_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
for (i = 0; i < mesh->index_count - 2; i++)
for (i = 0; i < pdmesh->index_count - 2; i++)
{
tri.p0 = tri.p1;
tri.p1 = tri.p2;
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
i2 = ((unsigned short *)mesh->indices)[i + 2];
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
i2 = ((unsigned short *)pdmesh->indices)[i + 2];
else
i2 = ((unsigned char *)mesh->indices)[i + 2];
i2 = ((unsigned char *)pdmesh->indices)[i + 2];
_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i0 = ((unsigned short *)mesh->indices)[i];
i1 = ((unsigned short *)mesh->indices)[i + 1];
i0 = ((unsigned short *)pdmesh->indices)[i];
i1 = ((unsigned short *)pdmesh->indices)[i + 1];
}
else
{
i0 = ((unsigned char *)mesh->indices)[i];
i1 = ((unsigned char *)mesh->indices)[i + 1];
i0 = ((unsigned char *)pdmesh->indices)[i];
i1 = ((unsigned char *)pdmesh->indices)[i + 1];
}
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2);
@ -443,39 +456,39 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray,
}
}
}
else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
{
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i0 = ((unsigned short *)mesh->indices)[0];
i2 = ((unsigned short *)mesh->indices)[1];
i0 = ((unsigned short *)pdmesh->indices)[0];
i2 = ((unsigned short *)pdmesh->indices)[1];
}
else
{
i0 = ((unsigned char *)mesh->indices)[0];
i2 = ((unsigned char *)mesh->indices)[1];
i0 = ((unsigned char *)pdmesh->indices)[0];
i2 = ((unsigned char *)pdmesh->indices)[1];
}
_position_get(&tri.p0, &pos0, &pos1, pos_weight, i0);
_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
for (i = 1; i < mesh->index_count - 1; i++)
for (i = 1; i < pdmesh->index_count - 1; i++)
{
tri.p1 = tri.p2;
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
i2 = ((unsigned short *)mesh->indices)[i + 1];
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
i2 = ((unsigned short *)pdmesh->indices)[i + 1];
else
i2 = ((unsigned char *)mesh->indices)[i + 1];
i2 = ((unsigned char *)pdmesh->indices)[i + 1];
_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
i1 = ((unsigned short *)mesh->indices)[i];
if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT)
i1 = ((unsigned short *)pdmesh->indices)[i];
else
i1 = ((unsigned char *)mesh->indices)[i];
i1 = ((unsigned char *)pdmesh->indices)[i];
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2);
data->mesh = mesh;
@ -484,11 +497,11 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray,
}
}
}
else if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_BYTE)
else if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_BYTE)
{
if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES)
if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES)
{
for (i = 0; i < mesh->index_count; i += 3)
for (i = 0; i < pdmesh->index_count; i += 3)
{
_position_get(&tri.p0, &pos0, &pos1, pos_weight, i);
_position_get(&tri.p1, &pos0, &pos1, pos_weight, i + 1);
@ -502,12 +515,12 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray,
}
}
}
else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
{
_position_get(&tri.p1, &pos0, &pos1, pos_weight, 0);
_position_get(&tri.p2, &pos0, &pos1, pos_weight, 1);
for (i = 0; i < mesh->index_count - 2; i++)
for (i = 0; i < pdmesh->index_count - 2; i++)
{
tri.p0 = tri.p1;
tri.p1 = tri.p2;
@ -522,12 +535,12 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray,
}
}
}
else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
{
_position_get(&tri.p0, &pos0, &pos1, pos_weight, 0);
_position_get(&tri.p2, &pos0, &pos1, pos_weight, 1);
for (i = 1; i < mesh->index_count - 1; i++)
for (i = 1; i < pdmesh->index_count - 1; i++)
{
tri.p1 = tri.p2;
@ -550,23 +563,24 @@ _node_pick(Evas_3D_Node *node, void *data)
Evas_Ray3 ray;
Evas_3D_Pick_Data *pick = (Evas_3D_Pick_Data *)data;
Evas_Mat4 mvp;
Evas_3D_Node_Data *pd_node = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS);
if (! evas_box3_ray3_intersect(&node->aabb, &pick->ray_world))
if (! evas_box3_ray3_intersect(&pd_node->aabb, &pick->ray_world))
{
/* Skip entire subtree. */
return EINA_FALSE;
}
if (node->type == EVAS_3D_NODE_TYPE_MESH)
if (pd_node->type == EVAS_3D_NODE_TYPE_MESH)
{
Eina_Iterator *itr;
void *ptr;
/* Transform ray into local coordinate space. */
evas_mat4_multiply(&mvp, &pick->matrix_vp, &node->data.mesh.matrix_local_to_world);
evas_mat4_multiply(&mvp, &pick->matrix_vp, &pd_node->data.mesh.matrix_local_to_world);
evas_ray3_init(&ray, pick->x, pick->y, &mvp);
itr = eina_hash_iterator_data_new(node->data.mesh.node_meshes);
itr = eina_hash_iterator_data_new(pd_node->data.mesh.node_meshes);
while (eina_iterator_next(itr, &ptr))
{
@ -578,16 +592,16 @@ _node_pick(Evas_3D_Node *node, void *data)
return EINA_TRUE;
}
EAPI Eina_Bool
evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y,
EOLIAN static Eina_Bool
_eo_evas_3d_scene_pick(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, Evas_Real x, Evas_Real y,
Evas_3D_Node **node, Evas_3D_Mesh **mesh,
Evas_Real *s, Evas_Real *t)
{
/* TODO: Use H/W picking if availabe. */
Evas_3D_Pick_Data data;
data.x = ((x * 2.0) / (Evas_Real)scene->w) - 1.0;
data.y = (((scene->h - y - 1) * 2.0) / ((Evas_Real)scene->h)) - 1.0;
data.x = ((x * 2.0) / (Evas_Real)pd->w) - 1.0;
data.y = (((pd->h - y - 1) * 2.0) / ((Evas_Real)pd->h)) - 1.0;
data.picked = EINA_FALSE;
data.z = 1.0;
@ -597,17 +611,18 @@ evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y,
data.t = 0.0;
/* Update the scene graph. */
evas_3d_object_update((Evas_3D_Object *)&scene->base);
evas_3d_object_update((Evas_3D_Object *)&pd->base);
Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(pd->camera_node, EO_EVAS_3D_NODE_CLASS);
Evas_3D_Camera_Data *pd_camera = eo_data_scope_get(pd_camera_node->data.camera.camera, EO_EVAS_3D_CAMERA_CLASS);
evas_mat4_multiply(&data.matrix_vp,
&scene->camera_node->data.camera.camera->projection,
&scene->camera_node->data.camera.matrix_world_to_eye);
&pd_camera->projection,
&pd_camera_node->data.camera.matrix_world_to_eye);
evas_ray3_init(&data.ray_world, data.x, data.y, &data.matrix_vp);
/* Traverse tree while adding meshes into pick data structure. */
evas_3d_node_tree_traverse(scene->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
evas_3d_node_tree_traverse(pd->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
_node_pick, &data);
if (!data.picked)
@ -620,3 +635,5 @@ evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y,
return EINA_TRUE;
}
#include "canvas/evas_3d_scene.eo.c"

View File

@ -0,0 +1,145 @@
class EO_Evas_3D_Scene (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_scene;
data: Evas_3D_Scene_Data;
methods {
size_set {
/*
Set the resolution of a scene.
A scene should be rendered to be displayed through an image objects. The
resolution defines size of the internal surface holding the rendered result.
@ingroup Evas_3D_Scene
*/
params {
@in int w; /*@ Width of the resolution. */
@in int h; /*@ Height of the resolution. */
}
}
size_get {
/*
Get the internal resolution of a scene.
@ingroup Evas_3D_Scene
*/
const;
params {
@out int w; /*@ Pointer to receive width of the resolution. */
@out int h; /*@ Pointer to receive height of the resolution. */
}
}
background_color_set {
/*
Set the background color of a scene.
Background color defines initial color of pixels before a scene is rendered.
If you want to display a scene with background evas objects are still
remaining as if it was the background, set the alpha term to 0.0.
Default background color is (0.0, 0.0, 0.0, 0.0).
@ingroup Evas_3D_Scene
*/
params {
@in Evas_Real r; /*@ Red component of the background color. */
@in Evas_Real g; /*@ Green component of the background color. */
@in Evas_Real b; /*@ Blue component of the background color. */
@in Evas_Real a; /*@ Alpha component of the background color. */
}
}
background_color_get {
/*
Get the background color of a scene.
@ingroup Evas_3D_Scene
*/
const;
params {
@out Evas_Real r; /*@ Pointer to receive red component of the background color.*/
@out Evas_Real g; /*@ Pointer to receive green component of the background color. */
@out Evas_Real b; /*@ Pointer to receive blue component of the background color. */
@out Evas_Real a; /*@ Pointer to receive alpha component of the background color. */
}
}
pick {
/*
Get information on the most front visible mesh for the given position.
(x, y) is the screen coordinate of the given scene. That is, left-top is
(0, 0) and right-bottom is (w, h) where (w, h) is the size of the scene.
The texture coordinate is useful when using proxy texture source.
@ingroup Evas_3D_Scene
*/
const;
return Eina_Bool ;
params {
@in Evas_Real x; /*@ X coordinate of the picking position. */
@in Evas_Real y; /*@ Y coordinate of the picking position. */
@out Evas_3D_Node *node; /*@ Pointer to receive the node contains the picked mesh. */
@out Evas_3D_Mesh *mesh; /*@ Pointer to receive the picked mesh. */
@out Evas_Real s; /*@ Pointer to receive the texture "s" coordinate. */
@out Evas_Real t; /*@ Pointer to receive the texture "t" coordinate. */
}
}
}
properties {
root_node {
set {
/*
Set the root node of a scene.
@ingroup Evas_3D_Scene
*/
}
get {
/*
Get the root node of a scene.
@return The root node of the given scene.
@ingroup Evas_3D_Scene
*/
}
values {
Evas_3D_Node *node; /*@ A node which will be used as a root node for the scene. */
}
}
camera_node {
set {
/*
Set the camera node of a scene.
@ingroup Evas_3D_Scene
*/
}
get {
/*
Get the camera node of a scene.
@return The camera node of the given scene.
@ingroup Evas_3D_Scene
*/
}
values {
Evas_3D_Node *node; /*@ A node which will be used as a camera node for the scene. */
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

View File

@ -6,21 +6,26 @@
#include "evas_common_private.h"
#include "evas_private.h"
#include "Eo.h"
#define MY_CLASS EO_EVAS_3D_TEXTURE_CLASS
static inline void
_texture_proxy_set(Evas_3D_Texture *texture, Evas_Object *eo_src, Evas_Object_Protected_Data *src)
{
Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, MY_CLASS);
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, src->proxy, Evas_Object_Proxy_Data, proxy_src)
{
proxy_src->proxy_textures = eina_list_append(proxy_src->proxy_textures, texture);
proxy_src->proxy_textures = eina_list_append(proxy_src->proxy_textures, pd);
proxy_src->redraw = EINA_TRUE;
}
EINA_COW_WRITE_END(evas_object_proxy_cow, src->proxy, proxy_src);
texture->source = eo_src;
pd->source = eo_src;
}
static inline void
_texture_proxy_unset(Evas_3D_Texture *texture)
_texture_proxy_unset(Evas_3D_Texture_Data *texture)
{
Evas_Object_Protected_Data *src = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS);
@ -53,7 +58,7 @@ _texture_proxy_unset(Evas_3D_Texture *texture)
}
static inline void
_texture_proxy_subrender(Evas_3D_Texture *texture)
_texture_proxy_subrender(Evas_3D_Texture_Data *texture)
{
/* Code taken from _proxy_subrender() in file evas_object_image.c */
@ -160,7 +165,7 @@ _texture_proxy_subrender(Evas_3D_Texture *texture)
}
static void
_texture_fini(Evas_3D_Texture *texture)
_texture_fini(Evas_3D_Texture_Data *texture)
{
if (texture->engine_data)
{
@ -184,10 +189,10 @@ _texture_fini(Evas_3D_Texture *texture)
static void
_texture_free(Evas_3D_Object *obj)
{
Evas_3D_Texture *texture = (Evas_3D_Texture *)obj;
Evas_3D_Texture_Data *texture = (Evas_3D_Texture_Data *)obj;
_texture_fini(texture);
free(texture);
//free(texture);
}
static Eina_Bool
@ -195,7 +200,8 @@ _texture_material_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *k
void *data EINA_UNUSED, void *fdata)
{
Evas_3D_Material *m = *(Evas_3D_Material **)key;
evas_3d_object_change(&m->base, EVAS_3D_STATE_MATERIAL_TEXTURE, (Evas_3D_Object *)fdata);
Evas_3D_Material_Data *pdm = eo_data_scope_get(m, EO_EVAS_3D_MATERIAL_CLASS);
evas_3d_object_change(&pdm->base, EVAS_3D_STATE_MATERIAL_TEXTURE, (Evas_3D_Object *)fdata);
return EINA_TRUE;
}
@ -203,7 +209,7 @@ static void
_texture_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED,
Evas_3D_Object *ref EINA_UNUSED)
{
Evas_3D_Texture *texture = (Evas_3D_Texture *)obj;
Evas_3D_Texture_Data *texture = (Evas_3D_Texture_Data *)obj;
if (texture->materials)
eina_hash_foreach(texture->materials, _texture_material_change_notify, obj);
@ -212,7 +218,7 @@ _texture_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED,
static void
_texture_update(Evas_3D_Object *obj)
{
Evas_3D_Texture *texture = (Evas_3D_Texture *)obj;
Evas_3D_Texture_Data *texture = (Evas_3D_Texture_Data *)obj;
if (texture->source)
{
@ -258,119 +264,135 @@ void
evas_3d_texture_material_add(Evas_3D_Texture *texture, Evas_3D_Material *material)
{
int count = 0;
if (texture->materials == NULL)
Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, MY_CLASS);
if (pd->materials == NULL)
{
texture->materials = eina_hash_pointer_new(NULL);
pd->materials = eina_hash_pointer_new(NULL);
if (texture->materials == NULL)
if (pd->materials == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)eina_hash_find(texture->materials, &material);
count = (int)eina_hash_find(pd->materials, &material);
/* Increase reference count or add new one if not exist. */
eina_hash_set(texture->materials, &material, (const void *)(count + 1));
eina_hash_set(pd->materials, &material, (const void *)(count + 1));
}
void
evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *material)
{
int count = 0;
if (texture->materials == NULL)
Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, MY_CLASS);
if (pd->materials == NULL)
{
ERR("No material to delete.");
return;
}
count = (int)eina_hash_find(texture->materials, &material);
count = (int)eina_hash_find(pd->materials, &material);
if (count == 1)
eina_hash_del(texture->materials, &material, NULL);
eina_hash_del(pd->materials, &material, NULL);
else
eina_hash_set(texture->materials, &material, (const void *)(count - 1));
eina_hash_set(pd->materials, &material, (const void *)(count - 1));
}
Evas_3D_Texture *
evas_3d_texture_new(Evas *e)
{
Evas_3D_Texture *texture = NULL;
// Evas_3D_Texture *
// evas_3d_texture_new(Evas *e)
// {
// Evas_3D_Texture *texture = NULL;
texture = (Evas_3D_Texture *)calloc(1, sizeof(Evas_3D_Texture));
// texture = (Evas_3D_Texture *)calloc(1, sizeof(Evas_3D_Texture_Data));
if (texture == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
// if (texture == NULL)
// {
// ERR("Failed to allocate memory.");
// return NULL;
// }
evas_3d_object_init(&texture->base, e, EVAS_3D_OBJECT_TYPE_TEXTURE, &texture_func);
return texture;
}
// evas_3d_object_init(&texture->base, e, EVAS_3D_OBJECT_TYPE_TEXTURE, &texture_func);
// return texture;
// }
EAPI Evas_3D_Texture *
evas_3d_texture_add(Evas *e)
{
return evas_3d_texture_new(e);
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Object *eo_obj = eo_add(MY_CLASS, e);
eo_unref(eo_obj);
return eo_obj;
//return evas_3d_texture_new(e);
}
EAPI void
evas_3d_texture_del(Evas_3D_Texture *texture)
EOLIAN static void
_eo_evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd)
{
evas_3d_object_unreference(&texture->base);
Eo *e;
eo_do_super(obj, MY_CLASS, eo_constructor());
eo_do(obj, e = eo_parent_get());
evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &texture_func);
}
EAPI Evas *
evas_3d_texture_evas_get(const Evas_3D_Texture *texture)
EOLIAN static void
_eo_evas_3d_texture_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd)
{
return texture->base.evas;
evas_3d_object_unreference(&pd->base);
}
EAPI void
evas_3d_texture_data_set(Evas_3D_Texture *texture, Evas_3D_Color_Format color_format,
Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data)
EOLIAN static Evas *
_eo_evas_3d_texture_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
return pd->base.evas;
}
if (texture->engine_data == NULL)
texture->engine_data = e->engine.func->texture_new(e->engine.data.output);
EOLIAN static void
_eo_evas_3d_texture_data_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Color_Format color_format,
Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data)
{
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_data_set(e->engine.data.output, texture->engine_data,
if (pd->engine_data == NULL)
pd->engine_data = e->engine.func->texture_new(e->engine.data.output);
e->engine.func->texture_data_set(e->engine.data.output, pd->engine_data,
color_format, pixel_format, w, h, data);
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
}
EAPI void
evas_3d_texture_file_set(Evas_3D_Texture *texture, const char *file, const char *key)
EOLIAN static void
_eo_evas_3d_texture_file_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, const char *file, const char *key)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
if (texture->engine_data == NULL)
texture->engine_data = e->engine.func->texture_new(e->engine.data.output);
if (pd->engine_data == NULL)
pd->engine_data = e->engine.func->texture_new(e->engine.data.output);
e->engine.func->texture_file_set(e->engine.data.output, texture->engine_data, file, key);
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
e->engine.func->texture_file_set(e->engine.data.output, pd->engine_data, file, key);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
}
EAPI void
evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source)
_eo_evas_3d_texture_source_set(Eo *obj , Evas_3D_Texture_Data *pd, Evas_Object *source)
{
Evas_Object_Protected_Data *src;
if (source == texture->source)
if (source == pd->source)
return;
_texture_fini(texture);
_texture_fini(pd);
if (source == NULL)
return;
if (evas_object_evas_get(source) != texture->base.evas)
if (evas_object_evas_get(source) != pd->base.evas)
{
ERR("Not matching canvas.");
return;
@ -390,19 +412,19 @@ evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source)
return;
}
_texture_proxy_set(texture, source, src);
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
_texture_proxy_set(obj, source, src);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
}
EAPI void
evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible)
EOLIAN static void
_eo_evas_3d_texture_source_visible_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Eina_Bool visible)
{
Evas_Object_Protected_Data *src_obj;
if (texture->source == NULL)
if (pd->source == NULL)
return;
src_obj = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS);
src_obj = eo_data_scope_get(pd->source, EVAS_OBJ_CLASS);
if (src_obj->proxy->src_invisible == !visible)
return;
@ -412,69 +434,66 @@ evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible)
EINA_COW_WRITE_END(evas_object_proxy_cow, src_obj->proxy, proxy_write);
src_obj->changed_src_visible = EINA_TRUE;
evas_object_smart_member_cache_invalidate(texture->source, EINA_FALSE, EINA_FALSE, EINA_TRUE);
evas_object_change(texture->source, src_obj);
evas_object_smart_member_cache_invalidate(pd->source, EINA_FALSE, EINA_FALSE, EINA_TRUE);
evas_object_change(pd->source, src_obj);
}
EAPI Eina_Bool
evas_3d_texture_source_visible_get(const Evas_3D_Texture *texture)
EOLIAN static Eina_Bool
_eo_evas_3d_texture_source_visible_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd)
{
Evas_Object_Protected_Data *src_obj;
if (texture->source == NULL)
if (pd->source == NULL)
return EINA_FALSE;
src_obj = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS);
src_obj = eo_data_scope_get(pd->source, EVAS_OBJ_CLASS);
return !src_obj->proxy->src_invisible;
}
EAPI Evas_3D_Color_Format
evas_3d_texture_color_format_get(const Evas_3D_Texture *texture)
EOLIAN static Evas_3D_Color_Format
_eo_evas_3d_texture_color_format_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
Evas_3D_Color_Format format;
e->engine.func->texture_color_format_get(e->engine.data.output, texture->engine_data, &format);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_color_format_get(e->engine.data.output, pd->engine_data, &format);
return format;
}
EAPI void
evas_3d_texture_size_get(const Evas_3D_Texture *texture, int *w, int *h)
EOLIAN static void
_eo_evas_3d_texture_size_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, int *w, int *h)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
e->engine.func->texture_size_get(e->engine.data.output, texture->engine_data, w, h);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_size_get(e->engine.data.output, pd->engine_data, w, h);
}
EAPI void
evas_3d_texture_wrap_set(Evas_3D_Texture *texture,
Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t)
EOLIAN static void
_eo_evas_3d_texture_wrap_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
e->engine.func->texture_wrap_set(e->engine.data.output, texture->engine_data, s, t);
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_WRAP, NULL);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_wrap_set(e->engine.data.output, pd->engine_data, s, t);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_WRAP, NULL);
}
EAPI void
evas_3d_texture_wrap_get(const Evas_3D_Texture *texture,
Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t)
EOLIAN static void
_eo_evas_3d_texture_wrap_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
e->engine.func->texture_wrap_get(e->engine.data.output, texture->engine_data, s, t);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_wrap_get(e->engine.data.output, pd->engine_data, s, t);
}
EAPI void
evas_3d_texture_filter_set(Evas_3D_Texture *texture,
Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag)
EOLIAN static void
_eo_evas_3d_texture_filter_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
e->engine.func->texture_filter_set(e->engine.data.output, texture->engine_data, min, mag);
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_FILTER, NULL);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_filter_set(e->engine.data.output, pd->engine_data, min, mag);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_FILTER, NULL);
}
EAPI void
evas_3d_texture_filter_get(const Evas_3D_Texture *texture,
Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag)
EOLIAN static void
_eo_evas_3d_texture_filter_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag)
{
Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS);
e->engine.func->texture_filter_get(e->engine.data.output, texture->engine_data, min, mag);
Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS);
e->engine.func->texture_filter_get(e->engine.data.output, pd->engine_data, min, mag);
}
#include "canvas/evas_3d_texture.eo.c"

View File

@ -0,0 +1,199 @@
class EO_Evas_3D_Texture (Eo_Base, Evas_Common_Interface)
{
legacy_prefix: evas_3d_texture;
data : Evas_3D_Texture_Data;
properties {
source_visible {
set {
/*
Set the visibility flag of the source evas object of the given texture.
Recommend to call evas_object_show() on the source object and controll the
visibility using this function.
By default, source object is visible.
@see evas_3d_texture_source_set()
@ingroup Evas_3D_Texture
*/
}
get {
/*
Get the visibility flag of the source evas object of the given texture.
@see evas_3d_texture_source_visible_set()
@ingroup Evas_3D_Texture
*/
}
values {
Eina_Bool visible; /*@ @c EINA_TRUE for visible, @c EINA_FALSE for invisible.*/
}
}
}
methods {
data_set {
/*
Set the data of the given texture.
@see evas_3d_texture_file_set()
@ingroup Evas_3D_Texture
*/
params {
@in Evas_3D_Color_Format color_format; /*@ Color format of the texture. */
@in Evas_3D_Pixel_Format pixel_format; /*@ Pixel format of the data. */
@in int w; /*@ Width of the data. */
@in int h; /*@ Height of the data. */
@in const void *data; /*@ Pointer to the data. */
}
}
file_set {
/*
Set the data of the given texture from file.
Only PNG format is supported.
@ingroup Evas_3D_Texture
*/
return void ;
params {
@in const char *file; /*@ Path to the image file. */
@in const char *key; /*@ Key in the image file. */
}
}
source_set {
/*
Set the data of the given texture from an evas object.
Evas 3D support using existing evas object as a texture source. This feature
make it possible using any exisiting evas object inside 3D scene.
@see evas_3d_texture_source_visible_set
@ingroup Evas_3D_Texture
*/
return void ;
params {
@in Evas_Object *source; /*@ Source evas object to be used as the texture data. */
}
}
color_format_get {
/*
Get the color format of the given texture.
EVAS_3D_COLOR_FORMAT_RGBA will be returned if the texture has source object.
Otherwise, the color format of the data will be returned.
@see evas_3d_texture_data_set()
@see evas_3d_texture_file_set()
@see evas_3d_texture_source_set()
@ingroup Evas_3D_Texture
*/
const;
return Evas_3D_Color_Format ;
}
size_get {
/*
Get the size of the given texture.
If the texture has source object, the size of the source object will be
returned. Otherwise, the size of the data (or image file) will be returned.
@see evas_3d_texture_data_set()
@see evas_3d_texture_file_set()
@see evas_3d_texture_source_set()
@ingroup Evas_3D_Texture
*/
const;
params {
@out int w; /*@ Pointer to receive the width of the texture size. */
@out int h; /*@ Pointer to receive the height of the texture size. */
}
}
wrap_set {
/*
Set the wrap mode of the given texture.
If the texture coordinate exceed range [0.0, 1.0] the values are modified
according to the wrap mode.
Default wrap modes are both EVAS_3D_WRAP_MODE_CLAMP for s and t.
@ingroup Evas_3D_Texture
*/
params {
@in Evas_3D_Wrap_Mode s; /*@ Wrap mode for S-axis. */
@in Evas_3D_Wrap_Mode t; /*@ Wrap mode for T-axis. */
}
}
wrap_get {
/*
Get the wrap mode of the given texture.
@see evas_3d_texture_wrap_set()
@ingroup Evas_3D_Texture
*/
return void ;
params {
@out Evas_3D_Wrap_Mode s; /*@ Pointer to receive S-axis wrap mode. */
@out Evas_3D_Wrap_Mode t; /*@ Pointer to receive T-axis wrap mode. */
}
}
filter_set {
/*
Set the filter of the given texture.
Default filters are both EVAS_3D_TEXTURE_FILTER_NEAREST for s and t.
@ingroup Evas_3D_Texture
*/
params {
@in Evas_3D_Texture_Filter min; /*@ Minification filter used when down-scaling. */
@in Evas_3D_Texture_Filter mag; /*@ Magnification filter used when up-scaling. */
}
}
filter_get {
/*
Get the filter of the given texture.
@param texture The given texture.
@param min Pointer to receive the minification filter.
@param mag Pointer to receive the magnification filter.
@see evas_3d_texture_filter_set()
@ingroup Evas_3D_Texture
*/
const;
params {
@out Evas_3D_Texture_Filter min; /*@ Pointer to receive the minification filter. */
@out Evas_3D_Texture_Filter mag; /*@ Pointer to receive the magnification filter. */
}
}
}
implements {
Eo_Base::constructor;
Eo_Base::destructor;
Evas_Common_Interface::evas::get;
}
}

View File

@ -442,7 +442,7 @@ _image_init_set(const Eina_File *f, const char *file, const char *key,
}
EINA_COW_WRITE_END(evas_object_image_state_cow, o->prev, state_write);
}
if (o->engine_data)
{
if (o->preloading)
@ -1371,7 +1371,7 @@ _evas_image_data_update_add(Eo *eo_obj, Evas_Image_Data *o, int x, int y, int w,
if (r) pixi_write->pixel_updates = eina_list_append(pixi_write->pixel_updates, r);
EINA_COW_PIXEL_WRITE_END(o, pixi_write);
}
o->changed = EINA_TRUE;
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
evas_object_change(eo_obj, obj);
@ -2421,6 +2421,7 @@ _3d_set(Evas_Object *eo_obj, Evas_3D_Scene *scene)
{
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
Evas_Image_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(scene, EO_EVAS_3D_SCENE_CLASS);
evas_object_image_file_set(eo_obj, NULL, NULL);
@ -2429,7 +2430,7 @@ _3d_set(Evas_Object *eo_obj, Evas_3D_Scene *scene)
data->surface = NULL;
data->w = 0;
data->h = 0;
evas_3d_object_reference(&scene->base);
evas_3d_object_reference(&pd_scene->base);
}
EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
@ -2439,7 +2440,7 @@ _3d_set(Evas_Object *eo_obj, Evas_3D_Scene *scene)
}
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
scene->images = eina_list_append(scene->images, eo_obj);
pd_scene->images = eina_list_append(pd_scene->images, eo_obj);
}
static void
@ -2449,9 +2450,11 @@ _3d_unset(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas
if (o->cur->scene)
{
Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(o->cur->scene, EO_EVAS_3D_SCENE_CLASS);
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
o->cur->scene->images = eina_list_remove(o->cur->scene->images, eo_obj);
evas_3d_object_unreference(&state_write->scene->base);
pd_scene->images = eina_list_remove(pd_scene->images, eo_obj);
Evas_3D_Scene_Data *pd_scene_state_write = eo_data_scope_get(state_write->scene, EO_EVAS_3D_SCENE_CLASS);
evas_3d_object_unreference(&pd_scene_state_write->base);
state_write->scene = NULL;
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
}
@ -2487,35 +2490,36 @@ _3d_render(Evas *eo_e, Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Da
{
Evas_Public_Data *e;
Eina_Bool need_native_set = EINA_FALSE;
Evas_3D_Scene_Data scene_data;
Evas_3D_Scene_Public_Data scene_data;
if (scene == NULL)
return;
Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(scene, EO_EVAS_3D_SCENE_CLASS);
if((scene->w == 0) || (scene->h == 0))
if((pd_scene->w == 0) || (pd_scene->h == 0))
return;
e = eo_data_scope_get(eo_e, EVAS_CLASS);
if (scene->surface != NULL)
if (pd_scene->surface != NULL)
{
int w, h;
e->engine.func->drawable_size_get(e->engine.data.output, scene->surface, &w, &h);
e->engine.func->drawable_size_get(e->engine.data.output, pd_scene->surface, &w, &h);
if ((w != scene->w) || (h != scene->h))
if ((w != pd_scene->w) || (h != pd_scene->h))
{
e->engine.func->drawable_free(e->engine.data.output, scene->surface);
scene->surface = NULL;
e->engine.func->drawable_free(e->engine.data.output, pd_scene->surface);
pd_scene->surface = NULL;
need_native_set = EINA_TRUE;
}
}
if (scene->surface == NULL)
if (pd_scene->surface == NULL)
{
/* TODO: Hard-coded alpha on. */
scene->surface = e->engine.func->drawable_new(e->engine.data.output,
scene->w, scene->h, 1);
pd_scene->surface = e->engine.func->drawable_new(e->engine.data.output,
pd_scene->w, pd_scene->h, 1);
need_native_set = EINA_TRUE;
}
@ -2524,32 +2528,32 @@ _3d_render(Evas *eo_e, Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Da
if (need_native_set)
{
data->surface = e->engine.func->image_drawable_set(e->engine.data.output,
data->surface, scene->surface);
data->surface, pd_scene->surface);
}
data->w = scene->w;
data->h = scene->h;
data->w = pd_scene->w;
data->h = pd_scene->h;
}
EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
evas_3d_scene_data_init(&scene_data);
scene_data.bg_color = scene->bg_color;
scene_data.camera_node = scene->camera_node;
scene_data.bg_color = pd_scene->bg_color;
scene_data.camera_node = pd_scene->camera_node;
/* Phase 1 - Update scene graph tree. */
evas_3d_object_update(&scene->base);
evas_3d_object_update(&pd_scene->base);
/* Phase 2 - Do frustum culling and get visible model nodes. */
evas_3d_node_tree_traverse(scene->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
evas_3d_node_tree_traverse(pd_scene->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
evas_3d_node_mesh_collect, &scene_data);
/* Phase 3 - Collect active light nodes in the scene graph tree. */
evas_3d_node_tree_traverse(scene->root_node, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE,
evas_3d_node_tree_traverse(pd_scene->root_node, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE,
evas_3d_node_light_collect, &scene_data);
/* Phase 5 - Draw the scene. */
e->engine.func->drawable_scene_render(e->engine.data.output, scene->surface, &scene_data);
e->engine.func->drawable_scene_render(e->engine.data.output, pd_scene->surface, &scene_data);
/* Clean up temporary resources. */
evas_3d_scene_data_fini(&scene_data);
@ -2900,17 +2904,17 @@ evas_process_dirty_pixels(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj,
(direct_override)) &&
(!direct_force_off) )
{
if (obj->layer->evas->engine.func->gl_get_pixels_set)
{
obj->layer->evas->engine.func->gl_get_pixels_set(output, o->pixels->func.get_pixels, o->pixels->func.get_pixels_data, eo_obj);
}
o->direct_render = EINA_TRUE;
}
else
o->direct_render = EINA_FALSE;
}
if ( (ns) &&
@ -2924,7 +2928,7 @@ evas_process_dirty_pixels(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj,
x = obj->cur->geometry.x;
y = obj->cur->geometry.y;
w = obj->cur->geometry.w;
h = obj->cur->geometry.h;
h = obj->cur->geometry.h;
if (!o->direct_render)
o->pixels->func.get_pixels(o->pixels->func.get_pixels_data, eo_obj);
@ -3371,8 +3375,8 @@ evas_object_image_render_pre(Evas_Object *eo_obj,
else if (o->cur->scene)
{
Evas_3D_Scene *scene = o->cur->scene;
if (evas_3d_object_dirty_get(&scene->base, EVAS_3D_STATE_ANY))
Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(scene, EO_EVAS_3D_SCENE_CLASS);
if (evas_3d_object_dirty_get(&pd_scene->base, EVAS_3D_STATE_ANY))
{
evas_object_render_pre_prev_cur_add(&e->clip_changes, eo_obj, obj);
goto done;
@ -4181,7 +4185,7 @@ evas_object_image_is_inside(Evas_Object *eo_obj,
break;
}
// |
// .##
// .##
inx = bl; iny = imh - bb;
inw = imw - bl - br; inh = bb;
outx = ox + bsl; outy = oy + ih - bsb;

View File

@ -246,7 +246,8 @@ evas_object_change(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
}
EINA_LIST_FOREACH(obj->proxy->proxy_textures, l, texture)
{
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, EO_EVAS_3D_TEXTURE_CLASS);
evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
}
if (obj->smart.parent)
{

View File

@ -1,377 +1,7 @@
#ifndef EVAS_PRIVATE_H
# error You shall not include this header directly
#endif
#include "Evas_3D.h"
#include "evas_3d_utils.h"
#define EVAS_3D_VERTEX_ATTRIB_COUNT 5
#define EVAS_3D_MATERIAL_ATTRIB_COUNT 5
typedef struct _Evas_3D_Object Evas_3D_Object;
typedef struct _Evas_3D_Scene_Data Evas_3D_Scene_Data;
typedef struct _Evas_3D_Vertex_Buffer Evas_3D_Vertex_Buffer;
typedef struct _Evas_3D_Mesh_Frame Evas_3D_Mesh_Frame;
typedef struct _Evas_3D_Node_Mesh Evas_3D_Node_Mesh;
typedef struct _Evas_3D_Object_Func Evas_3D_Object_Func;
typedef struct _Evas_3D_Pick_Data Evas_3D_Pick_Data;
typedef struct _Evas_3D_Interpolate_Vertex_Buffer Evas_3D_Interpolate_Vertex_Buffer;
typedef Eina_Bool (*Evas_3D_Node_Func)(Evas_3D_Node *, void *data);
typedef enum _Evas_3D_Object_Type
{
EVAS_3D_OBJECT_TYPE_INVALID = 0,
EVAS_3D_OBJECT_TYPE_SCENE,
EVAS_3D_OBJECT_TYPE_NODE,
EVAS_3D_OBJECT_TYPE_CAMERA,
EVAS_3D_OBJECT_TYPE_LIGHT,
EVAS_3D_OBJECT_TYPE_MODEL,
EVAS_3D_OBJECT_TYPE_MESH,
EVAS_3D_OBJECT_TYPE_TEXTURE,
EVAS_3D_OBJECT_TYPE_MATERIAL,
} Evas_3D_Object_Type;
typedef enum _Evas_3D_State
{
EVAS_3D_STATE_MAX = 16,
EVAS_3D_STATE_ANY = 0,
EVAS_3D_STATE_SCENE_ROOT_NODE = 1,
EVAS_3D_STATE_SCENE_CAMERA_NODE,
EVAS_3D_STATE_SCENE_BACKGROUND_COLOR,
EVAS_3D_STATE_SCENE_SIZE,
EVAS_3D_STATE_TEXTURE_DATA = 1,
EVAS_3D_STATE_TEXTURE_WRAP,
EVAS_3D_STATE_TEXTURE_FILTER,
EVAS_3D_STATE_MATERIAL_ID = 1,
EVAS_3D_STATE_MATERIAL_COLOR,
EVAS_3D_STATE_MATERIAL_TEXTURE,
EVAS_3D_STATE_MESH_VERTEX_COUNT = 1,
EVAS_3D_STATE_MESH_FRAME,
EVAS_3D_STATE_MESH_MATERIAL,
EVAS_3D_STATE_MESH_TRANSFORM,
EVAS_3D_STATE_MESH_VERTEX_DATA,
EVAS_3D_STATE_MESH_INDEX_DATA,
EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY,
EVAS_3D_STATE_MESH_SHADE_MODE,
EVAS_3D_STATE_CAMERA_PROJECTION = 1,
EVAS_3D_STATE_LIGHT_AMBIENT = 1,
EVAS_3D_STATE_LIGHT_DIFFUSE,
EVAS_3D_STATE_LIGHT_SPECULAR,
EVAS_3D_STATE_LIGHT_SPOT_DIR,
EVAS_3D_STATE_LIGHT_SPOT_EXP,
EVAS_3D_STATE_LIGHT_SPOT_CUTOFF,
EVAS_3D_STATE_LIGHT_ATTENUATION,
EVAS_3D_STATE_NODE_TRANSFORM = 1,
EVAS_3D_STATE_NODE_MESH_GEOMETRY,
EVAS_3D_STATE_NODE_MESH_MATERIAL,
EVAS_3D_STATE_NODE_MESH_FRAME,
EVAS_3D_STATE_NODE_MESH_SHADE_MODE,
EVAS_3D_STATE_NODE_MESH_MATERIAL_ID,
EVAS_3D_STATE_NODE_LIGHT,
EVAS_3D_STATE_NODE_CAMERA,
EVAS_3D_STATE_NODE_PARENT,
EVAS_3D_STATE_NODE_MEMBER,
} Evas_3D_State;
typedef enum _Evas_3D_Node_Traverse_Type
{
EVAS_3D_NODE_TRAVERSE_DOWNWARD,
EVAS_3D_NODE_TRAVERSE_UPWARD,
} Evas_3D_Node_Traverse_Type;
typedef enum _Evas_3D_Tree_Traverse_Type
{
EVAS_3D_TREE_TRAVERSE_PRE_ORDER,
EVAS_3D_TREE_TRAVERSE_ANY_ORDER = EVAS_3D_TREE_TRAVERSE_PRE_ORDER,
EVAS_3D_TREE_TRAVERSE_POST_ORDER,
EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER,
} Evas_3D_Tree_Traverse_Type;
struct _Evas_3D_Object_Func
{
void (*free)(Evas_3D_Object *obj);
void (*change)(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref);
void (*update)(Evas_3D_Object *obj);
};
struct _Evas_3D_Object
{
Evas *evas;
Evas_3D_Object_Type type;
int ref_count;
Evas_3D_Object_Func func;
Eina_Bool dirty[EVAS_3D_STATE_MAX];
};
struct _Evas_3D_Scene
{
Evas_3D_Object base;
Evas_3D_Node *root_node;
Evas_3D_Node *camera_node;
Evas_Color bg_color;
void *surface;
int w, h;
Eina_List *images;
};
struct _Evas_3D_Node_Mesh
{
Evas_3D_Node *node;
Evas_3D_Mesh *mesh;
int frame;
};
struct _Evas_3D_Node
{
Evas_3D_Object base;
Eina_List *members;
Evas_3D_Node *parent;
Evas_Vec3 position;
Evas_Vec4 orientation;
Evas_Vec3 scale;
Evas_Vec3 position_world;
Evas_Vec4 orientation_world;
Evas_Vec3 scale_world;
Eina_Bool position_inherit;
Eina_Bool orientation_inherit;
Eina_Bool scale_inherit;
Evas_Box3 aabb;
Evas_3D_Node_Type type;
/* Camera node. */
union {
struct {
Evas_3D_Camera *camera;
Evas_Mat4 matrix_world_to_eye;
} camera;
struct {
Evas_3D_Light *light;
Evas_Mat4 matrix_local_to_world;
} light;
struct {
Eina_List *meshes;
Eina_Hash *node_meshes;
Evas_Mat4 matrix_local_to_world;
} mesh;
} data;
/* Scene using this node as root. */
Eina_Hash *scenes_root;
/* Scene using this node as camera. */
Eina_Hash *scenes_camera;
};
struct _Evas_3D_Camera
{
Evas_3D_Object base;
Evas_Mat4 projection;
Eina_Hash *nodes;
};
struct _Evas_3D_Light
{
Evas_3D_Object base;
Evas_Color ambient;
Evas_Color diffuse;
Evas_Color specular;
Eina_Bool directional;
Evas_Real spot_exp;
Evas_Real spot_cutoff;
Evas_Real spot_cutoff_cos;
Eina_Bool enable_attenuation;
Evas_Real atten_const;
Evas_Real atten_linear;
Evas_Real atten_quad;
Eina_Hash *nodes;
};
struct _Evas_3D_Vertex_Buffer
{
int element_count;
int stride;
void *data;
int size;
Eina_Bool owns_data;
Eina_Bool mapped;
};
struct _Evas_3D_Interpolate_Vertex_Buffer
{
void *data0;
int stride0;
int size0;
void *data1;
int stride1;
int size1;
Evas_Real weight;
};
struct _Evas_3D_Mesh_Frame
{
Evas_3D_Mesh *mesh;
int frame;
Evas_3D_Material *material;
Evas_Box3 aabb;
Evas_3D_Vertex_Buffer vertices[EVAS_3D_VERTEX_ATTRIB_COUNT];
};
struct _Evas_3D_Mesh
{
Evas_3D_Object base;
Evas_3D_Shade_Mode shade_mode;
int vertex_count;
int frame_count;
Eina_List *frames;
Evas_3D_Index_Format index_format;
int index_count;
void *indices;
int index_size;
Eina_Bool owns_indices;
Eina_Bool index_mapped;
Evas_3D_Vertex_Assembly assembly;
Eina_Hash *nodes;
};
struct _Evas_3D_Texture
{
Evas_3D_Object base;
/* List of materials using this texture. */
Eina_Hash *materials;
/* Proxy data. */
Evas_Object *source;
Eina_Bool proxy_rendering;
void *proxy_surface;
/* Engine-side object. */
void *engine_data;
};
struct _Evas_3D_Material
{
Evas_3D_Object base;
struct {
Eina_Bool enable;
Evas_Color color;
Evas_3D_Texture *texture;
} attribs[EVAS_3D_MATERIAL_ATTRIB_COUNT];
Evas_Real shininess;
Eina_Hash *meshes;
};
struct _Evas_3D_Scene_Data
{
Evas_Color bg_color;
Evas_3D_Node *camera_node;
Eina_List *light_nodes;
Eina_List *mesh_nodes;
};
struct _Evas_3D_Pick_Data
{
/* Input */
Evas_Real x, y;
Evas_Mat4 matrix_vp;
Evas_Ray3 ray_world;
/* Output */
Eina_Bool picked;
Evas_Real z;
Evas_3D_Node *node;
Evas_3D_Mesh *mesh;
Evas_Real u, v;
Evas_Real s, t;
};
/* Object generic functions. */
void evas_3d_object_init(Evas_3D_Object *obj, Evas *e, Evas_3D_Object_Type type, const Evas_3D_Object_Func *func);
Evas *evas_3d_object_evas_get(const Evas_3D_Object *obj);
Evas_3D_Object_Type evas_3d_object_type_get(const Evas_3D_Object *obj);
void evas_3d_object_reference(Evas_3D_Object *obj);
void evas_3d_object_unreference(Evas_3D_Object *obj);
int evas_3d_object_reference_count_get(const Evas_3D_Object *obj);
void evas_3d_object_change(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref);
Eina_Bool evas_3d_object_dirty_get(const Evas_3D_Object *obj, Evas_3D_State state);
void evas_3d_object_update(Evas_3D_Object *obj);
void evas_3d_object_update_done(Evas_3D_Object *obj);
/* Node functions. */
void evas_3d_node_traverse(Evas_3D_Node *from, Evas_3D_Node *to, Evas_3D_Node_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data);
void evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data);
Eina_Bool evas_3d_node_mesh_collect(Evas_3D_Node *node, void *data);
Eina_Bool evas_3d_node_light_collect(Evas_3D_Node *node, void *data);
void evas_3d_node_scene_root_add(Evas_3D_Node *node, Evas_3D_Scene *scene);
void evas_3d_node_scene_root_del(Evas_3D_Node *node, Evas_3D_Scene *scene);
void evas_3d_node_scene_camera_add(Evas_3D_Node *node, Evas_3D_Scene *scene);
void evas_3d_node_scene_camera_del(Evas_3D_Node *node, Evas_3D_Scene *scene);
/* Camera functions. */
void evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node);
void evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node);
/* Light functions. */
void evas_3d_light_node_add(Evas_3D_Light *light, Evas_3D_Node *node);
void evas_3d_light_node_del(Evas_3D_Light *light, Evas_3D_Node *node);
/* Mesh functions. */
void evas_3d_mesh_node_add(Evas_3D_Mesh *mesh, Evas_3D_Node *node);
void evas_3d_mesh_node_del(Evas_3D_Mesh *mesh, Evas_3D_Node *node);
void evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, Evas_3D_Vertex_Buffer *buffer0, Evas_3D_Vertex_Buffer *buffer1, Evas_Real *weight);
void evas_3d_mesh_file_md2_set(Evas_3D_Mesh *mesh, const char *file);
/* Texture functions. */
void evas_3d_texture_material_add(Evas_3D_Texture *texture, Evas_3D_Material *material);
void evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *material);
/* Material functions. */
void evas_3d_material_mesh_add(Evas_3D_Material *material, Evas_3D_Mesh *mesh);
void evas_3d_material_mesh_del(Evas_3D_Material *material, Evas_3D_Mesh *mesh);
/* Scene functions. */
void evas_3d_scene_data_init(Evas_3D_Scene_Data *data);
void evas_3d_scene_data_fini(Evas_3D_Scene_Data *data);

View File

@ -16,7 +16,7 @@
#include "../common/language/evas_bidi_utils.h"
#include "../common/language/evas_language_utils.h"
#include "evas_3d_private.h"
#include "evas_3d_utils.h"
#define RENDER_METHOD_INVALID 0x00000000
@ -52,6 +52,341 @@ typedef struct _Evas_Object_3D_Data Evas_Object_3D_Data;
typedef struct _Evas_Object_Protected_State Evas_Object_Protected_State;
typedef struct _Evas_Object_Protected_Data Evas_Object_Protected_Data;
// 3D stuff
#define EVAS_3D_VERTEX_ATTRIB_COUNT 5
#define EVAS_3D_MATERIAL_ATTRIB_COUNT 5
typedef struct _Evas_3D_Object Evas_3D_Object;
typedef struct _Evas_3D_Scene_Public_Data Evas_3D_Scene_Public_Data;
typedef struct _Evas_3D_Vertex_Buffer Evas_3D_Vertex_Buffer;
typedef struct _Evas_3D_Mesh_Frame Evas_3D_Mesh_Frame;
typedef struct _Evas_3D_Node_Mesh Evas_3D_Node_Mesh;
typedef struct _Evas_3D_Object_Func Evas_3D_Object_Func;
typedef struct _Evas_3D_Pick_Data Evas_3D_Pick_Data;
typedef struct _Evas_3D_Interpolate_Vertex_Buffer Evas_3D_Interpolate_Vertex_Buffer;
typedef struct _Evas_3D_Scene Evas_3D_Scene_Data;
typedef struct _Evas_3D_Node Evas_3D_Node_Data;
typedef struct _Evas_3D_Mesh Evas_3D_Mesh_Data;
typedef struct _Evas_3D_Camera Evas_3D_Camera_Data;
typedef struct _Evas_3D_Light Evas_3D_Light_Data;
typedef struct _Evas_3D_Material Evas_3D_Material_Data;
typedef struct _Evas_3D_Texture Evas_3D_Texture_Data;
typedef Eina_Bool (*Evas_3D_Node_Func)(Evas_3D_Node *, void *data);
typedef enum _Evas_3D_Object_Type
{
EVAS_3D_OBJECT_TYPE_INVALID = 0,
EVAS_3D_OBJECT_TYPE_SCENE,
EVAS_3D_OBJECT_TYPE_NODE,
EVAS_3D_OBJECT_TYPE_CAMERA,
EVAS_3D_OBJECT_TYPE_LIGHT,
EVAS_3D_OBJECT_TYPE_MODEL,
EVAS_3D_OBJECT_TYPE_MESH,
EVAS_3D_OBJECT_TYPE_TEXTURE,
EVAS_3D_OBJECT_TYPE_MATERIAL,
} Evas_3D_Object_Type;
typedef enum _Evas_3D_State
{
EVAS_3D_STATE_MAX = 16,
EVAS_3D_STATE_ANY = 0,
EVAS_3D_STATE_SCENE_ROOT_NODE = 1,
EVAS_3D_STATE_SCENE_CAMERA_NODE,
EVAS_3D_STATE_SCENE_BACKGROUND_COLOR,
EVAS_3D_STATE_SCENE_SIZE,
EVAS_3D_STATE_TEXTURE_DATA = 1,
EVAS_3D_STATE_TEXTURE_WRAP,
EVAS_3D_STATE_TEXTURE_FILTER,
EVAS_3D_STATE_MATERIAL_ID = 1,
EVAS_3D_STATE_MATERIAL_COLOR,
EVAS_3D_STATE_MATERIAL_TEXTURE,
EVAS_3D_STATE_MESH_VERTEX_COUNT = 1,
EVAS_3D_STATE_MESH_FRAME,
EVAS_3D_STATE_MESH_MATERIAL,
EVAS_3D_STATE_MESH_TRANSFORM,
EVAS_3D_STATE_MESH_VERTEX_DATA,
EVAS_3D_STATE_MESH_INDEX_DATA,
EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY,
EVAS_3D_STATE_MESH_SHADE_MODE,
EVAS_3D_STATE_CAMERA_PROJECTION = 1,
EVAS_3D_STATE_LIGHT_AMBIENT = 1,
EVAS_3D_STATE_LIGHT_DIFFUSE,
EVAS_3D_STATE_LIGHT_SPECULAR,
EVAS_3D_STATE_LIGHT_SPOT_DIR,
EVAS_3D_STATE_LIGHT_SPOT_EXP,
EVAS_3D_STATE_LIGHT_SPOT_CUTOFF,
EVAS_3D_STATE_LIGHT_ATTENUATION,
EVAS_3D_STATE_NODE_TRANSFORM = 1,
EVAS_3D_STATE_NODE_MESH_GEOMETRY,
EVAS_3D_STATE_NODE_MESH_MATERIAL,
EVAS_3D_STATE_NODE_MESH_FRAME,
EVAS_3D_STATE_NODE_MESH_SHADE_MODE,
EVAS_3D_STATE_NODE_MESH_MATERIAL_ID,
EVAS_3D_STATE_NODE_LIGHT,
EVAS_3D_STATE_NODE_CAMERA,
EVAS_3D_STATE_NODE_PARENT,
EVAS_3D_STATE_NODE_MEMBER,
} Evas_3D_State;
typedef enum _Evas_3D_Node_Traverse_Type
{
EVAS_3D_NODE_TRAVERSE_DOWNWARD,
EVAS_3D_NODE_TRAVERSE_UPWARD,
} Evas_3D_Node_Traverse_Type;
typedef enum _Evas_3D_Tree_Traverse_Type
{
EVAS_3D_TREE_TRAVERSE_PRE_ORDER,
EVAS_3D_TREE_TRAVERSE_ANY_ORDER = EVAS_3D_TREE_TRAVERSE_PRE_ORDER,
EVAS_3D_TREE_TRAVERSE_POST_ORDER,
EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER,
} Evas_3D_Tree_Traverse_Type;
struct _Evas_3D_Object_Func
{
void (*free)(Evas_3D_Object *obj);
void (*change)(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref);
void (*update)(Evas_3D_Object *obj);
};
struct _Evas_3D_Object
{
Evas *evas;
Evas_3D_Object_Type type;
int ref_count;
Evas_3D_Object_Func func;
Eina_Bool dirty[EVAS_3D_STATE_MAX];
};
struct _Evas_3D_Scene
{
Evas_3D_Object base;
Evas_3D_Node *root_node;
Evas_3D_Node *camera_node;
//@FIXME
Evas_3D_Scene *hack_this;
Evas_Color bg_color;
void *surface;
int w, h;
Eina_List *images;
};
struct _Evas_3D_Node_Mesh
{
Evas_3D_Node *node;
Evas_3D_Mesh *mesh;
int frame;
};
struct _Evas_3D_Node
{
Evas_3D_Object base;
Eina_List *members;
Evas_3D_Node *parent;
//@FIXME
Evas_3D_Node *hack_this;
Evas_Vec3 position;
Evas_Vec4 orientation;
Evas_Vec3 scale;
Evas_Vec3 position_world;
Evas_Vec4 orientation_world;
Evas_Vec3 scale_world;
Eina_Bool position_inherit;
Eina_Bool orientation_inherit;
Eina_Bool scale_inherit;
Evas_Box3 aabb;
Evas_3D_Node_Type type;
/* Camera node. */
union {
struct {
Evas_3D_Camera *camera;
Evas_Mat4 matrix_world_to_eye;
} camera;
struct {
Evas_3D_Light *light;
Evas_Mat4 matrix_local_to_world;
} light;
struct {
Eina_List *meshes;
Eina_Hash *node_meshes;
Evas_Mat4 matrix_local_to_world;
} mesh;
} data;
/* Scene using this node as root. */
Eina_Hash *scenes_root;
/* Scene using this node as camera. */
Eina_Hash *scenes_camera;
};
struct _Evas_3D_Camera
{
Evas_3D_Object base;
Evas_Mat4 projection;
Eina_Hash *nodes;
};
struct _Evas_3D_Light
{
Evas_3D_Object base;
Evas_Color ambient;
Evas_Color diffuse;
Evas_Color specular;
Eina_Bool directional;
Evas_Real spot_exp;
Evas_Real spot_cutoff;
Evas_Real spot_cutoff_cos;
Eina_Bool enable_attenuation;
Evas_Real atten_const;
Evas_Real atten_linear;
Evas_Real atten_quad;
Eina_Hash *nodes;
};
struct _Evas_3D_Vertex_Buffer
{
int element_count;
int stride;
void *data;
int size;
Eina_Bool owns_data;
Eina_Bool mapped;
};
struct _Evas_3D_Interpolate_Vertex_Buffer
{
void *data0;
int stride0;
int size0;
void *data1;
int stride1;
int size1;
Evas_Real weight;
};
struct _Evas_3D_Mesh_Frame
{
Evas_3D_Mesh *mesh;
int frame;
Evas_3D_Material *material;
Evas_Box3 aabb;
Evas_3D_Vertex_Buffer vertices[EVAS_3D_VERTEX_ATTRIB_COUNT];
};
struct _Evas_3D_Mesh
{
Evas_3D_Object base;
Evas_3D_Shade_Mode shade_mode;
int vertex_count;
int frame_count;
Eina_List *frames;
Evas_3D_Index_Format index_format;
int index_count;
void *indices;
int index_size;
Eina_Bool owns_indices;
Eina_Bool index_mapped;
Evas_3D_Vertex_Assembly assembly;
Eina_Hash *nodes;
};
struct _Evas_3D_Texture
{
Evas_3D_Object base;
/* List of materials using this texture. */
Eina_Hash *materials;
/* Proxy data. */
Evas_Object *source;
Eina_Bool proxy_rendering;
void *proxy_surface;
/* Engine-side object. */
void *engine_data;
};
struct _Evas_3D_Material
{
Evas_3D_Object base;
struct {
Eina_Bool enable;
Evas_Color color;
Evas_3D_Texture *texture;
} attribs[EVAS_3D_MATERIAL_ATTRIB_COUNT];
Evas_Real shininess;
Eina_Hash *meshes;
};
struct _Evas_3D_Scene_Public_Data
{
Evas_Color bg_color;
Evas_3D_Node *camera_node;
Eina_List *light_nodes;
Eina_List *mesh_nodes;
};
struct _Evas_3D_Pick_Data
{
/* Input */
Evas_Real x, y;
Evas_Mat4 matrix_vp;
Evas_Ray3 ray_world;
/* Output */
Eina_Bool picked;
Evas_Real z;
Evas_3D_Node *node;
Evas_3D_Mesh *mesh;
Evas_Real u, v;
Evas_Real s, t;
};
enum _Evas_Font_Style
{
EVAS_FONT_STYLE_SLANT,
@ -432,7 +767,7 @@ struct _Evas_Public_Data
Eina_List *touch_points;
Eina_List *devices;
Eina_Array *cur_device;
Eina_List *outputs;
unsigned char changed : 1;
@ -526,7 +861,7 @@ struct _Evas_Object_Proxy_Data
struct _Evas_Object_Map_Data
{
struct {
struct {
Evas_Map *map;
Evas_Object *map_parent;
@ -1240,6 +1575,63 @@ void _canvas_objects_in_rectangle_get(Eo *obj, void *_pd, va_list *list);
void _canvas_smart_objects_calculate(Eo *e, void *_pd, va_list *list);
void _canvas_smart_objects_calculate_count_get(Eo *e, void *_pd, va_list *list);
/* Object generic functions. 3D function*/
void evas_3d_object_init(Evas_3D_Object *obj, Evas *e, Evas_3D_Object_Type type, const Evas_3D_Object_Func *func);
Evas *evas_3d_object_evas_get(const Evas_3D_Object *obj);
Evas_3D_Object_Type evas_3d_object_type_get(const Evas_3D_Object *obj);
void evas_3d_object_reference(Evas_3D_Object *obj);
void evas_3d_object_unreference(Evas_3D_Object *obj);
int evas_3d_object_reference_count_get(const Evas_3D_Object *obj);
void evas_3d_object_change(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref);
Eina_Bool evas_3d_object_dirty_get(const Evas_3D_Object *obj, Evas_3D_State state);
void evas_3d_object_update(Evas_3D_Object *obj);
void evas_3d_object_update_done(Evas_3D_Object *obj);
/* Node functions. */
void evas_3d_node_traverse(Evas_3D_Node *from, Evas_3D_Node *to, Evas_3D_Node_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data);
void evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data);
Eina_Bool evas_3d_node_mesh_collect(Evas_3D_Node *node, void *data);
Eina_Bool evas_3d_node_light_collect(Evas_3D_Node *node, void *data);
void evas_3d_node_scene_root_add(Evas_3D_Node *node, Evas_3D_Scene *scene);
void evas_3d_node_scene_root_del(Evas_3D_Node *node, Evas_3D_Scene *scene);
void evas_3d_node_scene_camera_add(Evas_3D_Node *node, Evas_3D_Scene *scene);
void evas_3d_node_scene_camera_del(Evas_3D_Node *node, Evas_3D_Scene *scene);
/* Camera functions. */
void evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node);
void evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node);
/* Light functions. */
void evas_3d_light_node_add(Evas_3D_Light *light, Evas_3D_Node *node);
void evas_3d_light_node_del(Evas_3D_Light *light, Evas_3D_Node *node);
/* Mesh functions. */
void evas_3d_mesh_node_add(Evas_3D_Mesh *mesh, Evas_3D_Node *node);
void evas_3d_mesh_node_del(Evas_3D_Mesh *mesh, Evas_3D_Node *node);
void evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, Evas_3D_Vertex_Buffer *buffer0, Evas_3D_Vertex_Buffer *buffer1, Evas_Real *weight);
void evas_3d_mesh_file_md2_set(Evas_3D_Mesh *mesh, const char *file);
/* Texture functions. */
void evas_3d_texture_material_add(Evas_3D_Texture *texture, Evas_3D_Material *material);
void evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *material);
/* Material functions. */
void evas_3d_material_mesh_add(Evas_3D_Material *material, Evas_3D_Mesh *mesh);
void evas_3d_material_mesh_del(Evas_3D_Material *material, Evas_3D_Mesh *mesh);
/* Scene functions. */
void evas_3d_scene_data_init(Evas_3D_Scene_Public_Data *data);
void evas_3d_scene_data_fini(Evas_3D_Scene_Public_Data *data);
extern int _evas_alloc_error;
extern int _evas_event_counter;
@ -1310,7 +1702,7 @@ void _evas_device_cleanup(Evas *e);
Evas_Device *_evas_device_top_get(const Evas *e);
void _evas_device_ref(Evas_Device *dev);
void _evas_device_unref(Evas_Device *dev);
extern Eina_Cow *evas_object_proxy_cow;
extern Eina_Cow *evas_object_map_cow;
extern Eina_Cow *evas_object_state_cow;
@ -1336,7 +1728,7 @@ extern Eina_Cow *evas_object_image_state_cow;
/********************/
#define MPOOL 1
#ifdef MPOOL
#ifdef MPOOL
typedef struct _Evas_Mempool Evas_Mempool;
struct _Evas_Mempool

View File

@ -702,7 +702,8 @@ e3d_drawable_format_get(E3D_Drawable *drawable)
static inline GLuint
_texture_id_get(Evas_3D_Texture *texture)
{
E3D_Texture *tex = (E3D_Texture *)texture->engine_data;
Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, EO_EVAS_3D_TEXTURE_CLASS);
E3D_Texture *tex = (E3D_Texture *)pd->engine_data;
return tex->tex;
}
@ -713,8 +714,9 @@ _mesh_frame_find(Evas_3D_Mesh *mesh, int frame,
{
Eina_List *left, *right;
Evas_3D_Mesh_Frame *f0, *f1;
Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS);
left = mesh->frames;
left = pdmesh->frames;
right = eina_list_next(left);
while (right)
@ -940,8 +942,12 @@ _material_color_build(E3D_Draw_Data *data, int frame,
{
f0 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(l);
if (f0->material && f0->material->attribs[attrib].enable)
break;
if (f0->material)
{
Evas_3D_Material_Data *pdm = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS);
if (pdm->attribs[attrib].enable)
break;
}
l = eina_list_prev(l);
f0 = NULL;
@ -951,8 +957,12 @@ _material_color_build(E3D_Draw_Data *data, int frame,
{
f1 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(r);
if (f1->material && f1->material->attribs[attrib].enable)
break;
if (f1->material)
{
Evas_3D_Material_Data *pdm = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS);
if (pdm->attribs[attrib].enable)
break;
}
r = eina_list_next(r);
f1 = NULL;
@ -978,28 +988,29 @@ _material_color_build(E3D_Draw_Data *data, int frame,
f1 = NULL;
}
}
Evas_3D_Material_Data *pdmf0 = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS);
if (f1 == NULL)
{
data->materials[attrib].color = f0->material->attribs[attrib].color;
data->materials[attrib].color = pdmf0->attribs[attrib].color;
if (attrib == EVAS_3D_MATERIAL_SPECULAR)
data->shininess = f0->material->shininess;
data->shininess = pdmf0->shininess;
}
else
{
Evas_Real weight;
Evas_3D_Material_Data *pdmf1 = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS);
weight = (f1->frame - frame) / (Evas_Real)(f1->frame - f0->frame);
evas_color_blend(&data->materials[attrib].color,
&f0->material->attribs[attrib].color,
&f1->material->attribs[attrib].color,
&pdmf0->attribs[attrib].color,
&pdmf0->attribs[attrib].color,
weight);
if (attrib == EVAS_3D_MATERIAL_SPECULAR)
{
data->shininess = f0->material->shininess * weight +
f1->material->shininess * (1.0 - weight);
data->shininess = pdmf0->shininess * weight +
pdmf1->shininess * (1.0 - weight);
}
}
@ -1018,10 +1029,12 @@ _material_texture_build(E3D_Draw_Data *data, int frame,
{
f0 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(l);
if (f0->material &&
f0->material->attribs[attrib].enable &&
f0->material->attribs[attrib].texture != NULL)
break;
if (f0->material)
{
Evas_3D_Material_Data *pdm = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS);
if (pdm->attribs[attrib].enable && pdm->attribs[attrib].texture != NULL)
break;
}
l = eina_list_prev(l);
f0 = NULL;
@ -1031,10 +1044,12 @@ _material_texture_build(E3D_Draw_Data *data, int frame,
{
f1 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(r);
if (f1->material &&
f1->material->attribs[attrib].enable &&
f1->material->attribs[attrib].texture != NULL)
break;
if (f1->material)
{
Evas_3D_Material_Data *pdm = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS);
if (pdm->attribs[attrib].enable && pdm->attribs[attrib].texture != NULL)
break;
}
r = eina_list_next(r);
f1 = NULL;
@ -1061,24 +1076,26 @@ _material_texture_build(E3D_Draw_Data *data, int frame,
}
}
Evas_3D_Material_Data *pdmf0 = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS);
data->materials[attrib].sampler0 = data->texture_count++;
data->materials[attrib].tex0 =
(E3D_Texture *)f0->material->attribs[attrib].texture->engine_data;
Evas_3D_Texture_Data *pd = eo_data_scope_get(pdmf0->attribs[attrib].texture, EO_EVAS_3D_TEXTURE_CLASS);
data->materials[attrib].tex0 = (E3D_Texture *)pd->engine_data;
if (f1)
{
Evas_3D_Material_Data *pdmf1 = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS);
Evas_Real weight = (f1->frame - frame) / (Evas_Real)(f1->frame - f0->frame);
data->materials[attrib].sampler1 = data->texture_count++;
data->materials[attrib].tex1 =
(E3D_Texture *)f1->material->attribs[attrib].texture->engine_data;
Evas_3D_Texture_Data *pd = eo_data_scope_get(pdmf1->attribs[attrib].texture, EO_EVAS_3D_TEXTURE_CLASS);
data->materials[attrib].tex1 = (E3D_Texture *)pd->engine_data;
data->materials[attrib].texture_weight = weight;
if (attrib == EVAS_3D_MATERIAL_SPECULAR)
{
data->shininess = f0->material->shininess * weight +
f1->material->shininess * (1.0 - weight);
data->shininess = pdmf0->shininess * weight +
pdmf1->shininess * (1.0 - weight);
}
_material_texture_flag_add(data, attrib, EINA_TRUE);
@ -1086,7 +1103,7 @@ _material_texture_build(E3D_Draw_Data *data, int frame,
else
{
if (attrib == EVAS_3D_MATERIAL_SPECULAR)
data->shininess = f0->material->shininess;
data->shininess = pdmf0->shininess;
_material_texture_flag_add(data, attrib, EINA_FALSE);
}
@ -1099,20 +1116,22 @@ _light_build(E3D_Draw_Data *data,
const Evas_3D_Node *light,
const Evas_Mat4 *matrix_eye)
{
Evas_3D_Light *l = light->data.light.light;
Evas_3D_Node_Data *pd_light_node = eo_data_scope_get(light, EO_EVAS_3D_NODE_CLASS);
Evas_3D_Light *l = pd_light_node->data.light.light;
Evas_3D_Light_Data *pdl = eo_data_scope_get(l, EO_EVAS_3D_LIGHT_CLASS);
Evas_Vec3 pos, dir;
if (l == NULL)
if (pdl == NULL)
return;
/* Get light node's position. */
if (l->directional)
if (pdl->directional)
{
data->flags |= E3D_SHADER_FLAG_LIGHT_DIRECTIONAL;
/* Negative Z. */
evas_vec3_set(&dir, 0.0, 0.0, 1.0);
evas_vec3_quaternion_rotate(&dir, &dir, &light->orientation);
evas_vec3_quaternion_rotate(&dir, &dir, &pd_light_node->orientation);
/* Transform to eye space. */
evas_vec3_homogeneous_direction_transform(&dir, &dir, matrix_eye);
@ -1125,7 +1144,7 @@ _light_build(E3D_Draw_Data *data,
}
else
{
evas_vec3_copy(&pos, &light->position_world);
evas_vec3_copy(&pos, &pd_light_node->position_world);
evas_vec3_homogeneous_position_transform(&pos, &pos, matrix_eye);
data->light.position.x = pos.x;
@ -1133,31 +1152,31 @@ _light_build(E3D_Draw_Data *data,
data->light.position.z = pos.z;
data->light.position.w = 1.0;
if (l->enable_attenuation)
if (pdl->enable_attenuation)
{
data->flags |= E3D_SHADER_FLAG_LIGHT_ATTENUATION;
data->light.atten.x = l->atten_const;
data->light.atten.x = l->atten_linear;
data->light.atten.x = l->atten_quad;
data->light.atten.x = pdl->atten_const;
data->light.atten.x = pdl->atten_linear;
data->light.atten.x = pdl->atten_quad;
}
if (l->spot_cutoff < 180.0)
if (pdl->spot_cutoff < 180.0)
{
data->flags |= E3D_SHADER_FLAG_LIGHT_SPOT;
evas_vec3_set(&dir, 0.0, 0.0, -1.0);
evas_vec3_quaternion_rotate(&dir, &dir, &light->orientation);
evas_vec3_quaternion_rotate(&dir, &dir, &pd_light_node->orientation);
evas_vec3_homogeneous_direction_transform(&dir, &dir, matrix_eye);
data->light.spot_dir = dir;
data->light.spot_exp = l->spot_exp;
data->light.spot_cutoff_cos = l->spot_cutoff_cos;
data->light.spot_exp = pdl->spot_exp;
data->light.spot_cutoff_cos = pdl->spot_cutoff_cos;
}
}
data->light.ambient = l->ambient;
data->light.diffuse = l->diffuse;
data->light.specular = l->specular;
data->light.ambient = pdl->ambient;
data->light.diffuse = pdl->diffuse;
data->light.specular = pdl->specular;
}
static inline Eina_Bool
@ -1169,16 +1188,17 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
const Evas_3D_Node *light)
{
Eina_List *l, *r;
Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS);
if (mesh->frames == NULL)
if (pdmesh->frames == NULL)
return EINA_FALSE;
data->mode = mesh->shade_mode;
data->assembly = mesh->assembly;
data->vertex_count = mesh->vertex_count;
data->index_count = mesh->index_count;
data->index_format = mesh->index_format;
data->indices = mesh->indices;
data->mode = pdmesh->shade_mode;
data->assembly = pdmesh->assembly;
data->vertex_count = pdmesh->vertex_count;
data->index_count = pdmesh->index_count;
data->index_format = pdmesh->index_format;
data->indices = pdmesh->indices;
evas_mat4_copy(&data->matrix_mvp, matrix_mvp);
evas_mat4_copy(&data->matrix_mv, matrix_mv);
@ -1195,12 +1215,12 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
} \
} while (0)
if (mesh->shade_mode == EVAS_3D_SHADE_MODE_VERTEX_COLOR)
if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_VERTEX_COLOR)
{
BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
BUILD(vertex_attrib, VERTEX_COLOR, EINA_TRUE);
}
else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_DIFFUSE)
else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_DIFFUSE)
{
BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
BUILD(material_color, MATERIAL_DIFFUSE, EINA_TRUE);
@ -1209,7 +1229,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
if (_flags_need_tex_coord(data->flags))
BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE);
}
else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_FLAT)
else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_FLAT)
{
BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
BUILD(vertex_attrib, VERTEX_NORMAL, EINA_TRUE);
@ -1230,7 +1250,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
if (_flags_need_tex_coord(data->flags))
BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE);
}
else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_PHONG)
else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_PHONG)
{
BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
BUILD(vertex_attrib, VERTEX_NORMAL, EINA_TRUE);
@ -1251,7 +1271,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
if (_flags_need_tex_coord(data->flags))
BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE);
}
else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_NORMAL_MAP)
else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_NORMAL_MAP)
{
BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
BUILD(vertex_attrib, VERTEX_NORMAL, EINA_TRUE);
@ -1289,7 +1309,7 @@ _mesh_draw(E3D_Renderer *renderer, Evas_3D_Mesh *mesh, int frame, Evas_3D_Node *
}
void
e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Data *data)
e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data)
{
Eina_List *l;
Evas_3D_Node *n;
@ -1301,7 +1321,10 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3
e3d_renderer_clear(renderer, &data->bg_color);
/* Get eye matrix. */
matrix_eye = &data->camera_node->data.camera.matrix_world_to_eye;
Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(data->camera_node, EO_EVAS_3D_NODE_CLASS);
matrix_eye = &pd_camera_node->data.camera.matrix_world_to_eye;
Evas_3D_Camera_Data *pd = eo_data_scope_get(pd_camera_node->data.camera.camera, EO_EVAS_3D_CAMERA_CLASS);
EINA_LIST_FOREACH(data->mesh_nodes, l, n)
{
@ -1309,15 +1332,16 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3
Evas_Mat4 matrix_mvp;
Eina_Iterator *it;
void *ptr;
evas_mat4_multiply(&matrix_mv, matrix_eye, &n->data.mesh.matrix_local_to_world);
evas_mat4_multiply(&matrix_mvp, &data->camera_node->data.camera.camera->projection,
Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS);
evas_mat4_multiply(&matrix_mv, matrix_eye, &pd_mesh_node->data.mesh.matrix_local_to_world);
evas_mat4_multiply(&matrix_mvp, matrix_eye, &matrix_mv);
evas_mat4_multiply(&matrix_mvp, &pd->projection,
&matrix_mv);
/* TODO: Get most effective light node. */
light = eina_list_data_get(data->light_nodes);
it = eina_hash_iterator_data_new(n->data.mesh.node_meshes);
it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes);
while (eina_iterator_next(it, &ptr))
{

View File

@ -27,7 +27,7 @@ void e3d_texture_filter_get(const E3D_Texture *texture, Evas_3D_
/* Drawable */
E3D_Drawable *e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_format);
void e3d_drawable_free(E3D_Drawable *drawable);
void e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Data *data);
void e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data);
void e3d_drawable_size_get(E3D_Drawable *drawable, int *w, int *h);
GLuint e3d_drawable_texture_id_get(E3D_Drawable *drawable);
GLenum e3d_drawable_format_get(E3D_Drawable *drawable);

View File

@ -1251,15 +1251,27 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data)
{
switch (u)
{
case E3D_UNIFORM_MATRIX_MVP:
glUniformMatrix4fv(loc, 1, EINA_FALSE, &data->matrix_mvp.m[0]);
case E3D_UNIFORM_MATRIX_MVP: {
float m[16];
for(int i = 0 ; i <16 ; i++)
m[i] = data->matrix_mvp.m[i];
glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]);
break;
case E3D_UNIFORM_MATRIX_MV:
glUniformMatrix4fv(loc, 1, EINA_FALSE, &data->matrix_mv.m[0]);
}
case E3D_UNIFORM_MATRIX_MV: {
float m[16];
for(int i = 0 ; i <16 ; i++)
m[i] = data->matrix_mv.m[i];
glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]);
break;
case E3D_UNIFORM_MATRIX_NORMAL:
glUniformMatrix3fv(loc, 1, EINA_FALSE, &data->matrix_normal.m[0]);
}
case E3D_UNIFORM_MATRIX_NORMAL: {
float m[9];
for(int i = 0 ; i <9 ; i++)
m[i] = data->matrix_normal.m[i];
glUniformMatrix3fv(loc, 1, EINA_FALSE, &m[0]);
break;
}
case E3D_UNIFORM_POSITION_WEIGHT:
glUniform1f(loc, data->vertices[EVAS_3D_VERTEX_POSITION].weight);
break;