canvas 3d: remove all canvas3d features across efl.

Reviewers: jsuya, kimcinoo, bu5hm4n, raster

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11552
This commit is contained in:
Hermet Park 2020-03-25 19:14:02 +09:00
parent d4e6303d9e
commit 476e2b0521
118 changed files with 9 additions and 36960 deletions

View File

@ -270,7 +270,6 @@ static void st_collections_group_script_recursion(void);
static void st_collections_group_alias(void);
static void st_collections_group_min(void);
static void st_collections_group_max(void);
static void st_collections_group_scene_size(void);
static void st_collections_group_broadcast_signal(void);
static void st_collections_group_data_item(void);
static void st_collections_group_orientation(void);
@ -680,7 +679,6 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.alias", st_collections_group_alias},
{"collections.group.min", st_collections_group_min},
{"collections.group.max", st_collections_group_max},
{"collections.group.scene_size", st_collections_group_scene_size},
{"collections.group.broadcast_signal", st_collections_group_broadcast_signal},
{"collections.group.orientation", st_collections_group_orientation},
{"collections.group.mouse_events", st_collections_group_mouse_events},
@ -4126,9 +4124,6 @@ ob_collections_group(void)
pcp->default_mouse_events = 1;
pcp->inherit_script = EINA_FALSE;
pc->scene_size.width = 0;
pc->scene_size.height = 0;
#ifdef HAVE_EPHYSICS
pc->physics.world.gravity.x = 0;
pc->physics.world.gravity.y = 294;
@ -4317,18 +4312,6 @@ _parts_count_update(unsigned int type, int inc)
current_de->count.PROXY += inc;
break;
case EDJE_PART_TYPE_MESH_NODE:
current_de->count.MESH_NODE += inc;
break;
case EDJE_PART_TYPE_LIGHT:
current_de->count.LIGHT += inc;
break;
case EDJE_PART_TYPE_CAMERA:
current_de->count.CAMERA += inc;
break;
case EDJE_PART_TYPE_SPACER:
current_de->count.SPACER += inc;
break;
@ -5182,30 +5165,6 @@ st_collections_group_max(void)
pc->prop.max.h = parse_int_range(1, 0, 0x7fffffff);
}
/**
@page edcref
@property
scene_size
@parameters
[width] [height]
@effect
Size of scene.
Defaults: 0.0 0.0
@endproperty
*/
static void
st_collections_group_scene_size(void)
{
Edje_Part_Collection *pc;
check_arg_count(2);
pc = eina_list_data_get(eina_list_last(edje_collections));
pc->scene_size.width = parse_float(0);
pc->scene_size.height = parse_float(1);
}
/**
@page edcref
@property
@ -6524,9 +6483,6 @@ st_collections_group_parts_part_name(void)
@li BOX
@li TABLE
@li EXTERNAL
@li MESH_NODE
@li CAMERA
@li LIGHT
@li PROXY
@li SPACER
@li SNAPSHOT
@ -6538,9 +6494,6 @@ static void
st_collections_group_parts_part_type(void)
{
unsigned int type;
unsigned int i = 0;
Edje_Part_Collection *pc;
check_arg_count(1);
@ -6556,29 +6509,11 @@ st_collections_group_parts_part_type(void)
"TABLE", EDJE_PART_TYPE_TABLE,
"EXTERNAL", EDJE_PART_TYPE_EXTERNAL,
"PROXY", EDJE_PART_TYPE_PROXY,
"MESH_NODE", EDJE_PART_TYPE_MESH_NODE,
"LIGHT", EDJE_PART_TYPE_LIGHT,
"CAMERA", EDJE_PART_TYPE_CAMERA,
"SPACER", EDJE_PART_TYPE_SPACER,
"SNAPSHOT", EDJE_PART_TYPE_SNAPSHOT,
"VECTOR", EDJE_PART_TYPE_VECTOR,
NULL);
pc = eina_list_data_get(eina_list_last(edje_collections));
if (type == EDJE_PART_TYPE_CAMERA)
{
for (i = 0; i < (pc->parts_count - 1); i++)
{
if (pc->parts[i]->type == EDJE_PART_TYPE_CAMERA)
{
WRN("parse error %s:%i. more then one part of type CAMERA in scene.",
file_in, line - 1);
exit(-1);
}
}
}
_part_type_set(type);
}

View File

@ -715,13 +715,6 @@ check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef)
Edje_Program_Target *et;
Eina_List *l;
unsigned int i = 0;
int camera_id = -1;
for (i = 0; (i < pc->parts_count) && (camera_id < 0); i++)
{
if (pc->parts[i]->type == EDJE_PART_TYPE_CAMERA)
camera_id = i;
}
if ((!ep->targets) && (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT))
{

View File

@ -1297,8 +1297,6 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias);
EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "aliased", aliased);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.width", scene_size.width, EDJE_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.height", scene_size.height, EDJE_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT);

View File

@ -897,9 +897,6 @@ struct _Edje_Limit
TYPE TABLE; \
TYPE SPACER; \
TYPE EXTERNAL; \
TYPE MESH_NODE; \
TYPE LIGHT; \
TYPE CAMERA; \
TYPE SNAPSHOT; \
TYPE VECTOR;
@ -1149,11 +1146,6 @@ struct _Edje_Part_Collection
} patterns;
/* *** *** */
struct {
Evas_Real height;
Evas_Real width;
} scene_size;
unsigned char lua_script_only;
unsigned char broadcast_signal;
unsigned char physics_enabled; /* will be 1 if a body is declared */
@ -2368,9 +2360,6 @@ EAPI extern Eina_Mempool *_emp_BOX;
EAPI extern Eina_Mempool *_emp_TABLE;
EAPI extern Eina_Mempool *_emp_EXTERNAL;
EAPI extern Eina_Mempool *_emp_SPACER;
EAPI extern Eina_Mempool *_emp_MESH_NODE;
EAPI extern Eina_Mempool *_emp_LIGHT;
EAPI extern Eina_Mempool *_emp_CAMERA;
EAPI extern Eina_Mempool *_emp_SNAPSHOT;
EAPI extern Eina_Mempool *_emp_part;
EAPI extern Eina_Mempool *_emp_VECTOR;

View File

@ -119,218 +119,6 @@ struct _Efl_Canvas_Object_Animation_Event
#include "canvas/efl_canvas_object_animation.eo.h"
#include "canvas/efl_canvas_event_grabber.eo.h"
/**
* @defgroup Evas_3D Evas 3D Extensions
*
* Evas extension to support 3D rendering.
*
* @ingroup Evas
*/
#include "canvas/evas_canvas3d_types.eot.h"
/**
* @page evas_canvas3d_main Evas 3D
*
* @since 1.10
*
* @section evas_canvas3d_toc Table of Contents
*
* @li @ref evas_canvas3d_intro
* @li @ref evas_canvas3d_example
*
* @section evas_canvas3d_intro Introduction
*
* Evas 3D is an extension to support 3D scene graph rendering into 2D Evas
* canvases, with tree-based scene graph manipulation and other typical 3D
* rendering techniques.
*
* 3D objects are used to describe three dimensional scenes and to provide
* interfaces to connect the scene to an Evas image object for rendering.
*
* Scenes are constructed by locating cameras and lights and selecting desired
* meshes, and organizing Node objects into hierarchical n-ary tree data structures.
* The scene is stacked on the canvas with existing Evas objects, which permits
* intermingling 3D rendered content in existing 2D application layouts.
*
* Rendering techniques supported by Evas 3D include flat and phong
* shading, normal and texture mapping, and triangle meshes. Existing
* Evas objects may also be used as textures inside the 3D scene,
* including EFL widgets and even application windows. This latter
* capability makes it possible to create a 3D version of an arbitrary
* EFL application with minimal code changes.
*
* @section evas_canvas3d_example Introductory Example
*
* @include evas-3d-cube.c
*/
/**
* @defgroup Evas_Canvas3D_Types Types & Enums
* @ingroup Evas_3D
*
* Primitive type definitions and enumerations.
*/
/**
* @defgroup Evas_Canvas3D_Object Generic 3D Object Descriptions
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Object structure is an abstract base for other Evas
* 3D objects (scenes, nodes, lights, meshes, textures, and materials)
* with reference counting and propagation of modifications via
* reference tracking. This permits, for example, when a scene object
* is modified (marked dirty), a number of image objects rendering that
* object to be notified to update themselves, without needing to call
* update functions manually.
*/
/**
* @defgroup Evas_Canvas3D_Scene Scene Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Scene structure represents a captured image of a
* scene graph through its viewing camera. A scene can be associated
* with an image object for canvas display via the
* evas_object_image_scene_set() function.
*/
/**
* @defgroup Evas_Canvas3D_Node Node Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Node structure defines the position, orientation,
* and scale of canvas objects (cameras, lights, meshes, etc.) in a 3D
* space. These nodes can be organized into a hierarchical n-ary tree
* structure to construct a scene graph.
*/
/**
* @defgroup Evas_Canvas3D_Camera Camera Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Camera structure defines properties used to
* generate 2D pictures of a given scene graph, similar in concept to
* focus length and film size for a real world camera.
*
* A given camera definition can be used to take multiple pictures of
* the scene by establishing multiple nodes for the
* Evas_Canvas3D_Camera, each of which are located at different
* positions and with different orientations. Convenience routines
* evas_canvas3d_node_position_set() and
* evas_canvas3d_node_look_at_set() are provided to adjust the position
* and viewing direction for these nodes.
*/
/**
* @defgroup Evas_Canvas3D_Light Light Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Light structure defines various light source
* properties. Reflection models include: Ambient, diffuse, and
* specular. Light models include directional, point, and spot. The
* position and direction for the light is tracked by the node that
* contains the light.
*/
/**
* @defgroup Evas_Canvas3D_Mesh Mesh Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Mesh structure manages key-frame based mesh
* animations for geometrical objects like character models, terrain,
* buildings, and other such visible objects. Each mesh frame can have
* its own material and geometric data. Blending functions, fog
* effects, level of detail boundaries, and shadow properties are also
* supported.
*
* Like other data objects, a mesh definition is located and oriented in
* the canvas with one or more nodes, with the mesh transformed from its
* modeling coordinate space to the node's coordinate space. The frame
* number is also tracked by the node, permitting creation of multiple
* nodes in the canvas each set to a different animation frame, for
* example.
*
* Unlike camera and light objects, multiple meshes can be contained in
* a single node.
*/
/**
* @defgroup Evas_Canvas3D_Primitive Primitive Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Primitive structure defines the data for
* generating meshes for various types of primitive shapes such as
* cubes, cylinders, spheres, surfaces, terrain, etc. Use the
* evas_canvas3d_mesh_from_primitive_set() function to generate a
* mesh's frame of this primitive.
*/
/**
* @defgroup Evas_Canvas3D_Texture Texture Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Texture structure associates a 2D bitmap image to a
* material for a surface. Image data for the texture can be loaded
* from memory, a file, or an Evas_Object. Use the
* evas_canvas3d_material_texture_set() function to add the texture to
* an Evas_Canvas3DMaterial's slot.
*/
/**
* @defgroup Evas_Canvas3D_Material Material Object
* @ingroup Evas_3D
*
* The Evas_Canvas3D_Material structure defines a set of material
* attributes used for determining the color of mesh surfaces. Each
* attribute is defined by a color value and texture map. The five
* attributes are: ambient, diffuse, specular, emission, and normal.
*/
/**
* @typedef Evas_Canvas3D_Surface_Func
*
* The Evas_Canvas3D_Surface_Func type of functions are used to
* create parametric surfaces as primitives. These compute the
* vertex x,y,z values for given v,u values.
*
* @param out_x The x component of the calculated value.
* @param out_y The y component of the calculated value.
* @param out_z The z component of the calculated value.
* @param a is the v value.
* @param b is the u value.
* @see Evas_Canvas3D_Primitive
*
* @since 1.15
* @ingroup Evas_Canvas3D_Primitive
*/
typedef void (Evas_Canvas3D_Surface_Func)(Evas_Real *out_x,
Evas_Real *out_y,
Evas_Real *out_z,
Evas_Real a,
Evas_Real b);
#include "canvas/evas_canvas3d_object.eo.h"
#include "canvas/evas_canvas3d_texture.eo.h"
#include "canvas/evas_canvas3d_material.eo.h"
#include "canvas/evas_canvas3d_light.eo.h"
#include "canvas/evas_canvas3d_primitive.eo.h"
#include "canvas/evas_canvas3d_mesh.eo.h"
#include "canvas/evas_canvas3d_node.eo.h"
#include "canvas/evas_canvas3d_camera.eo.h"
#include "canvas/evas_canvas3d_scene.eo.h"
#include "canvas/efl_canvas_scene3d.eo.h"
#include "canvas/efl_canvas_image_internal.eo.h"
#include "canvas/efl_canvas_image.eo.h"
#include "canvas/efl_canvas_snapshot.eo.h"

View File

@ -1,310 +0,0 @@
#include "evas_image_private.h"
#include "efl_canvas_scene3d.eo.h"
#define MY_CLASS EFL_CANVAS_SCENE3D_CLASS
EOLIAN static void
_efl_canvas_scene3d_scene3d_set(Eo *eo_obj, void *pd EINA_UNUSED, Evas_Canvas3D_Scene *scene)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
Evas_Image_Load_Opts lo;
int load_error;
if (o->cur->scene == scene) return;
evas_object_async_block(obj);
_evas_image_init_set(NULL, NULL, eo_obj, obj, o, &lo);
o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &load_error, &lo);
o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error);
_evas_image_done_set(eo_obj, obj, o);
if (scene) _evas_image_3d_set(eo_obj, scene);
else _evas_image_3d_unset(eo_obj, obj, o);
}
EOLIAN static Evas_Canvas3D_Scene *
_efl_canvas_scene3d_scene3d_get(const Eo *eo_obj, void *pd EINA_UNUSED)
{
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
return o->cur->scene;
}
void
_evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj,
Evas_Object_Protected_Data *obj, Evas_Image_Data *o EINA_UNUSED,
Evas_Canvas3D_Scene *scene, void *engine, void *output)
{
Evas_Public_Data *e;
Eina_Bool need_native_set = EINA_FALSE;
Evas_Canvas3D_Scene_Public_Data scene_data;
Evas_Canvas3D_Scene_Data *pd_scene = NULL;
pd_scene = efl_data_scope_get(scene, EVAS_CANVAS3D_SCENE_CLASS);
if ((pd_scene->w == 0) || (pd_scene->h == 0)) return;
if (!pd_scene->camera_node)
{
WRN("Camera has not been set to scene(%p)", scene);
return;
}
e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
if (pd_scene->surface)
{
int w = 0;
int h = 0;
if (e->engine.func->drawable_size_get)
{
e->engine.func->drawable_size_get(engine,
pd_scene->surface, &w, &h);
}
if ((w != pd_scene->w) || (h != pd_scene->h))
{
if (e->engine.func->drawable_free)
{
e->engine.func->drawable_free(engine,
pd_scene->surface);
}
pd_scene->surface = NULL;
need_native_set = EINA_TRUE;
}
}
else
{
/* TODO: Hard-coded alpha on. */
if (e->engine.func->drawable_new)
{
pd_scene->surface =
e->engine.func->drawable_new(engine,
pd_scene->w, pd_scene->h, 1);
}
need_native_set = EINA_TRUE;
}
EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data,
data)
{
if (need_native_set)
{
if (e->engine.func->image_drawable_set)
{
data->surface =
e->engine.func->image_drawable_set(engine,
data->surface,
pd_scene->surface);
}
}
data->w = pd_scene->w;
data->h = pd_scene->h;
}
EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
evas_canvas3d_scene_data_init(&scene_data);
scene_data.bg_color = pd_scene->bg_color;
scene_data.shadows_enabled = pd_scene->shadows_enabled;
scene_data.camera_node = pd_scene->camera_node;
scene_data.depth_offset = pd_scene->depth_offset;
scene_data.depth_constant = pd_scene->depth_constant;
if (evas_object_anti_alias_get(eo_obj))
{
/*Use post processing render*/
scene_data.post_processing = EINA_TRUE;
scene_data.color_pick_enabled = EINA_FALSE;
scene_data.render_to_texture = EINA_TRUE;
scene_data.post_processing_type = EVAS_CANVAS3D_SHADER_MODE_POST_PROCESSING_FXAA;
}
/* Phase 1 - Update scene graph tree. */
evas_canvas3d_object_update(scene);
/* Phase 2 - Do frustum culling and get visible model nodes. */
evas_canvas3d_node_tree_traverse(pd_scene->root_node,
EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
evas_canvas3d_node_mesh_collect, &scene_data);
/* Phase 3 - Collect active light nodes in the scene graph tree. */
evas_canvas3d_node_tree_traverse(pd_scene->root_node,
EVAS_CANVAS3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE,
evas_canvas3d_node_light_collect, &scene_data);
/* Phase 5 - Draw the scene. */
if (e->engine.func->drawable_scene_render)
{
e->engine.func->drawable_scene_render(engine, output,
pd_scene->surface, &scene_data);
}
/* Clean up temporary resources. */
evas_canvas3d_scene_data_fini(&scene_data);
}
void
_evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
Evas_Canvas3D_Scene_Data *pd_scene = efl_data_scope_get(scene,
EVAS_CANVAS3D_SCENE_CLASS);
EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data,
data)
{
data->surface = NULL;
data->w = 0;
data->h = 0;
efl_ref(scene);
}
EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
{
state_write->scene = scene;
}
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
pd_scene->images = eina_list_append(pd_scene->images, eo_obj);
}
void
_evas_image_3d_unset(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj,
Evas_Image_Data *o)
{
Evas_Public_Data *e;
if (!o->cur->scene) return;
Evas_Canvas3D_Scene_Data *pd_scene =
efl_data_scope_get(o->cur->scene, EVAS_CANVAS3D_SCENE_CLASS);
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
{
pd_scene->images = eina_list_remove(pd_scene->images, eo_obj);
efl_unref(state_write->scene);
state_write->scene = NULL;
}
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
if (o->cur->defmap)
{
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
{
evas_map_free(state_write->defmap);
state_write->defmap = NULL;
}
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
}
EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data,
data)
{
e = obj->layer->evas;
if (data->surface)
e->engine.func->image_free(_evas_engine_context(e), data->surface);
data->surface = NULL;
data->w = 0;
data->h = 0;
}
EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
}
EOLIAN static Eina_Rw_Slice
_efl_canvas_scene3d_efl_gfx_buffer_buffer_map(Eo *eo_obj, void *_pd EINA_UNUSED,
Efl_Gfx_Buffer_Access_Mode mode,
const Eina_Rect *region,
Efl_Gfx_Colorspace cspace, int plane,
int *stride)
{
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
Evas_Public_Data *e;
Evas_Canvas3D_Object_Data *pd_parent;
Evas_Canvas3D_Scene_Data *pd_scene;
int width = -1, height = -1, ntex = -1;
unsigned char *pixels = NULL;
Eina_Rw_Slice slice = {};
int x, y, w, h;
size_t len = 0;
if (!o->cur->scene)
{
ERR("invalid scene data");
return slice;
}
if (mode & EFL_GFX_BUFFER_ACCESS_MODE_WRITE)
{
ERR("invalid map access mode");
return slice;
}
if (cspace != EFL_GFX_COLORSPACE_ARGB8888)
{
ERR("invalid map colorspace. Only ARGB is supported");
return slice;
}
pd_parent = efl_data_scope_get(o->cur->scene, EVAS_CANVAS3D_OBJECT_CLASS);
e = efl_data_scope_get(pd_parent->evas, EVAS_CANVAS_CLASS);
pd_scene = efl_data_scope_get(o->cur->scene, EVAS_CANVAS3D_SCENE_CLASS);
if (e->engine.func->drawable_size_get)
{
e->engine.func->drawable_size_get(_evas_engine_context(e),
pd_scene->surface, &width, &height);
}
if (region)
{
x = region->x;
y = region->y;
w = region->w;
h = region->h;
}
else
{
x = y = 0;
w = width;
h = height;
}
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || ((x + w) > width) || ((y + h) > height))
{
ERR("Invalid map dimensions : %dx%d +%d,%d. Image is %dx%d.",
w, h, x, y, width, height);
return slice;
}
if (e->engine.func->drawable_texture_target_id_get)
{
ntex = e->engine.func->drawable_texture_target_id_get(pd_scene->surface);
if (e->engine.func->drawable_texture_rendered_pixels_get)
{
len = w * h * sizeof(DATA32); //four component texture
pixels = malloc(len + sizeof(slice) + 8);
e->engine.func->drawable_texture_rendered_pixels_get(ntex, x, y, w, h,
pd_scene->surface, pixels);
}
else
return slice;
}
else
return slice;
if (stride) *stride = w * sizeof(DATA32);
slice.mem = pixels;
slice.len = len;
DBG("map(%p, %d,%d %dx%d plane:%d) -> " EINA_SLICE_FMT,
eo_obj, x, y, w, h, plane, EINA_SLICE_PRINT(slice));
return slice;
}
EOLIAN static Eina_Bool
_efl_canvas_scene3d_efl_gfx_buffer_buffer_unmap(Eo *eo_obj EINA_UNUSED, void *_pd EINA_UNUSED,
const Eina_Rw_Slice slice)
{
free(slice.mem);
return EINA_TRUE;
}
#include "efl_canvas_scene3d.eo.c"

View File

@ -1,20 +0,0 @@
class @beta Efl.Canvas.Scene3d extends Efl.Canvas.Image_Internal
{
[[A UI view for EFL Canvas 3D.]]
data: null;
methods {
@property scene3d {
[[The 3d scene to display in this view.
]]
set {}
get {}
values {
scene: Evas.Canvas3D.Scene; [[3D scene.]]
}
}
}
implements {
Efl.Gfx.Buffer.buffer_map;
Efl.Gfx.Buffer.buffer_unmap;
}
}

View File

@ -1,203 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_CAMERA_CLASS
static Eina_Bool
_camera_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_Canvas3D_Node *n = *(Evas_Canvas3D_Node **)key;
evas_canvas3d_object_change(n, EVAS_CANVAS3D_STATE_NODE_CAMERA, (Evas_Canvas3D_Object *)fdata);
return EINA_TRUE;
}
EOLIAN static void
_evas_canvas3d_camera_evas_canvas3d_object_change_notify(Eo *obj,Evas_Canvas3D_Camera_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
{
if (pd->nodes) eina_hash_foreach(pd->nodes, _camera_node_change_notify, obj);
}
EOLIAN static void
_evas_canvas3d_camera_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Camera_Data *pd EINA_UNUSED)
{
}
void
evas_canvas3d_camera_node_add(Evas_Canvas3D_Camera *camera, Evas_Canvas3D_Node *node)
{
Evas_Canvas3D_Camera_Data *pd = efl_data_scope_get(camera, MY_CLASS);
int count = 0;
if (!pd->nodes)
{
pd->nodes = eina_hash_pointer_new(NULL);
if (!pd->nodes)
{
ERR("Failed to create hash table. camera(%p)", camera);
return;
}
}
else count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count + 1));
}
void
evas_canvas3d_camera_node_del(Evas_Canvas3D_Camera *camera, Evas_Canvas3D_Node *node)
{
Evas_Canvas3D_Camera_Data *pd = efl_data_scope_get(camera, MY_CLASS);
int count = 0;
if (!pd->nodes)
{
ERR("No node to delete.");
return;
}
count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
if (count == 1) eina_hash_del(pd->nodes, &node, NULL);
else eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count - 1));
}
EOLIAN static Eo *
_evas_canvas3d_camera_efl_object_constructor(Eo *obj,
Evas_Canvas3D_Camera_Data *pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_CAMERA);
return obj;
}
EOLIAN static void
_evas_canvas3d_camera_efl_object_destructor(Eo *obj,
Evas_Canvas3D_Camera_Data *pd)
{
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_Canvas3D_Node_Data *node = NULL;
if (pd->nodes)
{
it = eina_hash_iterator_key_new(pd->nodes);
while (eina_iterator_next(it, &data))
{
node = efl_data_scope_get(data, EVAS_CANVAS3D_NODE_CLASS);
node->data.camera.camera = NULL;
}
eina_hash_free(pd->nodes);
}
efl_destructor(efl_super(obj, MY_CLASS));
}
EAPI Evas_Canvas3D_Camera *
evas_canvas3d_camera_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
return efl_add(MY_CLASS, e);
}
EOLIAN static void
_evas_canvas3d_camera_projection_matrix_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
const Evas_Real *matrix)
{
eina_matrix4_array_set(&pd->projection, matrix);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
}
EOLIAN static void
_evas_canvas3d_camera_projection_matrix_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Camera_Data *pd,
Evas_Real *matrix)
{
memcpy(matrix, &pd->projection.xx, sizeof(Evas_Real) * 16);
}
EOLIAN static void
_evas_canvas3d_camera_projection_perspective_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
Evas_Real fovy, Evas_Real aspect,
Evas_Real dnear, Evas_Real dfar)
{
Evas_Real xmax;
Evas_Real ymax;
ymax = dnear * (Evas_Real)tan((double)fovy * M_PI / 360.0);
xmax = ymax * aspect;
evas_mat4_frustum_set(&pd->projection, -xmax, xmax, -ymax, ymax, dnear, dfar);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
}
EOLIAN static void
_evas_canvas3d_camera_projection_frustum_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
Evas_Real left, Evas_Real right,
Evas_Real bottom, Evas_Real top,
Evas_Real dnear, Evas_Real dfar)
{
evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, dnear, dfar);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
}
EOLIAN static void
_evas_canvas3d_camera_projection_ortho_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
Evas_Real left, Evas_Real right,
Evas_Real bottom, Evas_Real top,
Evas_Real dnear, Evas_Real dfar)
{
eina_matrix4_ortho_set(&pd->projection, left, right, bottom, top, dnear, dfar);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
}
EOLIAN static Eina_Bool
_evas_canvas3d_camera_node_visible_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Camera_Data *pd, Evas_Canvas3D_Node *camera_node, Evas_Canvas3D_Node *node, Evas_Canvas3D_Frustum_Mode key)
{
Eina_Matrix4 matrix_vp;
Eina_Quaternion planes[6];
Evas_Canvas3D_Node_Data *pd_node = efl_data_scope_get(node, EVAS_CANVAS3D_NODE_CLASS);
Evas_Canvas3D_Node_Data *pd_camera = efl_data_scope_get(camera_node, EVAS_CANVAS3D_NODE_CLASS);
Eina_Vector3 central_point;
if (!node || pd_node->type != EVAS_CANVAS3D_NODE_TYPE_MESH)
{
ERR("Mesh node %p type mismatch.", node);
return EINA_FALSE;
}
if (!camera_node || pd_camera->type != EVAS_CANVAS3D_NODE_TYPE_CAMERA)
{
ERR("Camera node %p type mismatch.", camera_node);
return EINA_FALSE;
}
/*get need matrix like multiply projection matrix with view matrix*/
eina_matrix4_multiply(&matrix_vp, &pd->projection, &pd_camera->data.camera.matrix_world_to_eye);
evas_frustum_calculate(planes, &matrix_vp);
if (key == EVAS_CANVAS3D_FRUSTUM_MODE_BSPHERE)
return evas_is_sphere_in_frustum(&pd_node->bsphere, planes);
else if (key == EVAS_CANVAS3D_FRUSTUM_MODE_AABB)
return evas_is_box_in_frustum(&pd_node->aabb, planes);
else if (key == EVAS_CANVAS3D_FRUSTUM_MODE_CENTRAL_POINT)
{
central_point.x = (pd_node->aabb.p0.x + pd_node->aabb.p1.x) / 2;
central_point.y = (pd_node->aabb.p0.y + pd_node->aabb.p1.y) / 2;
central_point.z = (pd_node->aabb.p0.z + pd_node->aabb.p1.z) / 2;
return evas_is_point_in_frustum(&central_point, planes);
}
else
{
ERR("Unknown frustun mode.");
return EINA_TRUE;
}
}
#include "canvas/evas_canvas3d_camera.eo.c"

View File

@ -1,89 +0,0 @@
import evas_canvas3d_types;
class @beta Evas.Canvas3D.Camera extends Evas.Canvas3D.Object
{
[[Evas 3D canvas camera class]]
data: Evas_Canvas3D_Camera_Data;
methods {
projection_matrix_set {
[[Set the projection matrix of the given camera.
Default projection matrix is identity matrix.
See also @.projection_perspective_set, @.projection_ortho_set and @.projection_frustum_set.]]
params {
@in matrix: ptr(const(Evas.Real)); [[Projection Matrix]]
}
}
projection_matrix_get @const {
[[Get the projection matrix of the given camera.
See also @.projection_matrix_set.]]
params {
@out matrix: Evas.Real; [[Projection Matrix]]
}
}
projection_perspective_set {
[[Set the projection matrix of the given camera with perspective projection.
See also @.projection_matrix_set.]]
params {
fovy: Evas.Real; [[Field of view angle in Y direction.]]
aspect: Evas.Real; [[Aspect ratio.]]
dnear: Evas.Real; [[Distance to near clipping plane.]]
dfar: Evas.Real; [[Distance to far clipping plane.]]
}
}
projection_frustum_set {
[[Set the projection matrix of the given camera with frustum projection.
See also @.projection_matrix_set.]]
params {
left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
right: Evas.Real; [[Right X coordinate of the near clipping plane..]]
bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
dnear: Evas.Real; [[Distance to near clipping plane.]]
dfar: Evas.Real; [[Distance to far clipping plane.]]
}
}
projection_ortho_set {
[[Set the projection matrix of the given camera with orthogonal projection.
See also @.projection_matrix_set.]]
params {
left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
right: Evas.Real; [[Right X coordinate of the near clipping plane..]]
bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
dnear: Evas.Real; [[Distance to near clipping plane.]]
dfar: Evas.Real; [[Distance to far clipping plane.]]
}
}
node_visible_get {
[[Check is bounding sphere of given node inside frustum of camera node.
If the nodes are $null or nodes type mismatch error wrong type of nodes will be generated and returned $false.]]
return: bool; [[$true in frustum, $false otherwise]]
params {
@in camera_node: Evas.Canvas3D.Node; [[The given camera node.]]
@in node: Evas.Canvas3D.Node; [[The given node.]]
@in key: Evas.Canvas3D.Frustum_Mode; [[The given key]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

View File

@ -1,211 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
static Eet_Data_Descriptor *_vec2_descriptor = NULL;
static Eet_Data_Descriptor *_vec3_descriptor = NULL;
static Eet_Data_Descriptor *_vertex_descriptor = NULL;
static Eet_Data_Descriptor *_geometry_descriptor = NULL;
static Eet_Data_Descriptor *_color_descriptor = NULL;
static Eet_Data_Descriptor *_material_descriptor = NULL;
static Eet_Data_Descriptor *_frame_descriptor = NULL;
static Eet_Data_Descriptor *_mesh_descriptor = NULL;
static Eet_Data_Descriptor *_header_descriptor = NULL;
static Eet_Data_Descriptor *_file_descriptor = NULL;
Evas_Canvas3D_File_Eet *
_evas_canvas3d_eet_file_new(void)
{
Evas_Canvas3D_File_Eet *creating_file = calloc(1, sizeof(Evas_Canvas3D_File_Eet));
if (!creating_file)
{
ERR("Could not calloc Evas_Canvas3D_File_Eet");
return NULL;
}
return creating_file;
}
Eet_Data_Descriptor*
_evas_canvas3d_eet_file_get(void)
{
if(_file_descriptor == NULL)
_evas_canvas3d_eet_file_init();
return _file_descriptor;
}
void
_evas_canvas3d_eet_file_init(void)
{
/* initialization of bonding between structure units in eet file */
Eet_Data_Descriptor_Class eddc;
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vec2_Eet);
_vec2_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vec3_Eet);
_vec3_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vertex_Eet);
_vertex_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Geometry_Eet);
_geometry_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Color_Eet);
_color_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Frame_Eet);
_frame_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Material_Eet);
_material_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Mesh_Eet);
_mesh_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Header_Eet);
_header_descriptor = eet_data_descriptor_file_new(&eddc);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_File_Eet);
_file_descriptor = eet_data_descriptor_file_new(&eddc);
/* Vec_2 */
#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
(_vec2_descriptor, Evas_Canvas3D_Vec3_Eet, # member, member, eet_type);
ADD_BASIC(x, EET_T_FLOAT);
ADD_BASIC(y, EET_T_FLOAT);
#undef ADD_BASIC
/* Vec_3 */
#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
(_vec3_descriptor, Evas_Canvas3D_Vec3_Eet, # member, member, eet_type);
ADD_BASIC(x, EET_T_FLOAT);
ADD_BASIC(y, EET_T_FLOAT);
ADD_BASIC(z, EET_T_FLOAT);
#undef ADD_BASIC
/* Vertex */
EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_Canvas3D_Vertex_Eet,
"position", position, _vec3_descriptor);
EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_Canvas3D_Vertex_Eet,
"normal", normal, _vec3_descriptor);
EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_Canvas3D_Vertex_Eet,
"texcoord", texcoord, _vec2_descriptor);
/* Geometry */
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_geometry_descriptor, Evas_Canvas3D_Geometry_Eet,
"vertices", vertices, _vertex_descriptor);
#define ADD_BASIC(member, eet_type) \
EET_DATA_DESCRIPTOR_ADD_BASIC \
(_geometry_descriptor, Evas_Canvas3D_Geometry_Eet, # member, member, eet_type);
ADD_BASIC(vertices_count, EET_T_UINT);
ADD_BASIC(id, EET_T_UINT);
#undef ADD_BASIC
/* Color */
#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
(_color_descriptor, Evas_Canvas3D_Color_Eet, # member, member, eet_type);
ADD_BASIC(r, EET_T_FLOAT);
ADD_BASIC(g, EET_T_FLOAT);
ADD_BASIC(b, EET_T_FLOAT);
ADD_BASIC(a, EET_T_FLOAT);
#undef ADD_BASIC
/* Material */
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_material_descriptor, Evas_Canvas3D_Material_Eet,
"colors", colors, _color_descriptor);
#define ADD_BASIC(member, eet_type) \
EET_DATA_DESCRIPTOR_ADD_BASIC \
(_material_descriptor, Evas_Canvas3D_Material_Eet, # member, member, eet_type);
ADD_BASIC(id, EET_T_UINT);
ADD_BASIC(colors_count, EET_T_UINT);
ADD_BASIC(shininess, EET_T_FLOAT);
#undef ADD_BASIC
/* Frame */
#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
(_frame_descriptor, Evas_Canvas3D_Frame_Eet, # member, member, eet_type);
ADD_BASIC(id, EET_T_UINT);
ADD_BASIC(geometry_id, EET_T_UINT);
ADD_BASIC(material_id, EET_T_UINT);
#undef ADD_BASIC
/* Mesh */
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet,
"frames", frames, _frame_descriptor);
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet,
"geometries", geometries, _geometry_descriptor);
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet,
"materials", materials, _material_descriptor);
#define ADD_BASIC(member, eet_type) \
EET_DATA_DESCRIPTOR_ADD_BASIC \
(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet, # member, member, eet_type);
ADD_BASIC(materials_count, EET_T_UINT);
ADD_BASIC(frames_count, EET_T_UINT);
ADD_BASIC(geometries_count, EET_T_UINT);
#undef ADD_BASIC
/* Header */
EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(_header_descriptor, Evas_Canvas3D_Header_Eet,
"materials", materials, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(_header_descriptor, Evas_Canvas3D_Header_Eet,
"geometries", geometries, EET_T_UINT);
#define ADD_BASIC(member, eet_type) \
EET_DATA_DESCRIPTOR_ADD_BASIC \
(_header_descriptor, Evas_Canvas3D_Header_Eet, # member, member, eet_type);
ADD_BASIC(version, EET_T_UINT);
ADD_BASIC(materials_count, EET_T_UINT);
ADD_BASIC(frames, EET_T_UINT);
ADD_BASIC(geometries_count, EET_T_UINT);
#undef ADD_BASIC
/* File */
EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet,
"mesh", mesh, _mesh_descriptor);
EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet,
"header", header, _header_descriptor);
}
void
_evas_canvas3d_eet_descriptor_shutdown(void)
{
eet_data_descriptor_free(_geometry_descriptor);
_geometry_descriptor = NULL;
eet_data_descriptor_free(_vertex_descriptor);
_vertex_descriptor = NULL;
eet_data_descriptor_free(_vec2_descriptor);
_vec2_descriptor = NULL;
eet_data_descriptor_free(_vec3_descriptor);
_vec3_descriptor = NULL;
eet_data_descriptor_free(_color_descriptor);
_color_descriptor = NULL;
eet_data_descriptor_free(_material_descriptor);
_material_descriptor = NULL;
eet_data_descriptor_free(_frame_descriptor);
_frame_descriptor = NULL;
eet_data_descriptor_free(_mesh_descriptor);
_mesh_descriptor = NULL;
eet_data_descriptor_free(_header_descriptor);
_header_descriptor = NULL;
eet_data_descriptor_free(_file_descriptor);
_file_descriptor = NULL;
}
void
_evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file)
{
if (eet_file)
{
if (eet_file->mesh)
{
free(eet_file->mesh->geometries[0].vertices);
free(eet_file->mesh->geometries);
free(eet_file->mesh->frames);
free(eet_file->mesh->materials[0].colors);
free(eet_file->mesh->materials);
free(eet_file->mesh);
}
if (eet_file->header)
{
free(eet_file->header->materials);
free(eet_file->header->geometries);
free(eet_file->header);
}
free(eet_file);
}
_evas_canvas3d_eet_descriptor_shutdown();
}

View File

@ -1,309 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_LIGHT_CLASS
static Eina_Bool
_light_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_Canvas3D_Node *n = *(Evas_Canvas3D_Node **)key;
evas_canvas3d_object_change(n, EVAS_CANVAS3D_STATE_NODE_LIGHT, (Evas_Canvas3D_Object *)fdata);
return EINA_TRUE;
}
EOLIAN static void
_evas_canvas3d_light_evas_canvas3d_object_change_notify(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
{
if (pd->nodes)
eina_hash_foreach(pd->nodes, _light_node_change_notify, obj);
}
EOLIAN static void
_evas_canvas3d_light_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd EINA_UNUSED)
{
}
void
evas_canvas3d_light_node_add(Evas_Canvas3D_Light *light, Evas_Canvas3D_Node *node)
{
int count = 0;
Evas_Canvas3D_Light_Data *pd = efl_data_scope_get(light, MY_CLASS);
if (pd->nodes == NULL)
{
pd->nodes = eina_hash_pointer_new(NULL);
if (pd->nodes == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count + 1));
}
void
evas_canvas3d_light_node_del(Evas_Canvas3D_Light *light, Evas_Canvas3D_Node *node)
{
int count = 0;
Evas_Canvas3D_Light_Data *pd = efl_data_scope_get(light, MY_CLASS);
if (pd->nodes == NULL)
{
ERR("No node to delete.");
return;
}
count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
if (count == 1)
eina_hash_del(pd->nodes, &node, NULL);
else
eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count - 1));
}
EAPI Evas_Canvas3D_Light *
evas_canvas3d_light_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
return efl_add(MY_CLASS, e);
}
EOLIAN static Eo *
_evas_canvas3d_light_efl_object_constructor(Eo *obj, Evas_Canvas3D_Light_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_LIGHT);
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;
return obj;
}
EOLIAN static void
_evas_canvas3d_light_efl_object_destructor(Eo *obj, Evas_Canvas3D_Light_Data *pd)
{
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_Canvas3D_Node_Data *node = NULL;
if (pd->nodes)
{
it = eina_hash_iterator_key_new(pd->nodes);
while (eina_iterator_next(it, &data))
{
node = efl_data_scope_get(data, EVAS_CANVAS3D_NODE_CLASS);
node->data.light.light = NULL;
}
eina_hash_free(pd->nodes);
}
efl_destructor(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_evas_canvas3d_light_directional_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Eina_Bool directional)
{
if (pd->directional != directional)
{
pd->directional = directional;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_ANY, NULL);
}
}
EOLIAN static Eina_Bool
_evas_canvas3d_light_directional_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
{
return pd->directional;
}
EOLIAN static void
_evas_canvas3d_light_ambient_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
pd->ambient.r = r;
pd->ambient.g = g;
pd->ambient.b = b;
pd->ambient.a = a;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_AMBIENT, NULL);
}
EOLIAN static void
_evas_canvas3d_light_ambient_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *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;
}
EOLIAN static void
_evas_canvas3d_light_diffuse_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
pd->diffuse.r = r;
pd->diffuse.g = g;
pd->diffuse.b = b;
pd->diffuse.a = a;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_DIFFUSE, NULL);
}
EOLIAN static void
_evas_canvas3d_light_diffuse_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *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;
}
EOLIAN static void
_evas_canvas3d_light_specular_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
pd->specular.r = r;
pd->specular.g = g;
pd->specular.b = b;
pd->specular.a = a;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_SPECULAR, NULL);
}
EOLIAN static void
_evas_canvas3d_light_specular_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *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;
}
EOLIAN static void
_evas_canvas3d_light_spot_exponent_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real exponent)
{
pd->spot_exp = exponent;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_SPOT_EXP, NULL);
}
EOLIAN static Evas_Real
_evas_canvas3d_light_spot_exponent_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
{
return pd->spot_exp;
}
EOLIAN static void
_evas_canvas3d_light_spot_cutoff_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real cutoff)
{
pd->spot_cutoff = cutoff;
pd->spot_cutoff_cos = cos(cutoff * M_PI / 180.0);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_SPOT_CUTOFF, NULL);
}
EOLIAN static Evas_Real
_evas_canvas3d_light_spot_cutoff_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
{
return pd->spot_cutoff;
}
EOLIAN static void
_evas_canvas3d_light_attenuation_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real constant, Evas_Real linear, Evas_Real quadratic)
{
pd->atten_const = constant;
pd->atten_linear = linear;
pd->atten_quad = quadratic;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_ATTENUATION, NULL);
}
EOLIAN static void
_evas_canvas3d_light_attenuation_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic)
{
if (constant) *constant = pd->atten_const;
if (linear) *linear = pd->atten_linear;
if (quadratic) *quadratic = pd->atten_quad;
}
EOLIAN static void
_evas_canvas3d_light_attenuation_enable_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Eina_Bool enable)
{
if (pd->enable_attenuation != enable)
{
pd->enable_attenuation = enable;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_ATTENUATION, NULL);
}
}
EOLIAN static Eina_Bool
_evas_canvas3d_light_attenuation_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
{
return pd->enable_attenuation;
}
EOLIAN static void
_evas_canvas3d_light_projection_matrix_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
const Evas_Real *matrix)
{
eina_matrix4_array_set(&pd->projection, matrix);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
}
EOLIAN static void
_evas_canvas3d_light_projection_matrix_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Light_Data *pd,
Evas_Real *matrix)
{
memcpy(matrix, &pd->projection.xx, sizeof(Evas_Real) * 16);
}
EOLIAN static void
_evas_canvas3d_light_projection_perspective_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
Evas_Real fovy, Evas_Real aspect,
Evas_Real dnear, Evas_Real dfar)
{
Evas_Real xmax;
Evas_Real ymax;
ymax = dnear * (Evas_Real)tan((double)fovy * M_PI / 360.0);
xmax = ymax * aspect;
evas_mat4_frustum_set(&pd->projection, -xmax, xmax, -ymax, ymax, dnear, dfar);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
}
EOLIAN static void
_evas_canvas3d_light_projection_frustum_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
Evas_Real left, Evas_Real right,
Evas_Real bottom, Evas_Real top,
Evas_Real dnear, Evas_Real dfar)
{
evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, dnear, dfar);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
}
EOLIAN static void
_evas_canvas3d_light_projection_ortho_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
Evas_Real left, Evas_Real right,
Evas_Real bottom, Evas_Real top,
Evas_Real dnear, Evas_Real dfar)
{
eina_matrix4_ortho_set(&pd->projection, left, right, bottom, top, dnear, dfar);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
}
#include "canvas/evas_canvas3d_light.eo.c"

View File

@ -1,249 +0,0 @@
import evas_canvas3d_types;
class @beta Evas.Canvas3D.Light extends Evas.Canvas3D.Object
{
[[Evas 3D canvas light class]]
data: Evas_Canvas3D_Light_Data;
methods {
@property directional {
[[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.
\@ref evas_canvas3d_node_look_at_set]]
set {
}
get {
}
values {
directional: bool; [[Whether the light is directional ($true), or not ($false).]]
}
}
@property spot_exponent {
[[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 distributed. 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 also @.spot_cutoff.set]]
set {
}
get {
}
values {
exponent: Evas.Real; [[Spot exponent value.]]
}
}
@property spot_cutoff {
[[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.]]
set {
}
get {
}
values {
cutoff: Evas.Real; [[Cutoff angle in degree..]]
}
}
@property attenuation_enable {
[[The attenuation enable flag of the given light.
By default, light attenuation is not enabled.
See also @.attenuation_set]]
set {
}
get {
}
values {
enable: bool; [[Whether to enable attenuation ($true), or not ($false)..]]
}
}
ambient_set {
[[Set the ambient color of the given light.
Default ambient color is (0.0, 0.0, 0.0, 1.0).]]
params {
@in r: Evas.Real; [[Red component of the ambient color between [0.0, 1.0].]]
@in g: Evas.Real; [[Green component of the ambient color between [0.0, 1.0].]]
@in b: Evas.Real; [[Blue component of the ambient color between [0.0, 1.0].]]
@in a: Evas.Real; [[Alpha component of the ambient color between [0.0, 1.0].]]
}
}
ambient_get @const {
[[Get the ambient color of the given light.
See also @.ambient_set]]
params {
@out r: Evas.Real; [[Red component of the ambient color between [0.0, 1.0].]]
@out g: Evas.Real; [[Green component of the ambient color between [0.0, 1.0].]]
@out b: Evas.Real; [[Blue component of the ambient color between [0.0, 1.0].]]
@out a: Evas.Real; [[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).]]
params {
@in r: Evas.Real; [[Red component of the diffuse color between [0.0, 1.0].]]
@in g: Evas.Real; [[Green component of the diffuse color between [0.0, 1.0].]]
@in b: Evas.Real; [[Blue component of the diffuse color between [0.0, 1.0].]]
@in a: Evas.Real; [[Alpha component of the diffuse color between [0.0, 1.0].]]
}
}
diffuse_get @const {
[[Get the diffuse color of the given light.
See also @.diffuse_set]]
params {
@out r: Evas.Real; [[Red component of the diffuse color between [0.0, 1.0].]]
@out g: Evas.Real; [[Green component of the diffuse color between [0.0, 1.0].]]
@out b: Evas.Real; [[Blue component of the diffuse color between [0.0, 1.0].]]
@out a: Evas.Real; [[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).]]
params {
@in r: Evas.Real; [[Red component of the specular color between [0.0, 1.0].]]
@in g: Evas.Real; [[Green component of the specular color between [0.0, 1.0].]]
@in b: Evas.Real; [[Blue component of the specular color between [0.0, 1.0].]]
@in a: Evas.Real; [[Alpha component of the specular color between [0.0, 1.0].]]
}
}
specular_get @const {
[[Get the specular color of the given light.
See also @.specular_set]]
params {
@out r: Evas.Real; [[Red component of the specular color between [0.0, 1.0].]]
@out g: Evas.Real; [[Green component of the specular color between [0.0, 1.0].]]
@out b: Evas.Real; [[Blue component of the specular color between [0.0, 1.0].]]
@out a: Evas.Real; [[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 also @.attenuation_enable.set]]
params {
@in constant: Evas.Real; [[Constant attenuation term..]]
@in linear: Evas.Real; [[Linear attenuation term..]]
@in quadratic: Evas.Real; [[Quadratic attenuation term..]]
}
}
attenuation_get @const {
[[Get the attenuation of the given light.
See also @.attenuation_set]]
params {
@out constant: Evas.Real; [[Constant attenuation term..]]
@out linear: Evas.Real; [[Linear attenuation term..]]
@out quadratic: Evas.Real; [[Quadratic attenuation term..]]
}
}
projection_matrix_set {
[[Set the projection matrix of the given light source.
Default projection matrix is identity matrix.
See also @.projection_perspective_set, @.projection_ortho_set and @.projection_frustum_set]]
params {
@in matrix: ptr(const(Evas.Real)); [[Projection Matrix. Pointer to the array of 16 Evas.Real values in column major order.]]
}
}
projection_matrix_get @const {
[[Get the projection matrix of the given light source.
See also @.projection_matrix_set]]
params {
@out matrix: Evas.Real; [[Projection Matrix]]
}
}
projection_perspective_set {
[[Set the projection matrix of the given light source with perspective projection.
See also @.projection_matrix_set]]
params {
fovy: Evas.Real; [[Field of view angle in Y direction.]]
aspect: Evas.Real; [[Aspect ratio.]]
dnear: Evas.Real; [[Distance to near clipping plane.]]
dfar: Evas.Real; [[Distance to far clipping plane.]]
}
}
projection_frustum_set {
[[Set the projection matrix of the given light source with frustum projection.
@Evas.Canvas3D.Light.projection_matrix_set]]
params {
left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
right: Evas.Real; [[Right X coordinate of the near clipping plane.]]
bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
dnear: Evas.Real; [[Distance to near clipping plane.]]
dfar: Evas.Real; [[Distance to far clipping plane.]]
}
}
projection_ortho_set {
[[Set the projection matrix of the given light source with orthogonal projection.
See also @.projection_matrix_set]]
params {
left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
right: Evas.Real; [[Right X coordinate of the near clipping plane.]]
bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
dnear: Evas.Real; [[Distance to near clipping plane.]]
dfar: Evas.Real; [[Distance to far clipping plane.]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

View File

@ -1,206 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_MATERIAL_CLASS
static Eina_Bool
_material_mesh_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_Canvas3D_Mesh *m = *(Evas_Canvas3D_Mesh **)key;
evas_canvas3d_object_change(m, EVAS_CANVAS3D_STATE_MESH_MATERIAL, (Evas_Canvas3D_Object *)fdata);
return EINA_TRUE;
}
EOLIAN static void
_evas_canvas3d_material_evas_canvas3d_object_change_notify(Eo *obj, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
{
if (pd->meshes)
eina_hash_foreach(pd->meshes, _material_mesh_change_notify, obj);
}
EOLIAN static void
_evas_canvas3d_material_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd)
{
int i;
for (i = 0; i < EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (pd->attribs[i].enable)
{
if (pd->attribs[i].texture)
{
evas_canvas3d_object_update(pd->attribs[i].texture);
}
}
}
}
void
evas_canvas3d_material_mesh_add(Evas_Canvas3D_Material *material, Evas_Canvas3D_Mesh *mesh)
{
int count = 0;
Evas_Canvas3D_Material_Data *pd = efl_data_scope_get(material, MY_CLASS);
if (pd->meshes == NULL)
{
pd->meshes = eina_hash_pointer_new(NULL);
if (pd->meshes == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)(uintptr_t)eina_hash_find(pd->meshes, &mesh);
eina_hash_set(pd->meshes, &mesh, (const void *)(uintptr_t)(count + 1));
}
void
evas_canvas3d_material_mesh_del(Evas_Canvas3D_Material *material, Evas_Canvas3D_Mesh *mesh)
{
int count = 0;
Evas_Canvas3D_Material_Data *pd = efl_data_scope_get(material, MY_CLASS);
if (pd->meshes == NULL)
{
ERR("No mesh to delete.");
return;
}
count = (int)(uintptr_t)eina_hash_find(pd->meshes, &mesh);
if (count == 1)
eina_hash_del(pd->meshes, &mesh, NULL);
else
eina_hash_set(pd->meshes, &mesh, (const void *)(uintptr_t)(count - 1));
}
EAPI Evas_Canvas3D_Material *
evas_canvas3d_material_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
return efl_add(MY_CLASS, e);
}
EOLIAN static Eo *
_evas_canvas3d_material_efl_object_constructor(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_MATERIAL);
evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].color, 0.2, 0.2, 0.2, 1.0);
evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].color, 0.8, 0.8, 0.8, 1.0);
evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].color, 1.0, 1.0, 1.0, 1.0);
evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].color, 0.0, 0.0, 0.0, 1.0);
pd->shininess = 150.0;
return obj;
}
EOLIAN static void
_evas_canvas3d_material_efl_object_destructor(Eo *obj, Evas_Canvas3D_Material_Data *pd)
{
int i = 0;
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_Canvas3D_Mesh_Data *mesh = NULL;
Eina_List *l = NULL;
Evas_Canvas3D_Mesh_Frame *f = NULL;
if (pd->meshes)
{
it = eina_hash_iterator_key_new(pd->meshes);
while (eina_iterator_next(it, &data))
{
mesh = efl_data_scope_get(data, EVAS_CANVAS3D_MESH_CLASS);
if (mesh->frames)
{
EINA_LIST_FOREACH(mesh->frames, l, f)
f->material = NULL;
}
}
eina_iterator_free(it);
eina_hash_free(pd->meshes);
}
for (i = 0; i < EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (pd->attribs[i].texture)
{
evas_canvas3d_texture_material_del(pd->attribs[i].texture, obj);
}
}
efl_destructor(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_evas_canvas3d_material_enable_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Eina_Bool enable)
{
pd->attribs[attrib].enable = enable;
}
EOLIAN static Eina_Bool
_evas_canvas3d_material_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib)
{
return pd->attribs[attrib].enable;
}
EOLIAN static void
_evas_canvas3d_material_color_set(Eo *obj, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
evas_color_set(&pd->attribs[attrib].color, r, g, b, a);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MATERIAL_COLOR, NULL);
}
EOLIAN static void
_evas_canvas3d_material_color_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
{
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;
}
EOLIAN static void
_evas_canvas3d_material_shininess_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Real shininess)
{
pd->shininess = shininess;
}
EOLIAN static Evas_Real
_evas_canvas3d_material_shininess_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd)
{
return pd->shininess;
}
EOLIAN static void
_evas_canvas3d_material_texture_set(Eo *obj, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Evas_Canvas3D_Texture *texture)
{
if (pd->attribs[attrib].texture != texture)
{
if (pd->attribs[attrib].texture)
{
evas_canvas3d_texture_material_del(pd->attribs[attrib].texture, obj);
efl_unref(pd->attribs[attrib].texture);
}
pd->attribs[attrib].texture = texture;
evas_canvas3d_texture_material_add(texture, obj);
efl_ref(texture);
}
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MATERIAL_TEXTURE, NULL);
}
EOLIAN static Evas_Canvas3D_Texture *
_evas_canvas3d_material_texture_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib)
{
return pd->attribs[attrib].texture;
}
#include "canvas/evas_canvas3d_material.eo.c"

View File

@ -1,116 +0,0 @@
class @beta Evas.Canvas3D.Material extends Evas.Canvas3D.Object
{
[[Evas 3D canvas material class]]
data: Evas_Canvas3D_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 control 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
]]
params {
@in attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
@in r: Evas.Real; [[Red component of the color.]]
@in g: Evas.Real; [[Green component of the color.]]
@in b: Evas.Real; [[Blue component of the color.]]
@in a: Evas.Real; [[Alpha component of the color.]]
}
}
color_get @const {
[[Get the material attribute color of the given material.
See also @.color_set.
]]
params {
@in attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
@out r: Evas.Real; [[Pointer to receive red component of the color.]]
@out g: Evas.Real; [[Pointer to receive green component of the color.]]
@out b: Evas.Real; [[Pointer to receive blue component of the color.]]
@out a: Evas.Real; [[Pointer to receive alpha component of the color.]]
}
}
@property enable {
[[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.
]]
set {
}
get {
}
keys {
attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
}
values {
enable: bool; [[Whether to enable the attribute or not.]]
}
}
@property shininess {
[[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 also @.enable.set.
]]
set {
}
get {
}
values {
shininess: Evas.Real; [[Shininess value.]]
}
}
@property texture {
[[The texture of the given material.
You have to enable the desired attribute first.
See also @.enable.set.
]]
set {
}
get {
}
keys {
attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
}
values {
texture: Evas.Canvas3D.Texture; [[The texture set to the attribute.]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,421 +0,0 @@
import evas_canvas3d_types;
struct @beta @extern Eina.Inarray; [[Eina inarray data structure]]
class @beta Evas.Canvas3D.Mesh extends Evas.Canvas3D.Object implements Efl.File, Efl.File_Save
{
[[Evas 3D canvas mesh class]]
data: Evas_Canvas3D_Mesh_Data;
methods {
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
function, use @.frame_vertex_data_copy_set instead.
After setting the vertex data, further modifications should be
protected by map/unmap pair.
See also @.frame_vertex_data_map, @.frame_vertex_data_unmap.
]]
params {
@in frame: int; [[The number of the key frame.]]
@in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
@in stride: int; [[Stride to go to the next vertex (in bytes).]]
@in data: const(void_ptr); [[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 @.frame_vertex_data_map. After
finishing the modifications, you should call @.frame_vertex_data_unmap.
See also @.frame_vertex_data_set.
]]
params {
@in frame: int; [[The number of the key frame.]]
@in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
@in stride: int; [[Stride to go to the next vertex (in bytes).]]
@in data: const(void_ptr); [[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, @.frame_vertex_data_unmap
should be called to properly download the data to the engine. If
the data was set using @.frame_vertex_data_set, pointer to the
original buffer will be returned. Otherwise, the returned pointer
can differ every time calling this function.
]]
return: void_ptr; [[Starting address of the mapped vertex buffer.]]
params {
@in frame: int; [[The number of the key frame.]]
@in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
}
}
frame_vertex_data_unmap {
[[Unmap the vertex buffer of the key frame of the given mesh.
See also @.frame_vertex_data_map.
]]
params {
@in frame: int; [[The number of the key frame.]]
@in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
}
}
frame_vertex_stride_get @const {
[[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 @.frame_vertex_data_set, the
original stride will be returned unchanged.
]]
return: int; [[Stride to go to the next vertex (in bytes).]]
params {
@in frame: int; [[The number of the key frame.]]
@in attrib: Evas.Canvas3D.Vertex_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
@.index_data_copy_set. Further modifications should be made
within map/unmap pair.
]]
params {
@in format: Evas.Canvas3D.Index_Format; [[Vertex index data format.]]
@in count: int; [[Vertex index count.]]
@in indices: const(void_ptr); [[Pointer to the index data.]]
}
}
convex_hull_data_get {
[[Get the vertex and index data of convex hull around the given mesh.
]]
params {
@in frame: int; [[ The number of the key frame.]]
@in vertex: ptr(Eina.Inarray); [[Vertex data pointer]]
@in index: ptr(Eina.Inarray); [[Index data pointer]]
}
}
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. Further modifications can be made within
map/unmap pair.
See also @.index_data_set.
]]
params {
@in format: Evas.Canvas3D.Index_Format; [[Vertex index data format.]]
@in count: int; [[Vertex index count.]]
@in indices: const(void_ptr); [[Pointer to the index data.]]
}
}
index_format_get @const {
[[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 @.index_data_set, the
original format will be returned. Otherwise the format can differ
every time you call the @.index_data_map function.
]]
return: Evas.Canvas3D.Index_Format; [[Format of the index data.]]
}
index_count_get @const {
[[Get the count of the index data of the given mesh.
This function returns the index count of the last called data_set
function.
]]
return: int; [[Index data count.]]
}
index_data_map {
[[Map the index buffer of the given mesh.
@.index_data_unmap should be called after modifications. If the
data was set using @.index_data_set, the original pointer will
be returned, otherwise, the returned pointer may differ every
time you call this function.
]]
return: void_ptr; [[Pointer to the mapped buffer.]]
}
index_data_unmap {
[[Unmap the index buffer of the given mesh.
See also @.index_data_map.
]]
}
frame_exist {
[[Returns $true if frame was added and $false in other case.]]
params {
@in frame: int; [[Frame number.]]
}
return: bool; [[$true ifr frame was added, $false otherwise]]
}
frame_add {
[[Add a key frame to the given mesh.
If specified frame is already exist, error message will be generated.
]]
params {
@in frame: int; [[The number of the key frame to be added.]]
}
}
frame_del {
[[Delete a key frame from the given mesh.]]
params {
@in frame: int; [[The number of the key frame to be added.]]
}
}
fog_color_set {
[[Set the fog color and density for the given mesh.]]
params {
@in r: Evas.Real; [[The red component of the fog color.]]
@in g: Evas.Real; [[The green component of the fog color.]]
@in b: Evas.Real; [[The blue component of the fog color.]]
@in a: Evas.Real; [[The transparency of fog.]]
}
}
fog_color_get {
[[Set the fog color and density for the given mesh.]]
params {
@out r: Evas.Real; [[Pointer to receive red component of the fog color.]]
@out g: Evas.Real; [[Pointer to receive green component of the fog color.]]
@out b: Evas.Real; [[Pointer to receive blue component of the fog color.]]
@out a: Evas.Real; [[Pointer to receive transparency of fog.]]
}
}
blending_func_set {
[[Set the blending function for given mesh.]]
params {
@in sfactor: Evas.Canvas3D.Blend_Func; [[Specifies how the red, green, blue,
and alpha source blending factors
are computed.
]]
@in dfactor: Evas.Canvas3D.Blend_Func; [[Specifies how the red, green, blue,
and alpha destination blending
factors are computed.
]]
}
}
blending_func_get {
[[Get blending function for given mesh.]]
params {
@out sfactor: Evas.Canvas3D.Blend_Func; [[Pointer to receive source blending factors key.]]
@out dfactor: Evas.Canvas3D.Blend_Func; [[Pointer to receive destination blending factors key.]]
}
}
from_primitive_set {
[[Set the data of given mesh frame from the given primitive.]]
params {
@in frame: int; [[Specifies data of which frame of given mesh will be set.]]
@in primitive: Evas.Canvas3D.Primitive; [[Specifies which data will be set.]]
}
}
@property shader_mode {
[[Set the shader mode of the given mesh.
Default shader mode is EVAS_CANVAS3D_SHADER_MODE_VERTEX_COLOR.
]]
set {
}
get {
}
values {
mode: Evas.Canvas3D.Shader_Mode; [[The shader mode.]]
}
}
@property color_pick_enable {
[[Set possibility color picking.]]
set {
}
get {
}
values {
enabled: bool; [[Possibility flag.]]
}
}
@property vertex_count {
[[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.
]]
set {
}
get {
}
values {
count: uint; [[Vertex count.]]
}
}
@property fog_enable {
[[Enable or disable fog effect for given mesh.
Default fog is disabled.
]]
set {
}
get {
}
values {
enabled: bool; [[Fog enabled status.]]
}
}
@property alpha_test_enable {
[[The enable status of alpha test for given mesh.
Default alpha test disabled.
]]
set {
}
get {
[[Get the enable status of alpha test for given mesh.]]
}
values {
enabled: bool; [[The alpha test status.]]
}
}
@property alpha_func {
[[The alpha function.
The alpha test discards fragments depending on the outcome of
a comparison between an incoming fragment's alpha value and a
constant reference value. This function specifies the reference
value and the comparison function.
]]
set {
}
get {
}
values {
comparison_func: Evas.Canvas3D.Comparison; [[The alpha comparison function.]]
ref_value: Evas.Real; [[The reference value that incoming alpha values are compared to.]]
}
}
@property blending_enable {
[[Enable or disable blending for given mesh.]]
set {
}
get {
}
values {
blending: bool; [[The blending state.]]
}
}
@property frame_material {
[[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 animations.
]]
set {
}
get {
}
keys {
frame: int; [[The number of the key frame.]]
}
values {
material: Evas.Canvas3D.Material; [[The material to be set to the key frame.]]
}
}
@property vertex_assembly {
[[The vertex assembly of the given mesh.
Vertex assembly defines how the engine organizes vertices into
geometric primitives.
Default vertex assembly is EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES.
]]
set {
}
get {
}
values {
assembly: Evas.Canvas3D.Vertex_Assembly; [[The vertex assembly.]]
}
}
@property shadows_edges_filtering {
[[The shadow edges blur parameters.
The averaging values in window is used for blurring.
User can set the size of window and num of points in window.
]]
set {
}
get {
}
values {
blur_level: int; [[Number of points within a bluring radius.]]
edges_size: Evas.Real; [[The bluring radius.]]
}
}
@property shadows_constant_bias {
[[The offset shadow toward object.]]
set {
}
get {
}
values {
bias: Evas.Real; [[Offset.]]
}
}
@property lod_boundary {
[[The LOD boundary distances.]]
set {
}
get {
}
values {
near_lod: Evas.Real; [[Up boundary]]
far_lod: Evas.Real; [[Down boundary]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
Efl.File.load;
Efl.File.unload;
Efl.File_Save.save;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,368 +0,0 @@
import evas_canvas3d_types;
class @beta Evas.Canvas3D.Node extends Evas.Canvas3D.Object
{
[[Evas 3D canvas node class]]
data: Evas_Canvas3D_Node_Data;
methods {
@property node_type {
[[Get the type of the given node.
See also @Evas.Canvas3D.Node.member_add.]]
set {
[[Type can only be set before finalize.]]
}
get {
[[If the object is not node object, returns $unknown.]]
}
values {
type: Evas.Canvas3D.Node_Type(Evas.Canvas3D.Node_Type.unknown); [[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
graphs. A node inherit transforms from its parent.
See also @Evas.Canvas3D.Node.parent_get.]]
params {
@in member: Evas.Canvas3D.Node; [[Node object to be added.]]
}
}
member_del {
[[Delete a member node from the given node.
See also @Evas.Canvas3D.Node.member_add.]]
params {
@in member: Evas.Canvas3D.Node; [[Member node to be deleted from the given node.]]
}
}
parent_get @const {
[[Get the parent node of the given node.
See also @Evas.Canvas3D.Node.member_add.]]
return: Evas.Canvas3D.Node; [[The parent node of the given node.]]
}
member_list_get @const {
[[Get the list of member nodes of the given node.
See also @Evas.Canvas3D.Node.member_add.]]
return: const(list<Evas.Canvas3D.Node>); [[The list of member nodes if any or $null if there are none.]]
}
scene_root_get {
[[Get hash table of scenes using this node as root.]]
/* FIXME: void_ptr is actually uintptr and that is also wrong */
return: hash<Evas.Canvas3D.Object, void_ptr>; [[ scenes using this node as root. FIXME: Actually a scene, not object.]]
}
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 also @Evas.Canvas3D.Node.position_inherit.set.]]
params {
@in x: Evas.Real; [[X coordinate of the position.]]
@in y: Evas.Real; [[Y coordinate of the position.]]
@in z: Evas.Real; [[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 also @Evas.Canvas3D.Node.orientation_inherit.set.]]
params {
@in x: Evas.Real; [[X term of the orientation quaternion (w, x, y, z.]]
@in y: Evas.Real; [[Y term of the orientation quaternion (w, x, y, z.]]
@in z: Evas.Real; [[Z term of the orientation quaternion (w, x, y, z.]]
@in w: Evas.Real; [[W term of the orientation quaternion (w, x, y, z.]]
}
}
orientation_angle_axis_set {
[[Set the orientation of the given node using axis-angle.
See also @Evas.Canvas3D.Node.orientation_set.]]
params {
@in angle: Evas.Real; [[Rotation angle.]]
@in x: Evas.Real; [[X term of the rotation axis.]]
@in y: Evas.Real; [[Y term of the rotation axis.]]
@in z: Evas.Real; [[Z term of the rotation axis.]]
}
}
scale_set {
[[Set the scale of the given node.
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 also @Evas.Canvas3D.Node.scale_inherit.set.]]
params {
@in x: Evas.Real; [[Scale factor along X-axis.]]
@in y: Evas.Real; [[Scale factor along Y-axis.]]
@in z: Evas.Real; [[Scale factor along Z-axis.]]
}
}
position_get @const {
[[Get the position of the given node.
See also @Evas.Canvas3D.Node.position_set.]]
params {
@in space: Evas.Canvas3D.Space; [[The given node.]]
@out x: Evas.Real; [[Pointer to receive X coordinate of the position.]]
@out y: Evas.Real; [[Pointer to receive Y coordinate of the position.]]
@out z: Evas.Real; [[Pointer to receive Z coordinate of the position.]]
}
}
orientation_get @const {
[[Get the orientation of the given node as quaternion.
See also @Evas.Canvas3D.Node.orientation_set.]]
params {
@in space: Evas.Canvas3D.Space; [[The given node.]]
@out x: Evas.Real; [[Pointer to receive X term of the orientation quaternion.]]
@out y: Evas.Real; [[Pointer to receive Y term of the orientation quaternion.]]
@out z: Evas.Real; [[Pointer to receive Z term of the orientation quaternion.]]
@out w: Evas.Real; [[Pointer to receive W term of the orientation quaternion.]]
}
}
scale_get @const {
[[Get the scale of the given node.
See also @Evas.Canvas3D.Node.scale_get.]]
params {
@in space: Evas.Canvas3D.Space; [[The given node.]]
@out x: Evas.Real; [[Pointer to receive Scale factor along X-axis.]]
@out y: Evas.Real; [[Pointer to receive Scale factor along X-axis.]]
@out z: Evas.Real; [[Pointer to receive Scale factor along X-axis.]]
}
}
look_at_set {
[[Rotate the given node to look at desired position.
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 also @Evas.Canvas3D.Node.orientation_set.]]
params {
@in target_space: Evas.Canvas3D.Space; [[Space where the target position belongs to.]]
@in x: Evas.Real; [[X coordinate of the target position.]]
@in y: Evas.Real; [[Y coordinate of the target position.]]
@in z: Evas.Real; [[Z coordinate of the target position.]]
@in up_space: Evas.Canvas3D.Space; [[Space where the up vector belongs to.]]
@in ux: Evas.Real; [[X term of the up vector.]]
@in uy: Evas.Real; [[Y term of the up vector.]]
@in uz: Evas.Real; [[Z term of the up vector.]]
}
}
mesh_add {
[[Add a mesh to the given node.
If the node is not of type EVAS_CANVAS3D_NODE_TYPE_MESH, error message will be
generated and nothing happens.
See also @Evas.Canvas3D.Node.member_add.]]
params {
@in mesh: Evas.Canvas3D.Mesh; [[The mesh to be added.]]
}
}
mesh_del {
[[Delete a mesh from the given node.
If the node is not of type EVAS_CANVAS3D_NODE_TYPE_MESH or the given mesh does not
belong to the given node, error message will be gnerated and nothing happens.
See also @Evas.Canvas3D.Node.mesh_add.]]
params {
@in mesh: Evas.Canvas3D.Mesh; [[The mesh to be deleted.]]
}
}
mesh_list_get @const {
[[Get the list of meshes of the given node.
If the node is not of type EVAS_CANVAS3D_NODE_TYPE_MESH, error message will be
generated and $null will be returned. If there're no meshes in the given
node, $null will be returned.
See also @Evas.Canvas3D.Node.mesh_add.]]
return: const(list<Evas.Canvas3D.Mesh>); [[The list of meshes if any, or $null if there're none.]]
}
bounding_box_get{
[[Get axis-aligned bounding box (AABB) of the given node.]]
params {
@in x: ptr(Evas.Real); [[Pointer to receive X coordinate of the first point of AABB.]]
@in y: ptr(Evas.Real); [[Pointer to receive Y coordinate of the first point of AABB.]]
@in z: ptr(Evas.Real); [[Pointer to receive Z coordinate of the first point of AABB.]]
@in x2: ptr(Evas.Real); [[Pointer to receive X coordinate of the second point of AABB.]]
@in y2: ptr(Evas.Real); [[Pointer to receive Y coordinate of the second point of AABB.]]
@in z2: ptr(Evas.Real); [[Pointer to receive Z coordinate of the second point of AABB.]]
}
}
bounding_sphere_get {
[[Get bounding sphere of the given node.]]
params {
@in x: ptr(Evas.Real); [[Pointer to receive X coordinate of the center of sphere.]]
@in y: ptr(Evas.Real); [[Pointer to receive Y coordinate of the center of sphere.]]
@in z: ptr(Evas.Real); [[Pointer to receive Z coordinate of center of sphere.]]
@in r: ptr(Evas.Real); [[Pointer to receive radius of center of sphere.]]
}
}
@property position_inherit {
[[The position inheritance flag of the given node.
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.]]
set {
}
get {
}
values {
inherit: bool; [[Whether to inherit parent position.]]
}
}
@property orientation_inherit {
[[The orientation inheritance flag of the given node.
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.]]
set {
}
get {
}
values {
inherit: bool; [[Whether to inherit parent orientation.]]
}
}
@property scale_inherit {
[[The scale inheritance flag of the given node.
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.]]
set {
}
get {
}
values {
inherit: bool; [[Whether to inherit parent scale.]]
}
}
@property camera {
[[A camera attached to the given node.
If the node is not of type EVAS_CANVAS3D_NODE_TYPE_CAMERA, error message will be
generated and nothing happens.
See also @Evas.Canvas3D.Node.member_add.]]
set {
}
get {
}
values {
// FIXME: Evas_Canvas3D_Camera is necessary, but that introduces a cycle
camera: Evas.Canvas3D.Object; [[The camera of the given node if any, or $null if there're none.]]
}
}
@property light {
[[A light attached to the given node.
If the node is not of type EVAS_CANVAS3D_NODE_TYPE_LIGHT, error message will be
generated and nothing happens.
See also @Evas.Canvas3D.Node.member_add.]]
set {
}
get {
}
values {
light: Evas.Canvas3D.Light; [[The light of the given node if any, or $null if there're none.]]
}
}
@property mesh_frame {
[[The animation frame number of the given node for the given mesh.
If the node is not of type EVAS_CANVAS3D_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 also @Evas.Canvas3D.Node.mesh_add.]]
set {
}
get {
}
keys {
mesh: Evas.Canvas3D.Mesh; [[The given mesh.]]
}
values {
frame: int; [[The animation frame number.]]
}
}
@property billboard_target {
[[Set behavior of node like billboard object.]]
set {
}
get {
}
values {
target: Evas.Canvas3D.Node; [[The pointer to target node for billboard object,
or $null if there're none.]]
}
}
@property lod_enable {
[[Enable behavior of node like LOD object.]]
set {
}
get {
}
values {
enable: bool; [[status property (true/false)]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Object.finalize;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
Evas.Canvas3D.Object.callback_register;
Evas.Canvas3D.Object.callback_unregister;
}
}

View File

@ -1,36 +0,0 @@
/*Type of events and callbacks for object Evas_Canvas3D_Node*/
#define GET_CALLBACK_TYPE(check, type) \
if (!(strcmp(type, "clicked"))) \
check = PRIVATE_CALLBACK_CLICKED; \
else if (!(strcmp(type, "collision"))) \
check = PRIVATE_CALLBACK_COLLISION; \
else \
check = PRIVATE_CALLBACK_NONE;
typedef enum _Evas_Canvas3D_Node_Private_Callback_Type
{
PRIVATE_CALLBACK_CLICKED = 0,
PRIVATE_CALLBACK_COLLISION,
/*Insert here new type of callback*/
PRIVATE_CALLBACK_NONE
} Evas_Canvas3D_Node_Private_Callback_Type;
const Efl_Event_Description evas_canvas3d_node_private_event_desc[] =
{
EFL_EVENT_DESCRIPTION("clicked,private"),
EFL_EVENT_DESCRIPTION("collision,private")
};
/*Private callbacks */
static void
_evas_canvas3d_node_private_callback_clicked(void *data, const Efl_Event *event);
static void
_evas_canvas3d_node_private_callback_collision(void *data, const Efl_Event *event);
Efl_Event_Cb evas_canvas3d_node_private_callback_functions[] =
{
_evas_canvas3d_node_private_callback_clicked,
_evas_canvas3d_node_private_callback_collision,
};

View File

@ -1,101 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_OBJECT_CLASS
EOLIAN static Eo *
_evas_canvas3d_object_efl_object_constructor(Eo *obj, Evas_Canvas3D_Object_Data *pd)
{
Eo *e = NULL;
obj = efl_constructor(efl_super(obj, MY_CLASS));
e = efl_parent_get(obj);
pd->evas = e;
pd->type = EVAS_CANVAS3D_OBJECT_TYPE_INVALID;
memset(&pd->dirty[0], 0x00, sizeof(Eina_Bool) * EVAS_CANVAS3D_STATE_MAX);
return obj;
}
EOLIAN static Evas *
_evas_canvas3d_object_efl_object_provider_find(const Eo *obj, Evas_Canvas3D_Object_Data *pd, const Efl_Class *klass)
{
if (klass == EVAS_CANVAS_CLASS)
return pd->evas;
return efl_provider_find(efl_super(obj, MY_CLASS), klass);
}
EOLIAN static void
_evas_canvas3d_object_type_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Object_Data *pd, Evas_Canvas3D_Object_Type type)
{
pd->type = type;
}
EOLIAN static Evas_Canvas3D_Object_Type
_evas_canvas3d_object_type_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Object_Data *pd)
{
return pd->type;
}
EOLIAN static Eina_Bool
_evas_canvas3d_object_dirty_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Object_Data *pd, Evas_Canvas3D_State state)
{
return pd->dirty[state];
}
EOLIAN static void
_evas_canvas3d_object_change(Eo *obj, Evas_Canvas3D_Object_Data *pd, Evas_Canvas3D_State state, Evas_Canvas3D_Object *ref)
{
/* Skip already dirty properties. */
if (pd->dirty[state])
return;
pd->dirty[state] = EINA_TRUE;
pd->dirty[EVAS_CANVAS3D_STATE_ANY] = EINA_TRUE;
evas_canvas3d_object_change_notify(obj, state, ref);
}
EOLIAN static void
_evas_canvas3d_object_update(Eo *obj, Evas_Canvas3D_Object_Data *pd)
{
if (!pd->dirty[EVAS_CANVAS3D_STATE_ANY])
return;
evas_canvas3d_object_update_notify(obj);
memset(&pd->dirty[0], 0x00, sizeof(Eina_Bool) * EVAS_CANVAS3D_STATE_MAX);
}
EOLIAN static Eina_Bool
_evas_canvas3d_object_efl_object_event_callback_priority_add(Eo *obj,
Evas_Canvas3D_Object_Data *pd EINA_UNUSED,
const Efl_Event_Description *desc,
Efl_Callback_Priority priority,
Efl_Event_Cb func,
const void *user_data)
{
Eina_Bool r = EINA_FALSE;
r = efl_event_callback_priority_add(efl_super(obj, MY_CLASS), desc, priority, func, user_data);
evas_canvas3d_object_callback_register(obj, desc->name, user_data);
return r;
}
EOLIAN static Eina_Bool
_evas_canvas3d_object_efl_object_event_callback_del(Eo *obj, Evas_Canvas3D_Object_Data *pd EINA_UNUSED,
const Efl_Event_Description *desc,
Efl_Event_Cb func,
const void *user_data)
{
Eina_Bool r = EINA_FALSE;
r = efl_event_callback_del(efl_super(obj, MY_CLASS), desc, func, user_data);
if (r) evas_canvas3d_object_callback_unregister(obj, desc->name);
return r;
}
#define EVAS_CANVAS3D_OBJECT_EXTRA_OPS \
EFL_OBJECT_OP_FUNC(efl_event_callback_priority_add, _evas_canvas3d_object_efl_object_event_callback_priority_add), \
EFL_OBJECT_OP_FUNC(efl_event_callback_del, _evas_canvas3d_object_efl_object_event_callback_del)
#include "canvas/evas_canvas3d_object.eo.c"

View File

@ -1,77 +0,0 @@
import evas_canvas3d_types;
abstract @beta Evas.Canvas3D.Object extends Efl.Object
{
[[Evas 3D canvas object class]]
data: Evas_Canvas3D_Object_Data;
methods {
change {
[[Notify the object regarding its state change.]]
params {
@in state: Evas.Canvas3D.State; [[State that is changed.]]
@in ref: Evas.Canvas3D.Object; [[The Object that caused the change.]]
}
}
type_get @const {
[[Returns the type of the object.]]
return: Evas.Canvas3D.Object_Type; [[Object type]]
}
type_set {
[[Sets the type of the object.]]
params{
@in type: Evas.Canvas3D.Object_Type; [[Object type]]
}
}
dirty_get @const {
[[Returns the status of a particular state of the object.]]
return: bool; [[$true if the status is dirty, $false otherwise]]
params {
@in state: Evas.Canvas3D.State; [[State whose status is being asked.]]
}
}
update {
[[Update request for the object.]]
}
update_notify @pure_virtual {
[[Pure virtual update_notify function.
Update request for the object.]]
}
change_notify @pure_virtual {
[[Pure virtual change_notify function.
Update request for the object.]]
params {
@in state: Evas.Canvas3D.State; [[State that is changed.]]
@in ref: Evas.Canvas3D.Object; [[The Object that caused the change.]]
}
}
callback_register @pure_virtual {
[[Pure virtual register samrt callback function.]]
params {
@in event: string; [[Event type.]]
@in data: const(void_ptr); [[User data.]]
}
}
callback_unregister @pure_virtual {
[[Pure virtual unregister smart callback function.]]
params {
@in event: string; [[Event type.]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.provider_find;
}
events {
/* FIXME: Make sure that these two events are actually being emitted */
clicked: Evas.Canvas3D.Node; [[Clicked Event.]]
collision: Evas.Canvas3D.Node; [[Collision Event.]]
}
}

View File

@ -1,152 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_PRIMITIVE_CLASS
static inline void
_primitive_init(Evas_Canvas3D_Primitive_Data *pd)
{
pd->form = EVAS_CANVAS3D_MESH_PRIMITIVE_NONE;
pd->ratio = 3.0;
pd->precision = 10;
pd->surface = NULL;
pd->tex_scale.x = 1.0;
pd->tex_scale.y = 1.0;
}
EAPI Evas_Canvas3D_Primitive *
evas_canvas3d_primitive_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
return efl_add(MY_CLASS, e);
}
EOLIAN static Eo *
_evas_canvas3d_primitive_efl_object_constructor(Eo *obj, Evas_Canvas3D_Primitive_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_PRIMITIVE);
_primitive_init(pd);
return obj;
}
EOLIAN static void
_evas_canvas3d_primitive_efl_object_destructor(Eo *obj, Evas_Canvas3D_Primitive_Data *pd EINA_UNUSED)
{
efl_destructor(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_evas_canvas3d_primitive_form_set(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
Evas_Canvas3D_Mesh_Primitive form)
{
if (form >= EVAS_CANVAS3D_MESH_PRIMITIVE_COUNT)
{
ERR("Wrong form of primitive.");
return;
}
if (pd->form != form)
pd->form = form;
}
EOLIAN static Evas_Canvas3D_Mesh_Primitive
_evas_canvas3d_primitive_form_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd)
{
return pd->form;
}
EOLIAN static void
_evas_canvas3d_primitive_mode_set(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
Evas_Canvas3D_Primitive_Mode mode)
{
if (pd->mode != mode)
pd->mode = mode;
}
EOLIAN static Evas_Canvas3D_Primitive_Mode
_evas_canvas3d_primitive_mode_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd)
{
return pd->mode;
}
EOLIAN static void
_evas_canvas3d_primitive_ratio_set(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
Evas_Real ratio)
{
pd->ratio = ratio;
}
EOLIAN static Evas_Real
_evas_canvas3d_primitive_ratio_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd)
{
return pd->ratio;
}
EOLIAN static void
_evas_canvas3d_primitive_precision_set(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
int precision)
{
if ((precision < 3))
{
ERR("Precision of Evas_Canvas3D_Primitive cannot be less than 3.");
return;
}
if ((precision >= 100))
{
ERR("%s\n%s",
"Be careful with precision of Evas_Canvas3D_Primitive more than 100.",
"It can give unacceptable result.");
}
if (pd->precision != precision)
pd->precision = precision;
}
EOLIAN static int
_evas_canvas3d_primitive_precision_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd)
{
return pd->precision;
}
EOLIAN static void
_evas_canvas3d_primitive_surface_set(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
Evas_Canvas3D_Surface_Func surface_func)
{
pd->surface = surface_func;
}
EOLIAN static void
_evas_canvas3d_primitive_tex_scale_set(Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
Evas_Real x,
Evas_Real y)
{
if (!EINA_DBL_EQ(x, 0.0)) pd->tex_scale.x = x;
if (!EINA_DBL_EQ(y, 0.0)) pd->tex_scale.y = y;
}
EOLIAN static void
_evas_canvas3d_primitive_tex_scale_get(const Eo *obj EINA_UNUSED,
Evas_Canvas3D_Primitive_Data *pd,
Evas_Real *x,
Evas_Real *y)
{
if (x) *x = pd->tex_scale.x;
if (y) *y = pd->tex_scale.y;
}
#include "canvas/evas_canvas3d_primitive.eo.c"

View File

@ -1,130 +0,0 @@
import evas_canvas3d_types;
class @beta Evas.Canvas3D.Primitive extends Evas.Canvas3D.Object
{
[[Evas 3D canvas primitive class]]
data: Evas_Canvas3D_Primitive_Data;
methods {
@property form {
[[The form of the given primitive.
Form defines which function will be chosen to set data to mesh
on call of evas_canvas3d_mesh_primitive_set.
Now available next forms of primitives are tabulated primitives (SQUARE and CUBE),
solids of revolution (CYLINDER, CONE, SPHERE and TORUS) and surfaces (SURFACE and TERRAIN).
Default form is EVAS_CANVAS3D_MESH_PRIMITIVE_NONE.]]
set {
}
get {
}
values {
form: Evas.Canvas3D.Mesh_Primitive; [[Form of primitive.]]
}
}
@property mode {
[[The mode of the given primitive.
Mode defines which function will be chosen to set data to mesh
on call of evas_canvas3d_mesh_primitive_set. It helps to choose
an alternative algorithm for primitives with a given form,
such as a cone without a base or sphere textured in alternative way.
Mods of primitives are now available
without base (bases) (supported for cylinder and cone) and
with alternative UV (supported by sphere).
Default form is EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT.]]
set {
}
get {
}
values {
mode: Evas.Canvas3D.Primitive_Mode; [[Mode of primitive.]]
}
}
@property ratio {
[[The ratio of the given primitive.
Ratio is used only in torus as the ratio of the
major radius and minor radius. For this usage
Available values is from 1.0 to infinity.
If ratio for torus has a bad value,
3.0 will be used as the ratio.
Default ratio is 3.0.]]
set {
}
get {
}
values {
ratio: Evas.Real; [[Ratio of primitive.]]
}
}
@property precision {
[[The precision of the given primitive.
Precision is used in all non tabulated primitives and defines
the precision of created primitives.
Available values range from 3 to infinity.
If the value is more than 100, you may see a warning
about possibility of incorrect values or slow processing.
Default ratio is 10.]]
set {
}
get {
}
values {
precision: int; [[Precision of primitive.]]
}
}
@property surface {
[[The surface of the given primitive.
Surface is used only in surface primitives and defines
the equation of filling mesh data on call of
evas_canvas3d_mesh_primitive_set.
This allows you to create customers primitives like
shell, heart, hyperbolic paraboloid etc. See _shell_func in
examples/evas/evas-3d-visual-test.c or _perlin_terrain in
modules/evas/primitives/surfaces/terrain.c for usage examples.
Default surface is $null]]
set {
}
values {
surface: ptr(Evas.Canvas3D.Surface_Func); [[Pointer to customers surface function.]]
}
}
@property tex_scale {
[[The texture scale of the given primitive.
Texture scale uses in all non tabulated primitives
and defines scale of texture coordinates or primitives.
It uses to create periodical textured meshes.
Default tex_scale is {1.0, 1.0}]]
set {
}
get {
}
values {
tex_scale_x: Evas.Real; [[Texture scale X coordinate]]
tex_scale_y: Evas.Real; [[Texture scale Y coordinate]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
@empty Evas.Canvas3D.Object.update_notify;
@empty Evas.Canvas3D.Object.change_notify;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

View File

@ -1,839 +0,0 @@
#include "eo_internal.h"
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_SCENE_CLASS
void
evas_canvas3d_scene_data_init(Evas_Canvas3D_Scene_Public_Data *data)
{
data->camera_node = NULL;
data->light_nodes = NULL;
data->mesh_nodes = NULL;
data->node_mesh_colors = NULL;
data->colors_node_mesh = NULL;
data->render_to_texture = EINA_FALSE;
data->lod_distance = 0;
data->post_processing = EINA_FALSE;
data->post_processing_type = EVAS_CANVAS3D_SHADER_MODE_POST_PROCESSING_FXAA;
}
void
evas_canvas3d_scene_data_fini(Evas_Canvas3D_Scene_Public_Data *data)
{
if (data->light_nodes)
eina_list_free(data->light_nodes);
if (data->mesh_nodes)
eina_list_free(data->mesh_nodes);
}
EOLIAN static void
_evas_canvas3d_scene_evas_canvas3d_object_change_notify(Eo *eo_obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd,
Evas_Canvas3D_State state EINA_UNUSED,
Evas_Canvas3D_Object *ref EINA_UNUSED)
{
Eina_List *l;
Evas_Object *eo;
EINA_LIST_FOREACH(pd->images, l, eo)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo, EFL_CANVAS_OBJECT_CLASS);
evas_object_change(eo, obj);
}
}
EOLIAN static void
_evas_canvas3d_scene_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd)
{
if (pd->root_node)
{
evas_canvas3d_object_update(pd->root_node);
}
if (pd->camera_node)
{
evas_canvas3d_object_update(pd->camera_node);
}
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_UPDATED, NULL);
}
EAPI Evas_Canvas3D_Scene *
evas_canvas3d_scene_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
return efl_add(MY_CLASS, e);
}
EOLIAN static Eo *
_evas_canvas3d_scene_efl_object_constructor(Eo *obj, Evas_Canvas3D_Scene_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_SCENE);
evas_color_set(&pd->bg_color, 0.0, 0.0, 0.0, 0.0);
pd->shadows_enabled = EINA_FALSE;
pd->color_pick_enabled = EINA_FALSE;
pd->node_mesh_colors = NULL;
pd->colors_node_mesh = NULL;
pd->depth_offset = 4.0;
pd->depth_constant = 100.0;
return obj;
}
EOLIAN static void
_evas_canvas3d_scene_root_node_set(Eo *obj, Evas_Canvas3D_Scene_Data *pd, Evas_Canvas3D_Node *node)
{
if (pd->root_node == node)
return;
if (pd->root_node)
{
evas_canvas3d_node_scene_root_del(pd->root_node, obj);
efl_unref(pd->root_node);
}
pd->root_node = node;
if (node)
{
efl_ref(node);
evas_canvas3d_node_scene_root_add(node, obj);
}
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_ROOT_NODE, NULL);
}
EOLIAN static Evas_Canvas3D_Node *
_evas_canvas3d_scene_root_node_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd)
{
return pd->root_node;
}
EOLIAN static void
_evas_canvas3d_scene_camera_node_set(Eo *obj, Evas_Canvas3D_Scene_Data *pd, Evas_Canvas3D_Node *node)
{
if (pd->camera_node == node)
return;
if (pd->camera_node)
{
evas_canvas3d_node_scene_camera_del(pd->camera_node, obj);
}
pd->camera_node = node;
if (node)
{
evas_canvas3d_node_scene_camera_add(node, obj);
}
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_CAMERA_NODE, NULL);
}
EOLIAN static Evas_Canvas3D_Node *
_evas_canvas3d_scene_camera_node_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd)
{
return pd->camera_node;
}
EOLIAN static void
_evas_canvas3d_scene_size_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd, int w, int h)
{
pd->w = w;
pd->h = h;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_SIZE, NULL);
}
EOLIAN static void
_evas_canvas3d_scene_size_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd, int *w, int *h)
{
if (w) *w = pd->w;
if (h) *h = pd->h;
}
EOLIAN static void
_evas_canvas3d_scene_background_color_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd,
Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
{
evas_color_set(&pd->bg_color, r, g, b, a);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_BACKGROUND_COLOR, NULL);
}
EOLIAN static void
_evas_canvas3d_scene_background_color_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd,
Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *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
_pick_data_triangle_add(Evas_Canvas3D_Pick_Data *data, const Evas_Ray3 *ray,
const Evas_Triangle3 *tri)
{
Eina_Vector3 e1, e2, tvec, pvec, qvec;
Evas_Real det, inv_det, u, v, t;
eina_vector3_subtract(&e1, &tri->p1, &tri->p0);
eina_vector3_subtract(&e2, &tri->p2, &tri->p0);
eina_vector3_cross_product(&pvec, &ray->dir, &e2);
det = eina_vector3_dot_product(&e1, &pvec);
/* If determinant is near zero, ray lies in plane of triangle. */
if (det > -0.0000001 && det < 0.0000001)
return EINA_FALSE;
inv_det = 1.0 / det;
/* Calculate distance from p0 to ray origin. */
eina_vector3_subtract(&tvec, &ray->org, &tri->p0);
/* Calculate U parameter and test bounds. */
u = eina_vector3_dot_product(&tvec, &pvec) * inv_det;
if (u < 0.0 || u > 1.0)
return EINA_FALSE;
/* Prepare to tst V parameter. */
eina_vector3_cross_product(&qvec, &tvec, &e1);
/* Calculate V parameter and test bounds. */
v = eina_vector3_dot_product(&ray->dir, &qvec) * inv_det;
if (v < 0.0 || u + v > 1.0)
return EINA_FALSE;
/* Calculate T parameter and test bounds. */
t = eina_vector3_dot_product(&e2, &qvec) * inv_det;
if (t >= 0.0 && t <= 1.0)
{
if (!data->picked || t < data->z)
{
data->picked = EINA_TRUE;
data->z = t;
data->u = u;
data->v = v;
return EINA_TRUE;
}
}
return EINA_FALSE;
}
static inline void
_pick_data_texcoord_update(Evas_Canvas3D_Pick_Data *data,
const Evas_Canvas3D_Vertex_Buffer *tex0, const Evas_Canvas3D_Vertex_Buffer *tex1,
Evas_Real weight, unsigned int i0, unsigned int i1, unsigned int i2)
{
Evas_Real s0, s1, s2;
Evas_Real t0, t1, t2;
if (tex1->data == NULL)
{
float *ptr;
ptr = (float *)((char *)tex0->data + tex0->stride * i0);
s0 = ptr[0];
t0 = ptr[1];
ptr = (float *)((char *)tex0->data + tex0->stride * i1);
s1 = ptr[0];
t1 = ptr[1];
ptr = (float *)((char *)tex0->data + tex0->stride * i2);
s2 = ptr[0];
t2 = ptr[1];
}
else
{
float *ptr0, *ptr1;
ptr0 = (float *)((char *)tex0->data + tex0->stride * i0);
ptr1 = (float *)((char *)tex1->data + tex1->stride * i0);
s0 = ptr0[0] * weight + ptr1[0] * (1.0 - weight);
t0 = ptr0[1] * weight + ptr1[1] * (1.0 - weight);
ptr0 = (float *)((char *)tex0->data + tex0->stride * i1);
ptr1 = (float *)((char *)tex1->data + tex1->stride * i1);
s1 = ptr0[0] * weight + ptr1[0] * (1.0 - weight);
t1 = ptr0[1] * weight + ptr1[1] * (1.0 - weight);
ptr0 = (float *)((char *)tex0->data + tex0->stride * i2);
ptr1 = (float *)((char *)tex1->data + tex1->stride * i2);
s2 = ptr0[0] * weight + ptr1[0] * (1.0 - weight);
t2 = ptr0[1] * weight + ptr1[1] * (1.0 - weight);
}
data->s = s0 * (1 - data->u - data->v) + s1 * data->u + s2 * data->v;
data->t = t0 * (1 - data->u - data->v) + t1 * data->u + t2 * data->v;
}
static inline Eina_Bool
_pick_data_mesh_add(Evas_Canvas3D_Pick_Data *data, const Evas_Ray3 *ray,
Evas_Canvas3D_Mesh *mesh, int frame, Evas_Canvas3D_Node *node)
{
Evas_Canvas3D_Vertex_Buffer pos0, pos1, tex0, tex1;
Evas_Real pos_weight, tex_weight;
Evas_Triangle3 tri;
int i;
memset(&pos0, 0x00, sizeof(Evas_Canvas3D_Vertex_Buffer));
memset(&pos1, 0x00, sizeof(Evas_Canvas3D_Vertex_Buffer));
memset(&tex0, 0x00, sizeof(Evas_Canvas3D_Vertex_Buffer));
memset(&tex1, 0x00, sizeof(Evas_Canvas3D_Vertex_Buffer));
evas_canvas3d_mesh_interpolate_vertex_buffer_get(mesh, frame, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION,
&pos0, &pos1, &pos_weight);
evas_canvas3d_mesh_interpolate_vertex_buffer_get(mesh, frame, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD,
&tex0, &tex1, &tex_weight);
Evas_Canvas3D_Mesh_Data *pdmesh = efl_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
if (pdmesh->indices)
{
unsigned int i0, i1, i2;
if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES)
{
for (i = 0; i < pdmesh->index_count; i += 3)
{
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i0 = ((unsigned short *)pdmesh->indices)[i];
i1 = ((unsigned short *)pdmesh->indices)[i + 1];
i2 = ((unsigned short *)pdmesh->indices)[i + 2];
}
else
{
i0 = ((unsigned char *)pdmesh->indices)[i];
i1 = ((unsigned char *)pdmesh->indices)[i + 1];
i2 = ((unsigned char *)pdmesh->indices)[i + 2];
}
evas_canvas3d_mesh_interpolate_position_get(&tri.p0, &pos0, &pos1, pos_weight, i0);
evas_canvas3d_mesh_interpolate_position_get(&tri.p1, &pos0, &pos1, pos_weight, i1);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2);
data->mesh = mesh;
data->node = node;
return EINA_TRUE;
}
}
}
else if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
{
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i1 = ((unsigned short *)pdmesh->indices)[0];
i2 = ((unsigned short *)pdmesh->indices)[1];
}
else
{
i1 = ((unsigned char *)pdmesh->indices)[0];
i2 = ((unsigned char *)pdmesh->indices)[1];
}
evas_canvas3d_mesh_interpolate_position_get(&tri.p1, &pos0, &pos1, pos_weight, i1);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
for (i = 0; i < pdmesh->index_count - 2; i++)
{
tri.p0 = tri.p1;
tri.p1 = tri.p2;
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
i2 = ((unsigned short *)pdmesh->indices)[i + 2];
else
i2 = ((unsigned char *)pdmesh->indices)[i + 2];
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i0 = ((unsigned short *)pdmesh->indices)[i];
i1 = ((unsigned short *)pdmesh->indices)[i + 1];
}
else
{
i0 = ((unsigned char *)pdmesh->indices)[i];
i1 = ((unsigned char *)pdmesh->indices)[i + 1];
}
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2);
data->mesh = mesh;
data->node = node;
return EINA_TRUE;
}
}
}
else if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
{
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
{
i0 = ((unsigned short *)pdmesh->indices)[0];
i2 = ((unsigned short *)pdmesh->indices)[1];
}
else
{
i0 = ((unsigned char *)pdmesh->indices)[0];
i2 = ((unsigned char *)pdmesh->indices)[1];
}
evas_canvas3d_mesh_interpolate_position_get(&tri.p0, &pos0, &pos1, pos_weight, i0);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
for (i = 1; i < pdmesh->index_count - 1; i++)
{
tri.p1 = tri.p2;
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
i2 = ((unsigned short *)pdmesh->indices)[i + 1];
else
i2 = ((unsigned char *)pdmesh->indices)[i + 1];
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
i1 = ((unsigned short *)pdmesh->indices)[i];
else
i1 = ((unsigned char *)pdmesh->indices)[i];
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2);
data->mesh = mesh;
data->node = node;
}
}
}
}
else if (pdmesh->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_BYTE)
{
if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES)
{
for (i = 0; i < pdmesh->index_count; i += 3)
{
evas_canvas3d_mesh_interpolate_position_get(&tri.p0, &pos0, &pos1, pos_weight, i);
evas_canvas3d_mesh_interpolate_position_get(&tri.p1, &pos0, &pos1, pos_weight, i + 1);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i + 2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i, i + 1, i + 2);
data->mesh = mesh;
data->node = node;
}
}
}
else if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
{
evas_canvas3d_mesh_interpolate_position_get(&tri.p1, &pos0, &pos1, pos_weight, 0);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, 1);
for (i = 0; i < pdmesh->index_count - 2; i++)
{
tri.p0 = tri.p1;
tri.p1 = tri.p2;
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i + 2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i, i + 1, i + 2);
data->mesh = mesh;
data->node = node;
}
}
}
else if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
{
evas_canvas3d_mesh_interpolate_position_get(&tri.p0, &pos0, &pos1, pos_weight, 0);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, 1);
for (i = 1; i < pdmesh->index_count - 1; i++)
{
tri.p1 = tri.p2;
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i + 1);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, 0, i, i + 1);
data->mesh = mesh;
data->node = node;
}
}
}
}
else if ((EINA_DBL_EQ(pdmesh->index_count, 0.0)) &&
pdmesh->vertex_count != 0)
{
if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES)
{
for (i = 0; i < pdmesh->vertex_count; i += 3)
{
evas_canvas3d_mesh_interpolate_position_get(&tri.p0, &pos0, &pos1, pos_weight, i);
evas_canvas3d_mesh_interpolate_position_get(&tri.p1, &pos0, &pos1, pos_weight, i + 1);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i + 2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i, i + 1, i + 2);
data->mesh = mesh;
data->node = node;
}
}
}
else if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP)
{
evas_canvas3d_mesh_interpolate_position_get(&tri.p1, &pos0, &pos1, pos_weight, 0);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, 1);
for (i = 0; i < pdmesh->vertex_count - 2; i++)
{
tri.p0 = tri.p1;
tri.p1 = tri.p2;
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i + 2);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i, i + 1, i + 2);
data->mesh = mesh;
data->node = node;
return EINA_TRUE;
}
}
}
else if (pdmesh->assembly == EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_FAN)
{
evas_canvas3d_mesh_interpolate_position_get(&tri.p0, &pos0, &pos1, pos_weight, 0);
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, 1);
for (i = 1; i < pdmesh->vertex_count - 1; i++)
{
tri.p1 = tri.p2;
evas_canvas3d_mesh_interpolate_position_get(&tri.p2, &pos0, &pos1, pos_weight, i + 1);
if (_pick_data_triangle_add(data, ray, &tri))
{
if (tex0.data)
_pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, 0, i, i + 1);
data->mesh = mesh;
data->node = node;
return EINA_TRUE;
}
}
}
}
return EINA_FALSE;
}
Eina_Bool
_node_pick(Evas_Canvas3D_Node *node, void *data)
{
Evas_Ray3 ray;
Evas_Canvas3D_Pick_Data *pick = (Evas_Canvas3D_Pick_Data *)data;
Eina_Matrix4 mvp;
Evas_Canvas3D_Node_Data *pd_node = efl_data_scope_get(node, EVAS_CANVAS3D_NODE_CLASS);
evas_canvas3d_node_tree_traverse(node, EVAS_CANVAS3D_TREE_TRAVERSE_POST_ORDER, EINA_FALSE,
node_aabb_update, NULL);
if (! evas_box3_ray3_intersect(&pd_node->aabb, &pick->ray_world))
{
/* Skip entire subtree. */
return EINA_FALSE;
}
if (pd_node->type == EVAS_CANVAS3D_NODE_TYPE_MESH)
{
Eina_Iterator *itr;
void *ptr;
/* Transform ray into local coordinate space. */
eina_matrix4_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(pd_node->data.mesh.node_meshes);
while (eina_iterator_next(itr, &ptr))
{
Evas_Canvas3D_Node_Mesh *nm = (Evas_Canvas3D_Node_Mesh *)ptr;
if(_pick_data_mesh_add(pick, &ray, nm->mesh, nm->frame, node))
break;
}
}
return EINA_TRUE;
}
static void _node_mesh_colors_free_cb(void *data)
{
if (data) free(data);
}
static inline void
_pick_data_init(Evas_Canvas3D_Pick_Data *data, Evas_Public_Data *e, Evas_Real x, Evas_Real y)
{
data->x = ((x * 2.0) / ((Evas_Real)e->viewport.w)) - 1.0;
data->y = ((((Evas_Real)e->viewport.h - y - 1) * 2.0) / ((Evas_Real)e->viewport.h)) - 1.0;
data->picked = EINA_FALSE;
data->z = 1.0;
data->node = NULL;
data->mesh = NULL;
data->s = 0.0;
data->t = 0.0;
}
EOLIAN static Eina_Bool
_evas_canvas3d_scene_pick(const Eo *obj, Evas_Canvas3D_Scene_Data *pd, Evas_Real x, Evas_Real y,
Evas_Canvas3D_Node **node, Evas_Canvas3D_Mesh **mesh,
Evas_Real *s, Evas_Real *t)
{
Evas_Canvas3D_Pick_Data data;
Evas_Canvas3D_Node_Data *pd_camera_node;
Evas_Canvas3D_Camera_Data *pd_camera;
Evas_Canvas3D_Object_Data *pd_parent;
Evas_Public_Data *e;
int tex = 0, px, py;;
Evas_Color color = {0.0, 0.0, 0.0, 0.0};
Eina_Stringshare *tmp;
Eina_Array *arr = NULL;
Eina_Bool update_scene = EINA_FALSE;
Evas_Canvas3D_Node *picked_node = NULL;
const Efl_Event_Description *eo_desc = NULL;
pd_parent = efl_data_scope_get(obj, EVAS_CANVAS3D_OBJECT_CLASS);
e = efl_data_scope_get(pd_parent->evas, EVAS_CANVAS_CLASS);
_pick_data_init(&data, e, x, y);
px = round(x * pd->w / e->viewport.w);
py = round((pd->h - (y * pd->h / e->viewport.h) - 1));
/*Use color pick mechanism finding node and mesh*/
if (pd->color_pick_enabled)
{
Evas_Canvas3D_Scene_Public_Data scene_data;
scene_data.bg_color = pd->bg_color;
scene_data.shadows_enabled = pd->shadows_enabled;
scene_data.camera_node = pd->camera_node;
scene_data.color_pick_enabled = pd->color_pick_enabled;
update_scene = evas_canvas3d_object_dirty_get(obj, EVAS_CANVAS3D_STATE_SCENE_UPDATED);
scene_data.post_processing = EINA_FALSE;
if (update_scene)
{
if (pd->node_mesh_colors)
{
eina_hash_free(pd->node_mesh_colors);
eina_hash_free(pd->colors_node_mesh);
pd->node_mesh_colors = NULL;
pd->colors_node_mesh = NULL;
}
pd->node_mesh_colors = eina_hash_stringshared_new(_node_mesh_colors_free_cb);
pd->colors_node_mesh = eina_hash_stringshared_new(_node_mesh_colors_free_cb);
}
scene_data.node_mesh_colors = pd->node_mesh_colors;
scene_data.colors_node_mesh = pd->colors_node_mesh;
evas_canvas3d_node_tree_traverse(pd->root_node,
EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
evas_canvas3d_node_color_node_mesh_collect, &scene_data);
if (e->engine.func->drawable_scene_render_to_texture)
{
if (e->engine.func->drawable_scene_render_to_texture(_evas_engine_context(e),
pd->surface, &scene_data))
{
if (e->engine.func->drawable_texture_color_pick_id_get)
tex = e->engine.func->drawable_texture_color_pick_id_get(pd->surface);
if (e->engine.func->drawable_texture_pixel_color_get)
{
e->engine.func->drawable_texture_pixel_color_get(tex, px, py, &color, pd->surface);
tmp = eina_stringshare_printf("%f %f %f", color.r, color.g, color.b);
arr = (Eina_Array *)eina_hash_find(pd->colors_node_mesh, tmp);
if (arr)
{
picked_node = (Evas_Canvas3D_Node *)eina_array_data_get(arr, 0);
if (mesh) *mesh = (Evas_Canvas3D_Mesh *)eina_array_data_get(arr, 1);
if (node) *node = picked_node;
eina_stringshare_del(tmp);
/*Calling callback clicked*/
eo_desc = efl_object_legacy_only_event_description_get("clicked,private");
efl_event_callback_legacy_call(picked_node, eo_desc, picked_node);
return EINA_TRUE;
}
else
{
eina_stringshare_del(tmp);
if (mesh) *mesh = NULL;
if (node) *node = NULL;
}
}
}
}
return EINA_FALSE;
}
/* Update the scene graph. */
evas_canvas3d_object_update((Eo *) obj);
pd_camera_node = efl_data_scope_get(pd->camera_node, EVAS_CANVAS3D_NODE_CLASS);
pd_camera = efl_data_scope_get(pd_camera_node->data.camera.camera, EVAS_CANVAS3D_CAMERA_CLASS);
eina_matrix4_multiply(&data.matrix_vp,
&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_canvas3d_node_tree_traverse(pd->root_node, EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
_node_pick, &data);
if (!data.picked)
return EINA_FALSE;
if (s) *s = data.s;
if (t) *t = data.t;
if (node) *node = data.node;
if (mesh) *mesh = data.mesh;
/*Calling callback clicked*/
eo_desc = efl_object_legacy_only_event_description_get("clicked,private");
efl_event_callback_legacy_call(data.node, eo_desc, data.node);
return EINA_TRUE;
}
EOLIAN static Evas_Canvas3D_Node *
_evas_canvas3d_scene_exist(const Eo *obj, Evas_Canvas3D_Scene_Data *pd, Evas_Real x, Evas_Real y, Evas_Canvas3D_Node *node)
{
Evas_Canvas3D_Pick_Data data;
Evas_Canvas3D_Node_Data *pd_camera_node;
Evas_Canvas3D_Camera_Data *pd_camera;
Evas_Canvas3D_Object_Data *pd_parent;
Evas_Public_Data *e;
pd_parent = efl_data_scope_get(obj, EVAS_CANVAS3D_OBJECT_CLASS);
e = efl_data_scope_get(pd_parent->evas, EVAS_CANVAS_CLASS);
_pick_data_init(&data, e, x, y);
/* Update the scene graph. */
evas_canvas3d_object_update((Eo *) obj);
pd_camera_node = efl_data_scope_get(pd->camera_node, EVAS_CANVAS3D_NODE_CLASS);
pd_camera = efl_data_scope_get(pd_camera_node->data.camera.camera, EVAS_CANVAS3D_CAMERA_CLASS);
eina_matrix4_multiply(&data.matrix_vp,
&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);
/* Check pick for given node. */
_node_pick(node, &data);
if (!data.picked || data.node != node) node = NULL;
return node;
}
EOLIAN static Eina_List *
_evas_canvas3d_scene_pick_member_list_get(const Eo *obj, Evas_Canvas3D_Scene_Data *pd, Evas_Real x, Evas_Real y)
{
const Eina_List *list = NULL, *l = NULL;
Eina_List *picked_nodes = NULL;
void *node;
Eina_Bool pick = EINA_FALSE;
/* Check pick for given scene. */
pick = evas_canvas3d_scene_pick(obj, x, y, NULL, NULL, NULL, NULL);
if (!pick)
return NULL;
/* Get all members from root node. */
list = evas_canvas3d_node_member_list_get(pd->root_node);
EINA_LIST_FOREACH(list, l, node)
{
if (evas_canvas3d_scene_exist(obj, x, y, node))
picked_nodes = eina_list_append(picked_nodes, l);
}
return picked_nodes;
}
EOLIAN static Eina_Bool
_evas_canvas3d_scene_shadows_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd)
{
return pd->shadows_enabled;
}
EOLIAN static void
_evas_canvas3d_scene_shadows_enable_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd, Eina_Bool _shadows_enabled)
{
pd->shadows_enabled = _shadows_enabled;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_SHADOWS_ENABLED, NULL);
}
EOLIAN static Eina_Bool
_evas_canvas3d_scene_color_pick_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd)
{
return pd->color_pick_enabled;
}
EOLIAN static Eina_Bool
_evas_canvas3d_scene_color_pick_enable_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd, Eina_Bool _enabled)
{
if (pd->color_pick_enabled != _enabled)
pd->color_pick_enabled = _enabled;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_UPDATED, NULL);
return EINA_TRUE;
}
EOLIAN static void
_evas_canvas3d_scene_shadows_depth_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd,
Evas_Real depth_offset, Evas_Real depth_constant)
{
pd->depth_offset = depth_offset;
pd->depth_constant = depth_constant;
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_SCENE_SHADOWS_DEPTH, NULL);
}
EOLIAN static void
_evas_canvas3d_scene_shadows_depth_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Scene_Data *pd,
Evas_Real *depth_offset, Evas_Real *depth_constant)
{
if (depth_offset) *depth_offset = pd->depth_offset;
if (depth_constant) *depth_constant = pd->depth_constant;
}
#include "canvas/evas_canvas3d_scene.eo.c"

View File

@ -1,168 +0,0 @@
import evas_canvas3d_types;
class @beta Evas.Canvas3D.Scene extends Evas.Canvas3D.Object
{
[[Efl 3D canvas scene class]]
data: Evas_Canvas3D_Scene_Data;
methods {
size_set {
[[Set the resolution of a scene.
A scene should be rendered to be displayed through image
objects. The resolution defines the size of the internal surface
holding the rendered result.
]]
params {
@in w: int; [[Width of the resolution.]]
@in h: int; [[Height of the resolution.]]
}
}
size_get @const {
[[Get the internal resolution of a scene.]]
params {
@out w: int; [[Pointer to receive width of the resolution.]]
@out h: int; [[Pointer to receive height of the resolution.]]
}
}
background_color_set {
[[Set the background color of a scene.
Background color defines the initial color of pixels before a scene
is rendered. If you want to display a scene with background evas
objects as if they're part of the background, set
the alpha term to 0.0.
Default background color is (0.0, 0.0, 0.0, 0.0).
]]
params {
@in r: Evas.Real; [[Red component of the background color.]]
@in g: Evas.Real; [[Green component of the background color.]]
@in b: Evas.Real; [[Blue component of the background color.]]
@in a: Evas.Real; [[Alpha component of the background color.]]
}
}
background_color_get @const {
[[Get the background color of a scene.]]
params {
@out r: Evas.Real; [[Pointer to receive red component of the background color.]]
@out g: Evas.Real; [[Pointer to receive green component of the background color.]]
@out b: Evas.Real; [[Pointer to receive blue component of the background color.]]
@out a: Evas.Real; [[Pointer to receive alpha component of the background color.]]
}
}
pick @const {
[[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.
]]
return: bool; [[$true on success, $false otherwise]]
params {
@in x: Evas.Real; [[X coordinate of the picking position.]]
@in y: Evas.Real; [[Y coordinate of the picking position.]]
@out node: Evas.Canvas3D.Node; [[Pointer to receive the node contains the picked mesh.]]
@out mesh: Evas.Canvas3D.Mesh; [[Pointer to receive the picked mesh.]]
@out s: Evas.Real; [[Pointer to receive the texture "s" coordinate.]]
@out t: Evas.Real; [[Pointer to receive the texture "t" coordinate.]]
}
}
exist @const {
[[Search given node in the given position.]]
return: Evas.Canvas3D.Node; [[Node at the given position]]
params {
@in x: Evas.Real; [[X coordinate of the picking position.]]
@in y: Evas.Real; [[Y coordinate of the picking position.]]
@in node: Evas.Canvas3D.Node; [[Node for search.]]
}
}
pick_member_list_get @const {
[[Get list of the all root members from scene in the given position.]]
return: list<Evas.Canvas3D.Node>; [[List of all root members from scene]]
params {
@in x: Evas.Real; [[X coordinate of the picking position.]]
@in y: Evas.Real; [[Y coordinate of the picking position.]]
}
}
shadows_enable_set {
[[Enable or disable shadows on given scene
If shadows_enabled is $true, the objects in the scene can throw
shadow to another objects located behind them. The depth map used
for shading. Directed and projective light sources are supported.
]]
params {
@in shadows_enabled: bool; [[Shadows enabled status.]]
}
}
shadows_enable_get @const {
[[Get shadows enabled status for given scene.]]
return: bool; [[The shadows enabled status.]]
}
color_pick_enable_get @const {
[[Get status of color picking of the scene.]]
return: bool; [[The pick enabled status]]
}
color_pick_enable_set {
[[Set possibility color picking.]]
return: bool; [[$true on success, $false otherwise]]
params {
@in color_pick: bool; [[Possibility flag]]
}
}
@property root_node {
[[The root node of a scene.]]
set {
}
get {
}
values {
node: Evas.Canvas3D.Node; [[A node which will be used as a
root node for the scene.]]
}
}
@property camera_node {
[[The camera node of a scene.]]
set {
}
get {
}
values {
node: Evas.Canvas3D.Node; [[A node which will be used as a
camera node for the scene.]]
}
}
@property shadows_depth {
[[Scale and units used to calculate depth values.]]
set {
}
get {
}
values {
depth_offset: Evas.Real; [[Scale factor that is used to
create a variable depth offset
for each polygon.]]
depth_constant: Evas.Real; [[Value to create a constant
depth offset]]
}
}
}
implements {
Efl.Object.constructor;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

View File

@ -1,606 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define MY_CLASS EVAS_CANVAS3D_TEXTURE_CLASS
static inline void
_texture_proxy_set(Evas_Canvas3D_Texture *texture, Evas_Object *eo_src, Evas_Object_Protected_Data *src)
{
Evas_Canvas3D_Texture_Data *pd = efl_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->redraw = EINA_TRUE;
}
EINA_COW_WRITE_END(evas_object_proxy_cow, src->proxy, proxy_src);
pd->source = eo_src;
}
static inline void
_texture_proxy_unset(Evas_Canvas3D_Texture_Data *texture)
{
Evas_Object_Protected_Data *src = efl_data_scope_get(texture->source, EFL_CANVAS_OBJECT_CLASS);
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, src->proxy, Evas_Object_Proxy_Data, proxy_src);
{
proxy_src->proxy_textures = eina_list_remove(proxy_src->proxy_textures, texture);
if (eina_list_count(proxy_src->proxy_textures) == 0 &&
eina_list_count(proxy_src->proxies) == 0 &&
proxy_src->surface != NULL)
{
Evas_Public_Data *e = src->layer->evas;
e->engine.func->image_free(_evas_engine_context(e), proxy_src->surface);
proxy_src->surface = NULL;
}
if (proxy_src->src_invisible)
{
proxy_src->src_invisible = EINA_FALSE;
src->changed_src_visible = EINA_TRUE;
evas_object_change(texture->source, src);
evas_object_smart_member_cache_invalidate(texture->source,
EINA_FALSE, EINA_FALSE, EINA_TRUE);
}
}
EINA_COW_WRITE_END(evas_object_proxy_cow, src->proxy, proxy_src);
texture->source = NULL;
}
static inline void
_texture_proxy_subrender(Evas_Canvas3D_Texture *obj, void *engine)
{
/* Code taken from _proxy_subrender() in file evas_object_image.c */
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
Evas_Canvas3D_Texture_Data *pd = efl_data_scope_get(obj, MY_CLASS);
Evas_Object_Protected_Data *source;
void *ctx;
int w, h;
Eina_Bool is_image;
if (!pd->source)
return;
// TODO: replace this function by evas_render_proxy_subrender (as appropriate)
source = efl_data_scope_get(pd->source, EFL_CANVAS_OBJECT_CLASS);
is_image = efl_isa(pd->source, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, source->proxy, Evas_Object_Proxy_Data, proxy_write)
{
proxy_write->redraw = EINA_FALSE;
if (is_image)
{
void *image = source->func->engine_data_get(pd->source);
e->engine.func->image_size_get(engine, image, &w, &h);
}
else
{
w = source->cur->geometry.w;
h = source->cur->geometry.h;
}
/* We need to redraw surface then */
if ((proxy_write->surface) &&
((proxy_write->w != w) || (proxy_write->h != h)))
{
e->engine.func->image_free(engine, proxy_write->surface);
proxy_write->surface = NULL;
}
/* FIXME: Hardcoded alpha 'on' */
/* FIXME (cont): Should see if the object has alpha */
if (!proxy_write->surface)
{
proxy_write->surface = e->engine.func->image_map_surface_new
(engine, w, h, 1);
if (!proxy_write->surface) goto end;
proxy_write->w = w;
proxy_write->h = h;
}
ctx = e->engine.func->context_new(engine);
e->engine.func->context_color_set(engine, ctx, 0, 0,
0, 0);
e->engine.func->context_render_op_set(engine, ctx,
EVAS_RENDER_COPY);
e->engine.func->rectangle_draw(engine, _evas_default_output_get(e), ctx,
proxy_write->surface, 0, 0, w, h,
EINA_FALSE);
e->engine.func->context_free(engine, ctx);
ctx = e->engine.func->context_new(engine);
if (is_image)
{
void *image = source->func->engine_data_get(pd->source);
if (image)
{
int imagew, imageh;
e->engine.func->image_size_get(engine, image,
&imagew, &imageh);
e->engine.func->image_draw(engine, _evas_default_output_get(e), ctx,
proxy_write->surface, image,
0, 0, imagew, imageh, 0, 0, w, h, 0, EINA_FALSE);
}
}
else
{
Evas_Proxy_Render_Data proxy_render_data = {
.eo_proxy = NULL,
.proxy_obj = NULL,
.eo_src = pd->source,
.src_obj = source,
.source_clip = EINA_FALSE
};
evas_render_mapped(e, pd->source, source, ctx,
_evas_default_output_get(e),
proxy_write->surface,
-source->cur->geometry.x,
-source->cur->geometry.y,
2, 0, 0, e->output.w, e->output.h,
&proxy_render_data, 1, EINA_FALSE);
}
e->engine.func->context_free(engine, ctx);
proxy_write->surface = e->engine.func->image_dirty_region
(engine, proxy_write->surface, 0, 0, w, h);
}
end:
EINA_COW_WRITE_END(evas_object_proxy_cow, source->proxy, proxy_write);
}
static void
_texture_fini(Evas_Canvas3D_Texture *obj)
{
Eo *evas = NULL;
int i = 0;
Eina_Iterator *it = NULL;
void *data = NULL;
Evas_Canvas3D_Material_Data *material = NULL;
evas = evas_object_evas_get(obj);
Evas_Canvas3D_Texture_Data *pd = efl_data_scope_get(obj, MY_CLASS);
if (pd->engine_data)
{
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->texture_free)
e->engine.func->texture_free(_evas_engine_context(e), pd->engine_data);
pd->engine_data = NULL;
}
if (pd->materials)
{
it = eina_hash_iterator_key_new(pd->materials);
EINA_ITERATOR_FOREACH(it, data)
{
material = efl_data_scope_get(data, EVAS_CANVAS3D_MATERIAL_CLASS);
if (!material) continue;
for (i = 0; i < EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (material->attribs[i].texture)
evas_canvas3d_texture_material_del(material->attribs[i].texture, data);
}
}
eina_iterator_free(it);
eina_hash_free(pd->materials);
pd->materials = NULL;
}
if (pd->source)
{
_texture_proxy_unset(pd);
}
}
static Eina_Bool
_texture_material_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
void *data EINA_UNUSED, void *fdata)
{
Evas_Canvas3D_Material *m = *(Evas_Canvas3D_Material **)key;
evas_canvas3d_object_change(m, EVAS_CANVAS3D_STATE_MATERIAL_TEXTURE, (Evas_Canvas3D_Object *)fdata);
return EINA_TRUE;
}
EOLIAN static void
_evas_canvas3d_texture_evas_canvas3d_object_change_notify(Eo *obj, Evas_Canvas3D_Texture_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
{
if (pd->materials)
eina_hash_foreach(pd->materials, _texture_material_change_notify, obj);
}
/* FIXME: This code is problematic as it actually does rendering and rely on the output before we start rendering. */
EOLIAN static void
_evas_canvas3d_texture_evas_canvas3d_object_update_notify(Eo *obj, Evas_Canvas3D_Texture_Data *pd)
{
if (pd->source)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
Evas_Object_Protected_Data *src = efl_data_scope_get(pd->source, EFL_CANVAS_OBJECT_CLASS);
if (pd->engine_data == NULL)
{
if (e->engine.func->texture_new)
{
pd->engine_data =
e->engine.func->texture_new(_evas_engine_context(e), pd->atlas_enable);
}
if (pd->engine_data == NULL)
{
ERR("Failed to create engine-side texture object.");
return;
}
}
if (src->proxy->surface && !src->proxy->redraw)
{
if (e->engine.func->texture_image_set)
{
e->engine.func->texture_image_set(_evas_engine_context(e),
pd->engine_data,
src->proxy->surface);
}
return;
}
pd->proxy_rendering = EINA_TRUE;
_texture_proxy_subrender(obj, _evas_engine_context(e));
if (e->engine.func->texture_image_set)
e->engine.func->texture_image_set(_evas_engine_context(e),
pd->engine_data,
src->proxy->surface);
pd->proxy_rendering = EINA_FALSE;
}
}
void
evas_canvas3d_texture_material_add(Evas_Canvas3D_Texture *texture, Evas_Canvas3D_Material *material)
{
int count = 0;
Evas_Canvas3D_Texture_Data *pd = efl_data_scope_get(texture, MY_CLASS);
if (pd->materials == NULL)
{
pd->materials = eina_hash_pointer_new(NULL);
if (pd->materials == NULL)
{
ERR("Failed to create hash table.");
return;
}
}
else
count = (int)(uintptr_t)eina_hash_find(pd->materials, &material);
/* Increase reference count or add new one if not exist. */
eina_hash_set(pd->materials, &material, (const void *)(uintptr_t)(count + 1));
}
void
evas_canvas3d_texture_material_del(Evas_Canvas3D_Texture *texture, Evas_Canvas3D_Material *material)
{
int count = 0;
Evas_Canvas3D_Texture_Data *pd = efl_data_scope_get(texture, MY_CLASS);
if (pd->materials == NULL)
{
ERR("No material to delete.");
return;
}
count = (int)(uintptr_t)eina_hash_find(pd->materials, &material);
if (count == 1)
eina_hash_del(pd->materials, &material, NULL);
else
eina_hash_set(pd->materials, &material, (const void *)(uintptr_t)(count - 1));
}
EAPI Evas_Canvas3D_Texture *
evas_canvas3d_texture_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
return efl_add(MY_CLASS, e);
}
EOLIAN static Eo *
_evas_canvas3d_texture_efl_object_constructor(Eo *obj, Evas_Canvas3D_Texture_Data *pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
pd->atlas_enable = EINA_TRUE;
evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_TEXTURE);
return obj;
}
EOLIAN static void
_evas_canvas3d_texture_efl_object_destructor(Eo *obj, Evas_Canvas3D_Texture_Data *pd)
{
eina_file_close(pd->f); // close matching open (matches open in _evas_canvas3d_texture_efl_file_load) OK
pd->f = NULL;
_texture_fini(obj);
efl_destructor(efl_super(obj, MY_CLASS));
}
EOLIAN static void
_evas_canvas3d_texture_data_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd,
Evas_Colorspace color_format,
int w, int h, const void *data)
{
Eo *evas = NULL;
void *image = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (!pd->engine_data && e->engine.func->texture_new)
pd->engine_data = e->engine.func->texture_new(_evas_engine_context(e), pd->atlas_enable);
if (!data)
{
ERR("Failure, image data is empty");
return;
}
image = e->engine.func->image_new_from_data(_evas_engine_context(e), w, h, (DATA32 *)data, EINA_TRUE, color_format);
if (!image)
{
ERR("Can't load image from data");
return;
}
if (e->engine.func->texture_image_set)
e->engine.func->texture_image_set(_evas_engine_context(e),
pd->engine_data,
image);
e->engine.func->image_free(_evas_engine_context(e), image);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_TEXTURE_DATA, NULL);
}
EOLIAN static void
_evas_canvas3d_texture_efl_file_unload(Eo *obj, Evas_Canvas3D_Texture_Data *pd)
{
efl_file_unload(efl_super(obj, MY_CLASS));
eina_file_close(pd->f); // close matching open (matches open in _evas_canvas3d_texture_efl_file_load) OK
pd->f = NULL;
_texture_fini(obj);
}
EOLIAN static Eina_Error
_evas_canvas3d_texture_efl_file_load(Eo *obj, Evas_Canvas3D_Texture_Data *pd)
{
Evas_Image_Load_Opts lo;
int load_error;
Eo *evas = NULL;
void *image;
const Eina_File *f;
const char *key;
if (efl_file_loaded_get(obj)) return 0;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
Eina_Error err = efl_file_load(efl_super(obj, MY_CLASS));
if (err) return err;
f = efl_file_mmap_get(obj);
key = efl_file_key_get(obj);
if (!pd->engine_data && e->engine.func->texture_new)
pd->engine_data = e->engine.func->texture_new(_evas_engine_context(e), pd->atlas_enable);
memset(&lo, 0x0, sizeof(Evas_Image_Load_Opts));
image = e->engine.func->image_mmap(_evas_engine_context(e),
(Eina_File *) f, key, &load_error, &lo);
if (!image)
{
ERR("Can't load image from file");
return EINA_FALSE;
}
if (e->engine.func->texture_image_set)
e->engine.func->texture_image_set(_evas_engine_context(e),
pd->engine_data,
image);
e->engine.func->image_free(_evas_engine_context(e), image);
pd->f = eina_file_dup(f);
pd->key = eina_stringshare_add(key);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_TEXTURE_DATA, NULL);
return EINA_TRUE;
}
EAPI void
_evas_canvas3d_texture_source_set(Eo *obj , Evas_Canvas3D_Texture_Data *pd, Evas_Object *source)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
Evas_Object_Protected_Data *src;
if (source == pd->source)
return;
_texture_fini(obj);
if (source == NULL)
return;
if (evas_object_evas_get(source) != evas)
{
ERR("Not matching canvas.");
return;
}
src = efl_data_scope_get(source, EFL_CANVAS_OBJECT_CLASS);
if (src->delete_me)
{
ERR("Source object is deleted.");
return;
}
if (src->layer == NULL)
{
ERR("No evas surface associated with the source object.");
return;
}
if (!pd->engine_data && e->engine.func->texture_new)
pd->engine_data = e->engine.func->texture_new(_evas_engine_context(e), pd->atlas_enable);
_texture_proxy_set(obj, source, src);
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_TEXTURE_DATA, NULL);
}
EOLIAN static void
_evas_canvas3d_texture_source_visible_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd, Eina_Bool visible)
{
Evas_Object_Protected_Data *src_obj;
if (pd->source == NULL)
return;
src_obj = efl_data_scope_get(pd->source, EFL_CANVAS_OBJECT_CLASS);
if (src_obj->proxy->src_invisible == !visible)
return;
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, src_obj->proxy, Evas_Object_Proxy_Data, proxy_write)
proxy_write->src_invisible = !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(pd->source, EINA_FALSE, EINA_FALSE, EINA_TRUE);
evas_object_change(pd->source, src_obj);
}
EOLIAN static Eina_Bool
_evas_canvas3d_texture_source_visible_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd)
{
Evas_Object_Protected_Data *src_obj;
if (pd->source == NULL)
return EINA_FALSE;
src_obj = efl_data_scope_get(pd->source, EFL_CANVAS_OBJECT_CLASS);
return !src_obj->proxy->src_invisible;
}
EOLIAN static Evas_Colorspace
_evas_canvas3d_texture_color_format_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd)
{
Evas_Colorspace format = -1;
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->image_colorspace_get &&
e->engine.func->texture_image_get)
{
void *image;
image = e->engine.func->texture_image_get(_evas_engine_context(e), pd->engine_data);
format = e->engine.func->image_colorspace_get(_evas_engine_context(e), image);
}
return format;
}
EOLIAN static void
_evas_canvas3d_texture_size_get(const Eo *obj, Evas_Canvas3D_Texture_Data *pd, int *w, int *h)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->texture_size_get)
{
e->engine.func->texture_size_get(_evas_engine_context(e),
pd->engine_data, w, h);
}
}
EOLIAN static void
_evas_canvas3d_texture_wrap_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, Evas_Canvas3D_Wrap_Mode s, Evas_Canvas3D_Wrap_Mode t)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->texture_wrap_set)
{
e->engine.func->texture_wrap_set(_evas_engine_context(e),
pd->engine_data, s, t);
}
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_TEXTURE_WRAP, NULL);
}
EOLIAN static void
_evas_canvas3d_texture_wrap_get(Eo *obj, Evas_Canvas3D_Texture_Data *pd, Evas_Canvas3D_Wrap_Mode *s, Evas_Canvas3D_Wrap_Mode *t)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->texture_wrap_set)
{
e->engine.func->texture_wrap_get(_evas_engine_context(e),
pd->engine_data, s, t);
}
}
EOLIAN static void
_evas_canvas3d_texture_filter_set(Eo *obj, Evas_Canvas3D_Texture_Data *pd, Evas_Canvas3D_Texture_Filter min, Evas_Canvas3D_Texture_Filter mag)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->texture_filter_set)
{
e->engine.func->texture_filter_set(_evas_engine_context(e),
pd->engine_data, min, mag);
}
evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_TEXTURE_FILTER, NULL);
}
EOLIAN static void
_evas_canvas3d_texture_filter_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd, Evas_Canvas3D_Texture_Filter *min, Evas_Canvas3D_Texture_Filter *mag)
{
Eo *evas = NULL;
evas = evas_object_evas_get(obj);
Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
if (e->engine.func->texture_filter_get)
{
e->engine.func->texture_filter_get(_evas_engine_context(e),
pd->engine_data, min, mag);
}
}
EOLIAN static void
_evas_canvas3d_texture_atlas_enable_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd, Eina_Bool use_atlas)
{
if (pd->atlas_enable != use_atlas) pd->atlas_enable = use_atlas;
}
EOLIAN static Eina_Bool
_evas_canvas3d_texture_atlas_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Texture_Data *pd)
{
return pd->atlas_enable;
}
#include "canvas/evas_canvas3d_texture.eo.c"

View File

@ -1,159 +0,0 @@
type @beta @extern Evas_Colorspace: int; [[Evas colorspace type]] /* FIXME: Need to get emile migrated. */
class @beta Evas.Canvas3D.Texture extends Evas.Canvas3D.Object implements Efl.File
{
[[Evas 3d canvas texture class]]
data : Evas_Canvas3D_Texture_Data;
methods {
@property source_visible {
[[The visibility flag of the source evas object of the given
texture.
Call \@ref evas_object_show on the source object
and control the visibility using this function.
By default the source object is visible.
See also @.source_set.
]]
set {
}
get {
}
values {
visible: bool; [[$true for visible, $false for invisible.]]
}
}
@property atlas_enable {
[[Enable flag to generation texture unit with support atlas.
Use this flag only when you cannot normalize texture coordinates.
By default it is enabled.
]]
set {
}
get {
}
values {
use_atlas: bool; [[$true for enable, $false for disable.]]
}
}
data_set {
[[Set the data of the given texture.
See also @Efl.File.file.set.
]]
params {
@in color_format: Evas_Colorspace; [[Color format of the texture.]]
@in w: int; [[Width of the data.]]
@in h: int; [[Height of the data.]]
@in data: const(void_ptr); [[Pointer to the data.]]
}
}
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 existing evas object
inside 3D scene.
See also @.source_visible.set.
]]
params {
@in source: Efl.Canvas.Object; [[Source evas object to be used as
the texture data.]]
}
}
color_format_get @const {
[[Get the color format of the given texture.
EVAS_CANVAS3D_COLOR_FORMAT_RGBA will be returned if the texture
has source object. Otherwise, the color format of the data will
be returned.
See also @.data_set, @Efl.File.file.set, @.source_set.
]]
return: Evas_Colorspace; [[Color format of the given texture]]
}
size_get @const {
[[Get the size of the given texture.
If the texture has a source object, the size of the source object
will be returned. Otherwise the size of the data (or image file)
will be returned.
See also @.data_set, @Efl.File.file.set, @.source_set.
]]
params {
@out w: int; [[Pointer to receive the width of the texture size.]]
@out h: int; [[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_CANVAS3D_WRAP_MODE_CLAMP for s and t.
]]
params {
@in s: Evas.Canvas3D.Wrap_Mode; [[Wrap mode for S-axis.]]
@in t: Evas.Canvas3D.Wrap_Mode; [[Wrap mode for T-axis.]]
}
}
wrap_get {
[[Get the wrap mode of the given texture.
See also @.wrap_set.
]]
params {
@out s: Evas.Canvas3D.Wrap_Mode; [[Pointer to receive S-axis wrap mode.]]
@out t: Evas.Canvas3D.Wrap_Mode; [[Pointer to receive T-axis wrap mode.]]
}
}
filter_set {
[[Set the filter of the given texture.
Default filters are both EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST for
s and t.
]]
params {
@in min: Evas.Canvas3D.Texture_Filter; [[Minification filter used when down-scaling.]]
@in mag: Evas.Canvas3D.Texture_Filter; [[Magnification filter used when up-scaling.]]
}
}
filter_get @const {
[[Get the filter of the given texture.
See also @.filter_set.
]]
params {
@out min: Evas.Canvas3D.Texture_Filter; [[Pointer to receive the minification filter.]]
@out mag: Evas.Canvas3D.Texture_Filter; [[Pointer to receive the magnification filter.]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Evas.Canvas3D.Object.update_notify;
Evas.Canvas3D.Object.change_notify;
Efl.File.load;
Efl.File.unload;
@empty Evas.Canvas3D.Object.callback_register;
@empty Evas.Canvas3D.Object.callback_unregister;
}
}

View File

@ -1,293 +0,0 @@
// ----------------------------------------------------------------------------
// All the below types are for Evas 3D
type @beta Evas.Real: double; [[A type for floating value]]
enum @beta Evas.Canvas3D.Object_Type
{
[[Type of 3D Object
@since 1.10]]
invalid = 0, [[Evas 3D type: invalid]]
scene, [[Evas 3D type: scene]]
node, [[Evas 3D type: node]]
camera, [[Evas 3D type: camera]]
light, [[Evas 3D type: light]]
model, [[Evas 3D type: model]]
mesh, [[Evas 3D type: mesh]]
texture, [[Evas 3D type: texture]]
material, [[Evas 3D type: material]]
primitive [[Evas 3D type: primitive
@since 1.15]]
}
enum @beta Evas.Canvas3D.State
{
[[State of the Evas 3D
@since 1.10]]
max = 16, [[Evas 3D state: max]]
any = 0, [[Evas 3D state: any]]
scene_root_node = 1, [[Evas 3D state: scene root node]]
scene_camera_node, [[Evas 3D state: scene camera node]]
scene_background_color, [[Evas 3D state: scene background color]]
scene_size, [[Evas 3D state: scene size]]
scene_shadows_enabled, [[Evas 3D state: scene shadows enabled]]
scene_updated, [[Evas 3D state: scene updated
@since 1.14]]
scene_shadows_depth, [[Evas 3D state: scene shadows depth]]
scene_render_to_texture, [[Evas 3D state: scene render to texture]]
texture_data = 1, [[Evas 3D state: texture data]]
texture_wrap, [[Evas 3D state: texture wrap]]
texture_filter, [[Evas 3D state: texture filter]]
material_id = 1, [[Evas 3D state: material ID]]
material_color, [[Evas 3D state: material color]]
material_texture, [[Evas 3D state: material texture]]
mesh_vertex_count = 1, [[Evas 3D state: mesh vertex count]]
mesh_frame, [[Evas 3D state: mesh frame]]
mesh_material, [[Evas 3D state: mesh material]]
mesh_transform, [[Evas 3D state: mesh transform]]
mesh_vertex_data, [[Evas 3D state: mesh vertex data]]
mesh_index_data, [[Evas 3D state: mesh index data]]
mesh_vertex_assembly, [[Evas 3D state: mesh vertex assembly]]
mesh_shader_mode, [[Evas 3D state: mesh shader mode]]
mesh_fog, [[Evas 3D state: mesh fog]]
mesh_blending, [[Evas 3D state: mesh blending]]
mesh_alpha_test, [[Evas 3D state: mesh alpha test]]
mesh_color_pick, [[Evas 3D state: mesh color pick]]
mesh_shadows_edges_filtering, [[Evas 3D state: mesh shadows edges filtering]]
mesh_shadows_constant_bias, [[Evas 3D state: mesh shadows constant bias]]
camera_projection = 1, [[Evas 3D state: camera projection]]
light_ambient = 1, [[Evas 3D state: light ambient]]
light_diffuse, [[Evas 3D state: light diffuse]]
light_specular, [[Evas 3D state: light specular]]
light_spot_dir, [[Evas 3D state: light spot dir]]
light_spot_exp, [[Evas 3D state: light spot exp]]
light_spot_cutoff, [[Evas 3D state: light spot cutoff]]
light_attenuation, [[Evas 3D state: light attenuation]]
light_projection, [[Evas 3D state: light projection]]
node_transform_position = 1, [[Evas 3D state: node transform position]]
node_transform_orientation, [[Evas 3D state: node transform orientation]]
node_transform_scale, [[Evas 3D state: node transform scale]]
node_mesh_geometry, [[Evas 3D state: node mesh geometry]]
node_mesh_material, [[Evas 3D state: node mesh material]]
node_mesh_frame, [[Evas 3D state: node mesh frame]]
node_mesh_shader_mode, [[Evas 3D state: node mesh shader mode]]
node_mesh_material_id, [[Evas 3D state: node mesh material ID]]
node_light, [[Evas 3D state: node light]]
node_camera, [[Evas 3D state: node camera]]
node_parent_position, [[Evas 3D state: node parent position]]
node_parent_orientation, [[Evas 3D state: node parent orientation]]
node_parent_scale, [[Evas 3D state: node parent scale]]
node_member, [[Evas 3D state: node member]]
node_parent_billboard, [[Evas 3D state: node parent billboard
@since 1.14]]
node_lod [[Evas 3D state: node lod
@since 1.18]]
}
enum @beta Evas.Canvas3D.Space
{
[[Transform space
@since 1.10]]
local = 0, [[Local coordinate space]]
parent, [[Parent coordinate space]]
world [[World coordinate space]]
}
enum @beta Evas.Canvas3D.Node_Type
{
[[Types of a node
@since 1.10]]
unknown = -1, [[Unknown node type @since 1.21]]
node = 0, [[Node with no items]]
camera, [[Node which can contain camera object]]
light, [[Node which can contain light object]]
mesh [[Node which can contain mesh objects]]
}
enum @beta Evas.Canvas3D.Node_Orientation_Type
{
[[Types of node orientation
@since 1.13]]
none = 0, [[Node with no orientation properties]]
look_at, [[Node orientation is given as a point to look at and a vector that indicates the angle at which the subject is looking at the point]]
look_to, [[Node orientation is given as id of another part to look at and a vector that indicates the angle at which the subject is looking at the part]]
angle_axis, [[Node orientation is given as an angle and an axis to rotate around]]
quaternion [[Node orientation is given as a quaternion]]
}
enum @beta Evas.Canvas3D.Index_Format
{
[[Index formats
@since 1.10]]
none = 0, [[Indexing is not used]]
unsigned_byte, [[Index is of type unsigned byte]]
unsigned_short [[Index is of type unsigned short]]
}
enum @beta Evas.Canvas3D.Frustum_Mode
{
[[Frustum modes
@since 1.12]]
bsphere, [[Bounding sphere]]
aabb, [[Axis-aligned bounding box]]
central_point [[Central point]]
}
enum @beta Evas.Canvas3D.Vertex_Assembly
{
[[Vertex assembly modes. Vertex assembly represents how the vertices are organized into geometric primitives.
@since 1.10]]
points = 0, [[A vertex is rendered as a point]]
lines, [[Two vertices are organized as a line]]
line_strip, [[Vertices are organized as a connected line path]]
line_loop, [[Vertices are organized as a closed line path]]
triangles, [[Three vertices are organized as a triangle]]
triangle_strip, [[Vertices are organized as connected triangles]]
triangle_fan [[Vertices are organized as a triangle fan]]
}
enum @beta Evas.Canvas3D.Comparison
{
[[Comparsion functions for testing(alpha, depth, stencil) in fragment shader
@since 1.14]]
never, [[Never passes]]
less, [[Passes if the incoming value is less than the reference value]]
equal, [[Passes if the incoming value is equal to the reference value]]
lequal, [[Passes if the incoming value is less than or equal to the reference value]]
greater, [[Passes if the incoming value is greater than the reference value]]
notequal, [[Passes if the incoming value is not equal to the reference value]]
gequal, [[Passes if the incoming value is greater than or equal to the reference value]]
always [[Always passes (initial value)]]
}
enum @beta Evas.Canvas3D.Wrap_Mode
{
[[Wrap modes for texture units
@since 1.14]]
clamp = 0, [[Values will be clamped to be in range (min, max)]]
repeat, [[Values will be repeated]]
reflect [[Values will be repeated in a reflected manner]]
}
enum @beta Evas.Canvas3D.Texture_Filter
{
[[Filters for texture units
@since 1.14]]
nearest = 0, [[Samples nearest texel]]
linear, [[Lineary interpolate nearby texels]]
nearest_mipmap_nearest, [[Nearest sampling mipmap]]
linear_mipmap_nearest, [[Nearest sampling mipmap and interpolate]]
nearest_mipmap_linear, [[Linear sampling in nearest mipmap]]
linear_mipmap_linear [[Linear sampling in mipmap and interpolate]]
}
enum @beta Evas.Canvas3D.Mesh_Primitive
{
[[Mesh primitive
@since 1.12]]
none = 0, [[An empty space]]
square, [[One sided square]]
cube, [[Cube primitive]]
cylinder, [[Cylinder (can use precision and texture scale)]]
cone, [[Cone (can use precision and texture scale)]]
sphere, [[Sphere (can use precision and texture scale)]]
torus, [[Torus (can use ratio, precision and texture scale)]]
surface, [[Custom surface (can use pointer to users function, precision and texture scale)]]
terrain, [[Terrain as surface with pointer to perlin's noise function]]
count [[Sentinel value to indicate last enum field during iteration]]
}
enum @beta Evas.Canvas3D.Primitive_Mode
{
[[Mode of mesh primitive
@since 1.15]]
default = 0, [[Default mode of primitive]]
without_base, [[Primitive without base (supported for cylinder and cone)]]
alternative_uv [[Ptimitive with alternative uv (supported for sphere)]]
}
enum @beta Evas.Canvas3D.Shader_Mode
{
[[Shader shade modes
@since 1.10]]
vertex_color = 0, [[Shaded using vertex color attribute]]
diffuse, [[Shaded using material diffuse term]]
flat, [[Per-vertex flat lighting]]
phong, [[Per-pixel phong shading]]
normal_map, [[Per-pixel normal map shading]]
shadow_map_render, [[Fragment color is defined by its z-coord]]
color_pick, [[Rendering to additional frame bufer]]
parallax_occlusion, [[Per-pixel parallax occlusion map shading]]
post_processing_FXAA [[Render full screen quard]]
}
enum @beta Evas.Canvas3D.Vertex_Attrib
{
[[Vertex attribute IDs
@since 1.10]]
position = 0, [[vertex position]]
normal, [[vertex normal]]
tangent, [[vertex tangent (for normal mapping)]]
color, [[vertex color]]
texcoord [[vertex texture coordinate]]
}
enum @beta Evas.Canvas3D.Blend_Func
{
[[Blending function
@since 1.14]]
zero = 0, [[The scale factors for color components is (0, 0, 0, 0)]]
one, [[The scale factors for color components is (1, 1, 1, 1)]]
src_color, [[The scale factors for color components is (rs/kr, gs/kg, bs/kb, as/ka)]]
one_minus_src_color, [[The scale factors for color components is (1, 1, 1, 1) - (rs/kr, gs/kg, bs/kb, as/ka)]]
dst_color, [[The scale factors for color components is (rd/kr, gd/kg, bd/kb, ad/ka)]]
one_minus_dst_color, [[The scale factors for color components is (1, 1, 1, 1) - (rd/kr, gd/kg, bd/kb, ad/ka)]]
src_alpha, [[The scale factors for color components is (as/ka, as/ka, as/ka, as/ka)]]
one_minus_src_alpha, [[The scale factors for color components is (1, 1, 1, 1) - (as/ka, as/ka, as/ka, as/ka)]]
dst_alpha, [[The scale factors for color components is (ad/ka, ad/ka, ad/ka, ad/ka)]]
one_minus_dst_alpha, [[The scale factors for color components is (1, 1, 1, 1) - (ad/ka, ad/ka, ad/ka, ad/ka)]]
constant_color, [[The scale factors for color components is (rc, gc, bc, ac)]]
one_minus_constant_color, [[The scale factors for color components is (1, 1, 1, 1) - (rc, gc, bc, ac)]]
constant_alpha, [[The scale factors for color components is (ac, ac, ac, ac)]]
one_minus_constant_alpha, [[The scale factors for color components is (1, 1, 1, 1) - (ac, ac, ac, ac)]]
src_alpha_saturate [[The scale factors for color components is (i, i, i, 1) where i = min(as, ka, ad)/ka]]
}
enum @beta Evas.Canvas3D.Material_Attrib
{
[[Material attributes
@since 1.10]]
ambient = 0, [[ambient term]]
diffuse, [[diffuse term]]
specular, [[specular term]]
emission, [[emission term]]
normal [[Normal map term]]
}
type @beta Evas.Canvas3D.Surface_Func: __undefined_type; [[Evas 3D canvas surface function type]]

View File

@ -853,8 +853,6 @@ evas_object_image_size_set(Evas_Object *eo_obj, int w, int h)
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
int stride = 0;
if (o->cur->scene) return;
evas_object_async_block(obj);
_evas_image_cleanup(eo_obj, obj, o);
if (w < 1) w = 1;

View File

@ -82,7 +82,6 @@ struct _Evas_Object_Image_State
Evas_Object *source;
Evas_Map *defmap;
Evas_Canvas3D_Scene *scene;
Eina_File *f;
const char *key;
@ -213,11 +212,6 @@ Eina_Bool _evas_image_proxy_source_clip_get(const Eo *eo_obj);
void _evas_image_proxy_source_events_set(Eo *eo_obj, Eina_Bool source_events);
Eina_Bool _evas_image_proxy_source_events_get(const Eo *eo_obj);
/* Efl.Canvas.Scene3d */
void _evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Canvas3D_Scene *scene, void *engine, void *output);
void _evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene);
void _evas_image_3d_unset(Evas_Object *eo_obj, Evas_Object_Protected_Data *image, Evas_Image_Data *o);
/* Efl.Canvas.Surface */
Eina_Bool _evas_image_native_surface_set(Eo *eo_obj, Evas_Native_Surface *surf);
Evas_Native_Surface *_evas_image_native_surface_get(const Evas_Object *eo_obj);

View File

@ -1077,9 +1077,6 @@ _image_data_unset(Evas_Object_Protected_Data *obj, Eina_List **list)
data->engine_data =
obj->layer->evas->engine.func->polygon_points_clear(ENC,
data->engine_data))
else CHECK(EVAS_CANVAS3D_TEXTURE_CLASS, Evas_Canvas3D_Texture_Data,
if (obj->layer->evas->engine.func->texture_free)
obj->layer->evas->engine.func->texture_free(ENC, data->engine_data))
else return;
#undef CHECK
evas_object_ref(obj->object);
@ -1136,10 +1133,8 @@ _image_data_regenerate(Evas_Object *eo_obj)
}
CHECK(EFL_CANVAS_IMAGE_INTERNAL_CLASS, Evas_Image_Data, _image_image_data_regenerate(eo_obj, obj, data))
else CHECK(EFL_CANVAS_IMAGE_CLASS, Evas_Image_Data, _image_image_data_regenerate(eo_obj, obj, data))
else CHECK(EFL_CANVAS_SCENE3D_CLASS, Evas_Image_Data, _image_image_data_regenerate(eo_obj, obj, data))
//else CHECK(EFL_CANVAS_VG_OBJECT_CLASS, Efl_Canvas_Vg_Object_Data,)
//else CHECK(EFL_CANVAS_POLYGON_CLASS, Efl_Canvas_Polygon_Data,)
//else CHECK(EVAS_CANVAS3D_TEXTURE_CLASS, Evas_Canvas3D_Texture_Data,
}
EAPI void

View File

@ -96,7 +96,7 @@ static const Evas_Object_Image_State default_state = {
{ 0, 0, 0 }, // image
{ 1.0, 0, 0, 0, 0, 1 }, // border
{ { NULL, 0, 0 }, { NULL, 0, 0 } },
NULL, NULL, NULL, //source, defmap, scene
NULL, NULL, //source, defmap
NULL, //f
NULL, //key
0, //frame
@ -171,7 +171,6 @@ _evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_I
ENFN->image_data_preload_cancel(ENC, o->engine_data, eo_obj, EINA_FALSE);
}
if (o->cur->source) _evas_image_proxy_unset(eo_obj, obj, o);
if (o->cur->scene) _evas_image_3d_unset(eo_obj, obj, o);
}
static Eina_Bool
@ -252,7 +251,6 @@ _evas_image_init_set(const Eina_File *f, const char *key,
Evas_Image_Load_Opts *lo)
{
if (o->cur->source) _evas_image_proxy_unset(eo_obj, obj, o);
if (o->cur->scene) _evas_image_3d_unset(eo_obj, obj, o);
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
{
@ -1033,22 +1031,15 @@ _efl_canvas_image_internal_efl_gfx_image_image_size_get(const Eo *eo_obj EINA_UN
}
EOLIAN static Eina_Size2D
_efl_canvas_image_internal_efl_gfx_view_view_size_get(const Eo *eo_obj, Evas_Image_Data *o)
_efl_canvas_image_internal_efl_gfx_view_view_size_get(const Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
{
int uvw, uvh;
Evas_Object_Protected_Data *source = NULL;
Evas_Object_Protected_Data *obj;
obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
if (o->cur->source)
source = efl_data_scope_get(o->cur->source, EFL_CANVAS_OBJECT_CLASS);
if (o->cur->scene)
{
uvw = obj->data_3d->w;
uvh = obj->data_3d->h;
}
else if (!o->cur->source)
if (!o->cur->source)
{
uvw = o->cur->image.w;
uvh = o->cur->image.h;
@ -1732,13 +1723,6 @@ evas_object_image_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
state_write->source = NULL;
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
}
if (o->cur->scene)
{
_evas_image_3d_unset(eo_obj, obj, o);
EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
state_write->scene = NULL;
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
}
if (o->cur->f)
{
eina_file_close(o->cur->f); // close matching open (dup in _evas_image_init_set) OK
@ -2318,15 +2302,6 @@ _evas_image_pixels_get(Eo *eo_obj, Evas_Object_Protected_Data *obj,
*uvw = *imagew;
*uvh = *imageh;
}
else if (o->cur->scene)
{
_evas_image_3d_render(obj->layer->evas->evas, eo_obj, obj, o, o->cur->scene, engine, output);
pixels = obj->data_3d->surface;
*imagew = obj->data_3d->w;
*imageh = obj->data_3d->h;
*uvw = *imagew;
*uvh = *imageh;
}
else if (obj->cur->snapshot)
{
pixels = o->engine_data;
@ -2868,18 +2843,6 @@ evas_object_image_render_pre(Evas_Object *eo_obj,
goto done;
}
}
else if (o->cur->scene)
{
Evas_Canvas3D_Scene *scene = o->cur->scene;
Eina_Bool dirty;
dirty = evas_canvas3d_object_dirty_get(scene, EVAS_CANVAS3D_STATE_ANY);
if (dirty)
{
evas_object_render_pre_prev_cur_add(&e->clip_changes, eo_obj, obj);
goto done;
}
}
/* now figure what changed and add draw rects */
/* if it just became visible or invisible */

View File

@ -13,7 +13,7 @@ EVAS_MEMPOOL(_mp_sh);
/* evas internal stuff */
static const Evas_Object_Proxy_Data default_proxy = {
NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0
NULL, NULL, 0, 0, NULL, 0, 0, 0, 0
};
static const Evas_Object_Map_Data default_map = {
{ NULL, NULL, 0, 0 }, { NULL, NULL, 0, 0 }, NULL, 0, 0, NULL, NULL
@ -34,7 +34,6 @@ static const Evas_Object_Events_Data default_events = {
Eina_Cow *evas_object_proxy_cow = NULL;
Eina_Cow *evas_object_map_cow = NULL;
Eina_Cow *evas_object_state_cow = NULL;
Eina_Cow *evas_object_3d_cow = NULL;
Eina_Cow *evas_object_mask_cow = NULL;
Eina_Cow *evas_object_events_cow = NULL;
@ -49,29 +48,26 @@ typedef struct _Event_Animation
static Eina_Bool
_init_cow(void)
{
if (evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow && evas_object_3d_cow) return EINA_TRUE;
if (evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow) return EINA_TRUE;
evas_object_proxy_cow = eina_cow_add("Evas Object Proxy", sizeof (Evas_Object_Proxy_Data), 8, &default_proxy, EINA_TRUE);
evas_object_map_cow = eina_cow_add("Evas Object Map", sizeof (Evas_Object_Map_Data), 8, &default_map, EINA_TRUE);
evas_object_state_cow = eina_cow_add("Evas Object State", sizeof (Evas_Object_Protected_State), 64, &default_state, EINA_FALSE);
evas_object_3d_cow = eina_cow_add("Evas Object 3D", sizeof (Evas_Object_3D_Data), 8, &default_proxy, EINA_TRUE);
evas_object_mask_cow = eina_cow_add("Evas Mask Data", sizeof (Evas_Object_Mask_Data), 8, &default_mask, EINA_TRUE);
evas_object_events_cow = eina_cow_add("Evas Events Data", sizeof (Evas_Object_Events_Data), 8, &default_events, EINA_TRUE);
if (!(evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow &&
evas_object_3d_cow && evas_object_mask_cow && evas_object_events_cow))
evas_object_mask_cow && evas_object_events_cow))
{
eina_cow_del(evas_object_proxy_cow);
eina_cow_del(evas_object_map_cow);
eina_cow_del(evas_object_state_cow);
eina_cow_del(evas_object_3d_cow);
eina_cow_del(evas_object_mask_cow);
eina_cow_del(evas_object_events_cow);
evas_object_proxy_cow = NULL;
evas_object_map_cow = NULL;
evas_object_state_cow = NULL;
evas_object_3d_cow = NULL;
evas_object_mask_cow = NULL;
evas_object_events_cow = NULL;
@ -206,7 +202,6 @@ _efl_canvas_object_efl_object_constructor(Eo *eo_obj, Evas_Object_Protected_Data
obj->map = eina_cow_alloc(evas_object_map_cow);
obj->cur = eina_cow_alloc(evas_object_state_cow);
obj->prev = eina_cow_alloc(evas_object_state_cow);
obj->data_3d = eina_cow_alloc(evas_object_3d_cow);
obj->mask = eina_cow_alloc(evas_object_mask_cow);
obj->events = eina_cow_alloc(evas_object_events_cow);
@ -519,7 +514,6 @@ evas_object_free(Evas_Object_Protected_Data *obj, Eina_Bool clean_layer)
eina_cow_free(evas_object_map_cow, (const Eina_Cow_Data**) &obj->map);
eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->cur);
eina_cow_free(evas_object_state_cow, (const Eina_Cow_Data**) &obj->prev);
eina_cow_free(evas_object_3d_cow, (const Eina_Cow_Data**) &obj->data_3d);
eina_cow_free(evas_object_mask_cow, (const Eina_Cow_Data**) &obj->mask);
eina_cow_free(evas_object_events_cow, (const Eina_Cow_Data**) &obj->events);
@ -539,7 +533,6 @@ evas_object_change(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *
Evas_Object_Protected_Data *obj2;
Evas_Object *eo_obj2;
Eina_Bool movch = EINA_FALSE;
Evas_Canvas3D_Texture *texture;
if ((!obj->layer) || (!obj->layer->evas)) return;
if (obj->layer->evas->nochange) return;
@ -570,10 +563,6 @@ evas_object_change(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *
if (!obj2) continue;
evas_object_change(eo_obj2, obj2);
}
EINA_LIST_FOREACH(obj->proxy->proxy_textures, l, texture)
{
evas_canvas3d_object_change(texture, EVAS_CANVAS3D_STATE_TEXTURE_DATA, NULL);
}
if (obj->smart.parent)
{
Evas_Object_Protected_Data *smart_parent = efl_data_scope_get(obj->smart.parent, MY_CLASS);
@ -1103,21 +1092,6 @@ _efl_canvas_object_efl_object_invalidate(Eo *eo_obj, Evas_Object_Protected_Data
if (efl_isa(proxy, EFL_GFX_FILTER_INTERFACE))
efl_gfx_filter_source_set(proxy, NULL, eo_obj);
}
/* Eina_Cow has no way to know if we are going to really change something
or not. So before calling the cow, let's check if we want to do something */
if (obj->proxy->proxy_textures)
{
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
Evas_Object_Proxy_Data, proxy_src)
{
Evas_Canvas3D_Texture *texture;
EINA_LIST_FREE(proxy_src->proxy_textures, texture)
evas_canvas3d_texture_source_set(texture, NULL);
}
EINA_COW_WRITE_END_NOGC(evas_object_proxy_cow, obj->proxy, proxy_src);
}
}
if (obj->cur)

View File

@ -389,15 +389,6 @@ _evas_proxy_redraw_set(Evas_Public_Data *e, Evas_Object_Protected_Data *obj,
//Update the proxies recursively.
_evas_proxy_redraw_set(e, proxy, render);
}
if (obj->proxy->proxy_textures)
{
/* Flag need redraw on proxy texture source */
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
Evas_Object_Proxy_Data, source)
source->redraw = EINA_TRUE;
EINA_COW_WRITE_END(evas_object_proxy_cow, obj->proxy, source);
}
}
/* sets the mask redraw flag for all the objects clipped by this mask */
@ -466,7 +457,7 @@ _evas_render_phase1_direct(Evas_Public_Data *e,
EINA_PREFETCH(&(obj->cur->clipper));
if (obj->changed) evas_object_clip_recalc(obj);
if (obj->proxy->proxies || obj->proxy->proxy_textures)
if (obj->proxy->proxies)
{
/* is proxy source */
if (_evas_render_object_changed_get(obj))
@ -498,7 +489,7 @@ _evas_render_phase1_direct(Evas_Public_Data *e,
if (!obj->smart.smart || evas_object_smart_changed_get(obj))
{
/* proxy sources */
if (obj->proxy->proxies || obj->proxy->proxy_textures)
if (obj->proxy->proxies)
{
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
Evas_Object_Proxy_Data, proxy_write)
@ -2313,7 +2304,6 @@ end:
* Render the source object when a proxy is set.
* Used to force a draw if necessary, else just makes sure it's available.
* Called from: image objects and text with filters.
* TODO: 3d objects subrender should probably be merged here as well.
*/
void
evas_render_proxy_subrender(Evas *eo_e, void *output, Evas_Object *eo_source, Evas_Object *eo_proxy,

View File

@ -2,19 +2,9 @@
pub_eo_files = [
'efl_canvas_polygon.eo',
'efl_canvas_image_internal.eo',
'evas_canvas3d_camera.eo',
'evas_canvas3d_texture.eo',
'evas_canvas3d_material.eo',
'evas_canvas3d_light.eo',
'evas_canvas3d_mesh.eo',
'evas_canvas3d_primitive.eo',
'evas_canvas3d_node.eo',
'evas_canvas3d_scene.eo',
'evas_canvas3d_object.eo',
'efl_canvas_image.eo',
'efl_canvas_snapshot.eo',
'efl_canvas_proxy.eo',
'efl_canvas_scene3d.eo',
'efl_canvas_surface.eo',
'efl_canvas_surface_tbm.eo',
'efl_canvas_surface_x11.eo',
@ -80,7 +70,6 @@ endforeach
pub_eo_types_files = [
'evas_canvas3d_types.eot',
'efl_canvas_animation_types.eot',
'efl_input_types.eot',
]
@ -166,7 +155,6 @@ evas_src += files([
'efl_canvas_event_grabber.c',
'efl_canvas_proxy.c',
'efl_canvas_snapshot.c',
'efl_canvas_scene3d.c',
'efl_canvas_surface.c',
'efl_canvas_surface_tbm.c',
'efl_canvas_surface_x11.c',
@ -198,17 +186,6 @@ evas_src += files([
'efl_canvas_vg_shape.c',
'efl_canvas_vg_image.c',
'evas_filter_mixin.c',
'evas_canvas3d_object.c',
'evas_canvas3d_scene.c',
'evas_canvas3d_node.c',
'evas_canvas3d_camera.c',
'evas_canvas3d_light.c',
'evas_canvas3d_mesh.c',
'evas_canvas3d_texture.c',
'evas_canvas3d_material.c',
'evas_canvas3d_primitive.c',
'evas_canvas3d_node_callback.h',
'evas_canvas3d_eet.c',
'efl_canvas_object_animation.c',
'efl_text_cursor.c',
'efl_text_formatter.c'

View File

@ -1,2 +0,0 @@
subdir('primitives')
subdir('save_load')

View File

@ -1,5 +0,0 @@
subdir('solids_of_revolution')
subdir('surfaces')
subdir('tabulated_primitives')
evas_src += files(['primitive_common.c'])

View File

@ -1,203 +0,0 @@
#include "primitive_common.h"
void _set_vertex_data_from_array(Evas_Canvas3D_Mesh *mesh,
int frame,
const float *data,
Evas_Canvas3D_Vertex_Attrib attr,
int start,
int attr_count,
int line,
int vcount)
{
float *address, *out;
int stride, i, j;
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, frame, attr, 0, NULL);
address = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, frame, attr);
stride = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, frame, attr);
if (stride == 0) stride = sizeof(float) * attr_count;
for (i = 0; i < vcount; i++)
{
out = (float *)((char *)address + stride * i);
for (j = 0; j < attr_count; j++)
out[j] = data[start + (line * i) + j];
}
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, attr);
}
void
_set_vec3_vertex_data(Evas_Canvas3D_Mesh *mesh,
int frame,
int vcount,
Eina_Vector3 *data,
Evas_Canvas3D_Vertex_Attrib attr)
{
float *address, *out;
int stride, i;
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, frame, attr, 0, NULL);
address = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, frame, attr);
stride = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, frame, attr);
if (stride == 0) stride = sizeof(float) * 3;
for (i = 0; i < vcount; i++)
{
out = (float *)((char *)address + stride * i);
out[0] = data[i].x;
out[1] = data[i].y;
out[2] = data[i].z;
}
free(data);
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, attr);
}
void
_set_vec2_vertex_data(Evas_Canvas3D_Mesh *mesh,
int frame,
int vcount,
Eina_Vector2 *data,
Evas_Canvas3D_Vertex_Attrib attr)
{
float *address, *out;
int stride, i;
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, frame, attr, 0, NULL);
address = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, frame, attr);
stride = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, frame, attr);
if (stride == 0) stride = sizeof(float) * 2;
for (i = 0; i < vcount; i++)
{
out = (float *)((char *)address + stride * i);
out[0] = data[i].x;
out[1] = data[i].y;
}
free(data);
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, attr);
}
void
_generate_indices(unsigned short *indices, int a, int b)
{
int i, j, a1 = a + 1;
unsigned short *index = &indices[0];
for (i = 0; i < b; i++)
{
for (j = 0; j < a; j++)
{
*index++ = j + a1 * i;
*index++ = j + a1 * (i + 1);
*index++ = j + 1 + a1 * (i + 1);
*index++ = j + a1 * i;
*index++ = j + 1 + a1 * i;
*index++ = j + a1 * (i + 1) + 1;
}
}
}
void
_primitives_vec3_copy(Eina_Vector3 *dst, const Eina_Vector3 *src)
{
dst->x = src->x;
dst->y = src->y;
dst->z = src->z;
}
void
_primitives_vec3_subtract(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b)
{
out->x = a->x - b->x;
out->y = a->y - b->y;
out->z = a->z - b->z;
}
void
_primitives_vec3_cross_product(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b)
{
Eina_Vector3 tmp;
tmp.x = a->y * b->z - a->z * b->y;
tmp.y = a->z * b->x - a->x * b->z;
tmp.z = a->x * b->y - a->y * b->x;
_primitives_vec3_copy(out, &tmp);
}
void
_primitives_vec3_normalize(Eina_Vector3 *out)
{
Evas_Real size = out->x * out->x + out->y *out->y + out->z * out->z;
size = sqrt(size);
out->x /= size;
out->y /= size;
out->z /= size;
}
void
evas_common_set_model_from_primitive(Evas_Canvas3D_Mesh *model,
int frame,
Evas_Canvas3D_Primitive_Data *primitive)
{
Evas_Real ratio = primitive->ratio;
int precision = primitive->precision;
Evas_Canvas3D_Surface_Func *surface = primitive->surface;
Eina_Vector2 tex_scale = primitive->tex_scale;
Evas_Canvas3D_Primitive_Mode mode = primitive->mode;
switch (primitive->form)
{
case EVAS_CANVAS3D_MESH_PRIMITIVE_NONE:
case EVAS_CANVAS3D_MESH_PRIMITIVE_COUNT:
{
ERR("Primitive with this type cannot be set to mesh.");
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_SQUARE:
{
evas_model_set_from_square_primitive(model, frame);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE:
{
evas_model_set_from_cube_primitive(model, frame);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_CYLINDER:
{
evas_model_set_from_cylinder_primitive(model, frame, mode,
precision, tex_scale);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_CONE:
{
evas_model_set_from_cone_primitive(model, frame, mode,
precision, tex_scale);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE:
{
evas_model_set_from_sphere_primitive(model, frame, mode,
precision, tex_scale);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_TORUS:
{
evas_model_set_from_torus_primitive(model, frame,
ratio, precision, tex_scale);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_SURFACE:
{
evas_model_set_from_surface_primitive(model, frame,
surface, precision, tex_scale);
break;
}
case EVAS_CANVAS3D_MESH_PRIMITIVE_TERRAIN:
{
evas_model_set_from_terrain_primitive(model, frame,
precision, tex_scale);
break;
}
default:
{
ERR("Unknown type of primitive");
}
}
}

View File

@ -1,62 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif //HAVE_CONFIG_H
#ifndef PRIMITIVE_COMMON
#define PRIMITIVE_COMMON
#include "evas_options.h"
#include "evas_common_private.h"
#include "evas_private.h"
#define ALLOCATE_VERTEX_DATA \
Eina_Vector3 *vertices = malloc(sizeof(Eina_Vector3) * vcount); \
Eina_Vector3 *normals = malloc(sizeof(Eina_Vector3) * vcount); \
Eina_Vector2 *tex_coord = malloc(sizeof(Eina_Vector2) * vcount); \
Eina_Vector3 *tangents = malloc(sizeof(Eina_Vector3) * vcount); \
unsigned short *indices = malloc(sizeof(short) * icount);
#define SET_VERTEX_DATA(frame) \
Eina_Bool frame_exist; \
frame_exist = evas_canvas3d_mesh_frame_exist(mesh, frame); \
if (!frame_exist) \
evas_canvas3d_mesh_frame_add(mesh, frame); \
evas_canvas3d_mesh_vertex_count_set(mesh, vcount); \
evas_canvas3d_mesh_index_data_copy_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
icount, &indices[0]); \
_set_vec3_vertex_data(mesh, frame, vcount, vertices, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION); \
_set_vec3_vertex_data(mesh, frame, vcount, normals, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL); \
_set_vec2_vertex_data(mesh, frame, vcount, tex_coord, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD); \
_set_vec3_vertex_data(mesh, frame, vcount, tangents, EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT); \
free(indices);
#define SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, varray, vcount, indices, icount) \
Eina_Bool frame_exist; \
frame_exist = evas_canvas3d_mesh_frame_exist(mesh, frame); \
if (!frame_exist) \
evas_canvas3d_mesh_frame_add(mesh, frame); \
evas_canvas3d_mesh_vertex_count_set(mesh, vcount); \
evas_canvas3d_mesh_index_data_copy_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
icount, &indices[0]); \
_set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, \
0, 3, 15, vcount); \
_set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, \
3, 3, 15, vcount); \
_set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, \
6, 4, 15, vcount); \
_set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, \
10, 2, 15, vcount); \
_set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT, \
12, 3, 15, vcount);
void _generate_indices(unsigned short *indices, int count, int width);
void _set_vec3_vertex_data(Evas_Canvas3D_Mesh *mesh, int frame, int vcount, Eina_Vector3 *data, Evas_Canvas3D_Vertex_Attrib attr);
void _set_vec2_vertex_data(Evas_Canvas3D_Mesh *mesh, int frame, int vcount, Eina_Vector2 *data, Evas_Canvas3D_Vertex_Attrib attr);
void _set_vertex_data_from_array(Evas_Canvas3D_Mesh *mesh, int frame, const float *data, Evas_Canvas3D_Vertex_Attrib attr, int start, int attr_count, int line, int vcount);
void _primitives_vec3_copy(Eina_Vector3 *dst, const Eina_Vector3 *src);
void _primitives_vec3_subtract(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b);
void _primitives_vec3_cross_product(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b);
void _primitives_vec3_normalize(Eina_Vector3 *out);
#endif //PRIMITIVE_COMMON

View File

@ -1,140 +0,0 @@
#include "../primitive_common.h"
void
_set_default_cone(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i, j, num;
double dfi, fi, sinfi, cosfi, nplane, nz;
icount = p * 18;
vccount = p + 1;
vcount = 4 * vccount;
dfi = 2.0 * M_PI / p;
nz = sqrt(1.0 / 3.0);
nplane = sqrt(2.0 / 3.0);
ALLOCATE_VERTEX_DATA
for (i = 0; i < vccount; i++)
{
fi = i * dfi;
sinfi = sin(fi);
cosfi = cos(fi);
vertices[i].x = 0.0;
vertices[i].y = 0.0;
vertices[i].z = -0.5;
vertices[i + vccount].x = sinfi / 2.0;
vertices[i + vccount].y = cosfi / 2.0;
vertices[i + vccount].z = -0.5;
vertices[i + 2 * vccount] = vertices[i + vccount];
vertices[i + 3 * vccount].x = 0.0;
vertices[i + 3 * vccount].y = 0.0;
vertices[i + 3 * vccount].z = 0.5;
normals[i].x = normals[i].y = 0.0;
normals[i].z = -1.0;
normals[i + vccount] = normals[i];
normals[i + 2 * vccount].x = sinfi * nplane;
normals[i + 2 * vccount].y = cosfi * nplane;
normals[i + 2 * vccount].z = nz;
normals[i + 3 * vccount] = normals[i + 2 * vccount];
for (j = 0; j < 4; j++)
{
num = i + j * vccount;
tangents[num].x = cosfi;
tangents[num].y = -sinfi;
tangents[num].z = 0.0;
tex_coord[num].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[num].y = ((j + 1) / 2.0) * tex_scale.y / 2.0;
}
}
_generate_indices(indices, p, 3);
SET_VERTEX_DATA(frame)
}
void
_set_cone_without_base(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i;
double dfi, fi, sinfi, cosfi, nplane, nz;
icount = p * 6;
vccount = p + 1;
vcount = 2 * vccount;
dfi = 2.0 * M_PI / p;
nz = sqrt(1.0 / 3.0);
nplane = sqrt(2.0 / 3.0);
ALLOCATE_VERTEX_DATA
for (i = 0; i < vccount; i++)
{
fi = i * dfi;
sinfi = sin(fi);
cosfi = cos(fi);
vertices[i].x = sinfi / 2.0;
vertices[i].y = cosfi / 2.0;
vertices[i].z = -0.5;
vertices[i + vccount].x = 0;
vertices[i + vccount].y = 0;
vertices[i + vccount].z = 0.5;
normals[i + vccount].x = normals[i].x = sinfi * nplane;
normals[i + vccount].y = normals[i].y = cosfi * nplane;
normals[i + vccount].z = normals[i].z = nz;
tangents[i + vccount].x = tangents[i].x = cosfi;
tangents[i + vccount].y = tangents[i].y = -sinfi;
tangents[i + vccount].z = tangents[i].z = 0;
tex_coord[i].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[i].y = 0;
tex_coord[i + vccount].x = tex_coord[i].x;
tex_coord[i + vccount].y = tex_scale.y;
}
_generate_indices(indices, p, 1);
SET_VERTEX_DATA(frame)
}
void
evas_model_set_from_cone_primitive(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Canvas3D_Primitive_Mode mode,
int p,
Eina_Vector2 tex_scale)
{
switch (mode)
{
case EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT:
case EVAS_CANVAS3D_PRIMITIVE_MODE_ALTERNATIVE_UV:
{
_set_default_cone(mesh, frame, p, tex_scale);
break;
}
case EVAS_CANVAS3D_PRIMITIVE_MODE_WITHOUT_BASE:
{
_set_cone_without_base(mesh, frame, p, tex_scale);
break;
}
default:
{
ERR("Unknown mode of primitive");
}
}
}

View File

@ -1,136 +0,0 @@
#include "../primitive_common.h"
void
_set_default_cylinder(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i, j, num;
icount = p * 30;
vccount = p + 1;
vcount = 6 * vccount;
ALLOCATE_VERTEX_DATA
double dfi, fi, sinfi, cosfi;
dfi = 2 * M_PI / p;
for (i = 0; i < vccount; i++)
{
fi = i * dfi;
sinfi = sin(fi);
cosfi = cos(fi);
for (j = 0; j < 6; j++)
{
num = i + j * vccount;
vertices[num].z = -0.5 + j / 3.0;
if ((j == 0) || (j == 5))
{
vertices[num].x = vertices[num].y = 0.0;
}
else
{
vertices[num].x = sinfi / 2.0;
vertices[num].y = cosfi / 2.0;
}
if ((j == 2) || (j == 3))
{
normals[num].x = sinfi;
normals[num].y = cosfi;
normals[num].z = 0.0;
}
else
{
normals[num].x = normals[num].y = 0.0;
normals[num].z = -1.0 + j / 2.0;
}
tangents[num].x = cosfi;
tangents[num].y = -sinfi;
tangents[num].z = 0.0;
tex_coord[num].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[num].y = ((j + 1) / 2.0) * tex_scale.y / 3.0;
}
}
_generate_indices(indices, p, 5);
SET_VERTEX_DATA(frame)
}
void
_set_cylinder_without_bases(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i;
icount = p * 6;
vccount = p + 1;
vcount = 2 * vccount;
ALLOCATE_VERTEX_DATA
double dfi, fi, sinfi, cosfi;
dfi = 2 * M_PI / p;
for (i = 0; i < vccount; i++)
{
fi = i * dfi;
sinfi = sin(fi);
cosfi = cos(fi);
vertices[i + vccount].x = vertices[i].x = sinfi / 2.0;
vertices[i + vccount].y = vertices[i].y = cosfi / 2.0;
vertices[i].z = -0.5;
vertices[i + vccount].z = 0.5;
normals[i + vccount].x = normals[i].x = sinfi;
normals[i + vccount].y = normals[i].y = cosfi;
normals[i + vccount].z = normals[i].z = 0;
tangents[i + vccount].x = tangents[i].x = cosfi;
tangents[i + vccount].y = tangents[i].y = -sinfi;
tangents[i + vccount].z = tangents[i].z = 0;
tex_coord[i].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[i].y = 0;
tex_coord[i + vccount].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[i + vccount].y = tex_scale.y;
}
_generate_indices(indices, p, 1);
SET_VERTEX_DATA(frame)
}
void
evas_model_set_from_cylinder_primitive(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Canvas3D_Primitive_Mode mode,
int p,
Eina_Vector2 tex_scale)
{
switch (mode)
{
case EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT:
case EVAS_CANVAS3D_PRIMITIVE_MODE_ALTERNATIVE_UV:
{
_set_default_cylinder(mesh, frame, p, tex_scale);
break;
}
case EVAS_CANVAS3D_PRIMITIVE_MODE_WITHOUT_BASE:
{
_set_cylinder_without_bases(mesh, frame, p, tex_scale);
break;
}
default:
{
ERR("Unknown mode of primitive");
}
}
}

View File

@ -1,6 +0,0 @@
evas_src += files([
'cone.c',
'cylinder.c',
'sphere.c',
'torus.c'
])

View File

@ -1,189 +0,0 @@
#include "../primitive_common.h"
void
_set_default_sphere(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i, j;
icount = p * p * 6;
vccount = p + 1;
vcount = vccount * vccount;
ALLOCATE_VERTEX_DATA
double dtheta, dfi, sinth, costh, fi, theta, sinfi, cosfi;
dtheta = M_PI / p;
dfi = 2 * M_PI / p;
for (j = 0; j < vccount; j++)
{
theta = j * dtheta;
sinth = sin(theta);
costh = cos(theta);
for (i = 0; i < vccount; i++)
{
fi = i * dfi;
sinfi = sin(fi);
cosfi = cos(fi);
normals[i + j * vccount].x = sinth * sinfi;
normals[i + j * vccount].y = sinth * cosfi;
normals[i + j * vccount].z = costh;
vertices[i + j * vccount].x = normals[i + j * vccount].x / 2;
vertices[i + j * vccount].y = normals[i + j * vccount].y / 2;
vertices[i + j * vccount].z = normals[i + j * vccount].z / 2;
tangents[i + j * vccount].x = -sinth * cosfi;
tangents[i + j * vccount].y = sinth * sinfi;
tangents[i + j * vccount].z = 0;
_primitives_vec3_normalize(&tangents[i + j * vccount]);
tex_coord[i + j * vccount].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[i + j *vccount].y = tex_scale.y - j / (float)(vccount - 1) * tex_scale.y;
}
}
_generate_indices(indices, p, p);
SET_VERTEX_DATA(frame)
}
void
_set_sphere_with_alternative_uv(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i, j;
vccount = p + 1;
vcount = vccount * vccount;
icount = p * p * 6;
ALLOCATE_VERTEX_DATA
/* Calculate vertices position of the sphere mesh by using
splitting of sphere by latitude and longitude. */
for (i = 0; i <= p; i++)
{
double lati, z, r, point_r;
point_r = 0.00001;//non-zero little value for correct tangents calculation.
lati = ((M_PI - 2 * point_r) * (double)i) / (double)p;
z = cos(lati + point_r);
r = fabs(sin(lati + point_r));
for (j = 0; j <= p; j++)
{
double longi;
int num = (i * (p + 1)) + j;
longi = (M_PI * 2.0 * (double)j) / (double)p;
normals[num].x = r * sin(longi);
normals[num].y = r * cos(longi);
normals[num].z = z;
vertices[num].x = normals[num].x / 2;
vertices[num].y = normals[num].y / 2;
vertices[num].z = normals[num].z / 2;
if (vertices[num].x > 0.0)
{
tangents[num].x = -normals[num].z;
tangents[num].y = normals[num].y;
tangents[num].z = normals[num].x;
}
else
{
tangents[num].x = normals[num].z;
tangents[num].y = normals[num].y;
tangents[num].z = -normals[num].x;
}
tex_coord[num].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[num].y = tex_scale.y - j / (float)(vccount - 1) * tex_scale.y;
}
}
_generate_indices(indices, p, p);
/* Triangulation of sphere mesh in appliance with buffer of indices. */
for (i = 0; i < icount; i += 3)
{
Eina_Vector3 e1, e2;
float du1, du2, dv1, dv2, f;
Eina_Vector3 tangent;
int num0, num1, num2;
num0 = indices[i + 0];
num1 = indices[i + 1];
num2 = indices[i + 2];
e1.x = vertices[num1].x - vertices[num0].x;
e1.y = vertices[num1].y - vertices[num0].y;
e1.z = vertices[num1].z - vertices[num0].z;
e2.x = vertices[num2].x - vertices[num0].x;
e2.y = vertices[num2].y - vertices[num0].y;
e2.z = vertices[num2].z - vertices[num0].z;
du1 = tex_coord[num1].x - tex_coord[num0].x;
dv1 = tex_coord[num1].y - tex_coord[num0].y;
du2 = tex_coord[num2].x - tex_coord[num0].x;
dv2 = tex_coord[num2].y - tex_coord[num0].y;
f = 1.0 / ((du1 * dv2) - (du2 * dv1));
tangent.x = f * ((dv2 * e1.x) - (dv1 * e2.x));
tangent.y = f * ((dv2 * e1.y) - (dv1 * e2.y));
tangent.z = f * ((dv2 * e1.z) - (dv1 * e2.z));
tangents[num0] = tangent;
}
/* Coupling between vertices by calculation of tangent parametr correct value. */
for (i = 0; i <= p; i++)
{
for (j = 0; j <= p; j++)
{
if (j == p)
{
tangents[(i * (p + 1)) + j] = tangents[i * (p + 1)];
}
}
}
SET_VERTEX_DATA(frame)
}
void
evas_model_set_from_sphere_primitive(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Canvas3D_Primitive_Mode mode,
int p,
Eina_Vector2 tex_scale)
{
switch (mode)
{
case EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT:
case EVAS_CANVAS3D_PRIMITIVE_MODE_WITHOUT_BASE:
{
_set_default_sphere(mesh, frame, p, tex_scale);
break;
}
case EVAS_CANVAS3D_PRIMITIVE_MODE_ALTERNATIVE_UV:
{
_set_sphere_with_alternative_uv(mesh, frame, p, tex_scale);
break;
}
default:
{
ERR("Unknown mode of primitive");
}
}
}

View File

@ -1,67 +0,0 @@
#include "../primitive_common.h"
void
evas_model_set_from_torus_primitive(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Real ratio,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i, j;
icount = p * p * 6;
vccount = p + 1;
vcount = vccount * vccount;
ALLOCATE_VERTEX_DATA
double d, sinth, costh, fi, theta, sinfi, cosfi;
d = 2 * M_PI / p;
float rratio;
if ((ratio < 1.0))
{
printf("Ratio of torus should be greater than or equal 1.0.\n");
printf("Ratio = %f is a bad value, so 3.0 is used like default ratio.\n",
ratio);
rratio = 1.0 / 3.0;
}
else
{
rratio = 1.0 / ratio;
}
for (j = 0; j < vccount; j++)
{
theta = j * d;
sinth = sin(theta);
costh = cos(theta);
for (i = 0; i < vccount; i++)
{
fi = i * d;
sinfi = sin(fi);
cosfi = cos(fi);
vertices[i + j * vccount].x = (1.0 - rratio + rratio * cosfi) * costh * 0.5;
vertices[i + j * vccount].y = (1.0 - rratio + rratio * cosfi) * sinth * 0.5;
vertices[i + j * vccount].z = rratio * sinfi * 0.5;
normals[i + j * vccount].x = cosfi * costh;
normals[i + j * vccount].y = cosfi * sinth;
normals[i + j * vccount].z = sinfi;
tangents[i + j * vccount].x = -sinfi * costh;
tangents[i + j * vccount].y = -sinfi * sinth;
tangents[i + j * vccount].z = cosfi;
_primitives_vec3_normalize(&normals[i + j * vccount]);
tex_coord[i + j * vccount].x = i / (float)(vccount - 1) * tex_scale.x;
tex_coord[i + j *vccount].y = tex_scale.y - j / (float)(vccount - 1) * tex_scale.y;
}
}
_generate_indices(indices, p, p);
SET_VERTEX_DATA(frame)
}

View File

@ -1,4 +0,0 @@
evas_src += files([
'surface.c',
'terrain.c'
])

View File

@ -1,91 +0,0 @@
#include "../primitive_common.h"
Eina_Vector3 _get_func_normal(Evas_Canvas3D_Surface_Func *func, Evas_Real x, Evas_Real y)
{
Eina_Vector3 v00, v01, v10, d1, d2, normal;
func(&v00.x, &v00.y, &v00.z, x, y);
func(&v01.x, &v01.y, &v01.z, x, y + 0.01);
func(&v10.x, &v10.y, &v10.z, x + 0.01, y);
_primitives_vec3_subtract(&d1, &v00, &v01);
_primitives_vec3_subtract(&d2, &v01, &v10);
_primitives_vec3_cross_product(&normal, &d1, &d2);
_primitives_vec3_normalize(&normal);
return normal;
}
void
_normalize(Eina_Vector3 *vertices, Eina_Vector3 *normals, int vcount)
{
int i;
Eina_Vector3 min, max;
min = max = vertices[0];
#define CHECK_MIN_AND_MAX(coord) \
if (min.coord > vertices[i].coord) \
min.coord = vertices[i].coord; \
else if (max.coord < vertices[i].coord) \
max.coord = vertices[i].coord;
for (i = 1; i < vcount; i++)
{
CHECK_MIN_AND_MAX(x)
CHECK_MIN_AND_MAX(y)
CHECK_MIN_AND_MAX(z)
}
#undef CHECK_MIN_AND_MAX
for (i = 0; i < vcount; i++)
{
vertices[i].x = (vertices[i].x - min.x) / (max.x - min.x) - 0.5;
vertices[i].y = (vertices[i].y - min.y) / (max.y - min.y) - 0.5;
vertices[i].z = (vertices[i].z - min.z) / (max.z - min.z) - 0.5;
normals[i].x = normals[i].x / (max.x - min.x);
normals[i].y = normals[i].y / (max.y - min.y);
normals[i].z = normals[i].z / (max.z - min.z);
}
}
void
evas_model_set_from_surface_primitive(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Canvas3D_Surface_Func func,
int p,
Eina_Vector2 tex_scale)
{
int vcount, icount, vccount, i, j, num;
icount = p * p * 6;
vccount = p + 1;
vcount = vccount * vccount;
ALLOCATE_VERTEX_DATA
Evas_Real v, u, d = 1.0 / p;
for (j = 0; j < vccount; j++)
{
u = j * d - 0.5;
for (i = 0; i < vccount; i++)
{
v = i * d - 0.5;
num = i + j * vccount;
func(&vertices[num].x,
&vertices[num].y,
&vertices[num].z,
v, u);
normals[num] = _get_func_normal(func, v, u);
tangents[num].x = tangents[num].y = tangents[num].z = 0;
tex_coord[num].x = i / ((vccount - 1) * tex_scale.x);
tex_coord[num].y = tex_scale.y - j / ((vccount - 1) * tex_scale.y);
}
}
_normalize(vertices, normals, vcount);
_generate_indices(indices, p, p);
SET_VERTEX_DATA(frame)
}

View File

@ -1,86 +0,0 @@
#include "../primitive_common.h"
static Evas_Real
_random(int x, int y)
{
int k = x + y * 57;
k = (k << 13) ^ k;
return (1.0f - ((k * (k * k * 15731 + 789221) + 1376312589) & 0x7fffffff) /
1073741824.0f);
}
static Evas_Real
_smooth(Evas_Real x, Evas_Real y)
{
Evas_Real res;
res = (_random(x - 1, y - 1) + _random(x + 1, y - 1) +
_random(x - 1, y + 1) + _random(x + 1, y + 1)) / 16;
res += (_random(x - 1, y) + _random(x + 1, y) +
_random(x, y - 1) + _random(x, y + 1)) / 8;
res += _random(x, y) / 4;
return res;
}
static Evas_Real
_interpolate(Evas_Real a, Evas_Real b, Evas_Real x)
{
Evas_Real ft = x * M_PI;
Evas_Real f = (1 - cosf(ft)) * 0.5;
return a * (1 - f) + b * f;
}
static Evas_Real _noise(Evas_Real x, Evas_Real y)
{
Evas_Real ix = (int)(x);
Evas_Real fx = x - ix;
Evas_Real iy = (int)(y);
Evas_Real fy = y - iy;
Evas_Real v1 = _smooth(ix, iy);
Evas_Real v2 = _smooth(ix + 1, iy);
Evas_Real v3 = _smooth(ix, iy + 1);
Evas_Real v4 = _smooth(ix + 1, iy + 1);
Evas_Real i1 = _interpolate(v1, v2, fx);
Evas_Real i2 = _interpolate(v3, v4, fx);
return _interpolate(i1, i2, fy);
}
static void
_perlin_terrain(Evas_Real *out_x,
Evas_Real *out_y,
Evas_Real *out_z,
Evas_Real x,
Evas_Real y)
{
Evas_Real persistence = 0.5f;
Evas_Real frequency = 5;
Evas_Real amplitude = 1;
int i = 0;
int octaves = 5;
*out_x = x;
x += 0.5;
*out_y = y;
y += 0.5;
*out_z = 0;
for(i = 0; i < octaves; i++)
{
*out_z += _noise(x * frequency, y * frequency) * amplitude;
amplitude *= persistence;
frequency *= 2;
}
}
void
evas_model_set_from_terrain_primitive(Evas_Canvas3D_Mesh *mesh,
int frame,
int p,
Eina_Vector2 tex_scale)
{
evas_model_set_from_surface_primitive(mesh, frame, _perlin_terrain, p, tex_scale);
}

View File

@ -1,57 +0,0 @@
#include "../primitive_common.h"
const float vertices_of_cube[] =
{
/* positions normals vertex_color tex_coords tangents */
/* Front */
0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0,
-0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, -1.0, 0.0, 0.0,
-0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 0.0,
0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0,
/* Left */
-0.5, -0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0,
-0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0,
-0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0,
-0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
/* Back */
-0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
-0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
/* Right */
0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0,
0.5, -0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0,
0.5, -0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, -1.0,
0.5, 0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0,
/* Top */
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
-0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
/* Bottom */
-0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, -1.0, 0.0, 0.0,
-0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 0.0,
0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0,
0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0,
};
const unsigned short indices_of_cube[] =
{
0, 1, 2, 6, 7, 4,
4, 5, 6, 10, 11, 8,
8, 9, 10, 14, 15, 12,
12, 13, 14, 2, 3, 0,
19, 16, 17, 17, 18, 19,
23, 20, 21, 21, 22, 23
};
void
evas_model_set_from_cube_primitive(Evas_Canvas3D_Mesh *mesh, int frame)
{
SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, vertices_of_cube, 24, indices_of_cube, 36)
}

View File

@ -1,4 +0,0 @@
evas_src += files([
'cube.c',
'square.c'
])

View File

@ -1,18 +0,0 @@
#include "../primitive_common.h"
const float vertices_of_square[] =
{
/* positions normals vertex_color tex_coords tangents */
-0.5, 0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
0.5, 0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
-0.5, -0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.5, -0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
};
const unsigned short indices_of_square[] = {0, 1, 2, 2, 1, 3};
void
evas_model_set_from_square_primitive(Evas_Canvas3D_Mesh *mesh, int frame)
{
SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, vertices_of_square, 4, indices_of_square, 6)
}

View File

@ -1,82 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "evas_options.h"
#include "evas_common_private.h"
#include "evas_private.h"
void
_evas_common_load_model(Evas_Canvas3D_Mesh *model,
Eina_File *file,
const char *file_path)
{
char *p;
char *loader_type = NULL;
p = strrchr(file_path, '.');
if (p)
{
p++;
#define CHECK_EXTENTION_BY_FILE_NAME(extention) \
if (!strcasecmp(p, #extention)) \
{ \
evas_model_load_file_##extention(model, file); \
loader_type = #extention; \
}
CHECK_EXTENTION_BY_FILE_NAME(eet)
CHECK_EXTENTION_BY_FILE_NAME(md2)
CHECK_EXTENTION_BY_FILE_NAME(obj)
CHECK_EXTENTION_BY_FILE_NAME(ply)
#undef CHECK_EXTENTION_BY_FILE_NAME
}
if (!loader_type) ERR("Invalid mesh file type.");
}
void
evas_common_load_model_from_file(Evas_Canvas3D_Mesh *model, const char *file)
{
Eina_File *tmp_file = eina_file_open(file, 0);
if (tmp_file == NULL)
{
ERR("Failed to open file %s", file);
ERR("Failed to initialize loader.");
return;
}
Eina_File *e_file = eina_file_dup(tmp_file);
if (e_file == NULL)
{
eina_file_close(tmp_file);
file = NULL;
ERR("Failed to initialize loader.");
return;
}
eina_file_close(tmp_file);
_evas_common_load_model(model, e_file, file);
eina_file_close(e_file);
e_file = NULL;
}
void
evas_common_load_model_from_eina_file(Evas_Canvas3D_Mesh *model, const Eina_File *file)
{
Eina_File *e_file = eina_file_dup(file);
if (e_file == NULL)
{
ERR("Failed to initialize loader.");
return;
}
_evas_common_load_model(model, e_file, eina_file_filename_get(e_file));
eina_file_close(e_file);
e_file = NULL;
}

View File

@ -1,230 +0,0 @@
#include "evas_model_load_save_common.h"
# define SAVE_MESH_INDICES_COPY \
if (header.indices_count) \
{ \
data->indices = malloc(header.indices_count \
* sizeof(unsigned short)); \
if (pd->index_format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_BYTE) \
{ \
for (i = 0; i < header.indices_count; i++) \
data->indices[i] = ((unsigned char*)(pd->indices))[i]; \
} \
else \
{ \
for (i = 0; i < header.indices_count; i++) \
data->indices[i] = ((unsigned short*)(pd->indices))[i]; \
} \
} \
else \
{ \
data->indices = malloc(header.vertices_count * 3 \
* sizeof(unsigned short)); \
for (i = 0; i < header.vertices_count * 3; i++) \
data->indices[i] = (unsigned short)i; \
}
/* create new header */
Evas_Model_Load_Save_Header
evas_model_load_save_header_new(void)
{
Evas_Model_Load_Save_Header header;
header.vertices_count = 0;
header.indices_count = 0;
header.existence_of_positions = EINA_FALSE;
header.existence_of_normals = EINA_FALSE;
header.existence_of_tex_coords = EINA_FALSE;
header.existence_of_colors = EINA_FALSE;
return header;
}
void
evas_model_load_vertex_data_unmap(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Model_Load_Save_Header header)
{
#define UNMAP_IF_EXIST(existence, vertex_data_type) \
if (existence) \
{ \
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, \
vertex_data_type); \
}
UNMAP_IF_EXIST(header.existence_of_positions, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION)
UNMAP_IF_EXIST(header.existence_of_normals, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL)
UNMAP_IF_EXIST(header.existence_of_tex_coords, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD)
UNMAP_IF_EXIST(header.existence_of_colors, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR)
#undef UNMAP_IF_EXIST
}
void
evas_model_load_save_data_free(Evas_Model_Load_Save_Header header,
Evas_Model_Load_Save_Data *data)
{
if (header.existence_of_positions) free(data->positions);
if (header.existence_of_normals) free(data->normals);
if (header.existence_of_tex_coords) free(data->tex_coords);
if (header.existence_of_colors) free(data->colors);
free(data->indices);
}
void
evas_model_load_vertex_data_to_mesh(Evas_Canvas3D_Mesh *mesh,
Evas_Model_Load_Save_Header header,
Evas_Model_Load_Save_Data data,
Evas_Model_Load_Save_Stride *stride)
{
Evas_Model_Load_Save_Data map;
int i, j;
evas_canvas3d_mesh_vertex_count_set(mesh, header.vertices_count);
evas_canvas3d_mesh_vertex_assembly_set(mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
evas_canvas3d_mesh_frame_add(mesh, 0);
#define VERTEX_DATA_MAP(name, vertex_data_type, default_size) \
if (header.existence_of_##name) \
{ \
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, vertex_data_type, 0, NULL); \
map.name = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, vertex_data_type); \
stride->name = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, vertex_data_type); \
if (stride->name == 0) stride->name = sizeof(float) * default_size; \
}
VERTEX_DATA_MAP(positions, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 3)
VERTEX_DATA_MAP(normals, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 3)
VERTEX_DATA_MAP(tex_coords, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 2)
VERTEX_DATA_MAP(colors, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, 4)
#undef VERTEX_DATA_MAP
for (i = 0; i < header.vertices_count; i++)
{
Evas_Model_Load_Save_Data current_pointer;
#define FILL_VERTEX_DATA(name, size) \
if (header.existence_of_##name) \
{ \
current_pointer.name = (float *)((char *)map.name + stride->name * i); \
for (j = 0; j < size; j++) \
current_pointer.name[j] = ARRAY_2D(data.name, i, j, size); \
}
FILL_VERTEX_DATA(positions, 3)
FILL_VERTEX_DATA(normals, 3)
FILL_VERTEX_DATA(tex_coords, 2)
FILL_VERTEX_DATA(colors, 3)
#undef FILL_VERTEX_DATA
if (header.existence_of_colors) current_pointer.colors[3] = 1.0;
}
}
void
evas_model_load_indices_data_to_mesh(Evas_Canvas3D_Mesh *mesh,
Evas_Model_Load_Save_Header header,
Evas_Model_Load_Save_Data data)
{
evas_canvas3d_mesh_index_data_copy_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, header.indices_count, data.indices);
}
Eina_Bool
evas_model_load_allocate_data_due_to_header(Evas_Model_Load_Save_Header header,
Evas_Model_Load_Save_Data *data)
{
if (header.existence_of_positions)
data->positions = malloc(header.vertices_count * 3 * sizeof(float));
if (header.existence_of_normals)
data->normals = malloc(header.vertices_count * 3 * sizeof(float));
if (header.existence_of_tex_coords)
data->tex_coords = malloc(header.vertices_count * 2 * sizeof(float));
if (header.existence_of_colors)
data->colors = malloc(header.vertices_count * 3 * sizeof(float));
data->indices = malloc(header.indices_count * sizeof(unsigned short));
if ((header.existence_of_positions && (data->positions == NULL)) ||
(header.existence_of_normals && (data->normals == NULL)) ||
(header.existence_of_tex_coords && (data->tex_coords == NULL)) ||
(header.existence_of_colors && (data->colors == NULL)) ||
(data->indices == NULL))
{
free(data->positions);
free(data->normals);
free(data->tex_coords);
free(data->colors);
free(data->indices);
return EINA_FALSE;
}
return EINA_TRUE;
}
void
evas_model_load_aabb_add_to_frame(Evas_Canvas3D_Mesh *mesh,
int frame,
Evas_Model_Load_Save_Stride stride)
{
Evas_Canvas3D_Mesh_Data *pd;
pd = efl_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
if (!evas_canvas3d_mesh_aabb_add_to_frame(pd, frame, stride.positions))
{
ERR("Axis-Aligned Bounding Box wasn't added in frame %d ", 0);
}
}
Eina_Bool
evas_model_save_header_from_mesh(Evas_Canvas3D_Mesh_Data *pd,
Evas_Canvas3D_Mesh_Frame *f,
Evas_Model_Load_Save_Header *header)
{
header->indices_count = pd->index_count;
if (header->indices_count % 3 != 0)
{
printf("Index count is %d. It cannot be divided to triangles correctly.\n",
header->indices_count);
return EINA_FALSE;
}
header->existence_of_positions = (f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].data != NULL);
header->existence_of_normals = (f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL].data != NULL);
header->existence_of_tex_coords = (f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD].data != NULL);
header->existence_of_colors = (f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR].data != NULL);
header->vertices_count = pd->vertex_count;
return EINA_TRUE;
}
void
evas_model_save_data_from_mesh(Evas_Canvas3D_Mesh_Data *pd,
Evas_Canvas3D_Mesh_Frame *f,
Evas_Model_Load_Save_Header header,
Evas_Model_Load_Save_Data *data)
{
int i;
if (header.existence_of_positions)
data->positions = (float*)(&f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION])->data;
if (header.existence_of_normals)
data->normals = (float*)(&f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL])->data;
if (header.existence_of_tex_coords)
data->tex_coords = (float*)(&f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD])->data;
if (header.existence_of_colors)
data->colors = (float*)(&f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR])->data;
SAVE_MESH_INDICES_COPY
}
void
evas_model_save_data_copy_from_mesh(Evas_Canvas3D_Mesh_Data *pd,
Evas_Canvas3D_Mesh_Frame *f,
Evas_Model_Load_Save_Header header,
Evas_Model_Load_Save_Data *data)
{
int i;
#define SAVE_MESH_VERTICES_COPY(name, vertex_data_type) \
if (header.existence_of_##name) \
memcpy(data->name, \
(&f->vertices[vertex_data_type])->data, \
header.vertices_count);
SAVE_MESH_VERTICES_COPY(positions, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION)
SAVE_MESH_VERTICES_COPY(normals, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL)
SAVE_MESH_VERTICES_COPY(tex_coords, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD)
SAVE_MESH_VERTICES_COPY(colors, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR)
#undef SAVE_MESH_VERTICES_COPY
SAVE_MESH_INDICES_COPY
}

View File

@ -1,62 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifndef MODEL_LOAD_COMMON
#define MODEL_LOAD_COMMON
#include <stdlib.h>
#include <time.h>
#include "stdio.h"
#include "evas_common_private.h"
#include "evas_private.h"
#include <Eina.h>
/* set value to position [x][y] to array name which have. */
#define ARRAY_2D(name, x, y, count_y) (*(name + x * count_y + y))
/* Structures for reading data from file. */
typedef struct _Evas_Model_Load_Save_Header Evas_Model_Load_Save_Header;
typedef struct _Evas_Model_Load_Save_Data Evas_Model_Load_Save_Data;
typedef struct _Evas_Model_Load_Save_Stride Evas_Model_Load_Save_Stride;
struct _Evas_Model_Load_Save_Header
{
int vertices_count;
int indices_count;
Eina_Bool existence_of_positions;
Eina_Bool existence_of_normals;
Eina_Bool existence_of_tex_coords;
Eina_Bool existence_of_colors;
};
struct _Evas_Model_Load_Save_Data
{
float *positions;
float *normals;
float *tex_coords;
float *colors;
unsigned short *indices;
};
struct _Evas_Model_Load_Save_Stride
{
int positions;
int normals;
int tex_coords;
int colors;
};
/* create new header */
Evas_Model_Load_Save_Header evas_model_load_save_header_new(void);
void evas_model_load_vertex_data_unmap(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Model_Load_Save_Header header);
void evas_model_load_save_data_free(Evas_Model_Load_Save_Header header, Evas_Model_Load_Save_Data *data);
void evas_model_load_vertex_data_to_mesh(Evas_Canvas3D_Mesh *mesh, Evas_Model_Load_Save_Header header, Evas_Model_Load_Save_Data data, Evas_Model_Load_Save_Stride *stride);
void evas_model_load_indices_data_to_mesh(Evas_Canvas3D_Mesh *mesh, Evas_Model_Load_Save_Header header, Evas_Model_Load_Save_Data data);
Eina_Bool evas_model_load_allocate_data_due_to_header(Evas_Model_Load_Save_Header header, Evas_Model_Load_Save_Data *data);
void evas_model_load_aabb_add_to_frame(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Model_Load_Save_Stride stride);
Eina_Bool evas_model_save_header_from_mesh(Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Mesh_Frame *f, Evas_Model_Load_Save_Header *header);
void evas_model_save_data_from_mesh(Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Mesh_Frame *f, Evas_Model_Load_Save_Header header, Evas_Model_Load_Save_Data *data);
void evas_model_save_data_copy_from_mesh(Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Mesh_Frame *f, Evas_Model_Load_Save_Header header, Evas_Model_Load_Save_Data *data);
#endif //MODEL_LOAD_COMMON

View File

@ -1,34 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "evas_options.h"
#include "evas_common_private.h"
#include "evas_private.h"
void
evas_common_save_model_to_file(const Evas_Canvas3D_Mesh *model,
const char *file,
Evas_Canvas3D_Mesh_Frame *f)
{
char *p;
char *saver = NULL;
p = strrchr(file, '.');
if (p)
{
p++;
#define CHECK_EXTENTION_BY_FILE_NAME(extention) \
if (!strcasecmp(p, #extention)) \
{ \
evas_model_save_file_##extention(model, file, f); \
saver = #extention; \
}
CHECK_EXTENTION_BY_FILE_NAME(eet)
CHECK_EXTENTION_BY_FILE_NAME(obj)
CHECK_EXTENTION_BY_FILE_NAME(ply)
#undef CHECK_EXTENTION_BY_FILE_NAME
}
if (!saver) ERR("Invalid mesh file type.");
}

View File

@ -1,6 +0,0 @@
evas_src += files([
'evas_model_load.c',
'evas_model_load_save_common.c',
'evas_model_load_save_common.h',
'evas_model_save.c',
])

File diff suppressed because it is too large Load Diff

View File

@ -85,9 +85,6 @@
#define lround(x) (((x) < 0) ? (long int)ceil((x) - 0.5) : (long int)floor((x) + 0.5))
#endif
/*macro to be used in eet loader/saver*/
#define EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY "evas_3d file"
/* macros needed to log message through eina_log */
extern EAPI int _evas_log_dom_global;
#ifdef _EVAS_DEFAULT_LOG_DOM

View File

@ -166,7 +166,7 @@ evas_object_is_source_invisible(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Pro
{
if (obj->parent_cache.src_invisible_valid)
return obj->parent_cache.src_invisible;
if ((obj->proxy->proxies || obj->proxy->proxy_textures) && obj->proxy->src_invisible) return 1;
if (obj->proxy->proxies && obj->proxy->src_invisible) return 1;
if (!obj->smart.parent) return 0;
if (obj->mask->is_mask) return 0;
Evas_Object_Protected_Data *smart_parent_pd =

View File

@ -15,8 +15,6 @@
#include "../file/evas_module.h"
#include "../file/evas_path.h"
#include "evas_3d_utils.h"
#ifdef EAPI
# undef EAPI
@ -84,7 +82,6 @@ typedef struct _Evas_Object_Proxy_Data Evas_Object_Proxy_Data;
typedef struct _Evas_Object_Map_Data Evas_Object_Map_Data;
typedef struct _Evas_Object_Events_Data Evas_Object_Events_Data;
typedef struct _Evas_Proxy_Render_Data Evas_Proxy_Render_Data;
typedef struct _Evas_Object_3D_Data Evas_Object_3D_Data;
typedef struct _Evas_Object_Mask_Data Evas_Object_Mask_Data;
typedef struct _Evas_Object_Pointer_Data Evas_Object_Pointer_Data;
@ -104,405 +101,10 @@ typedef struct _Evas_Pointer_Data Evas_Pointer_Data;
typedef struct _Evas_Filter_Command Evas_Filter_Command;
typedef enum _Evas_Filter_Support Evas_Filter_Support;
// 3D stuff
#define EVAS_CANVAS3D_VERTEX_ATTRIB_COUNT 5
#define EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT 5
typedef struct _Evas_Canvas3D_Object Evas_Canvas3D_Object_Data;
typedef struct _Evas_Canvas3D_Scene_Public_Data Evas_Canvas3D_Scene_Public_Data;
typedef struct _Evas_Canvas3D_Vertex_Buffer Evas_Canvas3D_Vertex_Buffer;
typedef struct _Evas_Canvas3D_Mesh_Frame Evas_Canvas3D_Mesh_Frame;
typedef struct _Evas_Canvas3D_Node_Mesh Evas_Canvas3D_Node_Mesh;
typedef struct _Evas_Canvas3D_Object_Func Evas_Canvas3D_Object_Func;
typedef struct _Evas_Canvas3D_Pick_Data Evas_Canvas3D_Pick_Data;
typedef struct _Evas_Canvas3D_Interpolate_Vertex_Buffer Evas_Canvas3D_Interpolate_Vertex_Buffer;
typedef struct _Evas_Canvas3D_Scene Evas_Canvas3D_Scene_Data;
typedef struct _Evas_Canvas3D_Node Evas_Canvas3D_Node_Data;
typedef struct _Evas_Canvas3D_Mesh Evas_Canvas3D_Mesh_Data;
typedef struct _Evas_Canvas3D_Camera Evas_Canvas3D_Camera_Data;
typedef struct _Evas_Canvas3D_Light Evas_Canvas3D_Light_Data;
typedef struct _Evas_Canvas3D_Material Evas_Canvas3D_Material_Data;
typedef struct _Evas_Canvas3D_Texture Evas_Canvas3D_Texture_Data;
typedef struct _Evas_Canvas3D_Primitive Evas_Canvas3D_Primitive_Data;
/* Structs for mesh eet saver/loader */
typedef struct _Evas_Canvas3D_Vec2_Eet Evas_Canvas3D_Vec2_Eet;
typedef struct _Evas_Canvas3D_Vec3_Eet Evas_Canvas3D_Vec3_Eet;
typedef struct _Evas_Canvas3D_Vertex_Eet Evas_Canvas3D_Vertex_Eet;
typedef struct _Evas_Canvas3D_Geometry_Eet Evas_Canvas3D_Geometry_Eet;
typedef struct _Evas_Canvas3D_Color_Eet Evas_Canvas3D_Color_Eet;
typedef struct _Evas_Canvas3D_Material_Eet Evas_Canvas3D_Material_Eet;
typedef struct _Evas_Canvas3D_Frame_Eet Evas_Canvas3D_Frame_Eet;
typedef struct _Evas_Canvas3D_Mesh_Eet Evas_Canvas3D_Mesh_Eet;
typedef struct _Evas_Canvas3D_Header_Eet Evas_Canvas3D_Header_Eet;
typedef struct _Evas_Canvas3D_File_Eet Evas_Canvas3D_File_Eet;
typedef struct _Vg_File_Data Vg_File_Data;
typedef struct _Vg_File_Anim_Data Vg_File_Anim_Data;
typedef struct _Vg_File_Anim_Data_Marker Vg_File_Anim_Data_Marker;
struct _Evas_Canvas3D_Vec2_Eet
{
float x;
float y;
};
struct _Evas_Canvas3D_Vec3_Eet
{
float x;
float y;
float z;
};
struct _Evas_Canvas3D_Vertex_Eet
{
Evas_Canvas3D_Vec3_Eet position;
Evas_Canvas3D_Vec3_Eet normal;
Evas_Canvas3D_Vec2_Eet texcoord;
};//one point of mesh
struct _Evas_Canvas3D_Geometry_Eet
{
unsigned int id;
int vertices_count;
Evas_Canvas3D_Vertex_Eet *vertices;
};//contain array of vertices and id for using in Evas_Canvas3D_Frame_Eet in future
struct _Evas_Canvas3D_Color_Eet
{
float r;
float g;
float b;
float a;
};
struct _Evas_Canvas3D_Material_Eet
{
int id;
float shininess;
int colors_count;
Evas_Canvas3D_Color_Eet *colors;//Color per attribute (ambient, diffuse, specular etc.)
};
struct _Evas_Canvas3D_Frame_Eet
{
int id;
int geometry_id;
int material_id;
};//only ids to prevent of spending of memory when animation will change only geometry or only material
struct _Evas_Canvas3D_Mesh_Eet
{
int materials_count;
int frames_count;
int geometries_count;
Evas_Canvas3D_Material_Eet *materials;
Evas_Canvas3D_Frame_Eet *frames;
Evas_Canvas3D_Geometry_Eet *geometries;
};//contain materials, geometries and bounding between it (frames)
struct _Evas_Canvas3D_Header_Eet
{
int version;
int *materials;//colors_count
int materials_count;
int *geometries;//vertices_count
int geometries_count;
int frames;
};//can be use for fast allocating of memory
struct _Evas_Canvas3D_File_Eet
{
Evas_Canvas3D_Mesh_Eet *mesh;
Evas_Canvas3D_Header_Eet *header;
};//contain mesh data and information about mesh size
typedef Eina_Bool (*Evas_Canvas3D_Node_Func)(Evas_Canvas3D_Node *, void *data);
typedef enum _Evas_Canvas3D_Node_Traverse_Type
{
EVAS_CANVAS3D_NODE_TRAVERSE_DOWNWARD,
EVAS_CANVAS3D_NODE_TRAVERSE_UPWARD,
} Evas_Canvas3D_Node_Traverse_Type;
typedef enum _Evas_Canvas3D_Tree_Traverse_Type
{
EVAS_CANVAS3D_TREE_TRAVERSE_PRE_ORDER,
EVAS_CANVAS3D_TREE_TRAVERSE_ANY_ORDER = EVAS_CANVAS3D_TREE_TRAVERSE_PRE_ORDER,
EVAS_CANVAS3D_TREE_TRAVERSE_POST_ORDER,
EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER,
} Evas_Canvas3D_Tree_Traverse_Type;
struct _Evas_Canvas3D_Object
{
Evas *evas;
Evas_Canvas3D_Object_Type type;
Eina_Bool dirty[EVAS_CANVAS3D_STATE_MAX];
};
struct _Evas_Canvas3D_Scene
{
Evas_Canvas3D_Node *root_node;
Evas_Canvas3D_Node *camera_node;
Evas_Color bg_color;
Eina_Bool shadows_enabled :1;
Eina_Bool color_pick_enabled :1;
void *surface;
int w, h;
Eina_List *images;
Eina_Hash *node_mesh_colors;
Eina_Hash *colors_node_mesh;
/*sets constant for shadow rendering*/
Evas_Real depth_offset;
Evas_Real depth_constant;
};
struct _Evas_Canvas3D_Node_Mesh
{
Evas_Canvas3D_Node *node;
Evas_Canvas3D_Mesh *mesh;
int frame;
};
struct _Evas_Canvas3D_Node
{
Eina_List *members;
Evas_Canvas3D_Node *parent;
Evas_Canvas3D_Node *billboard_target;
Eina_Vector3 position;
Eina_Quaternion orientation;
Eina_Vector3 scale;
Eina_Vector3 position_world;
Eina_Quaternion orientation_world;
Eina_Vector3 scale_world;
Evas_Box3 aabb;
Evas_Box3 obb;
Evas_Sphere bsphere;
Evas_Canvas3D_Node_Type type;
/* Camera node. */
union {
struct {
Evas_Canvas3D_Camera *camera;
Eina_Matrix4 matrix_world_to_eye;
} camera;
struct {
Evas_Canvas3D_Light *light;
Eina_Matrix4 matrix_local_to_world;
} light;
struct {
Eina_List *meshes;
Eina_Hash *node_meshes;
Eina_Matrix4 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;
Eina_Bool position_inherit : 1;
Eina_Bool orientation_inherit : 1;
Eina_Bool scale_inherit : 1;
Eina_Bool lod : 1;
};
struct _Evas_Canvas3D_Camera
{
Eina_Matrix4 projection;
Eina_Hash *nodes;
};
struct _Evas_Canvas3D_Light
{
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_Matrix4 projection;
Eina_Hash *nodes;
};
struct _Evas_Canvas3D_Vertex_Buffer
{
int element_count;
int stride;
void *data;
int size;
Eina_Bool owns_data;
Eina_Bool mapped;
};
struct _Evas_Canvas3D_Interpolate_Vertex_Buffer
{
void *data0;
int stride0;
int size0;
void *data1;
int stride1;
int size1;
Evas_Real weight;
};
struct _Evas_Canvas3D_Mesh_Frame
{
Evas_Canvas3D_Mesh *mesh;
int frame;
Evas_Canvas3D_Material *material;
Evas_Box3 aabb;
Evas_Canvas3D_Vertex_Buffer vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_COUNT];
};
struct _Evas_Canvas3D_Mesh
{
Evas_Canvas3D_Shader_Mode shader_mode;
int vertex_count;
int frame_count;
Eina_List *frames;
Evas_Canvas3D_Index_Format index_format;
int index_count;
void *indices;
int index_size;
Eina_Bool owns_indices;
Eina_Bool index_mapped;
Evas_Canvas3D_Vertex_Assembly assembly;
Eina_Hash *nodes;
Eina_Bool shadowed;
Eina_Bool blending :1;
Evas_Canvas3D_Blend_Func blend_sfactor;
Evas_Canvas3D_Blend_Func blend_dfactor;
Evas_Canvas3D_Comparison alpha_comparison;
Evas_Real alpha_ref_value;
Eina_Bool alpha_test_enabled :1;
Evas_Color fog_color;
Eina_Bool fog_enabled :1;
Evas_Color color_pick_key;
Eina_Bool color_pick_enabled :1;
/*sets of the quality and offsets for shadow rendering*/
int shadows_edges_filtering_level;
Evas_Real shadows_edges_size;
Evas_Real shadows_constant_bias;
Evas_Real near_lod_boundary;
Evas_Real far_lod_boundary;
};
struct _Evas_Canvas3D_Texture
{
/* 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;
Eina_File *f;
const char *key;
/*Use atlases, @EINA_TRUE by default*/
Eina_Bool atlas_enable :1;
};
struct _Evas_Canvas3D_Material
{
struct {
Eina_Bool enable;
Evas_Color color;
Evas_Canvas3D_Texture *texture;
} attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT];
Evas_Real shininess;
Eina_Hash *meshes;
};
struct _Evas_Canvas3D_Primitive
{
Evas_Canvas3D_Mesh_Primitive form;
Evas_Canvas3D_Primitive_Mode mode;
Evas_Real ratio;
int precision;
Evas_Canvas3D_Surface_Func *surface;
Eina_Vector2 tex_scale;
};
struct _Evas_Canvas3D_Scene_Public_Data
{
Evas_Color bg_color;
Evas_Canvas3D_Node *camera_node;
Eina_List *light_nodes;
Eina_List *mesh_nodes;
Eina_Bool shadows_enabled :1;
Eina_Bool color_pick_enabled :1;
Eina_Hash *node_mesh_colors;
Eina_Hash *colors_node_mesh;
/*sets constant for shadow rendering*/
Evas_Real depth_offset;
Evas_Real depth_constant;
Eina_Bool render_to_texture;
unsigned int lod_distance;
Eina_Bool post_processing :1;
Evas_Canvas3D_Shader_Mode post_processing_type;
};
struct _Evas_Canvas3D_Pick_Data
{
/* Input */
Evas_Real x, y;
Eina_Matrix4 matrix_vp;
Evas_Ray3 ray_world;
/* Output */
Eina_Bool picked;
Evas_Real z;
Evas_Canvas3D_Node *node;
Evas_Canvas3D_Mesh *mesh;
Evas_Real u, v;
Evas_Real s, t;
};
/* General types - used for script type chceking */
#define OPAQUE_TYPE(type) struct __##type { int a; }; \
typedef struct __##type type
@ -1005,7 +607,6 @@ struct _Evas_Map
struct _Evas_Object_Proxy_Data
{
Eina_List *proxies;
Eina_List *proxy_textures;
void *surface;
int w,h;
Eina_List *src_event_in;
@ -1033,12 +634,6 @@ struct _Evas_Object_Map_Data
RGBA_Map *spans;
};
struct _Evas_Object_3D_Data
{
void *surface;
int w, h;
};
// Mask clipper information
struct _Evas_Object_Mask_Data
{
@ -1142,7 +737,6 @@ struct _Evas_Object_Protected_Data
// Eina_Cow pointer be careful when writing to it
const Evas_Object_Proxy_Data *proxy;
const Evas_Object_Map_Data *map;
const Evas_Object_3D_Data *data_3d;
const Evas_Object_Mask_Data *mask;
const Evas_Object_Events_Data *events;
@ -1490,29 +1084,6 @@ struct _Evas_Func
void (*context_flush) (void *engine);
/* 3D features */
void *(*drawable_new) (void *engine, int w, int h, int alpha);
void (*drawable_free) (void *engine, void *drawable);
void (*drawable_size_get) (void *engine, void *drawable, int *w, int *h);
void *(*image_drawable_set) (void *engine, void *image, void *drawable);
void (*drawable_texture_rendered_pixels_get) (unsigned int tex, int x, int y, int w, int h, void *drawable EINA_UNUSED, void *data);
void (*drawable_scene_render) (void *engine, void *data, void *drawable, void *scene_data);
Eina_Bool (*drawable_scene_render_to_texture) (void *engine, void *drawable, void *scene_data);
int (*drawable_texture_color_pick_id_get) (void *drawable);
int (*drawable_texture_target_id_get) (void *drawable);
void (*drawable_texture_pixel_color_get) (unsigned int tex EINA_UNUSED, int x, int y, Evas_Color *color, void *drawable);
void *(*texture_new) (void *engine, Eina_Bool use_atlas);
void (*texture_free) (void *engine, void *texture);
void (*texture_size_get) (void *engine, void *texture, int *w, int *h);
void (*texture_wrap_set) (void *engine, void *texture, Evas_Canvas3D_Wrap_Mode s, Evas_Canvas3D_Wrap_Mode t);
void (*texture_wrap_get) (void *engine, void *texture, Evas_Canvas3D_Wrap_Mode *s, Evas_Canvas3D_Wrap_Mode *t);
void (*texture_filter_set) (void *engine, void *texture, Evas_Canvas3D_Texture_Filter min, Evas_Canvas3D_Texture_Filter mag);
void (*texture_filter_get) (void *engine, void *texture, Evas_Canvas3D_Texture_Filter *min, Evas_Canvas3D_Texture_Filter *mag);
void (*texture_image_set) (void *engine, void *texture, void *image);
void *(*texture_image_get) (void *engine, void *texture);
Ector_Surface *(*ector_create) (void *engine);
void (*ector_destroy) (void *engine, Ector_Surface *surface);
Ector_Buffer *(*ector_buffer_wrap) (void *engine, Evas *e, void *engine_image);
@ -1730,61 +1301,6 @@ Eina_Bool _efl_canvas_object_efl_gfx_entity_size_set_block(Eo *eo_obj, Evas_Obje
void _evas_focus_device_invalidate_cb(void *data, const Efl_Event *ev);
/* Node functions. */
void evas_canvas3d_node_traverse(Evas_Canvas3D_Node *from, Evas_Canvas3D_Node *to, Evas_Canvas3D_Node_Traverse_Type type, Eina_Bool skip, Evas_Canvas3D_Node_Func func, void *data);
void evas_canvas3d_node_tree_traverse(Evas_Canvas3D_Node *root, Evas_Canvas3D_Tree_Traverse_Type type, Eina_Bool skip, Evas_Canvas3D_Node_Func func, void *data);
Eina_Bool evas_canvas3d_node_mesh_collect(Evas_Canvas3D_Node *node, void *data);
Eina_Bool evas_canvas3d_node_color_node_mesh_collect(Evas_Canvas3D_Node *node, void *data);
Eina_Bool evas_canvas3d_node_light_collect(Evas_Canvas3D_Node *node, void *data);
void evas_canvas3d_node_scene_root_add(Evas_Canvas3D_Node *node, Evas_Canvas3D_Scene *scene);
void evas_canvas3d_node_scene_root_del(Evas_Canvas3D_Node *node, Evas_Canvas3D_Scene *scene);
void evas_canvas3d_node_scene_camera_add(Evas_Canvas3D_Node *node, Evas_Canvas3D_Scene *scene);
void evas_canvas3d_node_scene_camera_del(Evas_Canvas3D_Node *node, Evas_Canvas3D_Scene *scene);
Eina_Bool node_aabb_update(Evas_Canvas3D_Node *node, void *data EINA_UNUSED);
/* Camera functions. */
void evas_canvas3d_camera_node_add(Evas_Canvas3D_Camera *camera, Evas_Canvas3D_Node *node);
void evas_canvas3d_camera_node_del(Evas_Canvas3D_Camera *camera, Evas_Canvas3D_Node *node);
/* Light functions. */
void evas_canvas3d_light_node_add(Evas_Canvas3D_Light *light, Evas_Canvas3D_Node *node);
void evas_canvas3d_light_node_del(Evas_Canvas3D_Light *light, Evas_Canvas3D_Node *node);
/* Mesh functions. */
void evas_canvas3d_mesh_node_add(Evas_Canvas3D_Mesh *mesh, Evas_Canvas3D_Node *node);
void evas_canvas3d_mesh_node_del(Evas_Canvas3D_Mesh *mesh, Evas_Canvas3D_Node *node);
void evas_canvas3d_mesh_interpolate_position_get(Eina_Vector3 *out, const Evas_Canvas3D_Vertex_Buffer *pos0, const Evas_Canvas3D_Vertex_Buffer *pos1, Evas_Real weight, int index);
void evas_canvas3d_mesh_interpolate_vertex_buffer_get(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Canvas3D_Vertex_Attrib attrib, Evas_Canvas3D_Vertex_Buffer *buffer0, Evas_Canvas3D_Vertex_Buffer *buffer1, Evas_Real *weight);
void evas_canvas3d_mesh_file_md2_set(Evas_Canvas3D_Mesh *mesh, const char *file);
void evas_canvas3d_mesh_save_obj(Evas_Canvas3D_Mesh *mesh, const char *file, Evas_Canvas3D_Mesh_Frame *f);
void evas_canvas3d_mesh_file_obj_set(Evas_Canvas3D_Mesh *mesh, const char *file);
Eina_Bool evas_canvas3d_mesh_aabb_add_to_frame(Evas_Canvas3D_Mesh_Data *pd, int frame, int stride);
void evas_canvas3d_mesh_file_eet_set(Evas_Canvas3D_Mesh *mesh, const char *file);
void evas_canvas3d_mesh_save_eet(Evas_Canvas3D_Mesh *mesh, const char *file, Evas_Canvas3D_Mesh_Frame *f);
void evas_canvas3d_mesh_file_ply_set(Evas_Canvas3D_Mesh *mesh, const char *file);
void evas_canvas3d_mesh_save_ply(Evas_Canvas3D_Mesh *mesh, const char *file, Evas_Canvas3D_Mesh_Frame *f);
/* Texture functions. */
void evas_canvas3d_texture_material_add(Evas_Canvas3D_Texture *texture, Evas_Canvas3D_Material *material);
void evas_canvas3d_texture_material_del(Evas_Canvas3D_Texture *texture, Evas_Canvas3D_Material *material);
/* Material functions. */
void evas_canvas3d_material_mesh_add(Evas_Canvas3D_Material *material, Evas_Canvas3D_Mesh *mesh);
void evas_canvas3d_material_mesh_del(Evas_Canvas3D_Material *material, Evas_Canvas3D_Mesh *mesh);
/* Scene functions. */
void evas_canvas3d_scene_data_init(Evas_Canvas3D_Scene_Public_Data *data);
void evas_canvas3d_scene_data_fini(Evas_Canvas3D_Scene_Public_Data *data);
/* Eet saver/loader functions */
Evas_Canvas3D_File_Eet *_evas_canvas3d_eet_file_new(void);
Eet_Data_Descriptor* _evas_canvas3d_eet_file_get();
void _evas_canvas3d_eet_file_init();
void _evas_canvas3d_eet_descriptor_shutdown();
void _evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file);
/* Filters */
void evas_filter_init(void);
void evas_filter_shutdown(void);
@ -1797,29 +1313,6 @@ void _efl_gfx_mapping_update(Eo *eo_obj);
/* Ector */
Ector_Surface *evas_ector_get(Evas_Public_Data *evas);
/* Temporary save/load functions */
void evas_common_load_model_from_file(Evas_Canvas3D_Mesh *model, const char *file);
void evas_common_load_model_from_eina_file(Evas_Canvas3D_Mesh *model, const Eina_File *file);
void evas_common_save_model_to_file(const Evas_Canvas3D_Mesh *model, const char *file, Evas_Canvas3D_Mesh_Frame *f);
void evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file);
void evas_model_load_file_md2(Evas_Canvas3D_Mesh *mesh, Eina_File *file);
void evas_model_load_file_obj(Evas_Canvas3D_Mesh *mesh, Eina_File *file);
void evas_model_load_file_ply(Evas_Canvas3D_Mesh *mesh, Eina_File *file);
void evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh, const char *file, Evas_Canvas3D_Mesh_Frame *f);
void evas_model_save_file_obj(const Evas_Canvas3D_Mesh *mesh, const char *file, Evas_Canvas3D_Mesh_Frame *f);
void evas_model_save_file_ply(const Evas_Canvas3D_Mesh *mesh, const char *file, Evas_Canvas3D_Mesh_Frame *f);
/* Primitives functions */
void evas_common_set_model_from_primitive(Evas_Canvas3D_Mesh *model, int frame, Evas_Canvas3D_Primitive_Data *primitive);
void evas_model_set_from_square_primitive(Evas_Canvas3D_Mesh *mesh, int frame);
void evas_model_set_from_cube_primitive(Evas_Canvas3D_Mesh *mesh, int frame);
void evas_model_set_from_cylinder_primitive(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Canvas3D_Primitive_Mode mode, int precision, Eina_Vector2 tex_scale);
void evas_model_set_from_cone_primitive(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Canvas3D_Primitive_Mode mode, int precision, Eina_Vector2 tex_scale);
void evas_model_set_from_sphere_primitive(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Canvas3D_Primitive_Mode mode, int precision, Eina_Vector2 tex_scale);
void evas_model_set_from_torus_primitive(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Real ratio, int precision, Eina_Vector2 tex_scale);
void evas_model_set_from_surface_primitive(Evas_Canvas3D_Mesh *mesh, int frame, Evas_Canvas3D_Surface_Func func, int precision, Eina_Vector2 tex_scale);
void evas_model_set_from_terrain_primitive(Evas_Canvas3D_Mesh *mesh, int frame, int precision, Eina_Vector2 tex_scale);
/* Filter functions */
Eina_Bool evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj, void *engine, void *output, void *context, void *surface, int x, int y, Eina_Bool do_async, Eina_Bool alpha);
@ -1963,8 +1456,6 @@ extern Eina_Cow *evas_object_proxy_cow;
extern Eina_Cow *evas_object_map_cow;
extern Eina_Cow *evas_object_state_cow;
extern Eina_Cow *evas_object_3d_cow;
extern Eina_Cow *evas_object_image_pixels_cow;
extern Eina_Cow *evas_object_image_load_opts_cow;
extern Eina_Cow *evas_object_image_state_cow;

View File

@ -47,10 +47,6 @@ evas_vg_loaders_file = [
evas_vg_savers_file = ['eet', 'svg']
evas_model_savers_file = ['eet', 'obj', 'ply']
evas_model_loaders_file = ['eet', 'md2', 'obj', 'ply']
rel_evas_modules = join_paths('..', '..', '..', 'modules', 'evas', 'engines', 'software_generic')
evas_deps = [eo, eet, eina, efl, emile, ector, ecore, buildsystem, intl]
pub_eo_file_target = []
@ -130,8 +126,6 @@ evas_header_src = [
evas_include_directories += [
include_directories('.'),
include_directories('common'),
include_directories('common3d'),
include_directories(join_paths('common3d', 'save_load')),
include_directories('include'),
include_directories('filters'),
vg_common_inc_dir
@ -181,7 +175,6 @@ subdir('canvas')
subdir('gesture')
subdir('filters')
subdir('cache')
subdir('common3d')
subdir('file')
subdir('vg')
@ -286,22 +279,6 @@ foreach loader : evas_vg_savers_file
endif
endforeach
foreach loader : evas_model_loaders_file
file = join_paths(meson.source_root(), 'src', 'modules', 'evas', 'model_loaders', loader, 'evas_model_load_'+loader+'.c')
evas_static_list += [declare_dependency(
sources: file,
)]
endforeach
foreach loader : evas_model_savers_file
file = join_paths(meson.source_root(), 'src', 'modules', 'evas', 'model_savers', loader, 'evas_model_save_'+loader+'.c')
evas_static_list += [declare_dependency(
sources: file,
)]
endforeach
evas_lib = library('evas',
include_directories: evas_include_directories + [vg_common_inc_dir],
sources : [evas_src, pub_eo_file_target, priv_eo_file_target],

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +0,0 @@
#ifndef EVAS_GL_COMMON_H
# error You shall not include this header directly
#endif
typedef struct _E3D_Texture E3D_Texture;
typedef struct _E3D_Drawable E3D_Drawable;
typedef struct _E3D_Renderer E3D_Renderer;
/* Texture */
E3D_Texture *e3d_texture_new(Eina_Bool use_atlas);
void e3d_texture_free(E3D_Texture *texture);
void e3d_texture_size_get(const E3D_Texture *texture, int *w, int *h);
void e3d_texture_set(Evas_Engine_GL_Context *gc, E3D_Texture *texture, Evas_GL_Image *im);
Evas_GL_Image *e3d_texture_get(E3D_Texture *texture);
void e3d_texture_import(E3D_Texture *texture, GLuint tex);
Eina_Bool e3d_texture_is_imported_get(const E3D_Texture *texture);
void e3d_texture_wrap_set(E3D_Texture *texture, Evas_Canvas3D_Wrap_Mode s, Evas_Canvas3D_Wrap_Mode t);
void e3d_texture_wrap_get(const E3D_Texture *texture, Evas_Canvas3D_Wrap_Mode *s, Evas_Canvas3D_Wrap_Mode *t);
void e3d_texture_filter_set(E3D_Texture *texture, Evas_Canvas3D_Texture_Filter min, Evas_Canvas3D_Texture_Filter mag);
void e3d_texture_filter_get(const E3D_Texture *texture, Evas_Canvas3D_Texture_Filter *min, Evas_Canvas3D_Texture_Filter *mag);
/* 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_Canvas3D_Scene_Public_Data *data);
Eina_Bool e3d_drawable_scene_render_to_texture(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_Canvas3D_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);
GLuint e3d_drawable_texture_color_pick_id_get(E3D_Drawable *drawable);
void e3d_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y, Evas_Color *color, void *drawable);
GLenum e3d_drawable_format_get(E3D_Drawable *drawable);
void e3d_drawable_texture_rendered_pixels_get(GLuint tex EINA_UNUSED, int x, int y, int w, int h,
void *drawable EINA_UNUSED, void *data);
/* Renderer */
E3D_Renderer *e3d_renderer_new(void);
void e3d_renderer_free(E3D_Renderer *renderer);

View File

@ -1,183 +0,0 @@
#ifndef EVAS_GL_3D_PRIVATE_H
#define EVAS_GL_3D_PRIVATE_H
#include "evas_gl_common.h"
typedef struct _E3D_Program E3D_Program;
typedef struct _E3D_Draw_Data E3D_Draw_Data;
typedef unsigned long E3D_Shader_Flag;
// NOTE: order here should be equal with flag names in file evas_gl_3d_shader.c
#define E3D_SHADER_FLAG_NORMALIZE_NORMALS (1 << 0)
#define E3D_SHADER_FLAG_VERTEX_POSITION (1 << 1)
#define E3D_SHADER_FLAG_VERTEX_POSITION_BLEND (1 << 2)
#define E3D_SHADER_FLAG_VERTEX_NORMAL (1 << 3)
#define E3D_SHADER_FLAG_VERTEX_NORMAL_BLEND (1 << 4)
#define E3D_SHADER_FLAG_VERTEX_TANGENT (1 << 5)
#define E3D_SHADER_FLAG_VERTEX_TANGENT_BLEND (1 << 6)
#define E3D_SHADER_FLAG_VERTEX_COLOR (1 << 7)
#define E3D_SHADER_FLAG_VERTEX_COLOR_BLEND (1 << 8)
#define E3D_SHADER_FLAG_VERTEX_TEXCOORD (1 << 9)
#define E3D_SHADER_FLAG_VERTEX_TEXCOORD_BLEND (1 << 10)
#define E3D_SHADER_FLAG_LIGHT_DIRECTIONAL (1 << 11)
#define E3D_SHADER_FLAG_LIGHT_SPOT (1 << 12)
#define E3D_SHADER_FLAG_LIGHT_ATTENUATION (1 << 13)
#define E3D_SHADER_FLAG_AMBIENT (1 << 14)
#define E3D_SHADER_FLAG_DIFFUSE (1 << 15)
#define E3D_SHADER_FLAG_SPECULAR (1 << 16)
#define E3D_SHADER_FLAG_EMISSION (1 << 17)
#define E3D_SHADER_FLAG_DIFFUSE_TEXTURE (1 << 18)
#define E3D_SHADER_FLAG_AMBIENT_TEXTURE (1 << 19)
#define E3D_SHADER_FLAG_SPECULAR_TEXTURE (1 << 20)
#define E3D_SHADER_FLAG_EMISSION_TEXTURE (1 << 21)
#define E3D_SHADER_FLAG_NORMAL_TEXTURE (1 << 22)
#define E3D_SHADER_FLAG_DIFFUSE_TEXTURE_BLEND (1 << 23)
#define E3D_SHADER_FLAG_AMBIENT_TEXTURE_BLEND (1 << 24)
#define E3D_SHADER_FLAG_SPECULAR_TEXTURE_BLEND (1 << 25)
#define E3D_SHADER_FLAG_EMISSION_TEXTURE_BLEND (1 << 26)
#define E3D_SHADER_FLAG_NORMAL_TEXTURE_BLEND (1 << 27)
#define E3D_SHADER_FLAG_FOG_ENABLED (1 << 28)
#define E3D_SHADER_FLAG_ALPHA_TEST_ENABLED (1 << 29)
#define E3D_SHADER_FLAG_SHADOWED (1 << 30)
#define E3D_SHADER_FLAG_COUNT 31
static inline Eina_Bool
_flags_need_tex_coord(E3D_Shader_Flag flags)
{
return (flags & E3D_SHADER_FLAG_AMBIENT_TEXTURE) ||
(flags & E3D_SHADER_FLAG_DIFFUSE_TEXTURE) ||
(flags & E3D_SHADER_FLAG_SPECULAR_TEXTURE) ||
(flags & E3D_SHADER_FLAG_EMISSION_TEXTURE) ||
(flags & E3D_SHADER_FLAG_NORMAL_TEXTURE);
}
struct _E3D_Draw_Data
{
E3D_Shader_Flag flags;
Evas_Canvas3D_Shader_Mode mode;
Eina_Matrix4 matrix_mvp;
Eina_Matrix4 matrix_mv;
Eina_Matrix3 matrix_normal;
Eina_Matrix4 matrix_light;
struct {
Evas_Canvas3D_Vertex_Buffer vertex0;
Evas_Canvas3D_Vertex_Buffer vertex1;
Evas_Real weight;
} vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_COUNT];
Evas_Canvas3D_Vertex_Assembly assembly;
int vertex_count;
int index_count;
Evas_Canvas3D_Index_Format index_format;
const void *indices;
GLint texture_count;
struct {
Evas_Color color;
GLint sampler0;
GLint sampler1;
E3D_Texture *tex0;
E3D_Texture *tex1;
Evas_Real texture_weight;
} materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT];
Evas_Real shininess;
GLint smap_sampler;
GLint colortex_sampler;
Evas_Canvas3D_Blend_Func blend_sfactor;
Evas_Canvas3D_Blend_Func blend_dfactor;
Eina_Bool blending : 1;
Evas_Canvas3D_Comparison alpha_comparison;
Evas_Real alpha_ref_value;
Eina_Bool alpha_test_enabled :1;
struct {
Eina_Quaternion position;
Eina_Vector3 spot_dir;
Evas_Real spot_exp;
Evas_Real spot_cutoff_cos;
Eina_Vector3 atten;
Evas_Color ambient;
Evas_Color diffuse;
Evas_Color specular;
} light;
Evas_Color fog_color;
Evas_Color color_pick_key;
/*Sets of the quality of shadow rendering*/
Evas_Real pcf_step;
Evas_Real pcf_size;
Evas_Real constant_bias;
Eina_Bool render_to_texture;
Evas_Real frame_size_h;
Evas_Real frame_size_w;
};
struct _E3D_Texture
{
/*Offset for atlasses*/
int x, y;
int w, h;
Evas_GL_Image *surface;
/*Tranformation matrix, use it for adjusting texture unit coordinates*/
Eina_Matrix3 trans;
GLuint tex;
Eina_Bool wrap_dirty;
GLenum wrap_s;
GLenum wrap_t;
Eina_Bool filter_dirty;
GLenum filter_min;
GLenum filter_mag;
/*Use atlas for generation texture unit, @EINA_TRUE by default*/
Eina_Bool atlas_enable;
};
struct _E3D_Drawable
{
int w, h;
int alpha;
GLenum format;
GLenum depth_format;
GLenum stencil_format;
GLuint tex;
GLuint fbo;
GLuint depth_stencil_buf;
GLuint depth_buf;
GLuint stencil_buf;
GLuint texDepth;
GLuint texcolorpick;
GLuint color_pick_fb_id;
};
/* Texture internal functions. */
void e3d_texture_param_update(E3D_Texture *texture);
/* Program */
E3D_Program *e3d_program_new(Evas_Canvas3D_Shader_Mode mode, E3D_Shader_Flag flags);
void e3d_program_free(E3D_Program *program);
GLuint e3d_program_id_get(const E3D_Program *program);
Evas_Canvas3D_Shader_Mode e3d_program_shader_mode_get(const E3D_Program *program);
E3D_Shader_Flag e3d_program_shader_flags_get(const E3D_Program *program);
void e3d_program_uniform_upload(E3D_Program *program, const E3D_Draw_Data *data);
/* Renderer */
void e3d_renderer_target_set(E3D_Renderer *renderer, E3D_Drawable *target);
void e3d_renderer_viewport_set(E3D_Renderer *renderer, int x, int y, int w, int h);
void e3d_renderer_clear(E3D_Renderer *renderer, const Evas_Color *color);
void e3d_renderer_draw(E3D_Renderer *renderer, E3D_Draw_Data *data);
void e3d_renderer_flush(E3D_Renderer *renderer);
void e3d_renderer_color_pick_target_set(E3D_Renderer *renderer, E3D_Drawable *drawable);
Eina_Bool e3d_renderer_rendering_to_texture_get(E3D_Renderer *renderer);
GLint e3d_renderer_sampler_colortexture_get(E3D_Renderer *renderer);
GLint e3d_renderer_sampler_shadowmap_get(E3D_Renderer *renderer);
#endif /* EVAS_GL_3D_PRIVATE_H */

View File

@ -1,428 +0,0 @@
#include "evas_gl_private.h"
#include "evas_gl_3d_private.h"
#define E3D_MAX_TEXTURE_COUNT 8
#define E3D_MAX_VERTEX_ATTRIB_COUNT 8
struct _E3D_Renderer
{
Eina_List *programs;
GLuint fbo;
GLuint program;
E3D_Texture *textures[E3D_MAX_TEXTURE_COUNT];
Eina_Bool vertex_attrib_enable[E3D_MAX_VERTEX_ATTRIB_COUNT];
Eina_Bool depth_test_enable;
GLuint texDepth;
GLint smap_sampler;
Eina_Bool render_to_texture;
GLuint texcolorpick;
GLint colortex_sampler;
};
static inline GLenum
_gl_assembly_get(Evas_Canvas3D_Vertex_Assembly assembly)
{
switch (assembly)
{
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_POINTS:
return GL_POINTS;
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES:
return GL_LINES;
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINE_STRIP:
return GL_LINE_STRIP;
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINE_LOOP:
return GL_LINE_LOOP;
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES:
return GL_TRIANGLES;
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP:
return GL_TRIANGLE_STRIP;
case EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLE_FAN:
return GL_TRIANGLE_FAN;
default:
return GL_NONE;
}
}
static inline GLenum
_gl_blend_func_get(Evas_Canvas3D_Blend_Func blend_func)
{
switch (blend_func)
{
case EVAS_CANVAS3D_BLEND_FUNC_ZERO:
return GL_ZERO;
case EVAS_CANVAS3D_BLEND_FUNC_ONE:
return GL_ONE;
case EVAS_CANVAS3D_BLEND_FUNC_SRC_COLOR:
return GL_SRC_COLOR;
case EVAS_CANVAS3D_BLEND_FUNC_ONE_MINUS_SRC_COLOR:
return GL_ONE_MINUS_SRC_COLOR;
case EVAS_CANVAS3D_BLEND_FUNC_DST_COLOR:
return GL_DST_COLOR;
case EVAS_CANVAS3D_BLEND_FUNC_ONE_MINUS_DST_COLOR:
return GL_ONE_MINUS_DST_COLOR;
case EVAS_CANVAS3D_BLEND_FUNC_SRC_ALPHA:
return GL_SRC_ALPHA;
case EVAS_CANVAS3D_BLEND_FUNC_ONE_MINUS_SRC_ALPHA:
return GL_ONE_MINUS_SRC_ALPHA;
case EVAS_CANVAS3D_BLEND_FUNC_DST_ALPHA:
return GL_DST_ALPHA;
case EVAS_CANVAS3D_BLEND_FUNC_ONE_MINUS_DST_ALPHA:
return GL_ONE_MINUS_DST_ALPHA;
case EVAS_CANVAS3D_BLEND_FUNC_CONSTANT_COLOR:
return GL_CONSTANT_COLOR;
case EVAS_CANVAS3D_BLEND_FUNC_ONE_MINUS_CONSTANT_COLOR:
return GL_ONE_MINUS_CONSTANT_COLOR;
case EVAS_CANVAS3D_BLEND_FUNC_CONSTANT_ALPHA:
return GL_CONSTANT_ALPHA;
case EVAS_CANVAS3D_BLEND_FUNC_ONE_MINUS_CONSTANT_ALPHA:
return GL_ONE_MINUS_CONSTANT_ALPHA;
case EVAS_CANVAS3D_BLEND_FUNC_SRC_ALPHA_SATURATE:
return GL_SRC_ALPHA_SATURATE;
default:
return GL_ZERO;
}
}
#ifndef GL_GLES
static inline GLenum
_gl_comparison_func_get(Evas_Canvas3D_Comparison comparison_func)
{
switch (comparison_func)
{
case EVAS_CANVAS3D_COMPARISON_NEVER:
return GL_NEVER;
case EVAS_CANVAS3D_COMPARISON_LESS:
return GL_LESS;
case EVAS_CANVAS3D_COMPARISON_EQUAL:
return GL_EQUAL;
case EVAS_CANVAS3D_COMPARISON_LEQUAL:
return GL_LEQUAL;
case EVAS_CANVAS3D_COMPARISON_GREATER:
return GL_GREATER;
case EVAS_CANVAS3D_COMPARISON_NOTEQUAL:
return GL_NOTEQUAL;
case EVAS_CANVAS3D_COMPARISON_GEQUAL:
return GL_GEQUAL;
case EVAS_CANVAS3D_COMPARISON_ALWAYS:
return GL_ALWAYS;
default:
return GL_ALWAYS;
}
}
#endif
static inline void
_renderer_vertex_attrib_array_enable(E3D_Renderer *renderer, int index)
{
if (renderer->vertex_attrib_enable[index])
return;
glEnableVertexAttribArray(index);
renderer->vertex_attrib_enable[index] = EINA_TRUE;
}
static inline void
_renderer_vertex_attrib_array_disable(E3D_Renderer *renderer, int index)
{
if (!renderer->vertex_attrib_enable[index])
return;
glDisableVertexAttribArray(index);
renderer->vertex_attrib_enable[index] = EINA_FALSE;
}
static inline void
_renderer_vertex_attrib_pointer_set(E3D_Renderer *renderer EINA_UNUSED, int index,
const Evas_Canvas3D_Vertex_Buffer *buffer)
{
glVertexAttribPointer(index, buffer->element_count, GL_FLOAT,
GL_FALSE, buffer->stride, buffer->data);
}
static inline void
_renderer_elements_draw(E3D_Renderer *renderer EINA_UNUSED, Evas_Canvas3D_Vertex_Assembly assembly,
int count, Evas_Canvas3D_Index_Format format, const void *indices)
{
GLenum mode = _gl_assembly_get(assembly);
if (format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_BYTE)
glDrawElements(mode, count, GL_UNSIGNED_BYTE, indices);
else if (format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
glDrawElements(mode, count, GL_UNSIGNED_SHORT, indices);
}
static inline void
_renderer_array_draw(E3D_Renderer *renderer EINA_UNUSED,
Evas_Canvas3D_Vertex_Assembly assembly, int count)
{
GLenum mode = _gl_assembly_get(assembly);
glDrawArrays(mode, 0, count);
}
static inline void
_renderer_program_use(E3D_Renderer *renderer ,E3D_Program *program)
{
GLuint prog = e3d_program_id_get(program);
if (renderer->program != prog)
{
glUseProgram(prog);
renderer->program = prog;
}
}
static inline void
_renderer_texture_bind(E3D_Renderer *renderer, E3D_Draw_Data *data)
{
int i;
for (i = 0; i < EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT; i++)
{
if (data->materials[i].tex0)
{
if (renderer->textures[data->materials[i].sampler0] != data->materials[i].tex0)
{
glActiveTexture(GL_TEXTURE0 + data->materials[i].sampler0);
glBindTexture(GL_TEXTURE_2D, data->materials[i].tex0->tex);
e3d_texture_param_update(data->materials[i].tex0);
renderer->textures[data->materials[i].sampler0] = data->materials[i].tex0;
}
}
if (data->materials[i].tex1)
{
if (renderer->textures[data->materials[i].sampler1] != data->materials[i].tex1)
{
glActiveTexture(GL_TEXTURE0 + data->materials[i].sampler1);
glBindTexture(GL_TEXTURE_2D, data->materials[i].tex1->tex);
e3d_texture_param_update(data->materials[i].tex1);
renderer->textures[data->materials[i].sampler1] = data->materials[i].tex1;
}
}
}
if ((data->flags & E3D_SHADER_FLAG_SHADOWED) && (renderer->smap_sampler != data->smap_sampler))
{
glActiveTexture(GL_TEXTURE0 + data->smap_sampler);
glBindTexture(GL_TEXTURE_2D, renderer->texDepth);
renderer->smap_sampler = data->smap_sampler;
}
if (renderer->render_to_texture)
{
glActiveTexture(GL_TEXTURE0 + data->colortex_sampler);
glBindTexture(GL_TEXTURE_2D, renderer->texcolorpick);
renderer->colortex_sampler = data->colortex_sampler;
}
}
static inline void
_renderer_depth_test_enable(E3D_Renderer *renderer, Eina_Bool enable)
{
if (renderer->depth_test_enable != enable)
{
if (enable)
{
glEnable(GL_DEPTH_TEST);
/* Use default depth func. */
}
else
{
glDisable(GL_DEPTH_TEST);
}
renderer->depth_test_enable = enable;
}
}
E3D_Renderer *
e3d_renderer_new(void)
{
E3D_Renderer *renderer = NULL;
renderer = (E3D_Renderer *)calloc(1, sizeof(E3D_Renderer));
if (renderer == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
return renderer;
}
void
e3d_renderer_free(E3D_Renderer *renderer)
{
Eina_List *l;
E3D_Program *p;
EINA_LIST_FOREACH(renderer->programs, l, p)
{
e3d_program_free(p);
}
eina_list_free(renderer->programs);
}
void
e3d_renderer_target_set(E3D_Renderer *renderer, E3D_Drawable *target)
{
if (renderer->fbo == target->fbo)
return;
glBindFramebuffer(GL_FRAMEBUFFER, target->fbo);
glViewport(0, 0, target->w, target->h);
renderer->fbo = target->fbo;
renderer->texDepth = target->texDepth;
renderer->texcolorpick = target->texcolorpick;
renderer->render_to_texture = EINA_FALSE;
}
void
e3d_renderer_color_pick_target_set(E3D_Renderer *renderer, E3D_Drawable *drawable)
{
glBindFramebuffer(GL_FRAMEBUFFER, drawable->color_pick_fb_id);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, drawable->texcolorpick, 0);
#ifdef GL_GLES
glBindRenderbuffer(GL_RENDERBUFFER, drawable->depth_stencil_buf);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_TEXTURE_2D, drawable->depth_stencil_buf, 0);
#else
glBindRenderbuffer(GL_RENDERBUFFER, drawable->depth_stencil_buf);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, drawable->depth_stencil_buf);
#endif
glViewport(0, 0, drawable->w, drawable->h);
renderer->texDepth = drawable->texDepth;
renderer->texcolorpick = drawable->texcolorpick;
renderer->render_to_texture = EINA_TRUE;
}
Eina_Bool
e3d_renderer_rendering_to_texture_get(E3D_Renderer *renderer)
{
return renderer->render_to_texture;
}
void
e3d_renderer_clear(E3D_Renderer *renderer EINA_UNUSED, const Evas_Color *color)
{
glClearColor(color->r, color->g, color->b, color->a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void
e3d_renderer_draw(E3D_Renderer *renderer, E3D_Draw_Data *data)
{
Eina_List *l;
E3D_Program *program = NULL, *p;
int i, index = 0;
_renderer_depth_test_enable(renderer, EINA_TRUE);
EINA_LIST_FOREACH(renderer->programs, l, p)
{
if (e3d_program_shader_mode_get(p) == data->mode &&
e3d_program_shader_flags_get(p) == data->flags)
{
program = p;
break;
}
}
if (program == NULL)
{
program = e3d_program_new(data->mode, data->flags);
if (program == NULL)
{
ERR("Failed to create shader program.");
return;
}
renderer->programs = eina_list_append(renderer->programs, program);
}
_renderer_program_use(renderer, program);
e3d_program_uniform_upload(program, data);
_renderer_texture_bind(renderer, data);
/* Set up vertex attrib pointers. */
index = 0;
for (i = 0; i < EVAS_CANVAS3D_VERTEX_ATTRIB_COUNT; i++)
{
const Evas_Canvas3D_Vertex_Buffer *buffer;
buffer = &data->vertices[i].vertex0;
if (buffer->data != NULL)
{
_renderer_vertex_attrib_array_enable(renderer, index);
_renderer_vertex_attrib_pointer_set(renderer, index, buffer);
index++;
}
buffer = &data->vertices[i].vertex1;
if (buffer->data != NULL)
{
_renderer_vertex_attrib_array_enable(renderer, index);
_renderer_vertex_attrib_pointer_set(renderer, index, buffer);
index++;
}
}
while (index < E3D_MAX_VERTEX_ATTRIB_COUNT)
_renderer_vertex_attrib_array_disable(renderer, index++);
if (data->blending)
{
glEnable(GL_BLEND);
glBlendFunc(_gl_blend_func_get(data->blend_sfactor), _gl_blend_func_get(data->blend_dfactor));
}
else glDisable(GL_BLEND);
#ifndef GL_GLES
if (data->alpha_test_enabled)
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(_gl_comparison_func_get(data->alpha_comparison),
(GLclampf)data->alpha_ref_value);
}
else glDisable(GL_ALPHA_TEST);
#endif
if (data->indices)
{
_renderer_elements_draw(renderer, data->assembly, data->index_count,
data->index_format, data->indices);
}
else
{
_renderer_array_draw(renderer, data->assembly, data->vertex_count);
}
}
void
e3d_renderer_flush(E3D_Renderer *renderer EINA_UNUSED)
{
glFlush();
}
GLint
e3d_renderer_sampler_colortexture_get(E3D_Renderer *renderer)
{
return renderer->colortex_sampler;
}
GLint
e3d_renderer_sampler_shadowmap_get(E3D_Renderer *renderer)
{
return renderer->smap_sampler;
}

View File

@ -1,751 +0,0 @@
#include "evas_gl_3d_private.h"
#include "shader_3d/evas_gl_3d_shaders.x"
typedef enum _E3D_Uniform
{
E3D_UNIFORM_MATRIX_MVP,
E3D_UNIFORM_MATRIX_MV,
E3D_UNIFORM_MATRIX_NORMAL,
E3D_UNIFORM_MATRIX_LIGHT,
E3D_UNIFORM_POSITION_WEIGHT,
E3D_UNIFORM_NORMAL_WEIGHT,
E3D_UNIFORM_TANGENT_WEIGHT,
E3D_UNIFORM_COLOR_WEIGHT,
E3D_UNIFORM_TEXCOORD_WEIGHT,
E3D_UNIFORM_TEXTURE_WEIGHT_AMBIENT,
E3D_UNIFORM_TEXTURE_WEIGHT_DIFFUSE,
E3D_UNIFORM_TEXTURE_WEIGHT_SPECULAR,
E3D_UNIFORM_TEXTURE_WEIGHT_EMISSION,
E3D_UNIFORM_TEXTURE_WEIGHT_NORMAL,
E3D_UNIFORM_TEXTURE_AMBIENT0,
E3D_UNIFORM_TEXTURE_DIFFUSE0,
E3D_UNIFORM_TEXTURE_SPECULAR0,
E3D_UNIFORM_TEXTURE_EMISSION0,
E3D_UNIFORM_TEXTURE_NORMAL0,
E3D_UNIFORM_TEXTURE_AMBIENT1,
E3D_UNIFORM_TEXTURE_DIFFUSE1,
E3D_UNIFORM_TEXTURE_SPECULAR1,
E3D_UNIFORM_TEXTURE_EMISSION1,
E3D_UNIFORM_TEXTURE_NORMAL1,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT0,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE0,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR0,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION0,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL0,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT1,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE1,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR1,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION1,
E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL1,
E3D_UNIFORM_SHADOWMAP,
E3D_UNIFORM_SHADOWS_PCF_STEP,
E3D_UNIFORM_SHADOWS_PCF_SIZE,
E3D_UNIFORM_SHADOWS_CONSTANT_BIAS,
E3D_UNIFORM_LIGHT_POSITION,
E3D_UNIFORM_LIGHT_SPOT_DIR,
E3D_UNIFORM_LIGHT_SPOT_EXP,
E3D_UNIFORM_LIGHT_SPOT_CUTOFF_COS,
E3D_UNIFORM_LIGHT_ATTENUATION,
E3D_UNIFORM_LIGHT_AMBIENT,
E3D_UNIFORM_LIGHT_DIFFUSE,
E3D_UNIFORM_LIGHT_SPECULAR,
E3D_UNIFORM_MATERIAL_AMBIENT,
E3D_UNIFORM_MATERIAL_DIFFUSE,
E3D_UNIFORM_MATERIAL_SPECULAR,
E3D_UNIFORM_MATERIAL_EMISSION,
E3D_UNIFORM_MATERIAL_SHININESS,
E3D_UNIFORM_FOG_FACTOR,
E3D_UNIFORM_FOG_COLOR,
E3D_UNIFORM_COLOR_PICK,
E3D_UNIFORM_ALPHATEST_COMPARISON,
E3D_UNIFORM_ALPHATEST_REFVALUE,
E3D_UNIFORM_RENDER_TO_TEXTURE,
E3D_UNIFORM_FRAME_SIZE_H,
E3D_UNIFORM_FRAME_SIZE_W,
E3D_UNIFORM_COUNT,
} E3D_Uniform;
static const char *shader_flag_names[] =
{
"NORMALIZE_NORMALS",
"VERTEX_POSITION",
"VERTEX_POSITION_BLEND",
"VERTEX_NORMAL",
"VERTEX_NORMAL_BLEND",
"VERTEX_TANGENT",
"VERTEX_TANGENT_BLEND",
"VERTEX_COLOR",
"VERTEX_COLOR_BLEND",
"VERTEX_TEXCOORD",
"VERTEX_TEXCOORD_BLEND",
"LIGHT_DIRECTIONAL",
"LIGHT_SPOT",
"LIGHT_ATTENUATION",
"AMBIENT",
"DIFFUSE",
"SPECULAR",
"EMISSION",
"DIFFUSE_TEXTURE",
"AMBIENT_TEXTURE",
"SPECULAR_TEXTURE",
"EMISSION_TEXTURE",
"NORMAL_TEXTURE",
"DIFFUSE_TEXTURE_BLEND",
"AMBIENT_TEXTURE_BLEND",
"SPECULAR_TEXTURE_BLEND",
"EMISSION_TEXTURE_BLEND",
"NORMAL_TEXTURE_BLEND",
"FOG_ENABLED",
"ALPHA_TEST_ENABLED",
"SHADOWED"
};
typedef struct _E3D_Shader_String
{
char *str;
int size;
int count;
} E3D_Shader_String;
struct _E3D_Program
{
GLuint vert;
GLuint frag;
GLuint prog;
E3D_Shader_Flag flags;
Evas_Canvas3D_Shader_Mode mode;
GLint uniform_locations[E3D_UNIFORM_COUNT];
};
static void _shader_string_init(E3D_Shader_String *string)
{
string->str = NULL;
string->size = 0;
string->count = 0;
}
static void _shader_string_fini(E3D_Shader_String *string)
{
if (string->str)
{
free(string->str);
_shader_string_init(string);
}
}
void _shader_string_add(E3D_Shader_String *shader, const char *str)
{
int len;
if (str == NULL)
return;
len = strlen(str);
if ((shader->size - shader->count) < len)
{
int new_size = (shader->count + len) * 2;
char *new_buf = (char *)malloc(new_size + 1);
if (shader->str)
{
memcpy(new_buf, shader->str, sizeof(char) * shader->count);
free(shader->str);
}
shader->str = new_buf;
shader->size = new_size;
}
memcpy(&shader->str[shader->count], str, len + 1);
shader->count += len;
}
void _shader_flags_add(E3D_Shader_String *shader, E3D_Shader_Flag flags)
{
int i;
for (i = 0; i < E3D_SHADER_FLAG_COUNT; i++)
if (flags & (1 << i))
{
int len = strlen("#define ") + strlen(shader_flag_names[i]) + 2;
char str[len];
snprintf(str, len, "#define %s\n", shader_flag_names[i]);
_shader_string_add(shader, str);
}
if(_flags_need_tex_coord(flags))
_shader_string_add(shader, "#define NEED_TEX_COORD\n");
}
static inline Eina_Bool
_shader_compile(GLuint shader, const char *src)
{
GLint ok = 0;
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
if (!ok)
{
GLchar *log_str;
GLint len;
GLsizei info_len;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
log_str = (GLchar *)malloc(len);
glGetShaderInfoLog(shader, len, &info_len, log_str);
ERR("Shader compilation failed: %s", log_str);
DBG("Shader source was:\n%s", src);
free(log_str);
return EINA_FALSE;
}
return EINA_TRUE;
}
static inline void
_program_vertex_attrib_bind(E3D_Program *program)
{
GLint index = 0;
if (program->flags & E3D_SHADER_FLAG_VERTEX_POSITION)
glBindAttribLocation(program->prog, index++, "aPosition0");
if (program->flags & E3D_SHADER_FLAG_VERTEX_POSITION_BLEND)
glBindAttribLocation(program->prog, index++, "aPosition1");
if (program->flags & E3D_SHADER_FLAG_VERTEX_NORMAL)
glBindAttribLocation(program->prog, index++, "aNormal0");
if (program->flags & E3D_SHADER_FLAG_VERTEX_NORMAL_BLEND)
glBindAttribLocation(program->prog, index++, "aNormal1");
if (program->flags & E3D_SHADER_FLAG_VERTEX_TANGENT)
glBindAttribLocation(program->prog, index++, "aTangent0");
if (program->flags & E3D_SHADER_FLAG_VERTEX_TANGENT_BLEND)
glBindAttribLocation(program->prog, index++, "aTangent1");
if (program->flags & E3D_SHADER_FLAG_VERTEX_COLOR)
glBindAttribLocation(program->prog, index++, "aColor0");
if (program->flags & E3D_SHADER_FLAG_VERTEX_COLOR_BLEND)
glBindAttribLocation(program->prog, index++, "aColor1");
if (program->flags & E3D_SHADER_FLAG_VERTEX_TEXCOORD)
glBindAttribLocation(program->prog, index++, "aTexCoord0");
if (program->flags & E3D_SHADER_FLAG_VERTEX_TEXCOORD_BLEND)
glBindAttribLocation(program->prog, index++, "aTexCoord1");
}
static inline Eina_Bool
_program_build(E3D_Program *program, const char *vert_src, const char *frag_src)
{
GLint ok = 0;
/* Create OpenGL vertex & fragment shader object. */
program->vert = glCreateShader(GL_VERTEX_SHADER);
program->frag = glCreateShader(GL_FRAGMENT_SHADER);
/* Commpile vertex shader. */
if (!_shader_compile(program->vert, vert_src))
{
ERR("Faield to compile vertex shader.");
return EINA_FALSE;
}
/* Compile fragment shader. */
if (!_shader_compile(program->frag, frag_src))
{
ERR("Failed to compile fragment shader.");
return EINA_FALSE;
}
/* Create OpenGL program object. */
program->prog = glCreateProgram();
/* Attach shaders. */
glAttachShader(program->prog, program->vert);
glAttachShader(program->prog, program->frag);
_program_vertex_attrib_bind(program);
/* Link program. */
glLinkProgram(program->prog);
/* Check link status. */
glGetProgramiv(program->prog, GL_LINK_STATUS, &ok);
if (!ok)
{
GLchar *log_str;
GLint len = 0;
GLsizei info_len;
glGetProgramiv(program->prog, GL_INFO_LOG_LENGTH, &len);
log_str = (GLchar *)malloc(len);
glGetProgramInfoLog(program->prog, len, &info_len, log_str);
ERR("Shader link failed.\n%s", log_str);
free(log_str);
return EINA_FALSE;
}
return EINA_TRUE;
}
static const char *uniform_names[] =
{
"uMatrixMvp",
"uMatrixModelview",
"uMatrixNormal",
"uMatrixLight",
"uPositionWeight",
"uNormalWeight",
"uTangentWeight",
"uColorWeight",
"uTexCoordWeight",
"uTextureAmbientWeight",
"uTextureDiffuseWeight",
"uTextureSpecularWeight",
"uTextureEmissionWeight",
"uTextureNormalWeight",
"uTextureAmbient0",
"uTextureDiffuse0",
"uTextureSpecular0",
"uTextureEmission0",
"uTextureNormal0",
"uTextureAmbient1",
"uTextureDiffuse1",
"uTextureSpecular1",
"uTextureEmission1",
"uTextureNormal1",
"uTextureMatrixTransformAmbient0",
"uTextureMatrixTransformDiffuse0",
"uTextureMatrixTransformSpecular0",
"uTextureMatrixTransformEmission0",
"uTextureMatrixTransformNormal0",
"uTextureMatrixTransformAmbient1",
"uTextureMatrixTransformDiffuse1",
"uTextureMatrixTransformSpecular1",
"uTextureMatrixTransformEmission1",
"uTextureMatrixTransformNormal1",
"uShadowMap",
"uShadowsPCFStep",
"uShadowsPCFSize",
"uShadowsConstantBias",
"uLightPosition",
"uLightSpotDir",
"uLightSpotExp",
"uLightSpotCutoffCos",
"uLightAtten",
"uLightAmbient",
"uLightDiffuse",
"uLightSpecular",
"uMaterialAmbient",
"uMaterialDiffuse",
"uMaterialSpecular",
"uMaterialEmission",
"uMaterialShininess",
"uFogFactor",
"uFogColor",
"uColorPick",
"uAlphaTestComparison",
"uAlphaTestRefValue",
"uColorTexture",
"uFrameSizeH",
"uFrameSizeW"
};
static inline void
_program_uniform_init(E3D_Program *program)
{
int i;
for (i = 0; i < E3D_UNIFORM_COUNT; i++)
{
program->uniform_locations[i] = glGetUniformLocation(program->prog, uniform_names[i]);
}
}
#define UNIFORM_MATRIX3_FOREACH(m, data) \
m[0] = data.xx; \
m[1] = data.xy; \
m[2] = data.xz; \
m[3] = data.yx; \
m[4] = data.yy; \
m[5] = data.yz; \
m[6] = data.zx; \
m[7] = data.zy; \
m[8] = data.zz;
#define UNIFORM_MATRIX4_FOREACH(m, data) \
m[0] = data.xx; \
m[1] = data.xy; \
m[2] = data.xz; \
m[3] = data.xw; \
m[4] = data.yx; \
m[5] = data.yy; \
m[6] = data.yz; \
m[7] = data.yw; \
m[8] = data.zx; \
m[9] = data.zy; \
m[10] = data.zz; \
m[11] = data.zw; \
m[12] = data.wx; \
m[13] = data.wy; \
m[14] = data.wz; \
m[15] = data.ww;
static inline void
_uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data)
{
#define SET_TEX_COORD_TRANSFORM_MATRIX(attrib, tn) \
if (data->materials[attrib].tex##tn) \
{ \
float m[9]; \
UNIFORM_MATRIX3_FOREACH(m, data->materials[attrib].tex##tn->trans); \
glUniformMatrix3fv(loc, 1, EINA_FALSE, &m[0]); \
}
switch (u)
{
case E3D_UNIFORM_MATRIX_MVP: {
float m[16];
UNIFORM_MATRIX4_FOREACH(m, data->matrix_mvp);
glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]);
break;
}
case E3D_UNIFORM_MATRIX_MV: {
float m[16];
UNIFORM_MATRIX4_FOREACH(m, data->matrix_mv);
glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]);
break;
}
case E3D_UNIFORM_MATRIX_NORMAL: {
float m[9];
UNIFORM_MATRIX3_FOREACH(m, data->matrix_normal);
glUniformMatrix3fv(loc, 1, EINA_FALSE, &m[0]);
break;
}
case E3D_UNIFORM_MATRIX_LIGHT: {
float m[16];
UNIFORM_MATRIX4_FOREACH(m, data->matrix_light);
glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]);
break;
}
case E3D_UNIFORM_POSITION_WEIGHT:
glUniform1f(loc, data->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].weight);
break;
case E3D_UNIFORM_NORMAL_WEIGHT:
glUniform1f(loc, data->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL].weight);
break;
case E3D_UNIFORM_TANGENT_WEIGHT:
glUniform1f(loc, data->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT].weight);
break;
case E3D_UNIFORM_COLOR_WEIGHT:
glUniform1f(loc, data->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR].weight);
break;
case E3D_UNIFORM_TEXCOORD_WEIGHT:
glUniform1f(loc, data->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD].weight);
break;
case E3D_UNIFORM_TEXTURE_WEIGHT_AMBIENT:
glUniform1f(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].texture_weight);
break;
case E3D_UNIFORM_TEXTURE_WEIGHT_DIFFUSE:
glUniform1f(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].texture_weight);
break;
case E3D_UNIFORM_TEXTURE_WEIGHT_SPECULAR:
glUniform1f(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].texture_weight);
break;
case E3D_UNIFORM_TEXTURE_WEIGHT_EMISSION:
glUniform1f(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].texture_weight);
break;
case E3D_UNIFORM_TEXTURE_WEIGHT_NORMAL:
glUniform1f(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL].texture_weight);
break;
case E3D_UNIFORM_TEXTURE_AMBIENT0:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].sampler0);
break;
case E3D_UNIFORM_TEXTURE_DIFFUSE0:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].sampler0);
break;
case E3D_UNIFORM_TEXTURE_SPECULAR0:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].sampler0);
break;
case E3D_UNIFORM_TEXTURE_EMISSION0:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].sampler0);
break;
case E3D_UNIFORM_TEXTURE_NORMAL0:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL].sampler0);
break;
case E3D_UNIFORM_TEXTURE_AMBIENT1:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].sampler1);
break;
case E3D_UNIFORM_TEXTURE_DIFFUSE1:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].sampler1);
break;
case E3D_UNIFORM_TEXTURE_SPECULAR1:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].sampler1);
break;
case E3D_UNIFORM_TEXTURE_EMISSION1:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].sampler1);
break;
case E3D_UNIFORM_TEXTURE_NORMAL1:
glUniform1i(loc, data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL].sampler1);
break;
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT0: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE0: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR0: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 0)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION0: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION, 0)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL0: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, 0)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT1: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 1)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE1: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR1: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION1: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION, 1)
break;
}
case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL1: {
SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, 1)
break;
}
case E3D_UNIFORM_SHADOWMAP:
glUniform1i(loc, data->smap_sampler);
break;
case E3D_UNIFORM_SHADOWS_PCF_STEP:
glUniform1f(loc, data->pcf_step);
break;
case E3D_UNIFORM_SHADOWS_PCF_SIZE:
glUniform1f(loc, data->pcf_size);
break;
case E3D_UNIFORM_SHADOWS_CONSTANT_BIAS:
glUniform1f(loc, data->constant_bias);
break;
case E3D_UNIFORM_LIGHT_POSITION:
glUniform4f(loc, data->light.position.x, data->light.position.y,
data->light.position.z, data->light.position.w);
break;
case E3D_UNIFORM_LIGHT_SPOT_DIR:
glUniform3f(loc, data->light.spot_dir.x, data->light.spot_dir.y, data->light.spot_dir.z);
break;
case E3D_UNIFORM_LIGHT_SPOT_EXP:
glUniform1f(loc, data->light.spot_exp);
break;
case E3D_UNIFORM_LIGHT_SPOT_CUTOFF_COS:
glUniform1f(loc, data->light.spot_cutoff_cos);
break;
case E3D_UNIFORM_LIGHT_ATTENUATION:
glUniform3f(loc, data->light.atten.x, data->light.atten.y, data->light.atten.z);
break;
case E3D_UNIFORM_LIGHT_AMBIENT:
glUniform4f(loc,
data->light.ambient.r, data->light.ambient.g,
data->light.ambient.b, data->light.ambient.a);
break;
case E3D_UNIFORM_LIGHT_DIFFUSE:
glUniform4f(loc,
data->light.diffuse.r, data->light.diffuse.g,
data->light.diffuse.b, data->light.diffuse.a);
break;
case E3D_UNIFORM_LIGHT_SPECULAR:
glUniform4f(loc,
data->light.specular.r, data->light.specular.g,
data->light.specular.b, data->light.specular.a);
break;
case E3D_UNIFORM_MATERIAL_AMBIENT:
glUniform4f(loc,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].color.r,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].color.g,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].color.b,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].color.a);
break;
case E3D_UNIFORM_MATERIAL_DIFFUSE:
glUniform4f(loc,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].color.r,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].color.g,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].color.b,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].color.a);
break;
case E3D_UNIFORM_MATERIAL_SPECULAR:
glUniform4f(loc,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].color.r,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].color.g,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].color.b,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].color.a);
break;
case E3D_UNIFORM_MATERIAL_EMISSION:
glUniform4f(loc,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].color.r,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].color.g,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].color.b,
data->materials[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].color.a);
break;
case E3D_UNIFORM_MATERIAL_SHININESS:
glUniform1f(loc, data->shininess);
break;
case E3D_UNIFORM_FOG_FACTOR:
glUniform1f(loc, data->fog_color.a);
break;
case E3D_UNIFORM_FOG_COLOR:
glUniform4f(loc, data->fog_color.r, data->fog_color.g, data->fog_color.b, 1);
break;
case E3D_UNIFORM_COLOR_PICK:
glUniform4f(loc, data->color_pick_key.r, data->color_pick_key.g,
data->color_pick_key.b, 1.0);
break;
case E3D_UNIFORM_ALPHATEST_COMPARISON:
glUniform1i(loc,
(data->alpha_comparison ? data->alpha_comparison : EVAS_CANVAS3D_COMPARISON_GREATER));
break;
case E3D_UNIFORM_ALPHATEST_REFVALUE:
glUniform1f(loc, (data->alpha_ref_value ? data->alpha_ref_value : 0.0));
break;
case E3D_UNIFORM_RENDER_TO_TEXTURE:
glUniform1i(loc, data->colortex_sampler);
break;
case E3D_UNIFORM_FRAME_SIZE_H:
glUniform1f(loc, data->frame_size_h);
break;
case E3D_UNIFORM_FRAME_SIZE_W:
glUniform1f(loc, data->frame_size_w);
break;
default:
ERR("Invalid uniform ID.");
break;
}
#undef SET_TEX_SHIFT
}
void
e3d_program_uniform_upload(E3D_Program *program, const E3D_Draw_Data *data)
{
int i;
for (i = 0; i < E3D_UNIFORM_COUNT; i++)
{
if (program->uniform_locations[i] != -1)
{
_uniform_upload(i, program->uniform_locations[i], data);
}
}
}
E3D_Program *
e3d_program_new(Evas_Canvas3D_Shader_Mode mode, E3D_Shader_Flag flags)
{
E3D_Shader_String vert, frag;
E3D_Program *program = NULL;
_shader_string_init(&vert);
_shader_string_init(&frag);
program = (E3D_Program *)calloc(1, sizeof(E3D_Program));
if (program == NULL)
{
ERR("Failed to allocate memory.");
return NULL;
}
program->prog = glCreateProgram();
program->vert = glCreateShader(GL_VERTEX_SHADER);
program->frag = glCreateShader(GL_FRAGMENT_SHADER);
program->mode = mode;
program->flags = flags;
_shader_flags_add(&vert, flags);
_shader_string_add(&frag, vert.str);
_shader_string_add(&vert, vertex_shaders[mode]);
_shader_string_add(&frag, fragment_shaders[mode]);
if (! _program_build(program, vert.str, frag.str))
goto error;
_program_uniform_init(program);
_shader_string_fini(&vert);
_shader_string_fini(&frag);
return program;
error:
if (program->prog)
glDeleteProgram(program->prog);
if (program->vert)
glDeleteShader(program->vert);
if (program->frag)
glDeleteShader(program->frag);
_shader_string_fini(&vert);
_shader_string_fini(&frag);
free(program);
return NULL;
}
void
e3d_program_free(E3D_Program *program)
{
glDeleteProgram(program->prog);
glDeleteShader(program->vert);
glDeleteShader(program->frag);
free(program);
}
GLuint
e3d_program_id_get(const E3D_Program *program)
{
return program->prog;
}
Evas_Canvas3D_Shader_Mode
e3d_program_shader_mode_get(const E3D_Program *program)
{
return program->mode;
}
E3D_Shader_Flag
e3d_program_shader_flags_get(const E3D_Program *program)
{
return program->flags;
}

View File

@ -979,8 +979,6 @@ _comp_tex_sub_2d(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int fmt
#endif
#include "evas_gl_3d_common.h"
#undef EAPI
#define EAPI

View File

@ -285,7 +285,6 @@ Much of it is from Mesa, so their copyright is included as well.
#ifndef EGL_PLATFORM_X11_KHR
# define EGL_PLATFORM_X11_KHR 0x31D5
#endif
// Evas_3d require GL_BGR, but that's an extention and will not be necessary once we move to Evas_GL_Image
#ifndef GL_BGR
#define GL_BGR 0x80E0
#endif

View File

@ -1,15 +0,0 @@
uniform vec4 uColorPick;
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
void main()
{
vec4 color = uColorPick;
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#else
gl_FragColor = color;
#endif //ALPHA_TEST_ENABLED
}

View File

@ -1,11 +0,0 @@
uniform mat4 uMatrixMvp;
VERTEX_SHADER_USE_POSITION
void main()
{
VERTEX_SHADER_POSITION
gl_Position = uMatrixMvp * position;
}

View File

@ -1,16 +0,0 @@
FRAGMENT_SHADER_USE_TEX_COORD
FRAGMENT_SHADER_USE_FOG
FRAGMENT_SHADER_USE_DIFFUSE_TERM
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
void main() {
vec4 color;
FRAGMENT_SHADER_TEXTURE_BLEND(DIFFUSE, Diffuse)
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#else
gl_FragColor = color;
#endif //ALPHA_TEST_ENABLED
FRAGMENT_SHADER_FOG_APPLY
}

View File

@ -1,13 +0,0 @@
uniform mat4 uMatrixMvp;
VERTEX_SHADER_USE_POSITION
VERTEX_SHADER_USE_TEXCOORD
VERTEX_SHADER_NEED_TEX_COORD
void main()
{
VERTEX_SHADER_POSITION
VERTEX_SHADER_TEXCOORD
gl_Position = uMatrixMvp * position;
}

View File

@ -1,64 +0,0 @@
varying vec2 vFactor;
FRAGMENT_SHADER_USE_TEX_COORD
FRAGMENT_SHADER_USE_FOG
FRAGMENT_SHADER_USE_SHADOWS
FRAGMENT_SHADER_USE_DIFFUSE_TERM
FRAGMENT_SHADER_USE_SPECULAR_TERM
FRAGMENT_SHADER_USE_AMBIENT_TERM
FRAGMENT_SHADER_USE_EMISSION_TERM
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
vec4 fragmentFlat()
{
vec4 color;
vec4 fragcolor;
#ifdef DIFFUSE
FRAGMENT_SHADER_TEXTURE_BLEND(DIFFUSE, Diffuse)
fragcolor = uLightDiffuse * color * vFactor.x;
#else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#endif //DIFFUSE
#ifdef SPECULAR
FRAGMENT_SHADER_TEXTURE_BLEND(SPECULAR, Specular)
fragcolor += uLightSpecular * color * vFactor.y;
#endif //SPECULAR
#ifdef SHADOWED
fragcolor *= shadow;
#endif //SHADOWED
#ifdef AMBIENT
FRAGMENT_SHADER_TEXTURE_BLEND(AMBIENT, Ambient)
fragcolor += uLightAmbient * color;
#endif //AMBIENT
#ifdef EMISSION
FRAGMENT_SHADER_TEXTURE_BLEND(EMISSION, Emission)
fragcolor += color;
#endif //EMISSION
return fragcolor;
}
void main() {
vec4 color;
#ifdef SHADOWED
shadow = pcf(vLightPosition);
#endif //SHADOWED
color = fragmentFlat();
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#else
gl_FragColor = color;
#endif //ALPHA_TEST_ENABLED
FRAGMENT_SHADER_FOG_APPLY
}

View File

@ -1,92 +0,0 @@
uniform mat4 uMatrixMvp;
uniform mat3 uMatrixNormal;
uniform mat4 uMatrixModelview;
uniform vec4 uLightPosition;
varying vec2 vFactor;
VERTEX_SHADER_USE_SHADOWS
VERTEX_SHADER_USE_POSITION
VERTEX_SHADER_USE_NORMALS
VERTEX_SHADER_USE_TEXCOORD
VERTEX_SHADER_NEED_TEX_COORD
#ifdef LIGHT_SPOT
uniform vec3 uLightSpotDir;
uniform float uLightSpotExp;
uniform float uLightSpotCutoffCos;
#endif //LIGHT_SPOT
#ifdef SPECULAR
uniform float uMaterialShininess;
#endif //SPECULAR
#ifdef LIGHT_ATTENUATION
uniform vec3 uLightAtten;
#endif //LIGHT_ATTENUATION
void vertexFlat(vec4 position, vec3 normal)
{
vec3 lv;
float factor;
normal = uMatrixNormal * normal;
position = uMatrixModelview * position;
#ifdef NORMALIZE_NORMALS
normal = normalize(normal);
#endif //NORMALIZE_NORMALS
#ifdef LIGHT_DIRECTIONAL
lv = uLightPosition.xyz;
#else
lv = uLightPosition.xyz - position.xyz;
lv = normalize(lv);
#endif //LIGHT_DIRECTIONAL
factor = max(dot(lv, normal), 0.0);
#ifdef LIGHT_SPOT
float f = dot(-lv, uLightSpotDir);
if (f > uLightSpotCutoffCos)
factor *= pow(f, uLightSpotExp);
else
factor = 0.0;
#endif //LIGHT_SPOT
if (factor > 0.0)
{
#ifdef DIFFUSE
vFactor.x = factor;
#else
vFactor.x = 0.0;
#endif //DIFFUSE
#ifdef SPECULAR
vec3 hv = normalize(normalize(-position.xyz) + lv);
factor = pow(max(dot(hv, normal), 0.0), uMaterialShininess);
vFactor.y = factor;
#endif //SPECULAR
}
else
vFactor = vec2(0.0, 0.0);
/* Light attenuation. */
#ifdef LIGHT_ATTENUATION
float dist = length(lv);
vFactor /= dot(uLightAtten, vec3(1.0, dist, dist * dist));
#endif //LIGHT_ATTENUATION
}
void main()
{
VERTEX_SHADER_POSITION
VERTEX_SHADER_NORMAL
VERTEX_SHADER_TEXCOORD
gl_Position = uMatrixMvp * position;
vertexFlat(position, normal);
VERTEX_SHADER_SHADOWED
}

View File

@ -1,68 +0,0 @@
#!/bin/sh
# This script will generate a C file containing all the shaders used by Evas_3D
DIR=`dirname $0`
cd $DIR/../../../../../
OUTPUT="$DIR/evas_gl_3d_shaders.x"
# Skip generation during make distcheck
if [ "${top_distdir}" != "" ] ; then exit 0; fi
# Skip generation if file can not be written to
if [ -e ${OUTPUT} ] && [ ! -w ${OUTPUT} ] ; then exit 0; fi
# Skip generation if there is no diff (or no git)
if ! git rev-parse 2>> /dev/null >> /dev/null ; then exit 0 ; fi
if git diff --quiet --exit-code -- "$DIR"
then
touch "$OUTPUT"
exit 0
fi
exec 1<&-
exec 1>"$OUTPUT"
SHADERS=$@
VERT_SHADERS_SOURCE=""
FRAG_SHADERS_SOURCE=""
# Write header
printf "/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */\n"
printf "/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */\n\n"
for SHD in $SHADERS ; do
LNAME=`basename "$SHD" .shd`
if echo "$LNAME" | grep _vert 2>&1 >> /dev/null ; then
VERT_SHADERS_SOURCE="$VERT_SHADERS_SOURCE "$LNAME"_glsl,\n"
fi
if echo "$LNAME" | grep _frag 2>&1 >> /dev/null ; then
FRAG_SHADERS_SOURCE="$FRAG_SHADERS_SOURCE "$LNAME"_glsl,\n"
fi
m4 "$DIR/include.shd" "$SHD" > "$SHD.tmp"
OIFS="$IFS"
IFS=`printf '\n+'`
IFS=${IFS%+}
printf "static const char "$LNAME"_glsl[] ="
for LINE in `cat "$SHD.tmp"` ; do
printf "\n \"$LINE\\\n\""
done
printf ";\n\n"
IFS="$OIFS"
rm "$SHD.tmp"
done
printf "static const char *vertex_shaders[] =
{\n"
printf "$VERT_SHADERS_SOURCE"
printf "};\n\n"
printf "static const char *fragment_shaders[] =
{\n"
printf "$FRAG_SHADERS_SOURCE"
printf "};\n"

View File

@ -1,254 +0,0 @@
`#ifdef GL_ES
precision mediump float;
precision mediump int;
precision lowp sampler2D;
#endif'
define(`FRAGMENT_SHADER_USE_TEX_COORD',`
#ifdef NEED_TEX_COORD
varying vec2 vTexCoord;
#endif //TEX_COORD')
define(`FRAGMENT_SHADER_USE_TEXTURE', `
#ifdef $1_TEXTURE
uniform sampler2D uTexture$2`0';
uniform mat3 uTextureMatrixTransform$2`0';
#endif //$1_TEXTURE
#ifdef $1_TEXTURE_BLEND
uniform sampler2D uTexture$2`1';
uniform float uTexture$2Weight;
uniform mat3 uTextureMatrixTransform$2`1';
#endif //$1_TEXTURE_BLEND')
define(`FRAGMENT_SHADER_USE_FOG', `
#ifdef FOG_ENABLED
uniform float uFogFactor;
uniform vec4 uFogColor;
#endif //FOG_ENABLED')
define(`FRAGMENT_SHADER_USE_ALPHA_TEST_GLES',
uniform int uAlphaTestComparison;
uniform float uAlphaTestRefValue;)
define(`FRAGMENT_SHADER_USE_SHADOWS', `
#ifdef SHADOWED
varying vec4 vLightPosition;
uniform sampler2D uShadowMap;
uniform float uShadowsPCFStep;
uniform float uShadowsPCFSize;
uniform float uShadowsConstantBias;
float shadow;
float pcf(vec4 lpos)
{
vec3 smcoord = lpos.xyz / lpos.w * 0.5 + 0.5;
float i, j, shadow, q, c;
q = floor(uShadowsPCFStep * 2.0);
c = floor(uShadowsPCFStep * uShadowsPCFStep * 4.0);
shadow = 0.0;
const vec4 unpack = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);
for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)
for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)
{
vec4 zvalue = texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize);
shadow += float(smcoord.z < dot(zvalue, unpack) + uShadowsConstantBias);
}
return shadow / c;
}
#endif //SHADOWED')
define(`FRAGMENT_SHADER_FOG_APPLY', `
#ifdef FOG_ENABLED
float z = gl_FragCoord.z / gl_FragCoord.w;
float fogFactor = exp2(-uFogFactor * uFogFactor * z * z * 1.44);
fogFactor = clamp(fogFactor, 0.0, 1.0);
gl_FragColor = mix(uFogColor, gl_FragColor, fogFactor);
#endif //FOG_ENABLED')
define(`FRAGMENT_SHADER_USE_LIGHT', `
#ifdef LIGHT_SPOT
uniform vec3 uLightSpotDir;
uniform float uLightSpotExp;
uniform float uLightSpotCutoffCos;
#endif //LIGHT_SPOT
#ifdef LIGHT_ATTENUATION
varying float vLightDist;
#endif //LIGHT_ATTENUATION')
define(`FRAGMENT_SHADER_TEXTURE_BLEND', `
#ifdef $1_TEXTURE_BLEND
vec3 Tex0Coord$2 = vec3(vTexCoord, 1.0) * uTextureMatrixTransform$2`0';
vec3 Tex1Coord$2 = vec3(vTexCoord, 1.0) * uTextureMatrixTransform$2`1';
color = mix(texture2D(uTexture$2`1', vec2(Tex1Coord$2)),
texture2D(uTexture$2`0', vec2(Tex0Coord$2)), uTexture$2Weight);
color *= uMaterial$2;
#else
#ifdef $1_TEXTURE
vec3 Tex0Coord$2 = vec3(vTexCoord, 1.0) * uTextureMatrixTransform$2`0';
color = texture2D(uTexture$2`0', vec2(Tex0Coord$2)) * uMaterial$2;
#else
color = uMaterial$2;
#endif //$1_TEXTURE
#endif //$1_TEXTURE_BLEND')
define(`FRAGMENT_SHADER_USE_EMISSION_TERM',
`#ifdef EMISSION'
uniform vec4 uMaterialEmission;
FRAGMENT_SHADER_USE_TEXTURE(EMISSION, Emission)
`#endif //EMISSION')
define(`FRAGMENT_SHADER_USE_SPECULAR_TERM',
`#ifdef SPECULAR'
uniform vec4 uLightSpecular;
uniform float uMaterialShininess;
uniform vec4 uMaterialSpecular;
FRAGMENT_SHADER_USE_TEXTURE(SPECULAR, Specular)
`#endif //SPECULAR')
define(`FRAGMENT_SHADER_USE_AMBIENT_TERM',
`#ifdef AMBIENT'
uniform vec4 uMaterialAmbient;
uniform vec4 uLightAmbient;
FRAGMENT_SHADER_USE_TEXTURE(AMBIENT, Ambient)
`#endif //AMBIENT')
define(`FRAGMENT_SHADER_USE_DIFFUSE_TERM',
`#ifdef DIFFUSE'
uniform vec4 uMaterialDiffuse;
uniform vec4 uLightDiffuse;
FRAGMENT_SHADER_USE_TEXTURE(DIFFUSE, Diffuse)
`#endif //DIFFUSE')
define(`FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY',
/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/
const float p = 1000000.0;
float acolor = floor($1.a * p);
float refvalue = floor(uAlphaTestRefValue * p);
if (uAlphaTestComparison == 0) discard;
else if (uAlphaTestComparison == 1)
{
if (acolor < refvalue) gl_FragColor = $1;
else discard;
}
else if (uAlphaTestComparison == 2)
{
if (acolor == refvalue) gl_FragColor = $1;
else discard;
}
else if (uAlphaTestComparison == 3)
{
if (acolor <= refvalue) gl_FragColor = $1;
else discard;
}
else if (uAlphaTestComparison == 4)
{
if (acolor > refvalue) gl_FragColor = $1;
else discard;
}
else if (uAlphaTestComparison == 5)
{
if (acolor != refvalue) gl_FragColor = $1;
else discard;
}
else if (uAlphaTestComparison == 6)
{
if (acolor >= refvalue) gl_FragColor = $1;
else discard;
}
else if (uAlphaTestComparison == 7) ;)
define(`VERTEX_SHADER_NEED_TEX_COORD',
`#ifdef NEED_TEX_COORD'
varying vec2 vTexCoord;
`#endif //NEED_TEX_COORD')
define(`VERTEX_SHADER_USE_LIGHT_ATTENUATION',
`#ifdef LIGHT_ATTENUATION'
varying float vLightDist;
`#endif //LIGHT_ATTENUATION')
define(`VERTEX_SHADER_USE_SHADOWS',
`#ifdef SHADOWED'
uniform mat4 uMatrixLight;
varying vec4 vLightPosition;
`#endif //SHADOWED')
define(`VERTEX_SHADER_USE_POSITION',
`#ifdef VERTEX_POSITION'
attribute vec4 aPosition0;
`#endif //VERTEX_POSITION'
`#ifdef VERTEX_POSITION_BLEND'
attribute vec4 aPosition1;
uniform float uPositionWeight;
`#endif //VERTEX_POSITION_BLEND')
define(`VERTEX_SHADER_USE_NORMALS',
`#ifdef VERTEX_NORMAL'
attribute vec4 aNormal0;
`#endif //VERTEX_NORMAL'
`#ifdef VERTEX_NORMAL_BLEND'
attribute vec4 aNormal1;
uniform float uNormalWeight;
`#endif //VERTEX_NORMAL_BLEND'
)
define(`VERTEX_SHADER_USE_TEXCOORD',
`#ifdef VERTEX_TEXCOORD'
attribute vec4 aTexCoord0;
`#endif //VERTEX_TEXCOORD'
`#ifdef VERTEX_TEXCOORD_BLEND'
attribute vec4 aTexCoord1;
uniform float uTexCoordWeight;
`#endif //VERTEX_TEXCOORD_BLEND'
)
define(`VERTEX_SHADER_USE_COLOR',
`#ifdef VERTEX_COLOR'
attribute vec4 aColor0;
`#endif //VERTEX_COLOR'
`#ifdef VERTEX_COLOR_BLEND'
attribute vec4 aColor1;
uniform float uColorWeight;
`#endif //VERTEX_COLOR_BLEND')
define(`VERTEX_SHADER_POSITION',
`#ifdef VERTEX_POSITION_BLEND'
vec4 position = mix(aPosition1, aPosition0, uPositionWeight);
position = vec4(position.xyz, 1.0);
`#else'
`#ifdef VERTEX_POSITION'
vec4 position = vec4(aPosition0.xyz, 1.0);
`#endif // VERTEX_POSITION'
`#endif //VERTEX_POSITION_BLEND')
define(`VERTEX_SHADER_NORMAL',
`#ifdef VERTEX_NORMAL_BLEND'
vec3 normal = mix(aNormal1.xyz, aNormal0.xyz, uNormalWeight);
`#else'
`#ifdef VERTEX_NORMAL'
vec3 normal = aNormal0.xyz;
`#endif //VERTEX_NORMAL'
`#endif //VERTEX_NORMAL_BLEND')
define(`VERTEX_SHADER_TEXCOORD',
`#ifdef VERTEX_TEXCOORD_BLEND'
vTexCoord = mix(vec2(aTexCoord1.s, 1.0 - aTexCoord1.t),
vec2(aTexCoord0.s, 1.0 - aTexCoord0.t), uTexCoordWeight);
`#else'
`#ifdef VERTEX_TEXCOORD'
vTexCoord = vec2(aTexCoord0.s, 1.0 - aTexCoord0.t);
`#endif //VERTEX_TEXCOORD'
`#endif //VERTEX_TEXCOORD_BLEND')
define(`VERTEX_SHADER_SHADOWED',
`#ifdef SHADOWED'
vLightPosition = uMatrixLight * position;
`#endif //SHADOWED')

View File

@ -1,147 +0,0 @@
varying vec3 vLightVector;
varying vec3 vLightHalfVector;
varying vec3 vEyeVector;
FRAGMENT_SHADER_USE_TEX_COORD
FRAGMENT_SHADER_USE_FOG
FRAGMENT_SHADER_USE_SHADOWS
FRAGMENT_SHADER_USE_TEXTURE(NORMAL, Normal)
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
#ifndef VERTEX_TANGENT
varying vec3 vNormal;
#endif //VERTEX_TANGENT
FRAGMENT_SHADER_USE_DIFFUSE_TERM
FRAGMENT_SHADER_USE_SPECULAR_TERM
FRAGMENT_SHADER_USE_AMBIENT_TERM
FRAGMENT_SHADER_USE_EMISSION_TERM
FRAGMENT_SHADER_USE_LIGHT
#ifndef VERTEX_TANGENT
mat3 cotangent_frame(vec3 n, vec3 p, vec2 uv)
{
vec3 dp1 = dFdx(p);
vec3 dp2 = dFdy(p);
vec2 duv1 = dFdx(uv);
vec2 duv2 = dFdy(uv);
vec3 dp2perp = cross(dp2, n);
vec3 dp1perp = cross(n, dp1);
vec3 t = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 b = dp2perp * duv1.y + dp1perp * duv2.y;
float invmax = inversesqrt(max(dot(t, t), dot(b, b)));
return mat3(t * invmax, b * invmax, n);
}
vec3 perturb_normal(vec3 normal)
{
mat3 tbn = cotangent_frame(vNormal, -vEyeVector, vTexCoord);
return normalize(tbn * normal);
}
#endif //VERTEX_TANGENT
vec4 fragmentNormalMap()
{
float factor;
vec3 normal;
vec4 color;
vec4 fragcolor;
vec3 Tex0CoordNormal = vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal0;
#ifdef NORMAL_TEXTURE_BLEND
vec3 Tex1CoordNormal = vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal1;
normal = texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).rgb * uTextureNormalWeight / texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).a;
normal += texture2D(uTextureNormal1, vec2(Tex1CoordNormal)).rgb / texture2D(uTextureNormal1, vec2(Tex1CoordNormal)).a *
(1.0 - uTextureNormalWeight);
#else
normal = texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).rgb / texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).a;
#endif //NORMAL_TEXTURE_BLEND
normal = 2.0 * normal - 1.0;
#ifndef VERTEX_TANGENT
normal = perturb_normal(normal);
#endif //VERTEX_TANGENT
vec3 lv = normalize(vLightVector);
normal = normalize(normal);
factor = dot(lv, normal);
#ifdef LIGHT_SPOT
float f = dot(-lv, normalize(uLightSpotDir));
if (f > uLightSpotCutoffCos)
factor *= pow(f, uLightSpotExp);
else
factor = 0.0;
#endif //LIGHT_SPOT
if (factor > 0.0)
{
#ifdef DIFFUSE
FRAGMENT_SHADER_TEXTURE_BLEND(DIFFUSE, Diffuse)
fragcolor = uLightDiffuse * color * factor;
#else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#endif //DIFFUSE
#ifdef SPECULAR
factor = dot(normalize(vLightHalfVector), normal);
if (factor > 0.0)
{
factor = pow(factor, uMaterialShininess);
FRAGMENT_SHADER_TEXTURE_BLEND(SPECULAR, Specular)
fragcolor += uLightSpecular * color * factor;
}
#endif //SPECULAR
#ifdef SHADOWED
fragcolor *= shadow;
#endif //SHADOWED
}
else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#ifdef AMBIENT
FRAGMENT_SHADER_TEXTURE_BLEND(AMBIENT, Ambient)
fragcolor += uLightAmbient * color;
#endif //AMBIENT
#ifdef LIGHT_ATTENUATION
fragcolor /= dot(uLightAtten, vec3(1.0, vLightDist, vLightDist * vLightDist));
#endif //LIGHT_ATTENUATION
#ifdef EMISSION
FRAGMENT_SHADER_TEXTURE_BLEND(EMISSION, Emission)
fragcolor += color;
#endif //EMISSION
return fragcolor;
}
void main() {
vec4 color;
#ifdef SHADOWED
shadow = pcf(vLightPosition);
#endif //SHADOWED
color = fragmentNormalMap();
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#else
gl_FragColor = color;
#endif //ALPHA_TEST_ENABLED
FRAGMENT_SHADER_FOG_APPLY
}

View File

@ -1,128 +0,0 @@
uniform mat4 uMatrixMvp;
uniform mat3 uMatrixNormal;
uniform mat4 uMatrixModelview;
uniform vec4 uLightPosition;
varying vec3 vLightVector;
varying vec3 vLightHalfVector;
varying vec3 vEyeVector;
#ifndef VERTEX_TANGENT
varying vec3 vNormal;
#endif //VERTEX_TANGENT
VERTEX_SHADER_USE_SHADOWS
VERTEX_SHADER_USE_POSITION
VERTEX_SHADER_USE_NORMALS
#ifdef VERTEX_TANGENT
attribute vec4 aTangent0;
#endif //VERTEX_TANGENT
#ifdef VERTEX_TANGENT_BLEND
attribute vec4 aTangent1;
uniform float uTangentWeight;
#endif //VERTEX_TANGENT_BLEND
VERTEX_SHADER_USE_TEXCOORD
VERTEX_SHADER_NEED_TEX_COORD
VERTEX_SHADER_USE_LIGHT_ATTENUATION
#ifndef VERTEX_TANGENT
void vertexNormalMap(vec4 position, vec3 normal)
{
normal = uMatrixNormal * normal;
position = uMatrixModelview * position;
vEyeVector = normalize(-position.xyz);
#ifdef NORMALIZE_NORMALS
normal = normalize(normal);
#endif //NORMALIZE_NORMALS
#ifdef LIGHT_DIRECTIONAL
vLightVector = uLightPosition.xyz;
#else
vLightVector = uLightPosition.xyz - position.xyz;
#ifdef LIGHT_ATTENUATION
vLightDist = length(vLightVector);
#endif //LIGHT_ATTENUATION
vLightVector = normalize(vLightVector);
#endif //LIGHT_DIRECTIONAL
vLightHalfVector = normalize(vEyeVector + vLightVector);
vNormal = normal;
}
#else
void vertexNormalMap(vec4 position, vec3 normal, vec3 tangent)
{
vec3 n = normalize(uMatrixNormal * normal);
vec3 t = normalize(uMatrixNormal * tangent);
vec3 b = cross(n, t);
vec3 tmp;
position = uMatrixModelview * position;
#ifdef LIGHT_DIRECTIONAL
vec3 lightDir = uLightPosition.xyz;
#else
vec3 lightDir = uLightPosition.xyz - position.xyz;
#ifdef LIGHT_ATTENUATION
vLightDist = length(lightDir);
#endif //LIGHT_ATTENUATION
lightDir = normalize(lightDir);
#endif //LIGHT_DIRECTIONAL
tmp.x = dot(lightDir, t);
tmp.y = dot(lightDir, b);
tmp.z = dot(lightDir, n);
vLightVector = tmp;
tmp.x = dot(position.xyz, t);
tmp.y = dot(position.xyz, b);
tmp.z = dot(position.xyz, n);
vEyeVector = normalize(tmp);
vec3 hv = normalize(normalize(-position.xyz) + lightDir);
tmp.x = dot(hv, t);
tmp.y = dot(hv, b);
tmp.z = dot(hv, n);
vLightHalfVector = tmp;
}
#endif //VERTEX_TANGENT
void main()
{
VERTEX_SHADER_POSITION
VERTEX_SHADER_NORMAL
#ifdef VERTEX_TANGENT_BLEND
vec3 tangent = aTangent0.xyz * uTangentWeight +
aTangent1.xyz * (1.0 - uTangentWeight);
#else
#ifdef VERTEX_TANGENT
vec3 tangent = aTangent0.xyz;
#endif //VERTEX_TANGENT
#endif //VERTEX_TANGENT_BLEND
VERTEX_SHADER_TEXCOORD
gl_Position = uMatrixMvp * position;
#ifdef VERTEX_TANGENT
vertexNormalMap(position, normal, tangent);
#else
vertexNormalMap(position, normal);
#endif //VERTEX_TANGENT
#ifdef SHADOWED
vLightPosition = uMatrixLight * position;
#endif
}

View File

@ -1,240 +0,0 @@
varying vec3 vLightVector;
varying vec3 vLightHalfVector;
varying vec3 vEyeVector;
uniform sampler2D uTextureNormal0;
uniform mat3 uTextureMatrixTransformNormal0;
#ifdef NEED_TEX_COORD
varying vec2 vTexCoord;
vec3 Tex0CoordNormal;
#endif //TEX_COORD
#ifdef NORMAL_TEXTURE_BLEND
uniform sampler2D uTextureNormal1;
uniform float uTextureNormalWeight;
uniform mat3 uTextureMatrixTransformNormal1;
vec3 Tex1CoordNormal;
#endif //NORMAL_TEXTURE_BLEND
FRAGMENT_SHADER_USE_FOG
FRAGMENT_SHADER_USE_SHADOWS
FRAGMENT_SHADER_USE_DIFFUSE_TERM
FRAGMENT_SHADER_USE_SPECULAR_TERM
FRAGMENT_SHADER_USE_AMBIENT_TERM
FRAGMENT_SHADER_USE_EMISSION_TERM
FRAGMENT_SHADER_USE_LIGHT
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
const float parallaxScale = 0.2;
vec2 parallaxMapping(in vec3 view, in vec2 tex, out float parallaxHeight)
{
const float numLayers = 15.0;
vec2 texStep = parallaxScale * view.xy / view.z / numLayers;
float layerHeight = 1.0 / numLayers;
float curLayerHeight = 0.0;
vec2 dtex = parallaxScale * view.xy / view.z / numLayers;
vec2 currentTextureCoords = tex;
#ifdef NORMAL_TEXTURE_BLEND
float heightFromTexture = (1.0 - texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).a) * uTextureNormalWeight;
heightFromTexture += (1.0 - texture2D(uTextureNormal1, vec2(Tex1CoordNormal)).a) *
(1.0 - uTextureNormalWeight);
#else
float heightFromTexture = 1.0 - texture2D(uTextureNormal0, currentTextureCoords).a;
#endif //NORMAL_TEXTURE_BLEND
while(heightFromTexture > curLayerHeight)
{
curLayerHeight += layerHeight;
currentTextureCoords -= dtex;
#ifdef NORMAL_TEXTURE_BLEND
heightFromTexture = (1.0 - texture2D(uTextureNormal0, currentTextureCoords).a) * uTextureNormalWeight;
heightFromTexture += (1.0 - texture2D(uTextureNormal1, currentTextureCoords).a) *
(1.0 - uTextureNormalWeight);
#else
heightFromTexture = 1.0 - texture2D(uTextureNormal0, currentTextureCoords).a;
#endif //NORMAL_TEXTURE_BLEND
}
vec2 prevTCoords = currentTextureCoords + texStep;
float nextH = heightFromTexture - curLayerHeight;
#ifdef NORMAL_TEXTURE_BLEND
float prevH = (1.0 - texture2D(uTextureNormal0, prevTCoords).a
- curLayerHeight + layerHeight) * uTextureNormalWeight;
prevH += (1.0 - texture2D(uTextureNormal1, prevTCoords).a
- curLayerHeight + layerHeight) * (1.0 - uTextureNormalWeight);
#else
float prevH = 1.0 - texture2D(uTextureNormal0, prevTCoords).a
- curLayerHeight + layerHeight;
#endif //NORMAL_TEXTURE_BLEND
float weight = nextH / (nextH - prevH);
vec2 finalTexCoords = prevTCoords * weight + currentTextureCoords * (1.0-weight);
parallaxHeight = curLayerHeight + prevH * weight + nextH * (1.0 - weight);
return finalTexCoords;
}
vec4 fragmentParallaxMap()
{
float factor;
vec3 normal;
vec4 color;
vec4 fragcolor;
float parallaxHeight;
vec2 tex = parallaxMapping(vEyeVector, vec2(Tex0CoordNormal), parallaxHeight);
vec3 lv = normalize(vLightVector);
#ifdef NORMAL_TEXTURE_BLEND
normal = texture2D(uTextureNormal0, tex).rgb * uTextureNormalWeight / texture2D(uTextureNormal0, tex).a;
normal += texture2D(uTextureNormal1, tex).rgb *
(1.0 - uTextureNormalWeight) / texture2D(uTextureNormal1, tex).a;
#else
normal = texture2D(uTextureNormal0, tex).rgb / texture2D(uTextureNormal0, tex).a;
#endif //NORMAL_TEXTURE_BLEND
normal = 2.0 * normal - 1.0;
normal = normalize(normal);
factor = dot(lv, normal);
#ifdef LIGHT_SPOT
float f = dot(-lv, normalize(uLightSpotDir));
if (f > uLightSpotCutoffCos)
factor *= pow(f, uLightSpotExp);
else
factor = 0.0;
#endif //LIGHT_SPOT
if (factor > 0.0)
{
#ifdef DIFFUSE
#ifdef DIFFUSE_TEXTURE_BLEND
color = texture2D(uTextureDiffuse0, tex) * uTextureDiffuseWeight +
texture2D(uTextureDiffuse1, tex) * (1.0 - uTextureDiffuseWeight);
#else
#ifdef DIFFUSE_TEXTURE
color = texture2D(uTextureDiffuse0, tex);
#else
color = uMaterialDiffuse;
#endif //DIFFUSE_TEXTURE
#endif //DIFFUSE_TEXTURE_BLEND
fragcolor = uLightDiffuse * color * factor;
#else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#endif //DIFFUSE
#ifdef SPECULAR
factor = dot(normalize(vLightHalfVector), normal);
if (factor > 0.0)
{
factor = pow(factor, uMaterialShininess);
#ifdef SPECULAR_TEXTURE_BLEND
color = texture2D(uTextureSpecular0, tex) * uTextureSpecularWeight +
texture2D(uTextureSpecular1, tex) * (1.0 - uTextureSpecularWeight);
#else
#ifdef SPECULAR_TEXTURE
color = texture2D(uTextureSpecular0, tex);
#else
color = uMaterialSpecular;
#endif //SPECULAR_TEXTURE
#endif //SPECULAR_TEXTURE_BLEND
fragcolor += uLightSpecular * color * factor;
}
#endif //SPECULAR
#ifdef SHADOWED
fragcolor *= shadow;
#endif //SHADOWED
}
else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#ifdef AMBIENT
#ifdef AMBIENT_TEXTURE_BLEND
color = texture2D(uTextureAmbient0, tex) * uTextureAmbientWeight +
texture2D(uTextureAmbient1, tex) * (1.0 - uTextureAmbientWeight);
#else
#ifdef AMBIENT_TEXTURE
color = texture2D(uTextureAmbient0, tex);
#else
color = uMaterialAmbient;
#endif //AMBIENT_TEXTURE
#endif //AMBIENT_TEXTURE_BLEND
fragcolor += uLightAmbient * color;
#endif //AMBIENT
#ifdef LIGHT_ATTENUATION
fragcolor /= dot(uLightAtten, vec3(1.0, vLightDist, vLightDist * vLightDist));
#endif //LIGHT_ATTENUATION
#ifdef EMISSION
#ifdef EMISSION_TEXTURE_BLEND
color = texture2D(uTextureEmission0, tex) * uTextureEmissionWeight +
texture2D(uTextureEmission1, tex) * (1.0 - uTextureEmissionWeight);
#else
#ifdef EMISSION_TEXTURE
color = texture2D(uTextureEmission0, tex);
#else
color = uMaterialEmission;
#endif //EMISSION_TEXTURE
#endif //EMISSION_TEXTURE_BLEND
fragcolor += color;
#endif //EMISSION
return fragcolor;
}
void main() {
vec4 color;
#ifdef NEED_TEX_COORD
Tex0CoordNormal = vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal0;
#endif // NEED_TEX_COORD
#ifdef NORMAL_TEXTURE_BLEND
Tex1CoordNormal = vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal1;
#endif //NORMAL_TEXTURE_BLEND
#ifdef SHADOWED
shadow = pcf(vLightPosition);
#endif //SHADOWED
color = fragmentParallaxMap();
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#else
gl_FragColor = color;
#endif //ALPHA_TEST_ENABLED
FRAGMENT_SHADER_FOG_APPLY
}

View File

@ -1,88 +0,0 @@
uniform mat4 uMatrixMvp;
uniform mat3 uMatrixNormal;
uniform mat4 uMatrixModelview;
uniform vec4 uLightPosition;
varying vec3 vLightVector;
varying vec3 vLightHalfVector;
varying vec3 vEyeVector;
VERTEX_SHADER_USE_SHADOWS
VERTEX_SHADER_USE_POSITION
VERTEX_SHADER_USE_NORMALS
#ifdef VERTEX_TANGENT
attribute vec4 aTangent0;
#endif //VERTEX_TANGENT
#ifdef VERTEX_TANGENT_BLEND
attribute vec4 aTangent1;
uniform float uTangentWeight;
#endif //VERTEX_TANGENT_BLEND
VERTEX_SHADER_USE_TEXCOORD
VERTEX_SHADER_NEED_TEX_COORD
VERTEX_SHADER_USE_LIGHT_ATTENUATION
void vertexParallaxOcclusion(vec4 position, vec3 normal, vec3 tangent)
{
vec3 n = normalize(uMatrixNormal * normal);
vec3 t = normalize(uMatrixNormal * tangent);
vec3 b = cross(n, t);
vec3 tmp;
position = uMatrixModelview * position;
#ifdef LIGHT_DIRECTIONAL
vec3 lightDir = uLightPosition.xyz;
#else
vec3 lightDir = uLightPosition.xyz - position.xyz;
#ifdef LIGHT_ATTENUATION
vLightDist = length(lightDir);
#endif //LIGHT_ATTENUATION
lightDir = normalize(lightDir);
#endif //LIGHT_DIRECTIONAL
tmp.x = dot(lightDir, t);
tmp.y = dot(lightDir, b);
tmp.z = dot(lightDir, n);
vLightVector = tmp;
tmp.x = dot(position.xyz, t);
tmp.y = dot(position.xyz, b);
tmp.z = dot(position.xyz, n);
vEyeVector = normalize(tmp);
vec3 hv = normalize(normalize(-position.xyz) + lightDir);
tmp.x = dot(hv, t);
tmp.y = dot(hv, b);
tmp.z = dot(hv, n);
vLightHalfVector = tmp;
}
void main()
{
VERTEX_SHADER_POSITION
VERTEX_SHADER_NORMAL
#ifdef VERTEX_TANGENT_BLEND
vec3 tangent = aTangent0.xyz * uTangentWeight +
aTangent1.xyz * (1.0 - uTangentWeight);
#else
#ifdef VERTEX_TANGENT
vec3 tangent = aTangent0.xyz;
#endif //VERTEX_TANGENT
#endif //VERTEX_TANGENT_BLEND
VERTEX_SHADER_TEXCOORD
gl_Position = uMatrixMvp * position;
vertexParallaxOcclusion(position, normal, tangent);
VERTEX_SHADER_SHADOWED
}

View File

@ -1,103 +0,0 @@
varying vec3 vLightVector;
varying vec3 vLightHalfVector;
varying vec3 vNormal;
FRAGMENT_SHADER_USE_TEX_COORD
FRAGMENT_SHADER_USE_FOG
FRAGMENT_SHADER_USE_SHADOWS
FRAGMENT_SHADER_USE_DIFFUSE_TERM
FRAGMENT_SHADER_USE_SPECULAR_TERM
FRAGMENT_SHADER_USE_AMBIENT_TERM
FRAGMENT_SHADER_USE_EMISSION_TERM
FRAGMENT_SHADER_USE_LIGHT
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
vec4 fragmentPhong()
{
vec3 normal = normalize(vNormal);
vec3 lv = normalize(vLightVector);
float factor = dot(lv, normal);
vec4 color;
vec4 fragcolor;
#ifdef LIGHT_SPOT
float f = dot(-lv, normalize(uLightSpotDir));
if (f > uLightSpotCutoffCos)
factor *= pow(f, uLightSpotExp);
else
factor = 0.0;
#endif //LIGHT_SPOT
if (factor > 0.0)
{
/* Diffuse term. */
#ifdef DIFFUSE
FRAGMENT_SHADER_TEXTURE_BLEND(DIFFUSE, Diffuse)
fragcolor = uLightDiffuse * color * factor;
#else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#endif //DIFFUSE
/* Specular term. */
#ifdef SPECULAR
factor = dot(normalize(vLightHalfVector), normal);
if (factor > 0.0)
{
factor = pow(factor, uMaterialShininess);
FRAGMENT_SHADER_TEXTURE_BLEND(SPECULAR, Specular)
fragcolor += uLightSpecular * color * factor;
}
#endif
}
else
fragcolor = vec4(0.0, 0.0, 0.0, 0.0);
#ifdef SHADOWED
fragcolor *= shadow;
#endif //SHADOWED
#ifdef AMBIENT
FRAGMENT_SHADER_TEXTURE_BLEND(AMBIENT, Ambient)
fragcolor += uLightAmbient * color;
#endif
/* Light attenuation. */
#ifdef LIGHT_ATTENUATION
fragcolor /= dot(uLightAtten, vec3(1.0, vLightDist, vLightDist * vLightDist));
#endif
/* Emission term. */
#ifdef EMISSION
FRAGMENT_SHADER_TEXTURE_BLEND(EMISSION, Emission)
fragcolor += color;
#endif
return fragcolor;
}
void main()
{
vec4 color;
#ifdef SHADOWED
shadow = pcf(vLightPosition);
#endif //SHADOWED
color = fragmentPhong();
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#else
gl_FragColor = color;
#endif //ALPHA_TEST_ENABLED
FRAGMENT_SHADER_FOG_APPLY
}

View File

@ -1,51 +0,0 @@
uniform mat4 uMatrixMvp;
uniform mat3 uMatrixNormal;
uniform mat4 uMatrixModelview;
uniform vec4 uLightPosition;
varying vec3 vLightVector;
varying vec3 vLightHalfVector;
varying vec3 vNormal;
VERTEX_SHADER_USE_SHADOWS
VERTEX_SHADER_USE_POSITION
VERTEX_SHADER_USE_NORMALS
VERTEX_SHADER_USE_TEXCOORD
VERTEX_SHADER_NEED_TEX_COORD
VERTEX_SHADER_USE_LIGHT_ATTENUATION
void vertexPhong(vec4 position, vec3 normal)
{
normal = uMatrixNormal * normal;
position = uMatrixModelview * position;
#ifdef NORMALIZE_NORMALS
normal = normalize(normal);
#endif //NORMALIZE_NORMALS
#ifdef LIGHT_DIRECTIONAL
vLightVector = uLightPosition.xyz;
#else
vLightVector = uLightPosition.xyz - position.xyz;
#ifdef LIGHT_ATTENUATION
vLightDist = length(vLightVector);
#endif //LIGHT_ATTENUATION
vLightVector = normalize(vLightVector);
#endif //LIGHT_DIRECTIONAL
vLightHalfVector = normalize(normalize(-position.xyz) + vLightVector);
vNormal = normal;
}
void main() {
VERTEX_SHADER_POSITION
VERTEX_SHADER_NORMAL
VERTEX_SHADER_TEXCOORD
gl_Position = uMatrixMvp * position;
vertexPhong(position, normal);
VERTEX_SHADER_SHADOWED
}

View File

@ -1,63 +0,0 @@
//FXAA fragment shader by Timothy Lottes
//http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
//modified and adapted to www.enlightenment.org by Oleksander Shcherbina
uniform sampler2D uColorTexture;
uniform float uFrameSizeH;
uniform float uFrameSizeW;
varying vec2 tc0;
vec4 fxaa()
{
float _SPAN_MAX_ = 8.0;
float _REDUCE_MUL_ = (1.0/8.0);
float _REDUCE_MIN_ = (1.0/128.0);
vec4 l = vec4(0.299, 0.587, 0.114, 0.0);
vec2 frameBufSize = vec2(uFrameSizeW, uFrameSizeH);
vec2 direction;
vec4 colorNW = texture2D(uColorTexture, tc0 + (vec2(-1.0, -1.0)/frameBufSize));
vec4 colorNE = texture2D(uColorTexture, tc0 + (vec2(1.0, -1.0)/frameBufSize));
vec4 colorSW = texture2D(uColorTexture, tc0 + (vec2(-1.0, 1.0)/frameBufSize));
vec4 colorSE = texture2D(uColorTexture, tc0 + (vec2(1.0, 1.0)/frameBufSize));
vec4 colorM = texture2D(uColorTexture,tc0);
float lNW = dot(colorNW, l);
float lNE = dot(colorNE, l);
float lSW = dot(colorSW, l);
float lSE = dot(colorSE, l);
float lM = dot(colorM, l);
float lMin = min(lM, min(min(lNW, lNE), min(lSW, lSE)));
float lMax = max(lM, max(max(lNW, lNE), max(lSW, lSE)));
direction.x = -((lNW + lNE) - (lSW + lSE));
direction.y = ((lNW + lSW) - (lNE + lSE));
float directionReduce = max(
(lNW + lNE + lSW + lSE) * (0.25 * _REDUCE_MUL_),
_REDUCE_MIN_);
float rcpDirMin = 1.0/(min(abs(direction.x), abs(direction.y)) + directionReduce);
direction = min(vec2(_SPAN_MAX_, _SPAN_MAX_),
max(vec2(-_SPAN_MAX_, -_SPAN_MAX_),
direction * rcpDirMin)) / frameBufSize;
vec4 colorA = 0.5 * (
texture2D(uColorTexture, tc0.xy + direction * (1.0/3.0 - 0.5)) +
texture2D(uColorTexture, tc0.xy + direction * (2.0/3.0 - 0.5)));
vec4 colorB = colorA * 0.5 + 0.25 * (
texture2D(uColorTexture, tc0.xy + direction * (- 0.5)) +
texture2D(uColorTexture, tc0.xy + direction * 0.5));
float lB = dot(colorB, l);
if((lB < lMin) || (lB > lMax))
return colorA;
else
return colorB;
}
void main()
{
gl_FragColor = fxaa();
}

View File

@ -1,12 +0,0 @@
uniform mat4 uMatrixMvp;
VERTEX_SHADER_USE_POSITION
varying vec2 tc0;
void main()
{
VERTEX_SHADER_POSITION
gl_Position = uMatrixMvp * position;
tc0 = position.xy * 0.5 + 0.5;
}

View File

@ -1,60 +0,0 @@
varying vec4 shadowmapposition;
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_USE_TEX_COORD
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
#ifdef DIFFUSE
#ifdef DIFFUSE_TEXTURE
uniform sampler2D uTextureDiffuse0;
uniform mat3 uTextureMatrixTransformDiffuse0;
#endif //DIFFUSE_TEXTURE
#ifdef DIFFUSE_TEXTURE_BLEND
uniform sampler2D uTextureDiffuse1;
uniform float uTextureDiffuseWeight;
uniform mat3 uTextureMatrixTransformDiffuse1;
#endif //DIFFUSE_TEXTURE_BLEND
#endif //DIFFUSE
#endif //ALPHA_TEST_ENABLED
void main() {
vec4 color;
#ifndef NEED_TEX_COORD
gl_FragColor = vec4(1);
#endif
#ifdef ALPHA_TEST_ENABLED
#ifdef DIFFUSE_TEXTURE_BLEND
vec3 Tex1CoordDiffuse = vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;
color = (texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) *
uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)) *
(1.0 - uTextureDiffuseWeight));
#else
#ifdef DIFFUSE_TEXTURE
vec3 Tex0CoordDiffuse = vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;
color = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse));
#else
color = vec4(1);
#endif //DIFFUSE_TEXTURE
#endif //DIFFUSE_TEXTURE_BLEND
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
#endif //ALPHA_TEST_ENABLED
const vec4 pack = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);
const vec4 mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
vec4 depthcolor;
float normdist = shadowmapposition.z / shadowmapposition.w;
normdist = ((normdist + 1.0) / 2.0);
depthcolor = vec4(fract(pack * normdist));
depthcolor -= depthcolor.xxyz * mask;
gl_FragColor = depthcolor;
}

View File

@ -1,21 +0,0 @@
uniform mat4 uMatrixMvp;
varying vec4 shadowmapposition;
VERTEX_SHADER_USE_POSITION
#ifdef ALPHA_TEST_ENABLED
VERTEX_SHADER_USE_TEXCOORD
VERTEX_SHADER_NEED_TEX_COORD
#endif //ALPHA_TEST_ENABLED
void main()
{
VERTEX_SHADER_POSITION
#ifdef ALPHA_TEST_ENABLED
VERTEX_SHADER_TEXCOORD
#endif //ALPHA_TEST_ENABLED
gl_Position = uMatrixMvp * position;
shadowmapposition = gl_Position;
}

View File

@ -1,17 +0,0 @@
varying vec4 vColor;
FRAGMENT_SHADER_USE_FOG
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
void main()
{
#ifdef ALPHA_TEST_ENABLED
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(vColor)
#else
gl_FragColor = vColor;
#endif //ALPHA_TEST_ENABLED
FRAGMENT_SHADER_FOG_APPLY
}

View File

@ -1,24 +0,0 @@
uniform mat4 uMatrixMvp;
varying vec4 vColor;
VERTEX_SHADER_USE_POSITION
VERTEX_SHADER_USE_COLOR
void main()
{
VERTEX_SHADER_POSITION
#ifdef VERTEX_COLOR_BLEND
vec4 color = aColor0 * uColorWeight + aColor1 * (1.0 - uColorWeight);
#else
#ifdef VERTEX_COLOR
vec4 color = aColor0;
#endif //VERTEX_COLOR
#endif //VERTEX_COLOR_BLEND
vColor = color;
gl_Position = uMatrixMvp * position;
}

View File

@ -44,7 +44,6 @@ struct _Render_Output_GL_Generic
Window_GL_Context_Use window_gl_context_use;
Context_3D *context_3d;
E3D_Renderer *renderer_3d;
const EVGL_Interface *evgl_funcs;
};
@ -95,7 +94,6 @@ evas_render_engine_gl_generic_init(Render_Engine_Software_Generic *engine,
re->window_gl_context_use = window_gl_context_use;
re->context_3d = NULL;
re->renderer_3d = NULL;
re->evgl_funcs = evgl_funcs;
evas_render_engine_software_generic_tile_strict_set(&re->software, EINA_TRUE);

View File

@ -2378,187 +2378,6 @@ eng_context_dup(void *engine EINA_UNUSED, void *context)
return ctx;
}
static void
eng_context_3d_use(void *output)
{
Render_Output_GL_Generic *re = output;
if (!re->context_3d)
re->context_3d = re->window_gl_context_new(re->software.ob);
if (re->context_3d) re->window_gl_context_use(re->context_3d);
}
static E3D_Renderer *
eng_renderer_3d_get(void *output)
{
Render_Output_GL_Generic *re = output;
if (!re->renderer_3d)
re->renderer_3d = e3d_renderer_new();
return re->renderer_3d;
}
static void *
eng_drawable_new(void *engine, int w, int h, int alpha)
{
eng_context_3d_use(gl_generic_output_find(engine));
#ifdef GL_GLES
return e3d_drawable_new(w, h, alpha, GL_DEPTH_STENCIL_OES, GL_NONE);
#else
return e3d_drawable_new(w, h, alpha, GL_DEPTH24_STENCIL8, GL_NONE);
#endif
}
static void
eng_drawable_free(void *engine, void *drawable)
{
eng_context_3d_use(gl_generic_output_find(engine));
e3d_drawable_free(drawable);
}
static void
eng_drawable_size_get(void *engine EINA_UNUSED, void *drawable, int *w, int *h)
{
e3d_drawable_size_get((E3D_Drawable *)drawable, w, h);
}
static void *
eng_image_drawable_set(void *engine, void *image, void *drawable)
{
E3D_Drawable *d = drawable;
Evas_Native_Surface ns;
int w, h;
ns.type = EVAS_NATIVE_SURFACE_OPENGL;
ns.data.opengl.texture_id = e3d_drawable_texture_id_get(d);
ns.data.opengl.framebuffer_id = 0;
ns.data.opengl.internal_format = e3d_drawable_format_get(d);
ns.data.opengl.format = e3d_drawable_format_get(d);
ns.data.opengl.x = 0;
ns.data.opengl.y = 0;
e3d_drawable_size_get(d, &w, &h);
ns.data.opengl.w = w;
ns.data.opengl.h = h;
return eng_image_native_set(engine, image, &ns);
}
static void
eng_drawable_scene_render(void *engine, void *data, void *drawable, void *scene_data)
{
Evas_Engine_GL_Context *gl_context;
E3D_Renderer *renderer = NULL;
gl_context = gl_generic_context_get(data, 1);
evas_gl_common_context_flush(gl_context);
eng_context_3d_use(gl_generic_output_find(engine));
renderer = eng_renderer_3d_get(data);
e3d_drawable_scene_render(drawable, renderer, scene_data);
}
static int
eng_drawable_texture_target_id_get(void *drawable)
{
return e3d_drawable_texture_id_get((E3D_Drawable *)drawable);
}
static int
eng_drawable_texture_color_pick_id_get(void *drawable)
{
return e3d_drawable_texture_color_pick_id_get((E3D_Drawable *)drawable);
}
static void
eng_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y,
Evas_Color *color, void *drawable)
{
return e3d_drawable_texture_pixel_color_get(tex, x, y, color, drawable);
}
static Eina_Bool
eng_drawable_scene_render_to_texture(void *engine, void *drawable, void *scene_data)
{
Evas_Engine_GL_Context *gl_context;
E3D_Renderer *renderer = NULL;
gl_context = gl_generic_context_get(engine, 1);
evas_gl_common_context_flush(gl_context);
eng_context_3d_use(gl_generic_output_find(engine));
renderer = eng_renderer_3d_get(engine);
return e3d_drawable_scene_render_to_texture((E3D_Drawable *)drawable, renderer, scene_data);
}
static void
eng_drawable_texture_rendered_pixels_get(GLuint tex EINA_UNUSED, int x, int y,
int w, int h, void *drawable EINA_UNUSED, void *engine)
{
e3d_drawable_texture_rendered_pixels_get(tex, x, y, w, h, drawable, engine);
}
static void *
eng_texture_new(void *engine EINA_UNUSED, Eina_Bool use_atlas)
{
return e3d_texture_new(use_atlas);
}
static void
eng_texture_free(void *engine EINA_UNUSED, void *texture)
{
e3d_texture_free((E3D_Texture *)texture);
}
static void
eng_texture_size_get(void *engine EINA_UNUSED, void *texture, int *w, int *h)
{
e3d_texture_size_get((E3D_Texture *)texture, w, h);
}
static void
eng_texture_wrap_set(void *engine EINA_UNUSED, void *texture,
Evas_Canvas3D_Wrap_Mode s, Evas_Canvas3D_Wrap_Mode t)
{
e3d_texture_wrap_set((E3D_Texture *)texture, s, t);
}
static void
eng_texture_wrap_get(void *engine EINA_UNUSED, void *texture,
Evas_Canvas3D_Wrap_Mode *s, Evas_Canvas3D_Wrap_Mode *t)
{
e3d_texture_wrap_get((E3D_Texture *)texture, s, t);
}
static void
eng_texture_filter_set(void *engine EINA_UNUSED, void *texture,
Evas_Canvas3D_Texture_Filter min, Evas_Canvas3D_Texture_Filter mag)
{
e3d_texture_filter_set((E3D_Texture *)texture, min, mag);
}
static void
eng_texture_filter_get(void *engine EINA_UNUSED, void *texture,
Evas_Canvas3D_Texture_Filter *min, Evas_Canvas3D_Texture_Filter *mag)
{
e3d_texture_filter_get((E3D_Texture *)texture, min, mag);
}
static void
eng_texture_image_set(void *engine, void *texture, void *image)
{
Evas_Engine_GL_Context *gl_context;
gl_context = gl_generic_context_find(engine, 1);
e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image);
}
static void *
eng_texture_image_get(void *engine EINA_UNUSED, void *texture)
{
return e3d_texture_get((E3D_Texture *)texture);
}
static Eina_Bool use_gl = EINA_FALSE;
static Ector_Surface *
@ -3331,29 +3150,6 @@ module_open(Evas_Module *em)
ORD(context_flush);
/* 3D features */
ORD(drawable_new);
ORD(drawable_free);
ORD(drawable_size_get);
ORD(image_drawable_set);
ORD(drawable_scene_render);
ORD(drawable_texture_color_pick_id_get);
ORD(drawable_texture_target_id_get);
ORD(drawable_texture_pixel_color_get);
ORD(drawable_scene_render_to_texture);
ORD(drawable_texture_rendered_pixels_get);
ORD(texture_new);
ORD(texture_free);
ORD(texture_size_get);
ORD(texture_wrap_set);
ORD(texture_wrap_get);
ORD(texture_filter_set);
ORD(texture_filter_get);
ORD(texture_image_set);
ORD(texture_image_get);
ORD(ector_create);
ORD(ector_destroy);
ORD(ector_buffer_wrap);

View File

@ -39,11 +39,6 @@ common_engine_src = [
'evas_gl_api_gles1.c',
'evas_gl_api_gles3_def.h',
'evas_gl_api_ext.c',
'evas_gl_3d_common.h',
'evas_gl_3d_private.h',
'evas_gl_3d.c',
'evas_gl_3d_renderer.c',
'evas_gl_3d_shader.c',
]
foreach src : common_engine_src

View File

@ -4794,25 +4794,6 @@ static Evas_Func func =
eng_multi_font_draw,
eng_pixel_alpha_get,
NULL, // eng_context_flush - software doesn't use it
NULL, // eng_drawable_new
NULL, // eng_drawable_free
NULL, // eng_drawable_size_get
NULL, // eng_image_drawable_set
NULL, // eng_drawable_scene_render
NULL, // eng_drawable_scene_render_to_texture
NULL, // eng_drawable_texture_color_pick_id_get
NULL, // eng_drawable_texture_target_id_get
NULL, // eng_drawable_texture_pixel_color_get
NULL, // eng_drawable_texture_rendered_pixels_get
NULL, // eng_texture_new
NULL, // eng_texture_free
NULL, // eng_texture_size_get
NULL, // eng_texture_wrap_set
NULL, // eng_texture_wrap_get
NULL, // eng_texture_filter_set
NULL, // eng_texture_filter_get
NULL, // eng_texture_image_set
NULL, // eng_texture_image_get
eng_ector_create,
eng_ector_destroy,
eng_ector_buffer_wrap,

View File

@ -2,8 +2,6 @@
subdir('image_savers')
subdir('image_loaders')
subdir('model_savers')
subdir('model_loaders')
subdir('vg_savers')
subdir('vg_loaders')
subdir('engines')

View File

@ -1,111 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Eo.h>
#include <Eet.h>
#include <stdio.h>
#include "evas_common_private.h"
#include "evas_private.h"
static void
_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
Evas_Canvas3D_Mesh_Eet *eet_mesh)
{
float *pos, *nor, *tex;
int stride_pos, stride_nor, stride_tex, j;
evas_canvas3d_mesh_vertex_count_set(mesh, eet_mesh->geometries->vertices_count);
evas_canvas3d_mesh_vertex_assembly_set(mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
evas_canvas3d_mesh_frame_add(mesh, 0);
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 0, NULL);
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 0, NULL);
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 0, NULL);
pos = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
nor = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
tex = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
stride_pos = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
stride_nor = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
stride_tex = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
if (stride_pos == 0) stride_pos = sizeof(float) * 3;
if (stride_nor == 0) stride_nor = sizeof(float) * 3;
if (stride_tex == 0) stride_tex = sizeof(float) * 2;
/* set data to vertex buffer */
for (j = 0; j < eet_mesh->geometries->vertices_count; j++)
{
float *p, *n, *t;
p = (float *)((char *)pos + stride_pos * j);
n = (float *)((char *)nor + stride_nor * j);
t = (float *)((char *)tex + stride_tex * j);
p[0] = eet_mesh->geometries->vertices[j].position.x;
p[1] = eet_mesh->geometries->vertices[j].position.y;
p[2] = eet_mesh->geometries->vertices[j].position.z;
n[0] = eet_mesh->geometries->vertices[j].normal.x;
n[1] = eet_mesh->geometries->vertices[j].normal.y;
n[2] = eet_mesh->geometries->vertices[j].normal.z;
t[0] = eet_mesh->geometries->vertices[j].texcoord.x;
t[1] = eet_mesh->geometries->vertices[j].texcoord.y;
}
/* unmap vertex buffer */
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
}
static void
_set_material_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
Evas_Canvas3D_Mesh_Eet *eet_mesh)
{
Evas_Canvas3D_Object_Data *pd = efl_data_scope_get(mesh, EVAS_CANVAS3D_OBJECT_CLASS);
Eo *material = NULL;
material = efl_add(EVAS_CANVAS3D_MATERIAL_CLASS, pd->evas);
evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, !!(eet_mesh->materials->colors[0].a > 0));
evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, !!(eet_mesh->materials->colors[1].a > 0));
evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, !!(eet_mesh->materials->colors[2].a > 0));
evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, eet_mesh->materials->colors[0].r, eet_mesh->materials->colors[0].g, eet_mesh->materials->colors[0].b, eet_mesh->materials->colors[0].a);
evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, eet_mesh->materials->colors[1].r, eet_mesh->materials->colors[1].g, eet_mesh->materials->colors[1].b, eet_mesh->materials->colors[1].a);
evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, eet_mesh->materials->colors[2].r, eet_mesh->materials->colors[2].g, eet_mesh->materials->colors[2].b, eet_mesh->materials->colors[2].a);
evas_canvas3d_material_shininess_set(material, eet_mesh->materials->shininess);
evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
}
void
evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
{
Eet_File *ef;
Evas_Canvas3D_File_Eet* eet_file;
Eet_Data_Descriptor *_file_descriptor;
eet_init();
_file_descriptor = _evas_canvas3d_eet_file_get();
ef = eet_mmap(file);
eet_file = eet_data_read(ef,
_file_descriptor,
EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY);
eet_close(ef);
if (!eet_file || !eet_file->mesh || !eet_file->header)
{
ERR("Failed to read model file");
goto on_error;
}
_set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh);
_set_material_to_mesh_from_eet_file(mesh, eet_file->mesh);
on_error:
_evas_canvas3d_eet_file_free(eet_file);
eet_shutdown();
}

View File

@ -1,423 +0,0 @@
#include "evas_common_private.h"
#include "evas_private.h"
#define PACKED __attribute__((__packed__))
#define MD2_MAGIC_NUMBER 844121161
#define MD2_VERSION 8
#define MD2_FRAME_SCALE 256
/* Structures for reading data from file. */
typedef struct _MD2_Header MD2_Header;
typedef struct _MD2_Vertex MD2_Vertex;
typedef struct _MD2_Frame MD2_Frame;
typedef struct _MD2_Triangle MD2_Triangle;
typedef struct _MD2_Texcoord MD2_Texcoord;
struct PACKED _MD2_Header
{
int magic;
int version;
int skin_width;
int skin_height;
int frame_size;
int skins_count;
int vertex_count;
int texcoord_count;
int triangle_count;
int glcmd_count;
int frame_count;
int offset_skins;
int offset_texcoords;
int offset_triangles;
int offset_frames;
int offset_glcmds;
int offset_end;
};
struct PACKED _MD2_Vertex
{
unsigned char pos[3];
unsigned char normal_idx;
};
struct PACKED _MD2_Frame
{
float scale[3];
float trans[3];
char name[16];
MD2_Vertex vertices[1];
};
struct PACKED _MD2_Triangle
{
unsigned short vertex_idx[3];
unsigned short texcoord_idx[3];
};
struct PACKED _MD2_Texcoord
{
short s;
short t;
};
typedef struct _MD2_Loader
{
char *map;
int size;
int skin_width;
int skin_height;
int frame_count;
int frame_size;
char *frames;
int vertex_count;
int triangle_count;
int texcoord_count;
MD2_Triangle *triangles;
MD2_Texcoord *texcoords;
} MD2_Loader;
static const float normal_table[162][3] =
{
{-0.525731f, 0.000000f, 0.850651f},
{-0.442863f, 0.238856f, 0.864188f},
{-0.295242f, 0.000000f, 0.955423f},
{-0.309017f, 0.500000f, 0.809017f},
{-0.162460f, 0.262866f, 0.951056f},
{ 0.000000f, 0.000000f, 1.000000f},
{ 0.000000f, 0.850651f, 0.525731f},
{-0.147621f, 0.716567f, 0.681718f},
{ 0.147621f, 0.716567f, 0.681718f},
{ 0.000000f, 0.525731f, 0.850651f},
{ 0.309017f, 0.500000f, 0.809017f},
{ 0.525731f, 0.000000f, 0.850651f},
{ 0.295242f, 0.000000f, 0.955423f},
{ 0.442863f, 0.238856f, 0.864188f},
{ 0.162460f, 0.262866f, 0.951056f},
{-0.681718f, 0.147621f, 0.716567f},
{-0.809017f, 0.309017f, 0.500000f},
{-0.587785f, 0.425325f, 0.688191f},
{-0.850651f, 0.525731f, 0.000000f},
{-0.864188f, 0.442863f, 0.238856f},
{-0.716567f, 0.681718f, 0.147621f},
{-0.688191f, 0.587785f, 0.425325f},
{-0.500000f, 0.809017f, 0.309017f},
{-0.238856f, 0.864188f, 0.442863f},
{-0.425325f, 0.688191f, 0.587785f},
{-0.716567f, 0.681718f, -0.147621f},
{-0.500000f, 0.809017f, -0.309017f},
{-0.525731f, 0.850651f, 0.000000f},
{ 0.000000f, 0.850651f, -0.525731f},
{-0.238856f, 0.864188f, -0.442863f},
{ 0.000000f, 0.955423f, -0.295242f},
{-0.262866f, 0.951056f, -0.162460f},
{ 0.000000f, 1.000000f, 0.000000f},
{ 0.000000f, 0.955423f, 0.295242f},
{-0.262866f, 0.951056f, 0.162460f},
{ 0.238856f, 0.864188f, 0.442863f},
{ 0.262866f, 0.951056f, 0.162460f},
{ 0.500000f, 0.809017f, 0.309017f},
{ 0.238856f, 0.864188f, -0.442863f},
{ 0.262866f, 0.951056f, -0.162460f},
{ 0.500000f, 0.809017f, -0.309017f},
{ 0.850651f, 0.525731f, 0.000000f},
{ 0.716567f, 0.681718f, 0.147621f},
{ 0.716567f, 0.681718f, -0.147621f},
{ 0.525731f, 0.850651f, 0.000000f},
{ 0.425325f, 0.688191f, 0.587785f},
{ 0.864188f, 0.442863f, 0.238856f},
{ 0.688191f, 0.587785f, 0.425325f},
{ 0.809017f, 0.309017f, 0.500000f},
{ 0.681718f, 0.147621f, 0.716567f},
{ 0.587785f, 0.425325f, 0.688191f},
{ 0.955423f, 0.295242f, 0.000000f},
{ 1.000000f, 0.000000f, 0.000000f},
{ 0.951056f, 0.162460f, 0.262866f},
{ 0.850651f, -0.525731f, 0.000000f},
{ 0.955423f, -0.295242f, 0.000000f},
{ 0.864188f, -0.442863f, 0.238856f},
{ 0.951056f, -0.162460f, 0.262866f},
{ 0.809017f, -0.309017f, 0.500000f},
{ 0.681718f, -0.147621f, 0.716567f},
{ 0.850651f, 0.000000f, 0.525731f},
{ 0.864188f, 0.442863f, -0.238856f},
{ 0.809017f, 0.309017f, -0.500000f},
{ 0.951056f, 0.162460f, -0.262866f},
{ 0.525731f, 0.000000f, -0.850651f},
{ 0.681718f, 0.147621f, -0.716567f},
{ 0.681718f, -0.147621f, -0.716567f},
{ 0.850651f, 0.000000f, -0.525731f},
{ 0.809017f, -0.309017f, -0.500000f},
{ 0.864188f, -0.442863f, -0.238856f},
{ 0.951056f, -0.162460f, -0.262866f},
{ 0.147621f, 0.716567f, -0.681718f},
{ 0.309017f, 0.500000f, -0.809017f},
{ 0.425325f, 0.688191f, -0.587785f},
{ 0.442863f, 0.238856f, -0.864188f},
{ 0.587785f, 0.425325f, -0.688191f},
{ 0.688191f, 0.587785f, -0.425325f},
{-0.147621f, 0.716567f, -0.681718f},
{-0.309017f, 0.500000f, -0.809017f},
{ 0.000000f, 0.525731f, -0.850651f},
{-0.525731f, 0.000000f, -0.850651f},
{-0.442863f, 0.238856f, -0.864188f},
{-0.295242f, 0.000000f, -0.955423f},
{-0.162460f, 0.262866f, -0.951056f},
{ 0.000000f, 0.000000f, -1.000000f},
{ 0.295242f, 0.000000f, -0.955423f},
{ 0.162460f, 0.262866f, -0.951056f},
{-0.442863f, -0.238856f, -0.864188f},
{-0.309017f, -0.500000f, -0.809017f},
{-0.162460f, -0.262866f, -0.951056f},
{ 0.000000f, -0.850651f, -0.525731f},
{-0.147621f, -0.716567f, -0.681718f},
{ 0.147621f, -0.716567f, -0.681718f},
{ 0.000000f, -0.525731f, -0.850651f},
{ 0.309017f, -0.500000f, -0.809017f},
{ 0.442863f, -0.238856f, -0.864188f},
{ 0.162460f, -0.262866f, -0.951056f},
{ 0.238856f, -0.864188f, -0.442863f},
{ 0.500000f, -0.809017f, -0.309017f},
{ 0.425325f, -0.688191f, -0.587785f},
{ 0.716567f, -0.681718f, -0.147621f},
{ 0.688191f, -0.587785f, -0.425325f},
{ 0.587785f, -0.425325f, -0.688191f},
{ 0.000000f, -0.955423f, -0.295242f},
{ 0.000000f, -1.000000f, 0.000000f},
{ 0.262866f, -0.951056f, -0.162460f},
{ 0.000000f, -0.850651f, 0.525731f},
{ 0.000000f, -0.955423f, 0.295242f},
{ 0.238856f, -0.864188f, 0.442863f},
{ 0.262866f, -0.951056f, 0.162460f},
{ 0.500000f, -0.809017f, 0.309017f},
{ 0.716567f, -0.681718f, 0.147621f},
{ 0.525731f, -0.850651f, 0.000000f},
{-0.238856f, -0.864188f, -0.442863f},
{-0.500000f, -0.809017f, -0.309017f},
{-0.262866f, -0.951056f, -0.162460f},
{-0.850651f, -0.525731f, 0.000000f},
{-0.716567f, -0.681718f, -0.147621f},
{-0.716567f, -0.681718f, 0.147621f},
{-0.525731f, -0.850651f, 0.000000f},
{-0.500000f, -0.809017f, 0.309017f},
{-0.238856f, -0.864188f, 0.442863f},
{-0.262866f, -0.951056f, 0.162460f},
{-0.864188f, -0.442863f, 0.238856f},
{-0.809017f, -0.309017f, 0.500000f},
{-0.688191f, -0.587785f, 0.425325f},
{-0.681718f, -0.147621f, 0.716567f},
{-0.442863f, -0.238856f, 0.864188f},
{-0.587785f, -0.425325f, 0.688191f},
{-0.309017f, -0.500000f, 0.809017f},
{-0.147621f, -0.716567f, 0.681718f},
{-0.425325f, -0.688191f, 0.587785f},
{-0.162460f, -0.262866f, 0.951056f},
{ 0.442863f, -0.238856f, 0.864188f},
{ 0.162460f, -0.262866f, 0.951056f},
{ 0.309017f, -0.500000f, 0.809017f},
{ 0.147621f, -0.716567f, 0.681718f},
{ 0.000000f, -0.525731f, 0.850651f},
{ 0.425325f, -0.688191f, 0.587785f},
{ 0.587785f, -0.425325f, 0.688191f},
{ 0.688191f, -0.587785f, 0.425325f},
{-0.955423f, 0.295242f, 0.000000f},
{-0.951056f, 0.162460f, 0.262866f},
{-1.000000f, 0.000000f, 0.000000f},
{-0.850651f, 0.000000f, 0.525731f},
{-0.955423f, -0.295242f, 0.000000f},
{-0.951056f, -0.162460f, 0.262866f},
{-0.864188f, 0.442863f, -0.238856f},
{-0.951056f, 0.162460f, -0.262866f},
{-0.809017f, 0.309017f, -0.500000f},
{-0.864188f, -0.442863f, -0.238856f},
{-0.951056f, -0.162460f, -0.262866f},
{-0.809017f, -0.309017f, -0.500000f},
{-0.681718f, 0.147621f, -0.716567f},
{-0.681718f, -0.147621f, -0.716567f},
{-0.850651f, 0.000000f, -0.525731f},
{-0.688191f, 0.587785f, -0.425325f},
{-0.587785f, 0.425325f, -0.688191f},
{-0.425325f, 0.688191f, -0.587785f},
{-0.425325f, -0.688191f, -0.587785f},
{-0.587785f, -0.425325f, -0.688191f},
{-0.688191f, -0.587785f, -0.425325f},
};
static inline Eina_Bool
_md2_loader_init(MD2_Loader *loader, Eina_File *file)
{
MD2_Header header;
memset(loader, 0x00, sizeof(MD2_Loader));
loader->map = eina_file_map_all(file, EINA_FILE_SEQUENTIAL);
if (loader->map == NULL)
{
ERR("Failed to create map from file %s\n", eina_file_filename_get(file));
goto error;
}
/* Check file size. We require a file larger than MD2 header size. */
loader->size = eina_file_size_get(file);
if (loader->size < (int)sizeof(MD2_Header))
goto error;
/* Read header. */
memcpy(&header, loader->map, sizeof(MD2_Header));
/* Check identity */
if (header.magic != MD2_MAGIC_NUMBER || header.version != MD2_VERSION)
goto error;
/* Check offsets */
if (header.offset_skins > header.offset_end)
goto error;
if (header.offset_texcoords > header.offset_end)
goto error;
if (header.offset_triangles > header.offset_end)
goto error;
if (header.offset_frames > header.offset_end)
goto error;
if (header.offset_glcmds > header.offset_end)
goto error;
if (header.offset_end > loader->size)
goto error;
loader->skin_width = header.skin_width;
loader->skin_height = header.skin_height;
loader->frame_count = header.frame_count;
loader->frame_size = header.frame_size;
loader->frames = loader->map + header.offset_frames;
loader->vertex_count = header.vertex_count;
loader->triangle_count = header.triangle_count;
loader->texcoord_count = header.texcoord_count;
loader->triangles = (MD2_Triangle *)(loader->map + header.offset_triangles);
loader->texcoords = (MD2_Texcoord *)(loader->map + header.offset_texcoords);
return EINA_TRUE;
error:
return EINA_FALSE;
}
void
evas_model_load_file_md2(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
{
MD2_Loader loader;
int i, j, k;
float *pos, *nor, *tex;
int stride_pos, stride_nor, stride_tex;
float s_scale, t_scale;
Evas_Canvas3D_Mesh_Data *pd;
/* Initialize MD2 loader (Open file and read MD2 head ant etc) */
if (!_md2_loader_init(&loader, file))
{
ERR("Failed to initialize MD2 loader.");
return;
}
s_scale = 1.0 / (float)(loader.skin_width - 1);
t_scale = 1.0 / (float)(loader.skin_height - 1);
evas_canvas3d_mesh_vertex_count_set(mesh, loader.triangle_count * 3);
evas_canvas3d_mesh_vertex_assembly_set(mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
/* Load frames */
for (i = 0; i < loader.frame_count; i++)
{
const MD2_Frame *frame = (const MD2_Frame *)(loader.frames + loader.frame_size * i);
int f = i * MD2_FRAME_SCALE;
/* Add a mesh frame. */
evas_canvas3d_mesh_frame_add(mesh, f);
/* Allocate vertex buffer for the frame. */
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 0, NULL);
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 0, NULL);
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 0, NULL);
/* Map vertex buffer. */
pos = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
nor = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
tex = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
stride_pos = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
stride_nor = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
stride_tex = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
if (stride_pos == 0)
stride_pos = sizeof(float) * 3;
if (stride_nor == 0)
stride_nor = sizeof(float) * 3;
if (stride_tex == 0)
stride_tex = sizeof(float) * 2;
for (j = 0; j < loader.triangle_count; j++)
{
const MD2_Triangle *tri = &loader.triangles[j];
for (k = 0; k < 3; k++)
{
unsigned int tidx, vidx;
float *p, *n, *t;
tidx = tri->texcoord_idx[k];
vidx = tri->vertex_idx[k];
p = (float *)((char *)pos + stride_pos * (j * 3 + k));
n = (float *)((char *)nor + stride_nor * (j * 3 + k));
t = (float *)((char *)tex + stride_tex * (j * 3 + k));
p[0] = frame->vertices[vidx].pos[0] * frame->scale[0] + frame->trans[0];
p[1] = frame->vertices[vidx].pos[1] * frame->scale[1] + frame->trans[1];
p[2] = frame->vertices[vidx].pos[2] * frame->scale[2] + frame->trans[2];
n[0] = normal_table[frame->vertices[vidx].normal_idx][0];
n[1] = normal_table[frame->vertices[vidx].normal_idx][1];
n[2] = normal_table[frame->vertices[vidx].normal_idx][2];
t[0] = loader.texcoords[tidx].s * s_scale;
t[1] = 1.0 - loader.texcoords[tidx].t * t_scale;
}
}
/* Unmap vertex buffer. */
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, f, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
pd = efl_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
if (!evas_canvas3d_mesh_aabb_add_to_frame(pd, f, stride_pos))
{
ERR("Axis-Aligned Bounding Box wasn't added in frame %d ", f);
}
}
if (loader.map)
{
eina_file_map_free(file, loader.map);
loader.map = NULL;
}
}

View File

@ -1 +0,0 @@
#all the loaders here are build statically, the build instructions are in src/lib/evas/meson.build

View File

@ -1,461 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include "stdio.h"
#include "evas_common_private.h"
#include "evas_private.h"
//TODO Increase of stability (reading .obj file saved with any flags).
/* set value to position [x][y] to array name which have. */
#define ARRAY_2D(name, x, y, count_y) (*(name + x * count_y + y))
/* read 3 float values in string and put it in array */
#define PUT_DATA_TO_ARRAY(array_name, name) \
sscanf (current,"%f %f %f", \
&ARRAY_2D(_##array_name##_obj, counts.current_##name##_counter, 0, 3), \
&ARRAY_2D(_##array_name##_obj, counts.current_##name##_counter, 1, 3), \
&ARRAY_2D(_##array_name##_obj, counts.current_##name##_counter, 2, 3)); \
counts.current_##name##_counter++;
#define AFTER_NEXT_SPACE(pointer)\
do \
{ \
pointer++; \
i++; \
} \
while (*pointer != ' ');
/* Structures for reading data from file. */
typedef struct _OBJ_Counts OBJ_Counts;
struct _OBJ_Counts
{
int _vertex_counter;
int _normal_counter;
int _texture_point_counter;
int _triangles_counter;
int current_vertex_counter;
int current_normal_counter;
int current_texture_point_counter;
int current_triangles_counter;
Eina_Bool existence_of_normal;
Eina_Bool existence_of_tex_point;
};
/* create new counter */
static inline OBJ_Counts
_new_count_elements(void)
{
OBJ_Counts counts;
counts._vertex_counter = 0;
counts._normal_counter = 0;
counts._texture_point_counter = 0;
counts._triangles_counter = 0;
counts.current_vertex_counter = 0;
counts.current_normal_counter = 0;
counts.current_texture_point_counter = 0;
counts.current_triangles_counter = 0;
counts.existence_of_normal = EINA_FALSE;
counts.existence_of_tex_point = EINA_FALSE;
return counts;
}
/* count triangles in face */
static void
_analyze_face_line(char * face_analyzer,
int * count_of_triangles_in_line)
{
int polygon_checker = -2;
Eina_Bool previous_is_space = EINA_TRUE;
while ((*face_analyzer != '\n') && (*face_analyzer != '#'))
{
if (*face_analyzer == ' ')
{
previous_is_space = EINA_TRUE;
}
else if ((previous_is_space) && (*face_analyzer >= '0') && (*face_analyzer <= '9'))
{
polygon_checker++;
previous_is_space = EINA_FALSE;
}
face_analyzer++;
}
*count_of_triangles_in_line = polygon_checker;
}
static inline OBJ_Counts
_count_elements(char *map)//count elements of mesh in .obj
{
OBJ_Counts counts = _new_count_elements();
char *current = map;
int polygon_checker = -2;//polygons with n vertices can be represented as n-2 triangles
Eina_Bool will_check_next_char = EINA_FALSE;
Eina_Bool first_char_is_v = EINA_FALSE;
Eina_Bool first_char_is_f = EINA_FALSE;
Eina_Bool previous_is_space = EINA_FALSE;
long i = 0;
/* count elements of mesh in .obj */
for (; *current != '\00'; i++)
{
if (will_check_next_char)
{
if (first_char_is_v)
{
switch (*current)
{
case ' ':
counts._vertex_counter++;
break;
case 't':
counts._texture_point_counter++;
counts.existence_of_tex_point = EINA_TRUE;
break;
case 'n':
counts._normal_counter++;
counts.existence_of_normal = EINA_TRUE;
break;
default:
break;
}
first_char_is_v = EINA_FALSE;
will_check_next_char = EINA_FALSE;
}
else if (first_char_is_f)
{
switch (*current)
{
case '\n':
first_char_is_f = EINA_FALSE;
counts._triangles_counter += polygon_checker;
polygon_checker = -2;
previous_is_space = EINA_FALSE;
break;
case '#':
first_char_is_f = EINA_FALSE;
counts._triangles_counter += polygon_checker;
polygon_checker = -2;
previous_is_space = EINA_FALSE;
break;
case ' ':
previous_is_space = EINA_TRUE;
break;
default:
if ((previous_is_space) && (*current >= '0') && (*current <= '9'))
{
polygon_checker++;
previous_is_space = EINA_FALSE;
}
break;
}
}
else
{
switch (*current)
{
case 'v':
first_char_is_v = EINA_TRUE;
break;
case 'f':
first_char_is_f = EINA_TRUE;
break;
case 'm':
will_check_next_char = EINA_FALSE;
break;
default:
will_check_next_char = EINA_FALSE;
break;
}
}
}
if (*current == '\n')
{
will_check_next_char = EINA_TRUE;
}
current++;
}
return counts;
}
static void
_read_point(int *triangles,
int num,
OBJ_Counts counts,
int num_cur,
char *pointer)
{
if (counts.existence_of_normal)
{
if (counts.existence_of_tex_point)
sscanf(pointer, "%i/%i/%i",
&ARRAY_2D(triangles, num_cur, (num - 1) * 3, 9),
&ARRAY_2D(triangles, num_cur, (num - 1) * 3 + 1, 9),
&ARRAY_2D(triangles, num_cur, (num - 1) * 3 + 2, 9));
else
sscanf(pointer, "%i//%i",
&ARRAY_2D(triangles, num_cur, (num - 1) * 3, 9),
&ARRAY_2D(triangles, num_cur, (num - 1) * 3 + 2, 9));
}
else
{
if (counts.existence_of_tex_point)
sscanf(pointer, "%i/%i",
&ARRAY_2D(triangles, num_cur, (num - 1) * 3, 9),
&ARRAY_2D(triangles, num_cur, (num - 1) * 3 + 1, 9));
else
sscanf(pointer, "%i",
&ARRAY_2D(triangles, num_cur, (num - 1) * 3, 9));
}
}
void
evas_model_load_file_obj(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
{
long i;
OBJ_Counts counts;//count elements of mesh in .obj
Eina_Bool will_check_next_char = EINA_FALSE;
Eina_Bool first_char_is_v = EINA_FALSE;
Eina_Bool first_char_is_f = EINA_FALSE;
float *pos = NULL, *nor = NULL, *tex = NULL;
int stride_pos = 0, stride_nor = 0, stride_tex = 0;
int j, k, data_for_one_point;
char *current, *map;
float *_vertices_obj = NULL, *_normales_obj = NULL, *_tex_coords_obj = NULL;
int *_triangles;
map = eina_file_map_all(file, EINA_FILE_SEQUENTIAL);
if (map == NULL)
{
ERR("Failed to create map from file %s\n", eina_file_filename_get(file));
return;
}
counts = _count_elements(map);
_vertices_obj = malloc(counts._vertex_counter * 3 * sizeof(float));
data_for_one_point = 1;
if (counts.existence_of_normal)
{
data_for_one_point++;
_normales_obj = malloc(counts._normal_counter * 3 * sizeof(float));
}
if (counts.existence_of_tex_point)
{
data_for_one_point++;
_tex_coords_obj = malloc(counts._texture_point_counter * 3 * sizeof(float));
}
_triangles = malloc(counts._triangles_counter * 9 * sizeof(int));
if ((map == NULL) || (_vertices_obj == NULL) || (_triangles == NULL) ||
((counts.existence_of_normal) && (_normales_obj == NULL)) ||
((counts.existence_of_tex_point) && (_tex_coords_obj == NULL)))
{
ERR("Allocate memory is failed.");
free(_vertices_obj);
free(_triangles);
if (counts.existence_of_normal)
free(_normales_obj);
if (counts.existence_of_tex_point)
free(_tex_coords_obj);
return;
}
current = map;
i = 0;
/* put data to arrays */
for (; *current != '\00'; i++)
{
if (will_check_next_char)
{
if (first_char_is_v)
{
switch (*current)
{
case ' ':
PUT_DATA_TO_ARRAY(vertices, vertex)
i--;
break;
case 't':
current++;
if (counts.existence_of_tex_point)
{
PUT_DATA_TO_ARRAY(tex_coords, texture_point)
}
break;
case 'n':
current++;
if (counts.existence_of_normal)
{
PUT_DATA_TO_ARRAY(normales, normal)
}
break;
default:
break;
}
first_char_is_v = EINA_FALSE;
will_check_next_char = EINA_FALSE;
}
else if (first_char_is_f)
{
char *auxiliary_pointer = current;
int count_of_triangles_in_line;
int the_first_point = counts.current_triangles_counter;
_analyze_face_line(auxiliary_pointer,
&count_of_triangles_in_line);
current++;
i++;
_read_point(_triangles, 1, counts,
the_first_point,
current);
AFTER_NEXT_SPACE(current)
for (j = 0; j < count_of_triangles_in_line; j++)
{
auxiliary_pointer = current;
if (counts.current_triangles_counter != the_first_point)
{
ARRAY_2D(_triangles, counts.current_triangles_counter, 0, 9) = \
ARRAY_2D(_triangles, the_first_point, 0, 9);
ARRAY_2D(_triangles, counts.current_triangles_counter, 1, 9) = \
ARRAY_2D(_triangles, the_first_point, 1, 9);
ARRAY_2D(_triangles, counts.current_triangles_counter, 2, 9) = \
ARRAY_2D(_triangles, the_first_point, 2, 9);
}
_read_point(_triangles, 2, counts,
counts.current_triangles_counter,
auxiliary_pointer);
AFTER_NEXT_SPACE(auxiliary_pointer);
_read_point(_triangles, 3, counts,
counts.current_triangles_counter,
auxiliary_pointer);
AFTER_NEXT_SPACE(current);
counts.current_triangles_counter++;
}
first_char_is_f = EINA_FALSE;
}
else
{
switch (*current)
{
case 'v':
first_char_is_v = EINA_TRUE;
break;
case 'f':
first_char_is_f = EINA_TRUE;
break;
case 'm':
will_check_next_char = EINA_FALSE;
break;
default:
will_check_next_char = EINA_FALSE;
break;
}
}
}
if (*current == '\n')
{
will_check_next_char = EINA_TRUE;
}
current++;
}
/* prepare of mesh and take pointers to data which must be read */
evas_canvas3d_mesh_vertex_count_set(mesh, counts._triangles_counter * 3);
evas_canvas3d_mesh_vertex_assembly_set(mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
evas_canvas3d_mesh_frame_add(mesh, 0);
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 0, NULL);
pos = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
stride_pos = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
if (counts.existence_of_normal)
{
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 0, NULL);
nor = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
stride_nor = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
}
if (counts.existence_of_tex_point)
{
evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 0, NULL);
tex = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
stride_tex = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
}
if (stride_pos == 0) stride_pos = sizeof(float) * 3;
if ((counts.existence_of_normal) && (stride_nor == 0))
stride_nor = sizeof(float) * 3;
if ((counts.existence_of_tex_point) && (stride_tex == 0))
stride_tex = sizeof(float) * 2;
for (j = 0; j < counts._triangles_counter; j++)
{
for (k = 0; k < 3; k++)
{
float *p, *n, *t;
n = NULL;
t = NULL;
p = (float *)((char *)pos + stride_pos * (j * 3 + k));
if (counts.existence_of_normal)
n = (float *)((char *)nor + stride_nor * (j * 3 + k));
if (counts.existence_of_tex_point)
t = (float *)((char *)tex + stride_tex * (j * 3 + k));
p[0] = ARRAY_2D(_vertices_obj, (ARRAY_2D(_triangles, j, (3 * k), 9) - 1), 0, 3);
p[1] = ARRAY_2D(_vertices_obj, (ARRAY_2D(_triangles, j, (3 * k), 9) - 1), 1, 3);
p[2] = ARRAY_2D(_vertices_obj, (ARRAY_2D(_triangles, j, (3 * k), 9) - 1), 2, 3);
if (n)
{
n[0] = ARRAY_2D(_normales_obj, (ARRAY_2D(_triangles, j, (3 * k + 2), 9) - 1), 0, 3);
n[1] = ARRAY_2D(_normales_obj, (ARRAY_2D(_triangles, j, (3 * k + 2), 9) - 1), 1, 3);
n[2] = ARRAY_2D(_normales_obj, (ARRAY_2D(_triangles, j, (3 * k + 2), 9) - 1), 2, 3);
}
if (t)
{
t[0] = ARRAY_2D(_tex_coords_obj, (ARRAY_2D(_triangles, j, (3 * k + 1), 9) - 1), 0, 3);
t[1] = ARRAY_2D(_tex_coords_obj, (ARRAY_2D(_triangles, j, (3 * k + 1), 9) - 1), 1, 3);
}
}
}
free(_vertices_obj);
if (counts.existence_of_normal)
free(_normales_obj);
if (counts.existence_of_tex_point)
free(_tex_coords_obj);
free(_triangles);
/* Unmap vertex buffer. */
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);
if (counts.existence_of_normal)
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL);
if (counts.existence_of_tex_point)
evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD);
Evas_Canvas3D_Mesh_Data *pd = efl_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
if (!evas_canvas3d_mesh_aabb_add_to_frame(pd, 0, stride_pos))
{
ERR("Axis-Aligned Bounding Box wasn't added in frame %d ", 0);
}
if (map)
{
eina_file_map_free(file, map);
map = NULL;
}
}

View File

@ -1,252 +0,0 @@
#include "evas_model_load_save_common.h"
static inline char *
_to_next_line(char *current)
{
while (*current != '\n') current++;
current++;
return current;
}
static inline char *
_to_begin_of_line(char *current)
{
while (*current != '\n') current--;
current++;
return current;
}
static inline char *
_to_next_number(char *current, int count)
{
int i;
for (i = 0; i < count; i++)
{
while (*current != ' ') current++;
current++;
}
return current;
}
static inline char *
_read_data(float *array, int place, int count, char *current, float divider)
{
int i;
for (i = 0; i < count; i++)
{
sscanf (current,"%f", &ARRAY_2D(array, place, i, count));
ARRAY_2D(array, place, i, count) /= divider;
current = _to_next_number(current, 1);
}
return current;
}
static inline Eina_Bool
_read_ply_header(char *map, Evas_Model_Load_Save_Header *header, const char *filename)
{
Eina_Bool reading_vertices = EINA_TRUE, check_next_char = EINA_FALSE;
int vertex_lines, triangles = 0, vertices_in_current_face = 0;
char **helping_pointer;
char *current;
helping_pointer = eina_str_split(map, "vertex ", 0);
if (helping_pointer == NULL)
{
ERR("PLY file doesn't contain the required keyword 'vertex': %s", filename);
return EINA_FALSE;
}
sscanf(helping_pointer[1], "%d", &header->vertices_count);
free(helping_pointer[0]);
free(helping_pointer);
helping_pointer = eina_str_split(map, "end_header\n", 0);
if (helping_pointer == NULL)
{
ERR("PLY file doesn't contain the required keyword 'end_header': %s", filename);
return EINA_FALSE;
}
current = helping_pointer[1];
vertex_lines = header->vertices_count;
while (*current != '\0')
{
if (vertex_lines == 1)
reading_vertices = EINA_FALSE;
if (*current == '\n')
{
if (reading_vertices)
vertex_lines--;
else
check_next_char = EINA_TRUE;
}
if (check_next_char)
{
if ((*current <= '9') && (*current >= '0'))
vertices_in_current_face = (vertices_in_current_face * 10) + (*current - '0');
else if (*current >= ' ')
{
triangles += (vertices_in_current_face - 2);
vertices_in_current_face = 0;
check_next_char = EINA_FALSE;
}
}
current++;
}
header->indices_count = 3 * triangles;
free(helping_pointer[0]);
free(helping_pointer);
/* analyse flags used when file was saved in blender */
helping_pointer = eina_str_split(map, "property float ", 0);
if (helping_pointer == NULL)
{
ERR("PLY file doesn't contain any float properties: %s", filename);
return EINA_FALSE;
}
if ((helping_pointer[1] != NULL) && (*helping_pointer[1] == 'x') &&
(helping_pointer[2] != NULL) && (*helping_pointer[2] == 'y') &&
(helping_pointer[3] != NULL) && (*helping_pointer[3] == 'z'))
header->existence_of_positions = EINA_TRUE;
else
{
ERR("PLY file doesn't start with x,y,z float fields, they are required: %s", filename);
free(helping_pointer[0]);
free(helping_pointer);
return EINA_FALSE;
}
if ((helping_pointer[4] != NULL) && (*helping_pointer[4] == 'n') &&
(helping_pointer[5] != NULL) && (*helping_pointer[5] == 'n') &&
(helping_pointer[6] != NULL) && (*helping_pointer[6] == 'n'))
header->existence_of_normals = EINA_TRUE;
if ((header->existence_of_normals &&
((helping_pointer[7] != NULL) && (*helping_pointer[7] == 's') &&
(helping_pointer[8] != NULL) && (*helping_pointer[8] == 't'))) ||
(!header->existence_of_normals &&
((helping_pointer[4] != NULL) && (*helping_pointer[4] == 's') &&
(helping_pointer[5] != NULL) && (*helping_pointer[5] == 't'))))
header->existence_of_tex_coords = EINA_TRUE;
free(helping_pointer[0]);
free(helping_pointer);
helping_pointer = eina_str_split(map, "property uchar ", 0);
if (helping_pointer == NULL)
{
ERR("PLY file doesn't contain any uchar properties: %s", filename);
return EINA_FALSE;
}
if ((helping_pointer[1] != NULL) && (*helping_pointer[1] == 'r') &&
(helping_pointer[2] != NULL) && (*helping_pointer[2] == 'g') &&
(helping_pointer[3] != NULL) && (*helping_pointer[3] == 'b'))
header->existence_of_colors = EINA_TRUE;
free(helping_pointer[0]);
free(helping_pointer);
return EINA_TRUE;
}
static inline void
_read_ply_vertex_data(Evas_Model_Load_Save_Header header,
char **current,
Evas_Model_Load_Save_Data data)
{
int i;
for (i = 0; i < header.vertices_count; i++)
{
*current = _read_data(data.positions, i, 3, *current, 1.0);
if (header.existence_of_normals)
*current = _read_data(data.normals, i, 3, *current, 1.0);
if (header.existence_of_tex_coords)
*current = _read_data(data.tex_coords, i, 2, *current, 1.0);
if (header.existence_of_colors)
*current = _read_data(data.colors, i, 3, *current, 255.0);
*current = _to_begin_of_line(*current);
}
}
static inline void
_read_ply_indices_data(Evas_Model_Load_Save_Header header,
char **current,
Evas_Model_Load_Save_Data data)
{
int i, j, count_of_triangles_in_line = 0;
for (i = 0; i < header.indices_count;)
{
sscanf (*current,"%d", &count_of_triangles_in_line);
count_of_triangles_in_line -= 2;
*current = _to_next_number(*current, 1);
sscanf (*current,"%hu", data.indices + i);
for (j = 0; j < count_of_triangles_in_line; j++)
{
if (j > 0)
data.indices[i] = data.indices[i - 3];
*current = _to_next_number(*current, 1);
sscanf (*current,"%hu %hu",
data.indices + i + 1,
data.indices + i + 2);
i+=3;
}
*current = _to_next_line(*current);
}
}
void
evas_model_load_file_ply(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
{
char *current = NULL, *map = NULL, **split_of_map = NULL;
Evas_Model_Load_Save_Header header = { 0, 0, 0, 0, 0, 0 };
Evas_Model_Load_Save_Data data = { NULL, NULL, NULL, NULL, NULL };
Evas_Model_Load_Save_Stride stride = { 0, 0, 0, 0 };
map = eina_file_map_all(file, EINA_FILE_SEQUENTIAL);
if (map == NULL)
{
ERR("Failed to create map from file %s\n", eina_file_filename_get(file));
return;
}
header = evas_model_load_save_header_new();
if(!_read_ply_header(map, &header, eina_file_filename_get(file))) return;
if (!evas_model_load_allocate_data_due_to_header(header, &data))
{
ERR("Memory allocation is failed.");
return;
}
split_of_map = eina_str_split(map, "end_header\n", 0);
current = split_of_map[1];
_read_ply_vertex_data(header, &current, data);
_read_ply_indices_data(header, &current, data);
evas_model_load_vertex_data_to_mesh(mesh, header, data, &stride);
evas_model_load_indices_data_to_mesh(mesh, header, data);
evas_model_load_vertex_data_unmap(mesh, 0, header);
evas_model_load_aabb_add_to_frame(mesh, 0, stride);
free(split_of_map[0]);
free(split_of_map);
if (map)
{
eina_file_map_free(file, map);
map = NULL;
}
evas_model_load_save_data_free(header, &data);
}

View File

@ -1,205 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Eet.h>
#include <stdio.h>
#include "evas_common_private.h"
#include "evas_private.h"
#define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3
#define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5
static void
_set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh,
Evas_Canvas3D_Mesh_Eet *eet_mesh,
Evas_Canvas3D_Header_Eet *eet_header,
Evas_Canvas3D_Mesh_Frame *f)
{
Evas_Canvas3D_Vertex_Buffer *vb;
int i;
float *src;
Evas_Canvas3D_Vertex_Eet *vertices =
calloc(1, sizeof(Evas_Canvas3D_Vertex_Eet) * mesh->vertex_count);
Evas_Canvas3D_Geometry_Eet *geometry =
calloc(1, sizeof(Evas_Canvas3D_Geometry_Eet));
int *geometries = malloc(sizeof(int));
if ((vertices == NULL) || (geometry == NULL))
{
ERR("Allocating of memory is failed.");
free(vertices);
free(geometry);
free(geometries);
return;
}
geometry->vertices_count = mesh->vertex_count;
geometries[0] = mesh->vertex_count;
#define SAVE_GEOMETRICS(a, component, command_for_z_component)\
vb = &f->vertices[a];\
if (vb->data == NULL)\
{\
ERR("Failed to read geometrics for '%s'.", #component);\
}\
else\
{\
src = (float *)vb->data;\
for (i = 0; i < mesh->vertex_count; i++)\
{\
vertices[i].component.x = src[0];\
vertices[i].component.y = src[1];\
command_for_z_component\
src += f->vertices[a].element_count;\
}\
}
geometry->vertices = vertices;
SAVE_GEOMETRICS(EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, position, vertices[i].position.z = src[2];)
SAVE_GEOMETRICS(EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, normal, vertices[i].normal.z = src[2];)
SAVE_GEOMETRICS(EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, texcoord,)
#undef SAVE_GEOMETRICS
eet_mesh->geometries = geometry;
eet_header->geometries = geometries;
}
static void
_set_material_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Eet *eet_mesh,
Evas_Canvas3D_Header_Eet *eet_header,
Evas_Canvas3D_Mesh_Frame *f)
{
int i;
Evas_Canvas3D_Material_Data *material =
efl_data_scope_get(f->material, EVAS_CANVAS3D_MATERIAL_CLASS);
Evas_Canvas3D_Material_Eet *saved_materials =
malloc(sizeof(Evas_Canvas3D_Material_Eet));
Evas_Canvas3D_Color_Eet *saved_colors =
malloc(sizeof(Evas_Canvas3D_Color_Eet) * EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT);
int *materials = malloc(sizeof(int));
if ((saved_materials == NULL) || (saved_colors == NULL))
{
ERR("Allocating of memory is failed.");
free(material);
free(saved_materials);
free(saved_colors);
free(materials);
return;
}
if (material == NULL)
{
ERR("Material is set to the default values, because no custom material "
"was saved earlier by evas_3d_mesh_save.");
for (i = 0; i < 5; i++)
{
saved_colors[i].r = COMPONENT_OF_DEFAULT_GREY_COLOR;
saved_colors[i].g = COMPONENT_OF_DEFAULT_GREY_COLOR;
saved_colors[i].b = COMPONENT_OF_DEFAULT_GREY_COLOR;
saved_colors[i].a = TRANSPARENCY_OF_DEFAULT_GREY_COLOR;
}
saved_materials->shininess = 50;
}
else
{
for (i = 0; i < 5; i++)
{
saved_colors[i].r = material->attribs[i].color.r;
saved_colors[i].g = material->attribs[i].color.g;
saved_colors[i].b = material->attribs[i].color.b;
saved_colors[i].a = material->attribs[i].color.a;
}
saved_materials->shininess = material->shininess;
}
saved_materials->colors_count = EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT;
materials[0] = EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT;
saved_materials->id = 1;
saved_materials->colors = saved_colors;
eet_mesh->materials = saved_materials;
eet_header->materials = materials;
}
static void
_set_frame_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Eet *eet_mesh)
{
eet_mesh->frames = malloc(sizeof(Evas_Canvas3D_Frame_Eet));
if (eet_mesh->frames == NULL)
{
ERR("Allocating of memory is failed.");
return;
}
eet_mesh->frames->id = 1;
eet_mesh->frames->geometry_id = 1;
eet_mesh->frames->material_id = 1;
}
void
evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
const char *file,
Evas_Canvas3D_Mesh_Frame *f)
{
Evas_Canvas3D_Mesh_Data *pd = efl_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
Eet_File *ef;
Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet));
Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet));
Eet_Data_Descriptor *_file_descriptor;
Evas_Canvas3D_File_Eet *eet_file;
eet_init();
ef = eet_open(file, EET_FILE_MODE_WRITE);
if (ef == NULL)
{
ERR("Opening of file is failed.");
free(eet_mesh);
free(eet_header);
eet_shutdown();
return;
}
_file_descriptor = _evas_canvas3d_eet_file_get();
eet_file = _evas_canvas3d_eet_file_new();
if (!eet_file)
{
free(eet_mesh);
free(eet_header);
eet_shutdown();
return;
}
eet_mesh->materials_count = 1;
eet_header->materials_count = 1;
eet_mesh->frames_count = 1;
eet_header->frames = 1;
eet_mesh->geometries_count = 1;
eet_header->geometries_count = 1;
eet_header->version = 1;
_set_geometry_to_eet_file_from_mesh(pd, eet_mesh, eet_header, f);
_set_material_to_eet_file_from_mesh(eet_mesh, eet_header, f);
_set_frame_to_eet_file_from_mesh(eet_mesh);
eet_file->mesh = eet_mesh;
eet_file->header = eet_header;
eet_data_write(ef,
_file_descriptor,
EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY,
eet_file,
EINA_TRUE);
eet_close(ef);
_evas_canvas3d_eet_file_free(eet_file);
eet_shutdown();
}

View File

@ -1 +0,0 @@
#all the loaders here are build statically, the build instructions are in src/lib/evas/meson.build

Some files were not shown because too many files have changed in this diff Show More