From: subhransu Date: Mon, 14 Apr 2014 10:03:47 +0000 (+0900) Subject: Evas_3D : Eolian change X-Git-Tag: v1.10.0-alpha1~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e84e28fc225f46f5e5e25bf23677a647a75ea3c9;p=platform%2Fupstream%2Fefl.git Evas_3D : Eolian change Conflicts: src/Makefile_Evas.am src/lib/evas/Evas_3D.h src/lib/evas/Evas_Eo.h --- diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 9ca83a8..27f5054 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -61,7 +61,21 @@ BUILT_SOURCES += \ lib/evas/canvas/evas_zoomable_interface.eo.h \ lib/evas/canvas/evas_box.eo.c \ lib/evas/canvas/evas_box.eo.h \ - lib/evas/canvas/evas_box.eo.legacy.h + lib/evas/canvas/evas_box.eo.legacy.h \ + lib/evas/canvas/evas_3d_camera.eo.c\ + lib/evas/canvas/evas_3d_camera.eo.h\ + lib/evas/canvas/evas_3d_texture.eo.c\ + lib/evas/canvas/evas_3d_texture.eo.h\ + lib/evas/canvas/evas_3d_material.eo.c\ + lib/evas/canvas/evas_3d_material.eo.h\ + lib/evas/canvas/evas_3d_light.eo.c\ + lib/evas/canvas/evas_3d_light.eo.h\ + lib/evas/canvas/evas_3d_mesh.eo.c\ + lib/evas/canvas/evas_3d_mesh.eo.h\ + lib/evas/canvas/evas_3d_node.eo.c\ + lib/evas/canvas/evas_3d_node.eo.h\ + lib/evas/canvas/evas_3d_scene.eo.c\ + lib/evas/canvas/evas_3d_scene.eo.h evaseolianfilesdir = $(datadir)/eolian/include/evas-@VMAJ@ evaseolianfiles_DATA = \ @@ -86,8 +100,15 @@ evaseolianfiles_DATA = \ lib/evas/canvas/evas_scrollable_interface.eo \ lib/evas/canvas/evas_selectable_interface.eo \ lib/evas/canvas/evas_zoomable_interface.eo \ - lib/evas/canvas/evas_box.eo - + lib/evas/canvas/evas_box.eo\ + lib/evas/canvas/evas_3d_camera.eo\ + lib/evas/canvas/evas_3d_texture.eo\ + lib/evas/canvas/evas_3d_material.eo\ + lib/evas/canvas/evas_3d_light.eo\ + lib/evas/canvas/evas_3d_mesh.eo\ + lib/evas/canvas/evas_3d_node.eo\ + lib/evas/canvas/evas_3d_scene.eo + EXTRA_DIST += \ ${evaseolianfiles_DATA} diff --git a/src/lib/evas/Evas_3D.h b/src/lib/evas/Evas_3D.h index b18f69f..f3ed09f 100644 --- a/src/lib/evas/Evas_3D.h +++ b/src/lib/evas/Evas_3D.h @@ -1,2149 +1,3 @@ #ifndef _EVAS_3D_H #define _EVAS_3D_H - -/** - * @defgroup Evas_3D Evas 3D Extensions - * - * Evas extension to support 3D rendering. - * - * @ingroup Evas - */ - -/** - * @page evas_3d_main Evas 3D - * - * @date 2014 (created) - * - * @section toc Table of Contents - * - * @li @ref evas_3d_intro - * @li @ref evas_3d_example - * - * @section evas_3d_intro Introduction - * - * Evas 3D is an extension to support 3D scene graph rendering into 2D Evas - * canvas supporting typicall tree-based scene graph manipulation and other 3D - * graphics rendering techniques. - * - * Evas 3D provides 3D objects which are used for describing 3D scene and APIs - * to connect the scene with an evas image object so that the scene is rendered - * on that image object. - * - * Contruction of a 3D scene is process of locating desired cameras, lights and - * meshes in the scene. Typically the scene is structured with some hierarchical - * data structure. Evas 3D support n-ary tree structure for describing the - * scene. Node is used to build the tree representation of the scene. Other - * objects, like camera, light and mesh can be located in the scene by being - * contained in a node. - * - * Like other 3D graphics engine, Evas 3D support standard 3D rendering method - * like flat shading, phong shading and normal map and other features like - * texture mapping, triangle meshes. - * - * Besides all the traditional 3D rendering things, one of the key feature of - * the Evas 3D is that it is able to use existing evas objects as textures - * inside of the 3D scene. "Existing evas objects" means all the EFL widgets - * and applications. By supporting this, it is easy to make 3D version of an - * application without modifying the original source that much. - * - * Also, 3D scene can be located on the canvas naturally stacked with existing - * evas objects. This can make it possible putting 3D things into existing 2D - * application layouts. - * - * @section evas_3d_example Introductory Example - * - * @include evas-3d-cube.c - */ - -/** - * @defgroup Evas_3D_Types Types & Enums - * @ingroup Evas_3D - * - * Primitive type definitions and enumations. - */ - -/** - * @defgroup Evas_3D_Object Generic 3D Object Descriptions - * @ingroup Evas_3D - * - * Evas 3D object is a generic type of all evas 3D objects like scene, node, - * camera, light, mesh, texture and material. Evas 3D object is basically - * reference counted. Any successful function call on an object which make a - * reference to an another object will increase the reference count. When the - * reference count gets to 0, the object will be actually deleted. - * - * Any modifications are automatically propagated to other objects referencing - * the modified objects. As a result, if the scene object is set to modified - * state, all image objects having the scene as a rendering source are marked - * as dirty, so that rendering will be updated at next frame. But all these - * things are done internally, so feel free to forget about calling some kind - * of update functions. - */ - -/** - * @defgroup Evas_3D_Scene Scene Object - * @ingroup Evas_3D - * - * A scene represents a captured image of a scene graph through its viewing - * camera. A scene can be set to an image object to be displayed on the Evas - * canvas by using evas_object_image_3d_scene_set() function. - */ - -/** - * @defgroup Evas_3D_Node Node Object - * @ingroup Evas_3D - * - * A node is used for hierarchical construction of a scene graph. Evas 3D - * provides n-ary tree structure for the scene graph construction.A node has - * its position, orientation and scale. Other objects, like camera, light and - * mesh can be contained in a node to be located in a 3D space. - */ - -/** - * @defgroup Evas_3D_Camera Camera Object - * @ingroup Evas_3D - * - * A camera object is used for taking a picture of a scene graph. A camera - * object itself is just a set of properties on how the camera should take the - * picture (like focus length and film size of the real world cameras). To be - * able to take a shot of the scene, a camera should be located in the scene, so - * that it has its viewing position and direction. It is done by containing the - * camera on a node. If one wants to locate several cameras having same - * properties, instead of creating multiple cameras, just create one camera and - * multiple nodes containing the camera and locate them at each desired position - * and direction. Just for convinience, use evas_3d_node_position_set() to move - * the camera to desired position and use evas_3d_node_look_at_set() to adjust - * the viewing direction of the camera. - */ - -/** - * @defgroup Evas_3D_Light Light Object - * @ingroup Evas_3D - * - * A light object represents a set of properties of a light source. Evas 3D - * provides standard reflection model that of ambient, diffuse and specular - * reflection model. Also, Evas 3D support 3 types of light model, directional, - * point and spot light. Light position and direction is determined by the node - * containing the light. - */ - -/** - * @defgroup Evas_3D_Mesh Mesh Object - * @ingroup Evas_3D - * - * A mesh object is a set of information on a visible geometrical object like - * character model, terrain or other structures and entities. Evas 3D support - * key-frame-based mesh animation, so a mesh can have multiple frames and each - * frame has its own material and geometric data. Like other data objects, a - * mesh can be located on a scene by being contained in a node. The mesh is - * transformed from its modeling coordinate space into the node's coordinate - * space. Also, the frame number is saved in the containing node. So, one can - * locate multiple nodes having same mesh object with different animation frame - * and transform. Unlike camera and light object, multiple meshes can be - * contained in a single node. - */ - -/** - * @defgroup Evas_3D_Texture Texture Object - * @ingroup Evas_3D - * - * A texture object is an image represents material of surfaces. A texture can - * be set to a slot of Evas_3D_Material by using evas_3d_material_texture_set() - * function. The data of a texture can be loaded from memory, file and other - * Evas_Object. - */ - -/** - * @defgroup Evas_3D_Material Material Object - * @ingroup Evas_3D - * - * A material object represents properties of surfaces. Evas 3D defines the - * properties with 5 material attributes, ambient, diffuse, specular emission - * and normal. Each attribute have its color value and texture map. Materials - * are used to determine the color of mesh surfaces. - */ - -/** - * @typedef Evas_Real - * - * Floating-point data type - * - * Evas 3D use its own floating-point type. Even though it's a standard IEEE - * 754 floating-point type always use Evas_Real for the type safety. Double - * precision and fixed-point types will be useful but it's not supported yet. - * - * @ingroup Evas_3D_Types - */ -typedef float Evas_Real; - -/** - * @typedef Evas_3D_Scene - * - * Scene object handle - * - * @ingroup Evas_3D_Scene - */ -typedef struct _Evas_3D_Scene Evas_3D_Scene; - -/** - * @typedef Evas_3D_Node - * - * Node object handle - * - * @ingroup Evas_3D_Node - */ -typedef struct _Evas_3D_Node Evas_3D_Node; - -/** - * @typedef Evas_3D_Camera - * - * Camera object handle - * - * @ingroup Evas_3D_Camera - */ -typedef struct _Evas_3D_Camera Evas_3D_Camera; - -/** - * @typedef Evas_3D_Light - * - * Light object handle - * - * @ingroup Evas_3D_Light - */ -typedef struct _Evas_3D_Light Evas_3D_Light; - -/** - * @typedef Evas_3D_Mesh - * - * Mesh object handle - * - * @ingroup Evas_3D_Mesh - */ -typedef struct _Evas_3D_Mesh Evas_3D_Mesh; - -/** - * @typedef Evas_3D_Texture - * - * Texture object handle - * - * @ingroup Evas_3D_Texture - */ -typedef struct _Evas_3D_Texture Evas_3D_Texture; - -/** - * @typedef Evas_3D_Material - * - * Material object handle - * - * @ingroup Evas_3D_Material - */ -typedef struct _Evas_3D_Material Evas_3D_Material; - -/** - * Transform space - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Space -{ - EVAS_3D_SPACE_LOCAL, /**< Local coordinate space */ - EVAS_3D_SPACE_PARENT, /**< Parent coordinate space */ - EVAS_3D_SPACE_WORLD, /**< World coordinate space */ -} Evas_3D_Space; - -/** - * Types of a node - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Node_Type -{ - EVAS_3D_NODE_TYPE_NODE, /**< Node with no items */ - EVAS_3D_NODE_TYPE_CAMERA, /**< Node which can contain camera object */ - EVAS_3D_NODE_TYPE_LIGHT, /**< Node which can contain light object */ - EVAS_3D_NODE_TYPE_MESH, /**< Node which can contain mesh objects */ -} Evas_3D_Node_Type; - -/** - * Vertex attribute IDs - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Vertex_Attrib -{ - EVAS_3D_VERTEX_POSITION, /**< Vertex position */ - EVAS_3D_VERTEX_NORMAL, /**< Vertex normal */ - EVAS_3D_VERTEX_TANGENT, /**< Vertex tangent (for normal mapping) */ - EVAS_3D_VERTEX_COLOR, /**< Vertex color */ - EVAS_3D_VERTEX_TEXCOORD, /**< Vertex texture coordinate */ -} Evas_3D_Vertex_Attrib; - -/** - * Index formats - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Index_Format -{ - EVAS_3D_INDEX_FORMAT_NONE, /**< Indexing is not used */ - EVAS_3D_INDEX_FORMAT_UNSIGNED_BYTE, /**< Index is of type unsigned byte */ - EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, /**< Index is of type unsigned short */ -} Evas_3D_Index_Format; - -/** - * Vertex assembly modes - * @ingroup Evas_3D_Types - * - * Vertex assembly represents how the vertices are organized into geometric - * primitives. - */ -typedef enum _Evas_3D_Vertex_Assembly -{ - EVAS_3D_VERTEX_ASSEMBLY_POINTS, /**< A vertex is rendered as a point */ - EVAS_3D_VERTEX_ASSEMBLY_LINES, /**< Two vertices are organized as a line */ - EVAS_3D_VERTEX_ASSEMBLY_LINE_STRIP, /**< Vertices are organized as a connected line path */ - EVAS_3D_VERTEX_ASSEMBLY_LINE_LOOP, /**< Vertices are organized as a closed line path */ - EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES, /**< Three vertices are organized as a triangle */ - EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP, /**< Vertices are organized as connected triangles */ - EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN, /**< Vertices are organized as a triangle fan */ -} Evas_3D_Vertex_Assembly; - -/** - * Color formats of pixel data - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Color_Format -{ - EVAS_3D_COLOR_FORMAT_RGBA, /**< Color contains full components, red, green, blue and alpha */ - EVAS_3D_COLOR_FORMAT_RGB, /**< Color contains only red, green and blue components */ - EVAS_3D_COLOR_FORMAT_ALPHA, /**< Color contains only alpha component */ -} Evas_3D_Color_Format; - -/** - * Pixel formats - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Pixel_Format -{ - EVAS_3D_PIXEL_FORMAT_8, /**< 8-bit pixel with single component */ - EVAS_3D_PIXEL_FORMAT_565, /**< 16-bit pixel with three components (5-6-5 bit) */ - EVAS_3D_PIXEL_FORMAT_888, /**< 24-bit pixel with three 8-bit components */ - EVAS_3D_PIXEL_FORMAT_8888, /**< 32-bit pixel with four 8-bit components */ - EVAS_3D_PIXEL_FORMAT_4444, /**< 16-bit pixel with four 4-bit components */ - EVAS_3D_PIXEL_FORMAT_5551, /**< 16-bit pixel with four components (5-5-5-1 bit) */ -} Evas_3D_Pixel_Format; - -/** - * Wrap modes - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Wrap_Mode -{ - EVAS_3D_WRAP_MODE_CLAMP, /**< Values will be clamped to be in range [min, max] */ - EVAS_3D_WRAP_MODE_REPEAT, /**< Values will be repeated */ - EVAS_3D_WRAP_MODE_REFLECT, /**< Values will be repeated in a reflected manner */ -} Evas_3D_Wrap_Mode; - -/** - * Texture filters - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Texture_Filter -{ - EVAS_3D_TEXTURE_FILTER_NEAREST, /**< Samples nearest texel */ - EVAS_3D_TEXTURE_FILTER_LINEAR, /**< Lineary interpolate nearby texels */ - EVAS_3D_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST, /**< Nearest sampling mipmap */ - EVAS_3D_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST, /**< Nearest sampling mipmap and interpolate */ - EVAS_3D_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR, /**< Linear sampling in nearest mipmap */ - EVAS_3D_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR, /**< Linear sampling in mipmap and interpolate */ -} Evas_3D_Texture_Filter; - -/** - * Shade modes - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Shade_Mode -{ - EVAS_3D_SHADE_MODE_VERTEX_COLOR, /**< Shaded using vertex color attribute */ - EVAS_3D_SHADE_MODE_DIFFUSE, /**< Shaded using material diffuse term */ - EVAS_3D_SHADE_MODE_FLAT, /**< Per-vertex flat lighting */ - EVAS_3D_SHADE_MODE_PHONG, /**< Per-pixel phong shading */ - EVAS_3D_SHADE_MODE_NORMAL_MAP, /**< Per-pixel normal map shading */ -} Evas_3D_Shade_Mode; - -/** - * Material attributes - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Material_Attrib -{ - EVAS_3D_MATERIAL_AMBIENT, /**< Ambient term */ - EVAS_3D_MATERIAL_DIFFUSE, /**< Diffuse term */ - EVAS_3D_MATERIAL_SPECULAR, /**< Specular term */ - EVAS_3D_MATERIAL_EMISSION, /**< Emission term */ - EVAS_3D_MATERIAL_NORMAL, /**< Normal map term */ -} Evas_3D_Material_Attrib; - -/** - * Mesh file type - * @ingroup Evas_3D_Types - */ -typedef enum _Evas_3D_Mesh_File_Type -{ - EVAS_3D_MESH_FILE_TYPE_MD2, /**< Quake's MD2 mesh file format */ -} Evas_3D_Mesh_File_Type; - -typedef enum _Evas_3D_Pick_Type -{ - EVAS_3D_PICK_NODE, - EVAS_3D_PICK_MESH, -} Evas_3D_Pick_Type; - -/** - * Set the scene on an image object. - * - * @param obj Image object. - * @param scene Scene object used as a content of the given image object. - * - * An image object can get its content from various sources like memory buffers, - * image files and other evas object. A scene also can be a source for an image - * object to display the rendered result onto evas canvas. - * - * Any existing content (data, file or proxy source) will be removed after this - * call. Setting @p src to @c NULL detach the 3D scene from the image object. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_object_image_3d_scene_set(Evas_Object *obj, Evas_3D_Scene *scene) EINA_ARG_NONNULL(1); - -/** - * Get the current scene of an image object. - * - * @param obj Image object. - * @return Scene object handle (if any), or @c NULL if there's no scene attached. - * - * @ingroup Evas_3D_Scene - */ -EAPI Evas_3D_Scene *evas_object_image_t3d_scene_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Create a new scene on the given Evas @p e canvas. - * - * @param e The given canvas. - * @return The created scene handle. - * - * @ingroup Evas_3D_Scene - */ -EAPI Evas_3D_Scene *evas_3d_scene_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a scene from its belonging Evas canvas. - * - * @param scene The given scene to be deleted. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_del(Evas_3D_Scene *scene) EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given scene belongs to. - * - * @param scene The given scene. - * @return The Evas canvas. - * - * @ingroup Evas_3D_Scene - */ -EAPI Evas *evas_3d_scene_evas_get(const Evas_3D_Scene *scene) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the root node of a scene. - * - * @param scene The given scene. - * @param node A node which will be used as a root node for the scene. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_root_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node) EINA_ARG_NONNULL(1); - -/** - * Get the root node of a scene. - * - * @param scene The given scene. - * @return The root node of the given scene. - * - * @ingroup Evas_3D_Scene - */ -EAPI Evas_3D_Node *evas_3d_scene_root_node_get(const Evas_3D_Scene *scene) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the camera node of a scene. - * - * @param scene The given scene. - * @param node A node which will be used as a camera node for the scene. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_camera_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node) EINA_ARG_NONNULL(1); - -/** - * Get the camera node of a scene. - * - * @param scene The given scene. - * @return The camera node of the given scene. - * - * @ingroup Evas_3D_Scene - */ -EAPI Evas_3D_Node *evas_3d_scene_camera_node_get(const Evas_3D_Scene *scene) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the resolution of a scene. - * - * @param scene The given scene. - * @param w Width of the resolution. - * @param h Height of the resolution. - * - * A scene should be rendered to be displayed through an image objects. The - * resolution defines size of the internal surface holding the rendered result. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_size_set(Evas_3D_Scene *scene, int w, int h) EINA_ARG_NONNULL(1); - -/** - * Get the internal resolution of a scene. - * - * @param scene The given scene. - * @param w Pointer to receive width of the resolution. - * @param h Pointer to receive height of the resolution. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_size_get(const Evas_3D_Scene *scene, int *w, int *h) EINA_ARG_NONNULL(1); - -/** - * Set the background color of a scene. - * - * @param scene The given scene. - * @param r Red component of the background color. - * @param g Green component of the background color. - * @param b Blue component of the background color. - * @param a Alpha component of the background color. - * - * Background color defines initial color of pixels before a scene is rendered. - * If you want to display a scene with background evas objects are still - * remaining as if it was the background, set the alpha term to 0.0. - * - * Default background color is (0.0, 0.0, 0.0, 0.0). - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_background_color_set(Evas_3D_Scene *scene, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); - -/** - * Get the background color of a scene. - * - * @param scene The given scene. - * @param r Pointer to receive red component of the background color. - * @param g Pointer to receive green component of the background color. - * @param b Pointer to receive blue component of the background color. - * @param a Pointer to receive alpha component of the background color. - * - * @ingroup Evas_3D_Scene - */ -EAPI void evas_3d_scene_background_color_get(const Evas_3D_Scene *scene, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); - -/** - * Get information on the most front visible mesh for the given position. - * - * @param scene The given scene. - * @param x X coordinate of the picking position. - * @param y Y coordinate of the picking position. - * @param node Pointer to receive the node contains the picked mesh. - * @param mesh Pointer to receive the picked mesh. - * @param s Pointer to receive the texture "s" coordinate. - * @param t Pointer to receive the texture "t" coordinate. - * - * (x, y) is the screen coordinate of the given scene. That is, left-top is - * (0, 0) and right-bottom is (w, h) where (w, h) is the size of the scene. - * The texture coordinate is useful when using proxy texture source. - * - * @ingroup Evas_3D_Scene - */ -EAPI Eina_Bool evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y, Evas_3D_Node **node, Evas_3D_Mesh **mesh, Evas_Real *s, Evas_Real *t) EINA_ARG_NONNULL(1); - -/** - * Create a new node on the given Evas @p canvas. - * - * @param e The given canvas. - * @param type The type of the node. - * @return The created node handle. - * - * @ingroup Evas_3D_Node - */ -EAPI Evas_3D_Node *evas_3d_node_add(Evas *e, Evas_3D_Node_Type type) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a node from its belonging Evas canvas. - * - * @param node The given node. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_del(Evas_3D_Node *node) EINA_ARG_NONNULL(1); - -/** - * Get the type of the given node. - * - * @param node The given node. - * @return The type of the given node. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Node - */ -EAPI Evas_3D_Node_Type evas_3d_node_type_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given node belongs to. - * - * @param node The given node. - * @return The Evas canvas. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Node - */ -EAPI Evas *evas_3d_node_evas_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Add a member node to the given node. - * - * @param node The given node which will be the parent. - * @param member Node object to be added. - * - * Nodes can be constructed into N-ary tree structure like other ordinary scene - * graph. Basically a node inherit transforms from its parent. - * - * @see evas_3d_node_parent_get() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_member_add(Evas_3D_Node *node, Evas_3D_Node *member) EINA_ARG_NONNULL(1, 2); - -/** - * Delete a member node from the given node. - * - * @param node The given node. - * @param member Member node to be deleted from the given node. - * - * @see evas_3d_node_member_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_member_del(Evas_3D_Node *node, Evas_3D_Node *member) EINA_ARG_NONNULL(1, 2); - -/** - * Get the parent node of the given node. - * - * @param node The given node. - * @return The parent node of the given node. - * - * @see evas_3d_node_member_add() - * - * @ingroup Evas_3D_Node - */ -EAPI Evas_3D_Node *evas_3d_node_parent_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the list of member nodes of the given node. - * - * @param node The given node. - * @return The list of member nodes if any or @c NULL if there are none. - * - * @see evas_3d_node_member_add() - * - * @ingroup Evas_3D_Node - */ -EAPI const Eina_List *evas_3d_node_member_list_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @defgroup Evas_3D_Node_Transform - * @ingroup Evas_3D_Node - * - * Functions that manipulate node transforms. - * - * Evas_3D_Node does not provide standard 4x4 matrix to transform something. - * Instead, one can set position, orientation and scale of a node separately. - * A node will be first scaled and rotated and then translated according to its - * position, orientation and scale. Each transform attributes can be set to - * inherit from its parent or not. - */ - -/** - * Set the position of the given node. - * - * @param node The given node. - * @param x X coordinate of the position. - * @param y Y coordinate of the position. - * @param z Z coordinate of the position. - * - * According to the inheritance flag, (x, y, z) can be a world space position or - * parent space position. - * - * Default position is (0.0, 0.0, 0.0). - * - * @see evas_3d_node_position_inherit_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_position_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); - -/** - * Set the orientation of the given node using quaternion. - * - * @param node The given node. - * @param x X term of the orientation quaternion (w, x, y, z) - * @param y Y term of the orientation quaternion (w, x, y, z) - * @param z Z term of the orientation quaternion (w, x, y, z) - * @param w W term of the orientation quaternion (w, x, y, z) - * - * According the the inheritance flag, (w, x, y, z) can be a world space - * orientation or parent space orientation. - * - * Default orientation is (1.0, 0.0, 0.0, 0.0) (identity quaternion). - * - * @see evas_3d_node_orientation_inherit_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_orientation_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z, Evas_Real w) EINA_ARG_NONNULL(1); - -/** - * Set the orientation of the given node using euler angle. - * - * @param node The given node. - * @param x Rotation angle about X-axis. - * @param y Rotation angle about Y-axis. - * @param z Rotation angle about Z-axis. - * - * @see evas_3d_node_orientation_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_orientation_euler_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); - -/** - * Set the orientation of the given node using axis-angle. - * - * @param node The given node. - * @param angle Rotation angle. - * @param x X term of the rotation axis. - * @param y Y term of the rotation axis. - * @param z Z term of the rotation axis. - * - * @see evas_3d_node_orientation_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_orientation_angle_axis_set(Evas_3D_Node *node, Evas_Real angle, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); - -/** - * Set the scale of the given node. - * - * @param node The given node. - * @param x Scale factor along X-axis. - * @param y Scale factor along Y-axis. - * @param z Scale factor along Z-axis. - * - * According to the inheritance flag, (x, y, z) can be a world space scale or - * parent space scale. Be careful when using non-uniform scale factor with - * inheritance, each transform attributes are not affected by other attributes. - * - * Default scale is (1.0, 1.0, 1.0). - * - * @see evas_3d_node_scale_inherit_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_scale_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); - -/** - * Get the position of the given node. - * - * @param node The given node. - * @param x Pointer to receive X coordinate of the position. - * @param y Pointer to receive Y coordinate of the position. - * @param z Pointer to receive Z coordinate of the position. - * - * @see evas_3d_node_position_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_position_get(const Evas_3D_Node *node, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z) EINA_ARG_NONNULL(1); - -/** - * Get the orientation of the given node as quaternion. - * - * @param node The given node. - * @param x Pointer to receive X term of the orientation quaternion. - * @param y Pointer to receive Y term of the orientation quaternion. - * @param z Pointer to receive Z term of the orientation quaternion. - * @param w Pointer to receive W term of the orientation quaternion. - * - * @see evas_3d_node_orientation_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_orientation_get(const Evas_3D_Node *node, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z, Evas_Real *w) EINA_ARG_NONNULL(1); -EAPI void evas_3d_node_scale_get(const Evas_3D_Node *node, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z) EINA_ARG_NONNULL(1); - -/** - * Set the position inheritance flag of the given node. - * - * @param node The given node. - * @param inherit Whether to inherit parent position @c EINA_TRUE or not @c EINA_FALSE. - * - * When inheritance is enabled, a node's world space position is determined by - * adding the parent node's world position and the node's position, otherwise, - * the node's position will be the world space position. - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_position_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) EINA_ARG_NONNULL(1); - -/** - * Set the orientation inheritance flag of the given node. - * - * @param node The given node. - * @param inherit Whether to inherit parent orientation @c EINA_TRUE or not @c EINA_FALSE. - * - * When inheritance is enabled, a node's world space orientation is determined - * by multiplying the parent node's world orientation and the node's - * orientation, otherwise, the node's orientation will be the world space - * orientation. - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_orientation_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) EINA_ARG_NONNULL(1); - -/** - * Set the scale inheritance flag of the given node. - * - * @param node The given node. - * @param inherit Whether to inherit parent scale @c EINA_TRUE or not @c EINA_FALSE. - * - * When inheritance is enabled, a node's world space scale is determined by - * multiplying the parent node's world scale and the node's scale, otherwise, - * the node's scale will be the world space scale. - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_scale_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) EINA_ARG_NONNULL(1); - -/** - * Get the position inheritance flag of the given node. - * - * @param node The given node. - * @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. - * - * @see evas_3d_node_position_inherit_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI Eina_Bool evas_3d_node_position_inherit_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the orientation inheritance flag of the given node. - * - * @param node The given node. - * @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. - * - * @see evas_3d_node_orientation_inherit_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI Eina_Bool evas_3d_node_orientation_inherit_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the scale inheritance flag of the given node. - * - * @param node The given node. - * @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. - * - * @see evas_3d_node_scale_inherit_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI Eina_Bool evas_3d_node_scale_inherit_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Rotate the given node to look at desired position. - * - * @param node The given node. - * @param target_space Space where the target position belongs to. - * @param x X coordinate of the target position. - * @param y Y coordinate of the target position. - * @param z Z coordinate of the target position. - * @param up_space Space where the up vector belongs to. - * @param ux X term of the up vector. - * @param uy Y term of the up vector. - * @param uz Z term of the up vector. - * - * This function rotate the given node so that its forward vector (negative - * Z-axis) points to the desired position and the up vector coincide with the - * given up vector. - * - * @see evas_3d_node_orientation_set() - * - * @ingroup Evas_3D_Node_Transform - */ -EAPI void evas_3d_node_look_at_set(Evas_3D_Node *node, Evas_3D_Space target_space, Evas_Real x, Evas_Real y, Evas_Real z, Evas_3D_Space up_space, Evas_Real ux, Evas_Real uy, Evas_Real uz) EINA_ARG_NONNULL(1); - -/** - * Set a camera to the given node. - * - * @param node The given node. - * @param camera The camera to be set. - * - * If the node is not of type EVAS_3D_NODE_TYPE_CAMERA, error message will be - * generated and nothing happens. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_camera_set(Evas_3D_Node *node, Evas_3D_Camera *camera) EINA_ARG_NONNULL(1); - -/** - * Get the camera of the given node. - * - * @param node The given node. - * @return The camera of the given node if any, or @c NULL if there're none. - * - * @see evas_3d_node_camera_set() - * - * @ingroup Evas_3D_Node - */ -EAPI Evas_3D_Camera *evas_3d_node_camera_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the light of the given node. - * - * @param node The given node. - * @param light The light to be set. - * - * If the node is not of type EVAS_3D_NODE_TYPE_LIGHT, error message will be - * generated and nothing happens. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_light_set(Evas_3D_Node *node, Evas_3D_Light *light) EINA_ARG_NONNULL(1); - -/** - * Get the light of the given node. - * - * @param node The given node. - * @return The light of the given node if any, or @c NULL if there're none. - * - * @see evas_3d_node_light_set() - * - * @ingroup Evas_3D_Node - */ -EAPI Evas_3D_Light *evas_3d_node_light_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Add a mesh to the given node. - * - * @param node The given node. - * @param mesh The mesh to be added. - * - * If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be - * generated and nothing happens. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_mesh_add(Evas_3D_Node *node, Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); - -/** - * Delete a mesh from the given node. - * - * @param node The given node. - * @param mesh The mesh to be deleted. - * - * If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not - * belong to the given node, error message will be gnerated and nothing happens. - * - * @see evas_3d_node_mesh_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_mesh_del(Evas_3D_Node *node, Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); - -/** - * Get the list of meshes of the given node. - * - * @param node The given node. - * @return The list of meshes if any, or @c NULL if there're none. - * - * If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be - * generated and @c NULL will be returned. If there're no meshes in the given - * node, @c NULL will be returned. - * - * @see evas_3d_node_mesh_add() - * - * @ingroup Evas_3D_Node - */ -EAPI const Eina_List *evas_3d_node_mesh_list_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the animation frame number of the given node for the given mesh. - * - * @param node The given node. - * @param mesh The given mesh. - * @param frame The animation frame number. - * - * If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not - * belong to the given mesh error mesh will be generated and nothing happens. - * - * Default mesh frame is 0. - * - * @see evas_3d_node_mesh_add() - * - * @ingroup Evas_3D_Node - */ -EAPI void evas_3d_node_mesh_frame_set(Evas_3D_Node *node, Evas_3D_Mesh *mesh, int frame) EINA_ARG_NONNULL(1); - -/** - * Set the animation frame number of the given node for the given mesh. - * - * @param node The given node. - * @param mesh The given mesh. - * @param frame The animation frame number. - * - * If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not - * belong to the given mesh error mesh will be generated and nothing happens. - * - * @see evas_3d_node_mesh_add() - * - * @ingroup Evas_3D_Node - */ -EAPI int evas_3d_node_mesh_frame_get(const Evas_3D_Node *node, Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Create a new camera on the given Evas @p canvas. - * - * @param e The given canvas. - * @return The created camera handle. - * - * @ingroup Evas_3D_Camera - */ -EAPI Evas_3D_Camera *evas_3d_camera_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a node from its belonging Evas canvas. - * - * @param camera The given camera. - * - * @see evas_3d_camera_add() - * - * @ingroup Evas_3D_Camera - */ -EAPI void evas_3d_camera_del(Evas_3D_Camera *camera) EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given node belongs to. - * - * @param camera The given camera. - * @return The Evas canvas. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Camera - */ -EAPI Evas *evas_3d_camera_evas_get(const Evas_3D_Camera *camera) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the projection matrix of the given camera. - * - * @param camera The given camera. - * @param matrix Pointer to the array of 16 Evas_Real values in column major order. - * - * Default projection matrix is identity matrix. - * - * @see evas_3d_camera_projection_perspective_set() - * @see evas_3d_camera_projection_ortho_set() - * @see evas_3d_camera_projection_frustum_set() - * - * @ingroup Evas_3D_Camera - */ -EAPI void evas_3d_camera_projection_matrix_set(Evas_3D_Camera *camera, const Evas_Real *matrix) EINA_ARG_NONNULL(1); - -/** - * Get the projection matrix of the given camera. - * - * @param camera The given camera. - * @param matrix Pointer to receive the 16 Evas_Real values in column major order. - * - * @see evas_3d_camera_projection_matrix_set() - * - * @ingroup Evas_3D_Camera - */ -EAPI void evas_3d_camera_projection_matrix_get(const Evas_3D_Camera *camera, Evas_Real *matrix) EINA_ARG_NONNULL(1, 2); - -/** - * Set the projection matrix of the given camera with perspective projection. - * - * @param camera The given camera. - * @param fovy Field of view angle in Y direction. - * @param aspect Aspect ratio. - * @param near Distance to near clipping plane. - * @param far Distance to far clipping plane. - * - * @see evas_3d_camera_projection_matrix_set() - * - * @ingroup Evas_3D_Camera - */ -EAPI void evas_3d_camera_projection_perspective_set(Evas_3D_Camera *camera, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far) EINA_ARG_NONNULL(1); - -/** - * Set the projection matrix of the given camera with frustum projection. - * - * @param camera The given camera. - * @param left Left X coordinate of the near clipping plane. - * @param right Right X coordinate of the near clipping plane. - * @param top Top Y coordinate of the near clipping plane. - * @param bottom Bottom Y coordinate of the near clipping plane. - * @param near Distance to near clipping plane. - * @param far Distance to far clipping plane. - * - * @see evas_3d_camera_projection_matrix_set() - * - * @ingroup Evas_3D_Camera - */ -EAPI void evas_3d_camera_projection_frustum_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) EINA_ARG_NONNULL(1); - -/** - * Set the projection matrix of the given camera with orthogonal projection. - * - * @param camera The given camera. - * @param left Left X coordinate of the near clipping plane. - * @param right Right X coordinate of the near clipping plane. - * @param top Top Y coordinate of the near clipping plane. - * @param bottom Bottom Y coordinate of the near clipping plane. - * @param near Distance to near clipping plane. - * @param far Distance to far clipping plane. - * - * @see evas_3d_camera_projection_matrix_set() - * - * @ingroup Evas_3D_Camera - */ -EAPI void evas_3d_camera_projection_ortho_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) EINA_ARG_NONNULL(1); - -/** - * Create a new light on the given Evas @p canvas. - * - * @param e The given canvas. - * @return The created light handle. - * - * @ingroup Evas_3D_Light - */ -EAPI Evas_3D_Light *evas_3d_light_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a node from its belonging Evas canvas. - * - * @param light The given light. - * - * @see evas_3d_light_add() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_del(Evas_3D_Light *light) EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given node belongs to. - * - * @param light The given light. - * @return The Evas canvas. - * - * @see evas_3d_node_add() - * - * @ingroup Evas_3D_Light - */ -EAPI Evas *evas_3d_light_evas_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the directional flag of the given light. - * - * @param light The given light. - * @param directional Whether the light is directional (@c EINA_TRUE), or not (@c EINA_FALSE). - * - * Directional light is a type of light which is infinitely far away with no - * attenuation. The light direction is determined by the containing node's - * forward vector (negative Z-axis). - * - * By default, directional is not enabled. - * - * @see evas_3d_node_look_at_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_directional_set(Evas_3D_Light *light, Eina_Bool directional) EINA_ARG_NONNULL(1); - -/** - * Get the directional flag of the given light. - * - * @param light The given light. - * @return @c EINA_TRUE if the light is directional or @c EINA_FALSE if not. - * - * @see evas_3d_light_directional_set() - * - * @ingroup Evas_3D_Light - */ -EAPI Eina_Bool evas_3d_light_directional_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the ambient color of the given light. - * - * @param light The given light. - * @param r Red component of the ambient color between [0.0, 1.0]. - * @param g Green component of the ambient color between [0.0, 1.0]. - * @param b Blue component of the ambient color between [0.0, 1.0]. - * @param a Alpha component of the ambient color between [0.0, 1.0]. - * - * Default ambient color is (0.0, 0.0, 0.0, 1.0). - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_ambient_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); - -/** - * Get the ambient color of the given light. - * - * @param light The given light. - * @param r Pointer to receive the red component of the ambient color. - * @param g Pointer to receive the green component of the ambient color. - * @param b Pointer to receive the blue component of the ambient color. - * @param a Pointer to receive the alpha component of the ambient color. - * - * @see evas_3d_light_ambient_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_ambient_get(const Evas_3D_Light *light, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); - -/** - * Set the diffuse color of the given light. - * - * @param light The given light. - * @param r Red component of the diffuse color between [0.0, 1.0]. - * @param g Green component of the diffuse color between [0.0, 1.0]. - * @param b Blue component of the diffuse color between [0.0, 1.0]. - * @param a Alpha component of the diffuse color between [0.0, 1.0]. - * - * Default diffuse color is (1.0, 1.0, 1.0, 1.0). - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_diffuse_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); - -/** - * Get the diffuse color of the given light. - * - * @param light The given light. - * @param r Pointer to receive the red component of the diffuse color. - * @param g Pointer to receive the green component of the diffuse color. - * @param b Pointer to receive the blue component of the diffuse color. - * @param a Pointer to receive the alpha component of the diffuse color. - * - * @see evas_3d_light_diffuse_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_diffuse_get(const Evas_3D_Light *light, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); - -/** - * Get the specular color of the given light. - * - * @param light The given light. - * @param r Pointer to receive the red component of the specular color. - * @param g Pointer to receive the green component of the specular color. - * @param b Pointer to receive the blue component of the specular color. - * @param a Pointer to receive the alpha component of the specular color. - * - * Default specular color is (1.0, 1.0, 1.0, 1.0). - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_specular_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); - -/** - * Get the specular color of the given light. - * - * @param light The given light. - * @param r Pointer to receive the red component of the specular color. - * @param g Pointer to receive the green component of the specular color. - * @param b Pointer to receive the blue component of the specular color. - * @param a Pointer to receive the alpha component of the specular color. - * - * @see evas_3d_light_specular_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_specular_get(const Evas_3D_Light *light, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); - -/** - * Set the spot exponent of the given light. - * - * @param light The given light. - * @param exponent Spot exponent value. - * - * Higher spot exponent means intensity at the center of the cone is relatively - * stronger. Zero exponent means the light intensity is evenly distibuted. The - * spot exponent has no effect when the light is not spot light (spot cutoff - * angle is less than 180 degree). - * - * Default spot exponent is 0. - * - * @see evas_3d_light_spot_cutoff_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_spot_exponent_set(Evas_3D_Light *light, Evas_Real exponent) EINA_ARG_NONNULL(1); - -/** - * Get the spot exponent of the given light. - * - * @param light The given light. - * @return The spot exponent value. - * - * @see evas_3d_light_spot_exponent_set() - * - * @ingroup Evas_3D_Light - */ -EAPI Evas_Real evas_3d_light_spot_exponent_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the spot cutoff angle of the given light. - * - * @param light The given light. - * @param cutoff Cutoff angle in degree. - * - * Only angle less than 180 degree will make it spot light, so that other spot - * light attribute will take effect. - * - * Default spot cutoff angle is 180. - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_spot_cutoff_set(Evas_3D_Light *light, Evas_Real cutoff) EINA_ARG_NONNULL(1); - -/** - * Get the spot cutoff angle of the given light. - * - * @param light The given light. - * @return Cutoff angle in degree. - * - * @see evas_3d_light_spot_cutoff_set() - * - * @ingroup Evas_3D_Light - */ -EAPI Evas_Real evas_3d_light_spot_cutoff_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the attenuation of the given light. - * - * @param light The given light. - * @param constant Constant attenuation term. - * @param linear Linear attenuation term. - * @param quadratic Quadratic attenuation term. - * - * Light attenuation has no effect with directional light. And the attenuation - * should be enabled first to take effect. The attenuation factor is calculated - * as follows. - * - * atten = 1.0 / constant + linear * distance + quadratic * distance * distance - * - * Default attenuation is constant = 1.0, linear = 0.0, quadratic = 0.0. - * - * @see evas_3d_light_attenuation_enable_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_attenuation_set(Evas_3D_Light *light, Evas_Real constant, Evas_Real linear, Evas_Real quadratic) EINA_ARG_NONNULL(1); - -/** - * Get the attenuation of the given light. - * - * @param light The given light. - * @param constant Pointer to receive constant attenuation term. - * @param linear Pointer to receive linear attenuation term. - * @param quadratic Pointer to receive quadratic attenuation term. - * - * @see evas_3d_light_attenuation_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_attenuation_get(const Evas_3D_Light *light, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic) EINA_ARG_NONNULL(1); - -/** - * Set the attenuation enable flag of the given light. - * - * @param light The given light. - * @param enable Whether to enable attenuation (@c EINA_TRUE), or not (@c EINA_FALSE). - * - * By default, light attenuation is not enabled. - * - * @see evas_3d_light_attenuation_set() - * - * @ingroup Evas_3D_Light - */ -EAPI void evas_3d_light_attenuation_enable_set(Evas_3D_Light *light, Eina_Bool enable) EINA_ARG_NONNULL(1); - -/** - * Get the attenuation enable flag of the given light. - * - * @param light The given light. - * @return @c EINA_TRUE if enabled, or @c EINA_FALSE if not. - * - * @see evas_3d_light_attenuation_enable_set() - * - * @ingroup Evas_3D_Light - */ -EAPI Eina_Bool evas_3d_light_attenuation_enable_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Create a new mesh on the given Evas @p canvas. - * - * @param e The given canvas. - * @return The created mesh handle. - * - * @ingroup Evas_3D_Mesh - */ -EAPI Evas_3D_Mesh *evas_3d_mesh_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a mesh from its belonging Evas canvas. - * - * @param mesh The given mesh. - * - * @see evas_3d_mesh_add() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_del(Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given node belongs to. - * - * @param mesh The given mesh. - * @return The Evas canvas. - * - * @see evas_3d_mesh_add() - * - * @ingroup Evas_3D_Mesh - */ -EAPI Evas *evas_3d_mesh_evas_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the shade mode of the given mesh. - * - * @param mesh The given mesh. - * @param mode The shade mode. - * - * Default shade mode is EVAS_3D_SHADE_MODE_VERTEX_COLOR. - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_shade_mode_set(Evas_3D_Mesh *mesh, Evas_3D_Shade_Mode mode) EINA_ARG_NONNULL(1); - -/** - * Get the shade mode of the given mesh. - * - * @param mesh The given mesh. - * @return The shade mode. - * - * @see eavs_3d_mesh_shade_mode_set() - * - * @ingroup Evas_3D_Mesh - */ -EAPI Evas_3D_Shade_Mode evas_3d_mesh_shade_mode_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Load mesh data from file. - * - * @param mesh The given mesh. - * @param type The type of the mesh file. - * @param file Path to the mesh file. - * @param key Key in the mesh file. - * - * Loading a mesh from existing file is supported. Currently, only MD2 file - * format is supported. - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type, const char *file, const char *key) EINA_ARG_NONNULL(1); - -/** - * Set the vertex count of the given mesh. - * - * @param mesh The given mesh. - * @param count Vertex count. - * - * Each key frame should have same vertex count to be properly interpolated. - * Key frames have their own vertex data and the data should have more vertices - * than the mesh's vertex count. - * - * Default vertex count is 0. - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_vertex_count_set(Evas_3D_Mesh *mesh, unsigned int count) EINA_ARG_NONNULL(1); - -/** - * Get the vertex count of the given mesh. - * - * @param mesh The given mesh. - * @return Vertex count. - * - * @see evas_3d_mesh_vertex_count_set() - * - * @ingroup Evas_3D_Mesh - */ -EAPI int evas_3d_mesh_vertex_count_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Add a key frame to the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame to be added. - * - * If specified frame is already exist, error message will be generated. - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_frame_add(Evas_3D_Mesh *mesh, int frame) EINA_ARG_NONNULL(1); - -/** - * Delete a key frame from the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame to be deleted. - * - * @see evas_3d_mesh_frame_add() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_frame_del(Evas_3D_Mesh *mesh, int frame) EINA_ARG_NONNULL(1); - -/** - * Set the material of the key frame of the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @param material The material to be set to the key frame. - * - * Setting different materials for each key frame is useful for doing animations - * like GIF images or color changing animationas. - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_frame_material_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Material *material) EINA_ARG_NONNULL(1); - -/** - * Get the material of the key frame of the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @return The material of the key frame. - * - * @see evas_3d_mesh_frame_material_set() - * - * @ingroup Evas_3D_Mesh - */ -EAPI Evas_3D_Material *evas_3d_mesh_frame_material_get(const Evas_3D_Mesh *mesh, int frame) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the vertex data of the key frame of the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @param attrib Vertex attribute ID. - * @param stride Stride to go to the next vertex (in bytes). - * @param data Pointer to the vertex data buffer. - * - * This function make evas read from the given buffer whenever it requires. - * If you want to release the buffer after calling this functions, use - * evas_3d_mesh_frame_vertex_data_copy_set() instead. - * - * After setting the vertex data, further modifications should be protected - * by map/unmap pair. - * - * @see evas_3d_mesh_frame_vertex_data_copy_set() - * @see evas_3d_mesh_frame_vertex_data_map() - * @see evas_3d_mesh_frame_vertex_data_unmap() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_frame_vertex_data_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data) EINA_ARG_NONNULL(1); - -/** - * Set the vertex data of the key frame of the given mesh by copying from a buffer. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @param attrib Vertex attribute ID. - * @param stride Stride to go to the next vertex (in bytes). - * @param data Pointer to the vertex data buffer. - * - * This function allocates internal vertex buffer and copy from the given - * buffer. So you can release the buffer. If you want to modify the vertex data - * use evas_3d_mesh_frame_vertex_data_map(). After finishing the modifications, - * you should call evas_3d_mesh_frame_vertex_data_unmap(). - * - * @see evas_3d_mesh_frame_vertex_data_set() - * @see evas_3d_mesh_frame_vertex_data_map() - * @see evas_3d_mesh_frame_vertex_data_unmap() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data) EINA_ARG_NONNULL(1); - -/** - * Map the vertex buffer of the key frame of the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @param attrib Vertex attribute ID. - * @return Starting address of the mapped vertex buffer. - * - * After manipulating the mapped buffer, evas_3d_mesh_frame_vertex_data_unmap() - * should be called to properly download the data to the engine. If the data - * was set using evas_3d_mesh_frame_vertex_data_set(), pointer to the original - * buffer will be returned. Otherwise, the returned pointer can differ every - * time calling this function. - * - * @see evas_3d_mesh_frame_vertex_data_unmap() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void *evas_3d_mesh_frame_vertex_data_map(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Unmap the vertex buffer of the key frame of the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @param attrib Vertex attribute ID. - * - * @see evas_3d_mesh_frame_vertex_data_map() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_frame_vertex_data_unmap(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) EINA_ARG_NONNULL(1); - -/** - * Get the vertex buffer stride of the key frame of the given mesh. - * - * @param mesh The given mesh. - * @param frame The number of the key frame. - * @param attrib Vertex attribute ID. - * @return Stride to go to the next vertex (in bytes). - * - * This function returns valid stride only when the vertex buffer is mapped. - * If the data was set with evas_3d_mesh_frame_vertex_data_set(), the original - * stride will be returned unchanged. - * - * @see evas_3d_mesh_frame_vertex_data_map() - * - * @ingroup Evas_3D_Mesh - */ -EAPI int evas_3d_mesh_frame_vertex_stride_get(const Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the vertex index data of the given mesh. - * - * @param mesh The given mesh. - * @param format Vertex index data format. - * @param count Vertex index count. - * @param indices Pointer to the index data. - * - * When the index data is set, Evas 3D assembles vertices using the index data. - * If you want to free the data buffer, use evas_3d_mesh_index_data_copy_set(). - * Further modifications should be made within map/unmap pair. - * - * @see evas_3d_mesh_index_data_copy_set() - * @see evas_3d_mesh_index_data_map() - * @see evas_3d_mesh_index_data_unmap() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_index_data_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, const void *indices) EINA_ARG_NONNULL(1); - -/** - * Set the vertex index data of the given mesh by copying from a buffer. - * - * @param mesh The given mesh. - * @param format Vertex index data format. - * @param count Vertex index count. - * @param indices Pointer to the vertex data. - * - * This function allocates internal index buffer any copy data from the given - * buffer. Futher modifications can be made within map/unmap pair. - * - * @see evas_3d_mesh_index_data_set() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_index_data_copy_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, const void *indices) EINA_ARG_NONNULL(1); - -/** - * Get the format of the index data of the given mesh. - * - * @param mesh The given mesh. - * @return Format of the index data. - * - * Returns valid format only when the index buffer is mapped. First map the - * index buffer and then query the properties of the mapped buffer. If the index - * data was set by evas_3d_mesh_index_data_set(), the original format will be - * returned. Otherwise the format can differ every time you call the - * evas_3d_mesh_index_data_map() function. - * - * @see evas_3d_mesh_index_data_map() - * - * @ingroup Evas_3D_Mesh - */ -EAPI Evas_3D_Index_Format evas_3d_mesh_index_format_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the count of the index data of the given mesh. - * - * @param mesh The given mesh. - * @return Index data count. - * - * This function returns the index count of the last called data_set function. - * - * @see evas_3d_mesh_index_data_set() - * @see evas_3d_mesh_index_data_copy_set() - * - * @ingroup Evas_3D_Mesh - */ -EAPI int evas_3d_mesh_index_count_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Map the index buffer of the given mesh. - * - * @param mesh The given mesh. - * @return Pointer to the mapped buffer. - * - * evas_3d_mesh_index_data_unmap() should be called after modifications. If the - * data was set using evas_3d_mesh_index_data_set(), the original pointer will - * be returned, otherwise, the returned pointer may differ every time you call - * this function. - * - * @see evas_3d_mesh_index_data_unmap() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void *evas_3d_mesh_index_data_map(Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Unmap the index buffer of the given mesh. - * - * @param mesh The given mesh. - * - * @see evas_3d_mesh_index_data_map() - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_index_data_unmap(Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); - -/** - * Set the vertex assembly of the given mesh. - * - * @param mesh The given mesh. - * @param assembly Vertex assembly. - * - * Vertex assembly defines how the engine organizes vertices into geometric - * primitives. - * - * Default vertex assembly is EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES. - * - * @ingroup Evas_3D_Mesh - */ -EAPI void evas_3d_mesh_vertex_assembly_set(Evas_3D_Mesh *mesh, Evas_3D_Vertex_Assembly assembly); - -/** - * Get the vertex assembly of the given mesh. - * - * @param mesh The given mesh. - * @return The vertex assembly. - * - * @see evas_3d_mesh_vertex_assembly_set() - * - * @ingroup Evas_3D_Mesh - */ -EAPI Evas_3D_Vertex_Assembly evas_3d_mesh_vertex_assembly_get(const Evas_3D_Mesh *mesh); - -/** - * Create a new texture on the given Evas @p canvas. - * - * @param e The given canvas. - * @return The created texture handle. - * - * @ingroup Evas_3D_Texture - */ -EAPI Evas_3D_Texture *evas_3d_texture_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a texture from its belonging Evas canvas. - * - * @param texture The given texture. - * - * @see evas_3d_texture_add() - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_del(Evas_3D_Texture *texture) EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given texture belongs to. - * - * @param texture The given texture. - * @return The Evas canvas. - * - * @see evas_3d_texture_add() - * - * @ingroup Evas_3D_Texture - */ -EAPI Evas *evas_3d_texture_evas_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the data of the given texture. - * - * @param texure The given texture - * @param color_format Color format of the texture. - * @param pixel_format Pixel format of the data. - * @param w Width of the data. - * @param h Height of the data. - * @param data Pointer to the data. - * - * @see evas_3d_texture_file_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_data_set(Evas_3D_Texture *texture, Evas_3D_Color_Format color_format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data); - -/** - * Set the data of the given texture from file. - * - * @param texture The given texture. - * @param file Path to the image file. - * @param key Key in the image file. - * - * Only PNG format is supported. - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_file_set(Evas_3D_Texture *texture, const char *file, const char *key) EINA_ARG_NONNULL(1); - -/** - * Set the data of the given texture from an evas object. - * - * @param texture The given texture. - * @param source Source evas object to be used as the texture data. - * - * Evas 3D support using existing evas object as a texture source. This feature - * make it possible using any exisiting evas object inside 3D scene. - * - * @see evas_3d_texture_source_visible_set - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source) EINA_ARG_NONNULL(1); - -/** - * Set the visibility flag of the source evas object of the given texture. - * - * @param texture The given texture. - * @param visible @c EINA_TRUE for visible, @c EINA_FALSE for invisible. - * - * Recommend to call evas_object_show() on the source object and controll the - * visibility using this function. - * - * By default, source object is visible. - * - * @see evas_3d_texture_source_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible) EINA_ARG_NONNULL(1); - -/** - * Get the visibility flag of the source evas object of the given texture. - * - * @param texture The given texture. - * @return @c EINA_TRUE if visible, @c EINA_FALSE if invisible. - * - * @see evas_3d_texture_source_visible_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI Eina_Bool evas_3d_texture_source_visible_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the color format of the given texture. - * - * @param texture The given texture. - * - * EVAS_3D_COLOR_FORMAT_RGBA will be returned if the texture has source object. - * Otherwise, the color format of the data will be returned. - * - * @see evas_3d_texture_data_set() - * @see evas_3d_texture_file_set() - * @see evas_3d_texture_source_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI Evas_3D_Color_Format evas_3d_texture_color_format_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the size of the given texture. - * - * @param texture The given texture. - * @param w Pointer to receive the width of the texture size. - * @param h Pointer to receive the height of the texture size. - * - * If the texture has source object, the size of the source object will be - * returned. Otherwise, the size of the data (or image file) will be returned. - * - * @see evas_3d_texture_data_set() - * @see evas_3d_texture_file_set() - * @see evas_3d_texture_source_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_size_get(const Evas_3D_Texture *texture, int *w, int *h) EINA_ARG_NONNULL(1); - -/** - * Set the wrap mode of the given texture. - * - * @param texture The given texture. - * @param s Wrap mode for S-axis. - * @param t Wrap mode for T-axis. - * - * If the texture coordinate exceed range [0.0, 1.0] the values are modified - * according to the wrap mode. - * - * Default wrap modes are both EVAS_3D_WRAP_MODE_CLAMP for s and t. - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_wrap_set(Evas_3D_Texture *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t) EINA_ARG_NONNULL(1); - -/** - * Get the wrap mode of the given texture. - * - * @param texture The given texture. - * @param s Pointer to receive S-axis wrap mode. - * @param t Pointer to receive T-axis wrap mode. - * - * @see evas_3d_texture_wrap_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_wrap_get(const Evas_3D_Texture *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t) EINA_ARG_NONNULL(1); - -/** - * Set the filter of the given texture. - * - * @param texture The given texture. - * @param min Minification filter used when down-scaling. - * @param mag Magnification filter used when up-scaling. - * - * Default filters are both EVAS_3D_TEXTURE_FILTER_NEAREST for s and t. - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_filter_set(Evas_3D_Texture *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag) EINA_ARG_NONNULL(1); - -/** - * Get the filter of the given texture. - * - * @param texture The given texture. - * @param min Pointer to receive the minification filter. - * @param mag Pointer to receive the magnification filter. - * - * @see evas_3d_texture_filter_set() - * - * @ingroup Evas_3D_Texture - */ -EAPI void evas_3d_texture_filter_get(const Evas_3D_Texture *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag) EINA_ARG_NONNULL(1); - -/** - * Create a new material on the given Evas @p canvas. - * - * @param e The given canvas. - * @param type The type of the material. - * @return The created material handle. - * - * @ingroup Evas_3D_Material - */ -EAPI Evas_3D_Material *evas_3d_material_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Delete a material from its belonging Evas canvas. - * - * @param material The given material. - * - * @see evas_3d_material_add() - * - * @ingroup Evas_3D_Material - */ -EAPI void evas_3d_material_del(Evas_3D_Material *material) EINA_ARG_NONNULL(1); - -/** - * Get the Evas canvas where the given material belongs to. - * - * @param material The given material. - * @return The Evas canvas. - * - * @see evas_3d_material_add() - * - * @ingroup Evas_3D_Material - */ -EAPI Evas *evas_3d_material_evas_get(const Evas_3D_Material *material) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the material attribute enable flag of the given material. - * - * @param material The given material. - * @param attrib Material attribute ID. - * @param enable Whether to enable the attribute (@c EINA_TRUE), or not (@c EINA_FALSE). - * - * You might want to disable some material reflection contribution. For - * example,Emission attribute is rarely used. Disabling unused attributes - * might help the shading less complex so that can get speed up. - * - * By default, diffuse and specular is enabled. - * - * @ingroup Evas_3D_Material - */ -EAPI void evas_3d_material_enable_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Eina_Bool enable) EINA_ARG_NONNULL(1); - -/** - * Get the material attribute enable flag of the given material. - * - * @param material The given material. - * @param attrib Material attribute ID. - * @return @c EINA_TRUE if enabled, or @c EINA_FALSE if not. - * - * @see evas_3d_material_enable_set() - * - * @ingroup Evas_3D_Material - */ -EAPI Eina_Bool evas_3d_material_enable_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the material attribute color of the given material. - * - * @param material The given material. - * @param attrib Material attribute ID. - * @param r Red component of the color. - * @param g Green component of the color. - * @param b Blue component of the color. - * @param a Alpha component of the color. - * - * Material color is used also when texture map is enabled. The colors will be - * modulated (multiplied). To controll the color contribution of a material - * attribute, use gray color. Setting color value for normal attribute has no - * effect. - * - * Default color is as follows. - * - * Ambient : (0.2, 0.2, 0.2, 1.0) - * Diffuse : (0.8, 0.8, 0.8, 1.0) - * Specular : (1.0, 1.0, 1.0, 1.0) - * Emission : (0.0, 0.0, 0.0, 1.0) - * Normal : Not used - * - * @ingroup Evas_3D_Material - */ -EAPI void evas_3d_material_color_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); - -/** - * Get the material attribute color of the given material. - * - * @param material The given material. - * @param attrib Material attribute ID. - * @param r Pointer to receive red component of the color. - * @param g Pointer to receive green component of the color. - * @param b Pointer to receive blue component of the color. - * @param a Pointer to receive alpha component of the color. - * - * @see evas_3d_material_color_set() - * - * @ingroup Evas_3D_Material - */ -EAPI void evas_3d_material_color_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); - -/** - * Set the shininess of the given material. - * - * @param material The given material. - * @param shininess Shininess value. - * - * Shininess is only used when specular attribute is enabled. Higher shininess - * value will make the object more shiny. - * - * Default shininess value is 150.0. - * - * @see evas_3d_material_enable_set() - * - * @ingroup Evas_3D_Material - */ -EAPI void evas_3d_material_shininess_set(Evas_3D_Material *material, Evas_Real shininess) EINA_ARG_NONNULL(1); - -/** - * Get the shininess of the given material. - * - * @param material The given material. - * @return The shininess value. - * - * @see evas_3d_material_shininess_set() - * - * @ingroup Evas_3D_Material - */ -EAPI Evas_Real evas_3d_material_shininess_get(const Evas_3D_Material *material) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Set the texture of the given material. - * - * @param material The given material. - * @param attrib Material attribute ID. - * @param texture Texture to be set. - * - * You have to enable the desired attribute first. - * - * @see evas_3d_material_enable_set() - * - * @ingroup Evas_3D_Material - */ -EAPI void evas_3d_material_texture_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Evas_3D_Texture *texture) EINA_ARG_NONNULL(1); - -/** - * Get the texture of the given material. - * - * @param material The given material. - * @param attrib Material attribute ID. - * @return The texture that is set to the given material attribute. - * - * @see evas_3d_material_texture_set() - * - * @ingroup Evas_3D_Material - */ -EAPI Evas_3D_Texture *evas_3d_material_texture_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - #endif /* _EVAS_3D_H */ diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 88c4b61b..ebf3e8e 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -806,18 +806,18 @@ typedef void (*Evas_Async_Events_Put_Cb)(void *target, Evas_Callback_Type t /** * Get the path for the cserve binary to execute - * + * * There is little need for anyone except a desktop environment to call this. * This can be called before evas_init() has been called. It will try and find * the full path to the to the cserve binary to run to provide cserve image * and font caching services for evas. - * + * * @return NULL if error, or a string with the full path to the cserve binary. - * + * * @since 1.8 */ EAPI const char *evas_cserve_path_get(void); - + /** * Initialize Evas * @@ -1272,13 +1272,13 @@ EAPI void evas_render_updates_free(Eina_List *updates); /** * Add a new device type - * + * * @param e The canvas to create the device node for. - * + * * Adds a new device nod to the given canvas @p e. All devices created as * part of the canvas @p e will automatically be deleted when the canvas * is freed. - * + * * @see evas_device_del * @since 1.8 */ @@ -1286,73 +1286,73 @@ EAPI Evas_Device *evas_device_add(Evas *e); /** * Delete a new device type - * + * * @see evas_device_add * @see evas_device_push * @see evas_device_pop * @since 1.8 */ EAPI void evas_device_del(Evas_Device *dev); - + /** * Push the current context device onto the device stack - * + * * @param e The canvas to push the device on to * @param dev The device to push. - * + * * This pushes the given device @p dev onto the stack for the canvas @p e * resulting in the dev pointer in all events that get fed to the canvas * being the device at the top of the device stack for that canvas. - * + * * If a device is pushed onto the device stack, it will not be deleted * until a canvas free OR until it has been popped from the stack even if * evas_device_del() is called. - * + * * The device @p dev must have been created as a device for the canvas it * is pushed onto (and not another canvas). - * + * * Example: * @code * evas_device_push(canvas, dev); * evas_event_feed_mouse_move(canvas, 20, 30, 0, NULL); * evas_device_pop(canvas); * @endcode - * + * * @see evas_device_pop * @since 1.8 */ EAPI void evas_device_push(Evas *e, Evas_Device *dev); - + /** * This pops the top of the device stack for the canvas - * + * * @param e The canvas to pop the device stack from - * + * * This pops the top of the device stack making the current device context * used for device events being what is now at the top of the stack after * popping. - * + * * @see evas_device_push * @since 1.8 */ EAPI void evas_device_pop(Evas *e); - + /** * List all current devices attached to the given canvas and/or device - * + * * @param e The canvas to query for a device list * @param dev A specific device inside the canvas to query for child devices or NULL if just querying the base canvas devices * @return An internal list of Evas_Device pointers, or NULL if no devices are found - * + * * This will list all devices belonging to a specific evas canvas @p e, at the * top-level in the device tree if @p dev passed in is NULL. If @p dev is * a valid device for the given canvas @p e, then a list of child devices * of @p dev will be returned, allowing you to walk the device tree. - * + * * The list returned is only valid so long as no changes are made to the * device tree in the given canvas @p e. If there are no devices or children * then NULL is returned. - * + * * @see evas_device_parent_get * @see evas_device_name_get * @see evas_device_description_get @@ -1365,164 +1365,164 @@ EAPI const Eina_List *evas_device_list(Evas *e, const Evas_Device *dev); /** * Set the name of a device as a string - * + * * @p dev The device to set the name of * @p name The name string as a readable C UTF8 string - * + * * @since 1.8 */ EAPI void evas_device_name_set(Evas_Device *dev, const char *name); /** * Get the name of a device - * + * * @p dev The device to query * @return The device name string or NULL if none is set - * + * * This gets the name set by evas_device_name_set(). This is a readable UTF8 * C string, or NULL if no name is set. * * The name should be a short name like "Wireless Mouse", "Joystick", * "Finger", "Keyboard" or "Numberpad" etc. - * + * * @since 1.8 */ EAPI const char *evas_device_name_get(const Evas_Device *dev); /** * Set the description of a device as a string - * + * * @p dev The device to set the description of * @p name The description string as a readable C UTF8 string - * + * * @since 1.8 */ EAPI void evas_device_description_set(Evas_Device *dev, const char *desc); /** * Get the description of a device - * + * * @p dev The device to query * @return The device description string or NULL if none is set - * + * * This gets the description set by evas_device_description_set(). This is * a readable UTF8 C string, or NULL if no description is set. - * + * * A description is meant to be a longer string describing the device so a * human may make sense of it. For example "Wireless 6 button mouse in Black * with red buttons" would be a good description, so a user may identify * precisely which device is being talked about. - * + * * @since 1.8 */ EAPI const char *evas_device_description_get(const Evas_Device *dev); /** * Set the parent of a device - * + * * @p dev The device to set the parent of * @p parent The new parent device - * + * * This sets the parent of a device @p dev to the parent given by @p parent. * If the device already has a parent, it is removed from that parent's list. * If @p parent is NULL then the device is unparented and placed back as a * root device in the canvas. - * + * * When a device is deleted with evas_device_del(), all children are also * deleted along with it. - * + * * @see evas_device_del * @see evas_device_parent_get * @see evas_device_list - * + * * @since 1.8 */ EAPI void evas_device_parent_set(Evas_Device *dev, Evas_Device *parent); /** * Get the parent of a device - * + * * @param dev The device to query * @return The parent device or NULL if it is a toplevel - * + * * This returns the parent device of any given device entry, or NULL if no * parent device exists (is a toplevel device). - * + * * @since 1.8 */ EAPI const Evas_Device *evas_device_parent_get(const Evas_Device *dev); /** * Set the major class of device - * + * * @param dev The device whose class to set * @param clas The class to set it to - * + * * This sets the "primary" class of device (a broad thing like mouse, keyboard, * touch, pen etc.). - * + * * @since 1.8 */ EAPI void evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas); /** * Get the major class of a device - * + * * @param dev The devise to query * @return The device class to set - * + * * This sets the device class set by evas_device_class_set(). - * + * * @since 1.8 */ EAPI Evas_Device_Class evas_device_class_get(const Evas_Device *dev); /** * Set the sub-class of a device - * + * * @param dev The device to modify * @param clas The sub-class to set - * + * * This sets the sub-class of a device whihc gives much more detailed usage * within a broader category. - * + * * @since 1.8 */ EAPI void evas_device_subclass_set(Evas_Device *dev, Evas_Device_Subclass clas); /** * Get the device sub-class - * + * * @param dev The device to query * @return The device sub-class set by evas_device_subclass_set(). - * + * * @since 1.8 */ EAPI Evas_Device_Subclass evas_device_subclass_get(const Evas_Device *dev); - + /** * Set the emulation source device - * + * * @param dev The device being emulated * @param src The primary source device producing events in the emulated device - * + * * Devices may not be real, but may be emulated by listening to input on other * devices and modifying or interpeting it to generate output on an emulated * device (example a fingeron a touchscreen will often emulate a mouse when * it presses). This allows you to set which device primarily emulates @p dev * so the user can choose to ignore events from emulated devices if they also * pay attention to source device events for example. - * + * * @since 1.8 */ EAPI void evas_device_emulation_source_set(Evas_Device *dev, Evas_Device *src); - + /** * Get the emulation source device - * + * * @param dev The device to query * @return The source emulation device set by evas_device_emulation_source_set(). - * + * * @since 1.8 */ EAPI const Evas_Device *evas_device_emulation_source_get(const Evas_Device *dev); @@ -2101,7 +2101,7 @@ EAPI void evas_map_util_3d_rotate(Evas_Map *m, double dx, double dy, * Rotate the map in 3D using a unit quaternion. * * This will rotate in 3D using a unit quaternion. Like with - * evas_map_util_3d_rotate() you provide a center point + * evas_map_util_3d_rotate() you provide a center point * to rotate around (in 3D). * * @param m map to change. @@ -5290,3 +5290,2152 @@ EAPI const Eina_List *evas_font_path_global_list(void) EINA_WARN_UNUSED_R /** * @} */ + + + // 3D stuff + + /** + * @defgroup Evas_3D Evas 3D Extensions + * + * Evas extension to support 3D rendering. + * + * @ingroup Evas + */ + +/** + * @page evas_3d_main Evas 3D + * + * @date 2014 (created) + * + * @section toc Table of Contents + * + * @li @ref evas_3d_intro + * @li @ref evas_3d_example + * + * @section evas_3d_intro Introduction + * + * Evas 3D is an extension to support 3D scene graph rendering into 2D Evas + * canvas supporting typicall tree-based scene graph manipulation and other 3D + * graphics rendering techniques. + * + * Evas 3D provides 3D objects which are used for describing 3D scene and APIs + * to connect the scene with an evas image object so that the scene is rendered + * on that image object. + * + * Contruction of a 3D scene is process of locating desired cameras, lights and + * meshes in the scene. Typically the scene is structured with some hierarchical + * data structure. Evas 3D support n-ary tree structure for describing the + * scene. Node is used to build the tree representation of the scene. Other + * objects, like camera, light and mesh can be located in the scene by being + * contained in a node. + * + * Like other 3D graphics engine, Evas 3D support standard 3D rendering method + * like flat shading, phong shading and normal map and other features like + * texture mapping, triangle meshes. + * + * Besides all the traditional 3D rendering things, one of the key feature of + * the Evas 3D is that it is able to use existing evas objects as textures + * inside of the 3D scene. "Existing evas objects" means all the EFL widgets + * and applications. By supporting this, it is easy to make 3D version of an + * application without modifying the original source that much. + * + * Also, 3D scene can be located on the canvas naturally stacked with existing + * evas objects. This can make it possible putting 3D things into existing 2D + * application layouts. + * + * @section evas_3d_example Introductory Example + * + * @include evas-3d-cube.c + */ + +/** + * @defgroup Evas_3D_Types Types & Enums + * @ingroup Evas_3D + * + * Primitive type definitions and enumations. + */ + +/** + * @defgroup Evas_3D_Object Generic 3D Object Descriptions + * @ingroup Evas_3D + * + * Evas 3D object is a generic type of all evas 3D objects like scene, node, + * camera, light, mesh, texture and material. Evas 3D object is basically + * reference counted. Any successful function call on an object which make a + * reference to an another object will increase the reference count. When the + * reference count gets to 0, the object will be actually deleted. + * + * Any modifications are automatically propagated to other objects referencing + * the modified objects. As a result, if the scene object is set to modified + * state, all image objects having the scene as a rendering source are marked + * as dirty, so that rendering will be updated at next frame. But all these + * things are done internally, so feel free to forget about calling some kind + * of update functions. + */ + +/** + * @defgroup Evas_3D_Scene Scene Object + * @ingroup Evas_3D + * + * A scene represents a captured image of a scene graph through its viewing + * camera. A scene can be set to an image object to be displayed on the Evas + * canvas by using evas_object_image_3d_scene_set() function. + */ + +/** + * @defgroup Evas_3D_Node Node Object + * @ingroup Evas_3D + * + * A node is used for hierarchical construction of a scene graph. Evas 3D + * provides n-ary tree structure for the scene graph construction.A node has + * its position, orientation and scale. Other objects, like camera, light and + * mesh can be contained in a node to be located in a 3D space. + */ + +/** + * @defgroup Evas_3D_Camera Camera Object + * @ingroup Evas_3D + * + * A camera object is used for taking a picture of a scene graph. A camera + * object itself is just a set of properties on how the camera should take the + * picture (like focus length and film size of the real world cameras). To be + * able to take a shot of the scene, a camera should be located in the scene, so + * that it has its viewing position and direction. It is done by containing the + * camera on a node. If one wants to locate several cameras having same + * properties, instead of creating multiple cameras, just create one camera and + * multiple nodes containing the camera and locate them at each desired position + * and direction. Just for convinience, use evas_3d_node_position_set() to move + * the camera to desired position and use evas_3d_node_look_at_set() to adjust + * the viewing direction of the camera. + */ + +/** + * @defgroup Evas_3D_Light Light Object + * @ingroup Evas_3D + * + * A light object represents a set of properties of a light source. Evas 3D + * provides standard reflection model that of ambient, diffuse and specular + * reflection model. Also, Evas 3D support 3 types of light model, directional, + * point and spot light. Light position and direction is determined by the node + * containing the light. + */ + +/** + * @defgroup Evas_3D_Mesh Mesh Object + * @ingroup Evas_3D + * + * A mesh object is a set of information on a visible geometrical object like + * character model, terrain or other structures and entities. Evas 3D support + * key-frame-based mesh animation, so a mesh can have multiple frames and each + * frame has its own material and geometric data. Like other data objects, a + * mesh can be located on a scene by being contained in a node. The mesh is + * transformed from its modeling coordinate space into the node's coordinate + * space. Also, the frame number is saved in the containing node. So, one can + * locate multiple nodes having same mesh object with different animation frame + * and transform. Unlike camera and light object, multiple meshes can be + * contained in a single node. + */ + +/** + * @defgroup Evas_3D_Texture Texture Object + * @ingroup Evas_3D + * + * A texture object is an image represents material of surfaces. A texture can + * be set to a slot of Evas_3D_Material by using evas_3d_material_texture_set() + * function. The data of a texture can be loaded from memory, file and other + * Evas_Object. + */ + +/** + * @defgroup Evas_3D_Material Material Object + * @ingroup Evas_3D + * + * A material object represents properties of surfaces. Evas 3D defines the + * properties with 5 material attributes, ambient, diffuse, specular emission + * and normal. Each attribute have its color value and texture map. Materials + * are used to determine the color of mesh surfaces. + */ + +/** + * @typedef Evas_Real + * + * Floating-point data type + * + * Evas 3D use its own floating-point type. Even though it's a standard IEEE + * 754 floating-point type always use Evas_Real for the type safety. Double + * precision and fixed-point types will be useful but it's not supported yet. + * + * @ingroup Evas_3D_Types + */ +typedef double Evas_Real; + +/** + * @typedef Evas_3D_Scene + * + * Scene object handle + * + * @ingroup Evas_3D_Scene + */ +typedef Eo Evas_3D_Scene; + +/** + * @typedef Evas_3D_Node + * + * Node object handle + * + * @ingroup Evas_3D_Node + */ +typedef Eo Evas_3D_Node; + +/** + * @typedef Evas_3D_Camera + * + * Camera object handle + * + * @ingroup Evas_3D_Camera + */ +typedef Eo Evas_3D_Camera; + +/** + * @typedef Evas_3D_Light + * + * Light object handle + * + * @ingroup Evas_3D_Light + */ +typedef Eo Evas_3D_Light; + +/** + * @typedef Evas_3D_Mesh + * + * Mesh object handle + * + * @ingroup Evas_3D_Mesh + */ +typedef Eo Evas_3D_Mesh; + +/** + * @typedef Evas_3D_Texture + * + * Texture object handle + * + * @ingroup Evas_3D_Texture + */ +typedef Eo Evas_3D_Texture; + +/** + * @typedef Evas_3D_Material + * + * Material object handle + * + * @ingroup Evas_3D_Material + */ +typedef Eo Evas_3D_Material; + +/** + * Transform space + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Space +{ + EVAS_3D_SPACE_LOCAL, /**< Local coordinate space */ + EVAS_3D_SPACE_PARENT, /**< Parent coordinate space */ + EVAS_3D_SPACE_WORLD, /**< World coordinate space */ +} Evas_3D_Space; + +/** + * Types of a node + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Node_Type +{ + EVAS_3D_NODE_TYPE_NODE, /**< Node with no items */ + EVAS_3D_NODE_TYPE_CAMERA, /**< Node which can contain camera object */ + EVAS_3D_NODE_TYPE_LIGHT, /**< Node which can contain light object */ + EVAS_3D_NODE_TYPE_MESH, /**< Node which can contain mesh objects */ +} Evas_3D_Node_Type; + +/** + * Vertex attribute IDs + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Vertex_Attrib +{ + EVAS_3D_VERTEX_POSITION, /**< Vertex position */ + EVAS_3D_VERTEX_NORMAL, /**< Vertex normal */ + EVAS_3D_VERTEX_TANGENT, /**< Vertex tangent (for normal mapping) */ + EVAS_3D_VERTEX_COLOR, /**< Vertex color */ + EVAS_3D_VERTEX_TEXCOORD, /**< Vertex texture coordinate */ +} Evas_3D_Vertex_Attrib; + +/** + * Index formats + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Index_Format +{ + EVAS_3D_INDEX_FORMAT_NONE, /**< Indexing is not used */ + EVAS_3D_INDEX_FORMAT_UNSIGNED_BYTE, /**< Index is of type unsigned byte */ + EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, /**< Index is of type unsigned short */ +} Evas_3D_Index_Format; + +/** + * Vertex assembly modes + * @ingroup Evas_3D_Types + * + * Vertex assembly represents how the vertices are organized into geometric + * primitives. + */ +typedef enum _Evas_3D_Vertex_Assembly +{ + EVAS_3D_VERTEX_ASSEMBLY_POINTS, /**< A vertex is rendered as a point */ + EVAS_3D_VERTEX_ASSEMBLY_LINES, /**< Two vertices are organized as a line */ + EVAS_3D_VERTEX_ASSEMBLY_LINE_STRIP, /**< Vertices are organized as a connected line path */ + EVAS_3D_VERTEX_ASSEMBLY_LINE_LOOP, /**< Vertices are organized as a closed line path */ + EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES, /**< Three vertices are organized as a triangle */ + EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP, /**< Vertices are organized as connected triangles */ + EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN, /**< Vertices are organized as a triangle fan */ +} Evas_3D_Vertex_Assembly; + +/** + * Color formats of pixel data + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Color_Format +{ + EVAS_3D_COLOR_FORMAT_RGBA, /**< Color contains full components, red, green, blue and alpha */ + EVAS_3D_COLOR_FORMAT_RGB, /**< Color contains only red, green and blue components */ + EVAS_3D_COLOR_FORMAT_ALPHA, /**< Color contains only alpha component */ +} Evas_3D_Color_Format; + +/** + * Pixel formats + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Pixel_Format +{ + EVAS_3D_PIXEL_FORMAT_8, /**< 8-bit pixel with single component */ + EVAS_3D_PIXEL_FORMAT_565, /**< 16-bit pixel with three components (5-6-5 bit) */ + EVAS_3D_PIXEL_FORMAT_888, /**< 24-bit pixel with three 8-bit components */ + EVAS_3D_PIXEL_FORMAT_8888, /**< 32-bit pixel with four 8-bit components */ + EVAS_3D_PIXEL_FORMAT_4444, /**< 16-bit pixel with four 4-bit components */ + EVAS_3D_PIXEL_FORMAT_5551, /**< 16-bit pixel with four components (5-5-5-1 bit) */ +} Evas_3D_Pixel_Format; + +/** + * Wrap modes + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Wrap_Mode +{ + EVAS_3D_WRAP_MODE_CLAMP, /**< Values will be clamped to be in range [min, max] */ + EVAS_3D_WRAP_MODE_REPEAT, /**< Values will be repeated */ + EVAS_3D_WRAP_MODE_REFLECT, /**< Values will be repeated in a reflected manner */ +} Evas_3D_Wrap_Mode; + +/** + * Texture filters + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Texture_Filter +{ + EVAS_3D_TEXTURE_FILTER_NEAREST, /**< Samples nearest texel */ + EVAS_3D_TEXTURE_FILTER_LINEAR, /**< Lineary interpolate nearby texels */ + EVAS_3D_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST, /**< Nearest sampling mipmap */ + EVAS_3D_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST, /**< Nearest sampling mipmap and interpolate */ + EVAS_3D_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR, /**< Linear sampling in nearest mipmap */ + EVAS_3D_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR, /**< Linear sampling in mipmap and interpolate */ +} Evas_3D_Texture_Filter; + +/** + * Shade modes + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Shade_Mode +{ + EVAS_3D_SHADE_MODE_VERTEX_COLOR, /**< Shaded using vertex color attribute */ + EVAS_3D_SHADE_MODE_DIFFUSE, /**< Shaded using material diffuse term */ + EVAS_3D_SHADE_MODE_FLAT, /**< Per-vertex flat lighting */ + EVAS_3D_SHADE_MODE_PHONG, /**< Per-pixel phong shading */ + EVAS_3D_SHADE_MODE_NORMAL_MAP, /**< Per-pixel normal map shading */ +} Evas_3D_Shade_Mode; + +/** + * Material attributes + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Material_Attrib +{ + EVAS_3D_MATERIAL_AMBIENT, /**< Ambient term */ + EVAS_3D_MATERIAL_DIFFUSE, /**< Diffuse term */ + EVAS_3D_MATERIAL_SPECULAR, /**< Specular term */ + EVAS_3D_MATERIAL_EMISSION, /**< Emission term */ + EVAS_3D_MATERIAL_NORMAL, /**< Normal map term */ +} Evas_3D_Material_Attrib; + +/** + * Mesh file type + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Mesh_File_Type +{ + EVAS_3D_MESH_FILE_TYPE_MD2, /**< Quake's MD2 mesh file format */ +} Evas_3D_Mesh_File_Type; + +typedef enum _Evas_3D_Pick_Type +{ + EVAS_3D_PICK_NODE, + EVAS_3D_PICK_MESH, +} Evas_3D_Pick_Type; + +/** + * Set the scene on an image object. + * + * @param obj Image object. + * @param scene Scene object used as a content of the given image object. + * + * An image object can get its content from various sources like memory buffers, + * image files and other evas object. A scene also can be a source for an image + * object to display the rendered result onto evas canvas. + * + * Any existing content (data, file or proxy source) will be removed after this + * call. Setting @p src to @c NULL detach the 3D scene from the image object. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_object_image_t3d_scene_set(Evas_Object *obj, Evas_3D_Scene *scene) EINA_ARG_NONNULL(1); + +/** + * Get the current scene of an image object. + * + * @param obj Image object. + * @return Scene object handle (if any), or @c NULL if there's no scene attached. + * + * @ingroup Evas_3D_Scene + */ +EAPI Evas_3D_Scene *evas_object_image_t3d_scene_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Create a new scene on the given Evas @p e canvas. + * + * @param e The given canvas. + * @return The created scene handle. + * + * @ingroup Evas_3D_Scene + */ +EAPI Evas_3D_Scene *evas_3d_scene_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a scene from its belonging Evas canvas. + * + * @param scene The given scene to be deleted. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_del(Evas_3D_Scene *scene) EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given scene belongs to. + * + * @param scene The given scene. + * @return The Evas canvas. + * + * @ingroup Evas_3D_Scene + */ +EAPI Evas *evas_3d_scene_evas_get(const Evas_3D_Scene *scene) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the root node of a scene. + * + * @param scene The given scene. + * @param node A node which will be used as a root node for the scene. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_root_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node) EINA_ARG_NONNULL(1); + +/** + * Get the root node of a scene. + * + * @param scene The given scene. + * @return The root node of the given scene. + * + * @ingroup Evas_3D_Scene + */ +EAPI Evas_3D_Node *evas_3d_scene_root_node_get(const Evas_3D_Scene *scene) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the camera node of a scene. + * + * @param scene The given scene. + * @param node A node which will be used as a camera node for the scene. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_camera_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node) EINA_ARG_NONNULL(1); + +/** + * Get the camera node of a scene. + * + * @param scene The given scene. + * @return The camera node of the given scene. + * + * @ingroup Evas_3D_Scene + */ +EAPI Evas_3D_Node *evas_3d_scene_camera_node_get(const Evas_3D_Scene *scene) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the resolution of a scene. + * + * @param scene The given scene. + * @param w Width of the resolution. + * @param h Height of the resolution. + * + * A scene should be rendered to be displayed through an image objects. The + * resolution defines size of the internal surface holding the rendered result. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_size_set(Evas_3D_Scene *scene, int w, int h) EINA_ARG_NONNULL(1); + +/** + * Get the internal resolution of a scene. + * + * @param scene The given scene. + * @param w Pointer to receive width of the resolution. + * @param h Pointer to receive height of the resolution. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_size_get(const Evas_3D_Scene *scene, int *w, int *h) EINA_ARG_NONNULL(1); + +/** + * Set the background color of a scene. + * + * @param scene The given scene. + * @param r Red component of the background color. + * @param g Green component of the background color. + * @param b Blue component of the background color. + * @param a Alpha component of the background color. + * + * Background color defines initial color of pixels before a scene is rendered. + * If you want to display a scene with background evas objects are still + * remaining as if it was the background, set the alpha term to 0.0. + * + * Default background color is (0.0, 0.0, 0.0, 0.0). + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_background_color_set(Evas_3D_Scene *scene, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); + +/** + * Get the background color of a scene. + * + * @param scene The given scene. + * @param r Pointer to receive red component of the background color. + * @param g Pointer to receive green component of the background color. + * @param b Pointer to receive blue component of the background color. + * @param a Pointer to receive alpha component of the background color. + * + * @ingroup Evas_3D_Scene + */ +EAPI void evas_3d_scene_background_color_get(const Evas_3D_Scene *scene, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); + +/** + * Get information on the most front visible mesh for the given position. + * + * @param scene The given scene. + * @param x X coordinate of the picking position. + * @param y Y coordinate of the picking position. + * @param node Pointer to receive the node contains the picked mesh. + * @param mesh Pointer to receive the picked mesh. + * @param s Pointer to receive the texture "s" coordinate. + * @param t Pointer to receive the texture "t" coordinate. + * + * (x, y) is the screen coordinate of the given scene. That is, left-top is + * (0, 0) and right-bottom is (w, h) where (w, h) is the size of the scene. + * The texture coordinate is useful when using proxy texture source. + * + * @ingroup Evas_3D_Scene + */ +EAPI Eina_Bool evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y, Evas_3D_Node **node, Evas_3D_Mesh **mesh, Evas_Real *s, Evas_Real *t) EINA_ARG_NONNULL(1); + +/** + * Create a new node on the given Evas @p canvas. + * + * @param e The given canvas. + * @param type The type of the node. + * @return The created node handle. + * + * @ingroup Evas_3D_Node + */ +EAPI Evas_3D_Node *evas_3d_node_add(Evas *e, Evas_3D_Node_Type type) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a node from its belonging Evas canvas. + * + * @param node The given node. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_del(Evas_3D_Node *node) EINA_ARG_NONNULL(1); + +/** + * Get the type of the given node. + * + * @param node The given node. + * @return The type of the given node. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Node + */ +EAPI Evas_3D_Node_Type evas_3d_node_type_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given node belongs to. + * + * @param node The given node. + * @return The Evas canvas. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Node + */ +EAPI Evas *evas_3d_node_evas_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Add a member node to the given node. + * + * @param node The given node which will be the parent. + * @param member Node object to be added. + * + * Nodes can be constructed into N-ary tree structure like other ordinary scene + * graph. Basically a node inherit transforms from its parent. + * + * @see evas_3d_node_parent_get() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_member_add(Evas_3D_Node *node, Evas_3D_Node *member) EINA_ARG_NONNULL(1, 2); + +/** + * Delete a member node from the given node. + * + * @param node The given node. + * @param member Member node to be deleted from the given node. + * + * @see evas_3d_node_member_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_member_del(Evas_3D_Node *node, Evas_3D_Node *member) EINA_ARG_NONNULL(1, 2); + +/** + * Get the parent node of the given node. + * + * @param node The given node. + * @return The parent node of the given node. + * + * @see evas_3d_node_member_add() + * + * @ingroup Evas_3D_Node + */ +EAPI Evas_3D_Node *evas_3d_node_parent_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the list of member nodes of the given node. + * + * @param node The given node. + * @return The list of member nodes if any or @c NULL if there are none. + * + * @see evas_3d_node_member_add() + * + * @ingroup Evas_3D_Node + */ +EAPI const Eina_List *evas_3d_node_member_list_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * @defgroup Evas_3D_Node_Transform + * @ingroup Evas_3D_Node + * + * Functions that manipulate node transforms. + * + * Evas_3D_Node does not provide standard 4x4 matrix to transform something. + * Instead, one can set position, orientation and scale of a node separately. + * A node will be first scaled and rotated and then translated according to its + * position, orientation and scale. Each transform attributes can be set to + * inherit from its parent or not. + */ + +/** + * Set the position of the given node. + * + * @param node The given node. + * @param x X coordinate of the position. + * @param y Y coordinate of the position. + * @param z Z coordinate of the position. + * + * According to the inheritance flag, (x, y, z) can be a world space position or + * parent space position. + * + * Default position is (0.0, 0.0, 0.0). + * + * @see evas_3d_node_position_inherit_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_position_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); + +/** + * Set the orientation of the given node using quaternion. + * + * @param node The given node. + * @param x X term of the orientation quaternion (w, x, y, z) + * @param y Y term of the orientation quaternion (w, x, y, z) + * @param z Z term of the orientation quaternion (w, x, y, z) + * @param w W term of the orientation quaternion (w, x, y, z) + * + * According the the inheritance flag, (w, x, y, z) can be a world space + * orientation or parent space orientation. + * + * Default orientation is (1.0, 0.0, 0.0, 0.0) (identity quaternion). + * + * @see evas_3d_node_orientation_inherit_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_orientation_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z, Evas_Real w) EINA_ARG_NONNULL(1); + +/** + * Set the orientation of the given node using euler angle. + * + * @param node The given node. + * @param x Rotation angle about X-axis. + * @param y Rotation angle about Y-axis. + * @param z Rotation angle about Z-axis. + * + * @see evas_3d_node_orientation_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_orientation_euler_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); + +/** + * Set the orientation of the given node using axis-angle. + * + * @param node The given node. + * @param angle Rotation angle. + * @param x X term of the rotation axis. + * @param y Y term of the rotation axis. + * @param z Z term of the rotation axis. + * + * @see evas_3d_node_orientation_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_orientation_angle_axis_set(Evas_3D_Node *node, Evas_Real angle, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); + +/** + * Set the scale of the given node. + * + * @param node The given node. + * @param x Scale factor along X-axis. + * @param y Scale factor along Y-axis. + * @param z Scale factor along Z-axis. + * + * According to the inheritance flag, (x, y, z) can be a world space scale or + * parent space scale. Be careful when using non-uniform scale factor with + * inheritance, each transform attributes are not affected by other attributes. + * + * Default scale is (1.0, 1.0, 1.0). + * + * @see evas_3d_node_scale_inherit_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_scale_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) EINA_ARG_NONNULL(1); + +/** + * Get the position of the given node. + * + * @param node The given node. + * @param x Pointer to receive X coordinate of the position. + * @param y Pointer to receive Y coordinate of the position. + * @param z Pointer to receive Z coordinate of the position. + * + * @see evas_3d_node_position_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_position_get(const Evas_3D_Node *node, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z) EINA_ARG_NONNULL(1); + +/** + * Get the orientation of the given node as quaternion. + * + * @param node The given node. + * @param x Pointer to receive X term of the orientation quaternion. + * @param y Pointer to receive Y term of the orientation quaternion. + * @param z Pointer to receive Z term of the orientation quaternion. + * @param w Pointer to receive W term of the orientation quaternion. + * + * @see evas_3d_node_orientation_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_orientation_get(const Evas_3D_Node *node, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z, Evas_Real *w) EINA_ARG_NONNULL(1); +EAPI void evas_3d_node_scale_get(const Evas_3D_Node *node, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z) EINA_ARG_NONNULL(1); + +/** + * Set the position inheritance flag of the given node. + * + * @param node The given node. + * @param inherit Whether to inherit parent position @c EINA_TRUE or not @c EINA_FALSE. + * + * When inheritance is enabled, a node's world space position is determined by + * adding the parent node's world position and the node's position, otherwise, + * the node's position will be the world space position. + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_position_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) EINA_ARG_NONNULL(1); + +/** + * Set the orientation inheritance flag of the given node. + * + * @param node The given node. + * @param inherit Whether to inherit parent orientation @c EINA_TRUE or not @c EINA_FALSE. + * + * When inheritance is enabled, a node's world space orientation is determined + * by multiplying the parent node's world orientation and the node's + * orientation, otherwise, the node's orientation will be the world space + * orientation. + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_orientation_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) EINA_ARG_NONNULL(1); + +/** + * Set the scale inheritance flag of the given node. + * + * @param node The given node. + * @param inherit Whether to inherit parent scale @c EINA_TRUE or not @c EINA_FALSE. + * + * When inheritance is enabled, a node's world space scale is determined by + * multiplying the parent node's world scale and the node's scale, otherwise, + * the node's scale will be the world space scale. + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_scale_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) EINA_ARG_NONNULL(1); + +/** + * Get the position inheritance flag of the given node. + * + * @param node The given node. + * @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. + * + * @see evas_3d_node_position_inherit_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI Eina_Bool evas_3d_node_position_inherit_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the orientation inheritance flag of the given node. + * + * @param node The given node. + * @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. + * + * @see evas_3d_node_orientation_inherit_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI Eina_Bool evas_3d_node_orientation_inherit_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the scale inheritance flag of the given node. + * + * @param node The given node. + * @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. + * + * @see evas_3d_node_scale_inherit_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI Eina_Bool evas_3d_node_scale_inherit_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Rotate the given node to look at desired position. + * + * @param node The given node. + * @param target_space Space where the target position belongs to. + * @param x X coordinate of the target position. + * @param y Y coordinate of the target position. + * @param z Z coordinate of the target position. + * @param up_space Space where the up vector belongs to. + * @param ux X term of the up vector. + * @param uy Y term of the up vector. + * @param uz Z term of the up vector. + * + * This function rotate the given node so that its forward vector (negative + * Z-axis) points to the desired position and the up vector coincide with the + * given up vector. + * + * @see evas_3d_node_orientation_set() + * + * @ingroup Evas_3D_Node_Transform + */ +EAPI void evas_3d_node_look_at_set(Evas_3D_Node *node, Evas_3D_Space target_space, Evas_Real x, Evas_Real y, Evas_Real z, Evas_3D_Space up_space, Evas_Real ux, Evas_Real uy, Evas_Real uz) EINA_ARG_NONNULL(1); + +/** + * Set a camera to the given node. + * + * @param node The given node. + * @param camera The camera to be set. + * + * If the node is not of type EVAS_3D_NODE_TYPE_CAMERA, error message will be + * generated and nothing happens. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_camera_set(Evas_3D_Node *node, Evas_3D_Camera *camera) EINA_ARG_NONNULL(1); + +/** + * Get the camera of the given node. + * + * @param node The given node. + * @return The camera of the given node if any, or @c NULL if there're none. + * + * @see evas_3d_node_camera_set() + * + * @ingroup Evas_3D_Node + */ +EAPI Evas_3D_Camera *evas_3d_node_camera_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the light of the given node. + * + * @param node The given node. + * @param light The light to be set. + * + * If the node is not of type EVAS_3D_NODE_TYPE_LIGHT, error message will be + * generated and nothing happens. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_light_set(Evas_3D_Node *node, Evas_3D_Light *light) EINA_ARG_NONNULL(1); + +/** + * Get the light of the given node. + * + * @param node The given node. + * @return The light of the given node if any, or @c NULL if there're none. + * + * @see evas_3d_node_light_set() + * + * @ingroup Evas_3D_Node + */ +EAPI Evas_3D_Light *evas_3d_node_light_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Add a mesh to the given node. + * + * @param node The given node. + * @param mesh The mesh to be added. + * + * If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be + * generated and nothing happens. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_mesh_add(Evas_3D_Node *node, Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); + +/** + * Delete a mesh from the given node. + * + * @param node The given node. + * @param mesh The mesh to be deleted. + * + * If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not + * belong to the given node, error message will be gnerated and nothing happens. + * + * @see evas_3d_node_mesh_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_mesh_del(Evas_3D_Node *node, Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); + +/** + * Get the list of meshes of the given node. + * + * @param node The given node. + * @return The list of meshes if any, or @c NULL if there're none. + * + * If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be + * generated and @c NULL will be returned. If there're no meshes in the given + * node, @c NULL will be returned. + * + * @see evas_3d_node_mesh_add() + * + * @ingroup Evas_3D_Node + */ +EAPI const Eina_List *evas_3d_node_mesh_list_get(const Evas_3D_Node *node) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the animation frame number of the given node for the given mesh. + * + * @param node The given node. + * @param mesh The given mesh. + * @param frame The animation frame number. + * + * If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not + * belong to the given mesh error mesh will be generated and nothing happens. + * + * Default mesh frame is 0. + * + * @see evas_3d_node_mesh_add() + * + * @ingroup Evas_3D_Node + */ +EAPI void evas_3d_node_mesh_frame_set(Evas_3D_Node *node, Evas_3D_Mesh *mesh, int frame) EINA_ARG_NONNULL(1); + +/** + * Set the animation frame number of the given node for the given mesh. + * + * @param node The given node. + * @param mesh The given mesh. + * @param frame The animation frame number. + * + * If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not + * belong to the given mesh error mesh will be generated and nothing happens. + * + * @see evas_3d_node_mesh_add() + * + * @ingroup Evas_3D_Node + */ +EAPI int evas_3d_node_mesh_frame_get(const Evas_3D_Node *node, Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Create a new camera on the given Evas @p canvas. + * + * @param e The given canvas. + * @return The created camera handle. + * + * @ingroup Evas_3D_Camera + */ +EAPI Evas_3D_Camera *evas_3d_camera_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a node from its belonging Evas canvas. + * + * @param camera The given camera. + * + * @see evas_3d_camera_add() + * + * @ingroup Evas_3D_Camera + */ +EAPI void evas_3d_camera_del(Evas_3D_Camera *camera) EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given node belongs to. + * + * @param camera The given camera. + * @return The Evas canvas. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Camera + */ +EAPI Evas *evas_3d_camera_evas_get(const Evas_3D_Camera *camera) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the projection matrix of the given camera. + * + * @param camera The given camera. + * @param matrix Pointer to the array of 16 Evas_Real values in column major order. + * + * Default projection matrix is identity matrix. + * + * @see evas_3d_camera_projection_perspective_set() + * @see evas_3d_camera_projection_ortho_set() + * @see evas_3d_camera_projection_frustum_set() + * + * @ingroup Evas_3D_Camera + */ +EAPI void evas_3d_camera_projection_matrix_set(Evas_3D_Camera *camera, const Evas_Real *matrix) EINA_ARG_NONNULL(1); + +/** + * Get the projection matrix of the given camera. + * + * @param camera The given camera. + * @param matrix Pointer to receive the 16 Evas_Real values in column major order. + * + * @see evas_3d_camera_projection_matrix_set() + * + * @ingroup Evas_3D_Camera + */ +EAPI void evas_3d_camera_projection_matrix_get(const Evas_3D_Camera *camera, Evas_Real *matrix) EINA_ARG_NONNULL(1, 2); + +/** + * Set the projection matrix of the given camera with perspective projection. + * + * @param camera The given camera. + * @param fovy Field of view angle in Y direction. + * @param aspect Aspect ratio. + * @param near Distance to near clipping plane. + * @param far Distance to far clipping plane. + * + * @see evas_3d_camera_projection_matrix_set() + * + * @ingroup Evas_3D_Camera + */ +EAPI void evas_3d_camera_projection_perspective_set(Evas_3D_Camera *camera, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far) EINA_ARG_NONNULL(1); + +/** + * Set the projection matrix of the given camera with frustum projection. + * + * @param camera The given camera. + * @param left Left X coordinate of the near clipping plane. + * @param right Right X coordinate of the near clipping plane. + * @param top Top Y coordinate of the near clipping plane. + * @param bottom Bottom Y coordinate of the near clipping plane. + * @param near Distance to near clipping plane. + * @param far Distance to far clipping plane. + * + * @see evas_3d_camera_projection_matrix_set() + * + * @ingroup Evas_3D_Camera + */ +EAPI void evas_3d_camera_projection_frustum_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) EINA_ARG_NONNULL(1); + +/** + * Set the projection matrix of the given camera with orthogonal projection. + * + * @param camera The given camera. + * @param left Left X coordinate of the near clipping plane. + * @param right Right X coordinate of the near clipping plane. + * @param top Top Y coordinate of the near clipping plane. + * @param bottom Bottom Y coordinate of the near clipping plane. + * @param near Distance to near clipping plane. + * @param far Distance to far clipping plane. + * + * @see evas_3d_camera_projection_matrix_set() + * + * @ingroup Evas_3D_Camera + */ +EAPI void evas_3d_camera_projection_ortho_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) EINA_ARG_NONNULL(1); + +/** + * Create a new light on the given Evas @p canvas. + * + * @param e The given canvas. + * @return The created light handle. + * + * @ingroup Evas_3D_Light + */ +EAPI Evas_3D_Light *evas_3d_light_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a node from its belonging Evas canvas. + * + * @param light The given light. + * + * @see evas_3d_light_add() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_del(Evas_3D_Light *light) EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given node belongs to. + * + * @param light The given light. + * @return The Evas canvas. + * + * @see evas_3d_node_add() + * + * @ingroup Evas_3D_Light + */ +EAPI Evas *evas_3d_light_evas_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the directional flag of the given light. + * + * @param light The given light. + * @param directional Whether the light is directional (@c EINA_TRUE), or not (@c EINA_FALSE). + * + * Directional light is a type of light which is infinitely far away with no + * attenuation. The light direction is determined by the containing node's + * forward vector (negative Z-axis). + * + * By default, directional is not enabled. + * + * @see evas_3d_node_look_at_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_directional_set(Evas_3D_Light *light, Eina_Bool directional) EINA_ARG_NONNULL(1); + +/** + * Get the directional flag of the given light. + * + * @param light The given light. + * @return @c EINA_TRUE if the light is directional or @c EINA_FALSE if not. + * + * @see evas_3d_light_directional_set() + * + * @ingroup Evas_3D_Light + */ +EAPI Eina_Bool evas_3d_light_directional_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the ambient color of the given light. + * + * @param light The given light. + * @param r Red component of the ambient color between [0.0, 1.0]. + * @param g Green component of the ambient color between [0.0, 1.0]. + * @param b Blue component of the ambient color between [0.0, 1.0]. + * @param a Alpha component of the ambient color between [0.0, 1.0]. + * + * Default ambient color is (0.0, 0.0, 0.0, 1.0). + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_ambient_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); + +/** + * Get the ambient color of the given light. + * + * @param light The given light. + * @param r Pointer to receive the red component of the ambient color. + * @param g Pointer to receive the green component of the ambient color. + * @param b Pointer to receive the blue component of the ambient color. + * @param a Pointer to receive the alpha component of the ambient color. + * + * @see evas_3d_light_ambient_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_ambient_get(const Evas_3D_Light *light, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); + +/** + * Set the diffuse color of the given light. + * + * @param light The given light. + * @param r Red component of the diffuse color between [0.0, 1.0]. + * @param g Green component of the diffuse color between [0.0, 1.0]. + * @param b Blue component of the diffuse color between [0.0, 1.0]. + * @param a Alpha component of the diffuse color between [0.0, 1.0]. + * + * Default diffuse color is (1.0, 1.0, 1.0, 1.0). + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_diffuse_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); + +/** + * Get the diffuse color of the given light. + * + * @param light The given light. + * @param r Pointer to receive the red component of the diffuse color. + * @param g Pointer to receive the green component of the diffuse color. + * @param b Pointer to receive the blue component of the diffuse color. + * @param a Pointer to receive the alpha component of the diffuse color. + * + * @see evas_3d_light_diffuse_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_diffuse_get(const Evas_3D_Light *light, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); + +/** + * Get the specular color of the given light. + * + * @param light The given light. + * @param r Pointer to receive the red component of the specular color. + * @param g Pointer to receive the green component of the specular color. + * @param b Pointer to receive the blue component of the specular color. + * @param a Pointer to receive the alpha component of the specular color. + * + * Default specular color is (1.0, 1.0, 1.0, 1.0). + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_specular_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); + +/** + * Get the specular color of the given light. + * + * @param light The given light. + * @param r Pointer to receive the red component of the specular color. + * @param g Pointer to receive the green component of the specular color. + * @param b Pointer to receive the blue component of the specular color. + * @param a Pointer to receive the alpha component of the specular color. + * + * @see evas_3d_light_specular_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_specular_get(const Evas_3D_Light *light, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); + +/** + * Set the spot exponent of the given light. + * + * @param light The given light. + * @param exponent Spot exponent value. + * + * Higher spot exponent means intensity at the center of the cone is relatively + * stronger. Zero exponent means the light intensity is evenly distibuted. The + * spot exponent has no effect when the light is not spot light (spot cutoff + * angle is less than 180 degree). + * + * Default spot exponent is 0. + * + * @see evas_3d_light_spot_cutoff_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_spot_exponent_set(Evas_3D_Light *light, Evas_Real exponent) EINA_ARG_NONNULL(1); + +/** + * Get the spot exponent of the given light. + * + * @param light The given light. + * @return The spot exponent value. + * + * @see evas_3d_light_spot_exponent_set() + * + * @ingroup Evas_3D_Light + */ +EAPI Evas_Real evas_3d_light_spot_exponent_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the spot cutoff angle of the given light. + * + * @param light The given light. + * @param cutoff Cutoff angle in degree. + * + * Only angle less than 180 degree will make it spot light, so that other spot + * light attribute will take effect. + * + * Default spot cutoff angle is 180. + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_spot_cutoff_set(Evas_3D_Light *light, Evas_Real cutoff) EINA_ARG_NONNULL(1); + +/** + * Get the spot cutoff angle of the given light. + * + * @param light The given light. + * @return Cutoff angle in degree. + * + * @see evas_3d_light_spot_cutoff_set() + * + * @ingroup Evas_3D_Light + */ +EAPI Evas_Real evas_3d_light_spot_cutoff_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the attenuation of the given light. + * + * @param light The given light. + * @param constant Constant attenuation term. + * @param linear Linear attenuation term. + * @param quadratic Quadratic attenuation term. + * + * Light attenuation has no effect with directional light. And the attenuation + * should be enabled first to take effect. The attenuation factor is calculated + * as follows. + * + * atten = 1.0 / constant + linear * distance + quadratic * distance * distance + * + * Default attenuation is constant = 1.0, linear = 0.0, quadratic = 0.0. + * + * @see evas_3d_light_attenuation_enable_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_attenuation_set(Evas_3D_Light *light, Evas_Real constant, Evas_Real linear, Evas_Real quadratic) EINA_ARG_NONNULL(1); + +/** + * Get the attenuation of the given light. + * + * @param light The given light. + * @param constant Pointer to receive constant attenuation term. + * @param linear Pointer to receive linear attenuation term. + * @param quadratic Pointer to receive quadratic attenuation term. + * + * @see evas_3d_light_attenuation_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_attenuation_get(const Evas_3D_Light *light, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic) EINA_ARG_NONNULL(1); + +/** + * Set the attenuation enable flag of the given light. + * + * @param light The given light. + * @param enable Whether to enable attenuation (@c EINA_TRUE), or not (@c EINA_FALSE). + * + * By default, light attenuation is not enabled. + * + * @see evas_3d_light_attenuation_set() + * + * @ingroup Evas_3D_Light + */ +EAPI void evas_3d_light_attenuation_enable_set(Evas_3D_Light *light, Eina_Bool enable) EINA_ARG_NONNULL(1); + +/** + * Get the attenuation enable flag of the given light. + * + * @param light The given light. + * @return @c EINA_TRUE if enabled, or @c EINA_FALSE if not. + * + * @see evas_3d_light_attenuation_enable_set() + * + * @ingroup Evas_3D_Light + */ +EAPI Eina_Bool evas_3d_light_attenuation_enable_get(const Evas_3D_Light *light) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Create a new mesh on the given Evas @p canvas. + * + * @param e The given canvas. + * @return The created mesh handle. + * + * @ingroup Evas_3D_Mesh + */ +EAPI Evas_3D_Mesh *evas_3d_mesh_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a mesh from its belonging Evas canvas. + * + * @param mesh The given mesh. + * + * @see evas_3d_mesh_add() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_del(Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given node belongs to. + * + * @param mesh The given mesh. + * @return The Evas canvas. + * + * @see evas_3d_mesh_add() + * + * @ingroup Evas_3D_Mesh + */ +EAPI Evas *evas_3d_mesh_evas_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the shade mode of the given mesh. + * + * @param mesh The given mesh. + * @param mode The shade mode. + * + * Default shade mode is EVAS_3D_SHADE_MODE_VERTEX_COLOR. + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_shade_mode_set(Evas_3D_Mesh *mesh, Evas_3D_Shade_Mode mode) EINA_ARG_NONNULL(1); + +/** + * Get the shade mode of the given mesh. + * + * @param mesh The given mesh. + * @return The shade mode. + * + * @see eavs_3d_mesh_shade_mode_set() + * + * @ingroup Evas_3D_Mesh + */ +EAPI Evas_3D_Shade_Mode evas_3d_mesh_shade_mode_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Load mesh data from file. + * + * @param mesh The given mesh. + * @param type The type of the mesh file. + * @param file Path to the mesh file. + * @param key Key in the mesh file. + * + * Loading a mesh from existing file is supported. Currently, only MD2 file + * format is supported. + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type, const char *file, const char *key) EINA_ARG_NONNULL(1); + +/** + * Set the vertex count of the given mesh. + * + * @param mesh The given mesh. + * @param count Vertex count. + * + * Each key frame should have same vertex count to be properly interpolated. + * Key frames have their own vertex data and the data should have more vertices + * than the mesh's vertex count. + * + * Default vertex count is 0. + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_vertex_count_set(Evas_3D_Mesh *mesh, unsigned int count) EINA_ARG_NONNULL(1); + +/** + * Get the vertex count of the given mesh. + * + * @param mesh The given mesh. + * @return Vertex count. + * + * @see evas_3d_mesh_vertex_count_set() + * + * @ingroup Evas_3D_Mesh + */ +EAPI int evas_3d_mesh_vertex_count_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Add a key frame to the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame to be added. + * + * If specified frame is already exist, error message will be generated. + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_frame_add(Evas_3D_Mesh *mesh, int frame) EINA_ARG_NONNULL(1); + +/** + * Delete a key frame from the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame to be deleted. + * + * @see evas_3d_mesh_frame_add() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_frame_del(Evas_3D_Mesh *mesh, int frame) EINA_ARG_NONNULL(1); + +/** + * Set the material of the key frame of the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @param material The material to be set to the key frame. + * + * Setting different materials for each key frame is useful for doing animations + * like GIF images or color changing animationas. + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_frame_material_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Material *material) EINA_ARG_NONNULL(1); + +/** + * Get the material of the key frame of the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @return The material of the key frame. + * + * @see evas_3d_mesh_frame_material_set() + * + * @ingroup Evas_3D_Mesh + */ +EAPI Evas_3D_Material *evas_3d_mesh_frame_material_get(const Evas_3D_Mesh *mesh, int frame) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the vertex data of the key frame of the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @param attrib Vertex attribute ID. + * @param stride Stride to go to the next vertex (in bytes). + * @param data Pointer to the vertex data buffer. + * + * This function make evas read from the given buffer whenever it requires. + * If you want to release the buffer after calling this functions, use + * evas_3d_mesh_frame_vertex_data_copy_set() instead. + * + * After setting the vertex data, further modifications should be protected + * by map/unmap pair. + * + * @see evas_3d_mesh_frame_vertex_data_copy_set() + * @see evas_3d_mesh_frame_vertex_data_map() + * @see evas_3d_mesh_frame_vertex_data_unmap() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_frame_vertex_data_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data) EINA_ARG_NONNULL(1); + +/** + * Set the vertex data of the key frame of the given mesh by copying from a buffer. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @param attrib Vertex attribute ID. + * @param stride Stride to go to the next vertex (in bytes). + * @param data Pointer to the vertex data buffer. + * + * This function allocates internal vertex buffer and copy from the given + * buffer. So you can release the buffer. If you want to modify the vertex data + * use evas_3d_mesh_frame_vertex_data_map(). After finishing the modifications, + * you should call evas_3d_mesh_frame_vertex_data_unmap(). + * + * @see evas_3d_mesh_frame_vertex_data_set() + * @see evas_3d_mesh_frame_vertex_data_map() + * @see evas_3d_mesh_frame_vertex_data_unmap() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data) EINA_ARG_NONNULL(1); + +/** + * Map the vertex buffer of the key frame of the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @param attrib Vertex attribute ID. + * @return Starting address of the mapped vertex buffer. + * + * After manipulating the mapped buffer, evas_3d_mesh_frame_vertex_data_unmap() + * should be called to properly download the data to the engine. If the data + * was set using evas_3d_mesh_frame_vertex_data_set(), pointer to the original + * buffer will be returned. Otherwise, the returned pointer can differ every + * time calling this function. + * + * @see evas_3d_mesh_frame_vertex_data_unmap() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void *evas_3d_mesh_frame_vertex_data_map(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Unmap the vertex buffer of the key frame of the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @param attrib Vertex attribute ID. + * + * @see evas_3d_mesh_frame_vertex_data_map() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_frame_vertex_data_unmap(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) EINA_ARG_NONNULL(1); + +/** + * Get the vertex buffer stride of the key frame of the given mesh. + * + * @param mesh The given mesh. + * @param frame The number of the key frame. + * @param attrib Vertex attribute ID. + * @return Stride to go to the next vertex (in bytes). + * + * This function returns valid stride only when the vertex buffer is mapped. + * If the data was set with evas_3d_mesh_frame_vertex_data_set(), the original + * stride will be returned unchanged. + * + * @see evas_3d_mesh_frame_vertex_data_map() + * + * @ingroup Evas_3D_Mesh + */ +EAPI int evas_3d_mesh_frame_vertex_stride_get(const Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the vertex index data of the given mesh. + * + * @param mesh The given mesh. + * @param format Vertex index data format. + * @param count Vertex index count. + * @param indices Pointer to the index data. + * + * When the index data is set, Evas 3D assembles vertices using the index data. + * If you want to free the data buffer, use evas_3d_mesh_index_data_copy_set(). + * Further modifications should be made within map/unmap pair. + * + * @see evas_3d_mesh_index_data_copy_set() + * @see evas_3d_mesh_index_data_map() + * @see evas_3d_mesh_index_data_unmap() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_index_data_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, const void *indices) EINA_ARG_NONNULL(1); + +/** + * Set the vertex index data of the given mesh by copying from a buffer. + * + * @param mesh The given mesh. + * @param format Vertex index data format. + * @param count Vertex index count. + * @param indices Pointer to the vertex data. + * + * This function allocates internal index buffer any copy data from the given + * buffer. Futher modifications can be made within map/unmap pair. + * + * @see evas_3d_mesh_index_data_set() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_index_data_copy_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, const void *indices) EINA_ARG_NONNULL(1); + +/** + * Get the format of the index data of the given mesh. + * + * @param mesh The given mesh. + * @return Format of the index data. + * + * Returns valid format only when the index buffer is mapped. First map the + * index buffer and then query the properties of the mapped buffer. If the index + * data was set by evas_3d_mesh_index_data_set(), the original format will be + * returned. Otherwise the format can differ every time you call the + * evas_3d_mesh_index_data_map() function. + * + * @see evas_3d_mesh_index_data_map() + * + * @ingroup Evas_3D_Mesh + */ +EAPI Evas_3D_Index_Format evas_3d_mesh_index_format_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the count of the index data of the given mesh. + * + * @param mesh The given mesh. + * @return Index data count. + * + * This function returns the index count of the last called data_set function. + * + * @see evas_3d_mesh_index_data_set() + * @see evas_3d_mesh_index_data_copy_set() + * + * @ingroup Evas_3D_Mesh + */ +EAPI int evas_3d_mesh_index_count_get(const Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Map the index buffer of the given mesh. + * + * @param mesh The given mesh. + * @return Pointer to the mapped buffer. + * + * evas_3d_mesh_index_data_unmap() should be called after modifications. If the + * data was set using evas_3d_mesh_index_data_set(), the original pointer will + * be returned, otherwise, the returned pointer may differ every time you call + * this function. + * + * @see evas_3d_mesh_index_data_unmap() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void *evas_3d_mesh_index_data_map(Evas_3D_Mesh *mesh) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Unmap the index buffer of the given mesh. + * + * @param mesh The given mesh. + * + * @see evas_3d_mesh_index_data_map() + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_index_data_unmap(Evas_3D_Mesh *mesh) EINA_ARG_NONNULL(1); + +/** + * Set the vertex assembly of the given mesh. + * + * @param mesh The given mesh. + * @param assembly Vertex assembly. + * + * Vertex assembly defines how the engine organizes vertices into geometric + * primitives. + * + * Default vertex assembly is EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES. + * + * @ingroup Evas_3D_Mesh + */ +EAPI void evas_3d_mesh_vertex_assembly_set(Evas_3D_Mesh *mesh, Evas_3D_Vertex_Assembly assembly); + +/** + * Get the vertex assembly of the given mesh. + * + * @param mesh The given mesh. + * @return The vertex assembly. + * + * @see evas_3d_mesh_vertex_assembly_set() + * + * @ingroup Evas_3D_Mesh + */ +EAPI Evas_3D_Vertex_Assembly evas_3d_mesh_vertex_assembly_get(const Evas_3D_Mesh *mesh); + +/** + * Create a new texture on the given Evas @p canvas. + * + * @param e The given canvas. + * @return The created texture handle. + * + * @ingroup Evas_3D_Texture + */ +EAPI Evas_3D_Texture *evas_3d_texture_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a texture from its belonging Evas canvas. + * + * @param texture The given texture. + * + * @see evas_3d_texture_add() + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_del(Evas_3D_Texture *texture) EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given texture belongs to. + * + * @param texture The given texture. + * @return The Evas canvas. + * + * @see evas_3d_texture_add() + * + * @ingroup Evas_3D_Texture + */ +EAPI Evas *evas_3d_texture_evas_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the data of the given texture. + * + * @param texure The given texture + * @param color_format Color format of the texture. + * @param pixel_format Pixel format of the data. + * @param w Width of the data. + * @param h Height of the data. + * @param data Pointer to the data. + * + * @see evas_3d_texture_file_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_data_set(Evas_3D_Texture *texture, Evas_3D_Color_Format color_format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data); + +/** + * Set the data of the given texture from file. + * + * @param texture The given texture. + * @param file Path to the image file. + * @param key Key in the image file. + * + * Only PNG format is supported. + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_file_set(Evas_3D_Texture *texture, const char *file, const char *key) EINA_ARG_NONNULL(1); + +/** + * Set the data of the given texture from an evas object. + * + * @param texture The given texture. + * @param source Source evas object to be used as the texture data. + * + * Evas 3D support using existing evas object as a texture source. This feature + * make it possible using any exisiting evas object inside 3D scene. + * + * @see evas_3d_texture_source_visible_set + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source) EINA_ARG_NONNULL(1); + +/** + * Set the visibility flag of the source evas object of the given texture. + * + * @param texture The given texture. + * @param visible @c EINA_TRUE for visible, @c EINA_FALSE for invisible. + * + * Recommend to call evas_object_show() on the source object and controll the + * visibility using this function. + * + * By default, source object is visible. + * + * @see evas_3d_texture_source_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible) EINA_ARG_NONNULL(1); + +/** + * Get the visibility flag of the source evas object of the given texture. + * + * @param texture The given texture. + * @return @c EINA_TRUE if visible, @c EINA_FALSE if invisible. + * + * @see evas_3d_texture_source_visible_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI Eina_Bool evas_3d_texture_source_visible_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the color format of the given texture. + * + * @param texture The given texture. + * + * EVAS_3D_COLOR_FORMAT_RGBA will be returned if the texture has source object. + * Otherwise, the color format of the data will be returned. + * + * @see evas_3d_texture_data_set() + * @see evas_3d_texture_file_set() + * @see evas_3d_texture_source_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI Evas_3D_Color_Format evas_3d_texture_color_format_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Get the size of the given texture. + * + * @param texture The given texture. + * @param w Pointer to receive the width of the texture size. + * @param h Pointer to receive the height of the texture size. + * + * If the texture has source object, the size of the source object will be + * returned. Otherwise, the size of the data (or image file) will be returned. + * + * @see evas_3d_texture_data_set() + * @see evas_3d_texture_file_set() + * @see evas_3d_texture_source_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_size_get(const Evas_3D_Texture *texture, int *w, int *h) EINA_ARG_NONNULL(1); + +/** + * Set the wrap mode of the given texture. + * + * @param texture The given texture. + * @param s Wrap mode for S-axis. + * @param t Wrap mode for T-axis. + * + * If the texture coordinate exceed range [0.0, 1.0] the values are modified + * according to the wrap mode. + * + * Default wrap modes are both EVAS_3D_WRAP_MODE_CLAMP for s and t. + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_wrap_set(Evas_3D_Texture *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t) EINA_ARG_NONNULL(1); + +/** + * Get the wrap mode of the given texture. + * + * @param texture The given texture. + * @param s Pointer to receive S-axis wrap mode. + * @param t Pointer to receive T-axis wrap mode. + * + * @see evas_3d_texture_wrap_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_wrap_get(Evas_3D_Texture *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t) EINA_ARG_NONNULL(1); + +/** + * Set the filter of the given texture. + * + * @param texture The given texture. + * @param min Minification filter used when down-scaling. + * @param mag Magnification filter used when up-scaling. + * + * Default filters are both EVAS_3D_TEXTURE_FILTER_NEAREST for s and t. + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_filter_set(Evas_3D_Texture *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag) EINA_ARG_NONNULL(1); + +/** + * Get the filter of the given texture. + * + * @param texture The given texture. + * @param min Pointer to receive the minification filter. + * @param mag Pointer to receive the magnification filter. + * + * @see evas_3d_texture_filter_set() + * + * @ingroup Evas_3D_Texture + */ +EAPI void evas_3d_texture_filter_get(const Evas_3D_Texture *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag) EINA_ARG_NONNULL(1); + +/** + * Create a new material on the given Evas @p canvas. + * + * @param e The given canvas. + * @param type The type of the material. + * @return The created material handle. + * + * @ingroup Evas_3D_Material + */ +EAPI Evas_3D_Material *evas_3d_material_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Delete a material from its belonging Evas canvas. + * + * @param material The given material. + * + * @see evas_3d_material_add() + * + * @ingroup Evas_3D_Material + */ +EAPI void evas_3d_material_del(Evas_3D_Material *material) EINA_ARG_NONNULL(1); + +/** + * Get the Evas canvas where the given material belongs to. + * + * @param material The given material. + * @return The Evas canvas. + * + * @see evas_3d_material_add() + * + * @ingroup Evas_3D_Material + */ +EAPI Evas *evas_3d_material_evas_get(const Evas_3D_Material *material) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the material attribute enable flag of the given material. + * + * @param material The given material. + * @param attrib Material attribute ID. + * @param enable Whether to enable the attribute (@c EINA_TRUE), or not (@c EINA_FALSE). + * + * You might want to disable some material reflection contribution. For + * example,Emission attribute is rarely used. Disabling unused attributes + * might help the shading less complex so that can get speed up. + * + * By default, diffuse and specular is enabled. + * + * @ingroup Evas_3D_Material + */ +EAPI void evas_3d_material_enable_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Eina_Bool enable) EINA_ARG_NONNULL(1); + +/** + * Get the material attribute enable flag of the given material. + * + * @param material The given material. + * @param attrib Material attribute ID. + * @return @c EINA_TRUE if enabled, or @c EINA_FALSE if not. + * + * @see evas_3d_material_enable_set() + * + * @ingroup Evas_3D_Material + */ +EAPI Eina_Bool evas_3d_material_enable_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the material attribute color of the given material. + * + * @param material The given material. + * @param attrib Material attribute ID. + * @param r Red component of the color. + * @param g Green component of the color. + * @param b Blue component of the color. + * @param a Alpha component of the color. + * + * Material color is used also when texture map is enabled. The colors will be + * modulated (multiplied). To controll the color contribution of a material + * attribute, use gray color. Setting color value for normal attribute has no + * effect. + * + * Default color is as follows. + * + * Ambient : (0.2, 0.2, 0.2, 1.0) + * Diffuse : (0.8, 0.8, 0.8, 1.0) + * Specular : (1.0, 1.0, 1.0, 1.0) + * Emission : (0.0, 0.0, 0.0, 1.0) + * Normal : Not used + * + * @ingroup Evas_3D_Material + */ +EAPI void evas_3d_material_color_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) EINA_ARG_NONNULL(1); + +/** + * Get the material attribute color of the given material. + * + * @param material The given material. + * @param attrib Material attribute ID. + * @param r Pointer to receive red component of the color. + * @param g Pointer to receive green component of the color. + * @param b Pointer to receive blue component of the color. + * @param a Pointer to receive alpha component of the color. + * + * @see evas_3d_material_color_set() + * + * @ingroup Evas_3D_Material + */ +EAPI void evas_3d_material_color_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) EINA_ARG_NONNULL(1); + +/** + * Set the shininess of the given material. + * + * @param material The given material. + * @param shininess Shininess value. + * + * Shininess is only used when specular attribute is enabled. Higher shininess + * value will make the object more shiny. + * + * Default shininess value is 150.0. + * + * @see evas_3d_material_enable_set() + * + * @ingroup Evas_3D_Material + */ +EAPI void evas_3d_material_shininess_set(Evas_3D_Material *material, Evas_Real shininess) EINA_ARG_NONNULL(1); + +/** + * Get the shininess of the given material. + * + * @param material The given material. + * @return The shininess value. + * + * @see evas_3d_material_shininess_set() + * + * @ingroup Evas_3D_Material + */ +EAPI Evas_Real evas_3d_material_shininess_get(const Evas_3D_Material *material) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + +/** + * Set the texture of the given material. + * + * @param material The given material. + * @param attrib Material attribute ID. + * @param texture Texture to be set. + * + * You have to enable the desired attribute first. + * + * @see evas_3d_material_enable_set() + * + * @ingroup Evas_3D_Material + */ +EAPI void evas_3d_material_texture_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, Evas_3D_Texture *texture) EINA_ARG_NONNULL(1); + +/** + * Get the texture of the given material. + * + * @param material The given material. + * @param attrib Material attribute ID. + * @return The texture that is set to the given material attribute. + * + * @see evas_3d_material_texture_set() + * + * @ingroup Evas_3D_Material + */ +EAPI Evas_3D_Texture *evas_3d_material_texture_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); + diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 751c97f..cd3f017 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -206,6 +206,20 @@ EAPI extern const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_POST; #include "canvas/evas_object.eo.h" -#include"canvas/evas_image.eo.h" +#include "canvas/evas_image.eo.h" #include "canvas/evas_out.eo.h" + +#include "canvas/evas_3d_camera.eo.h" + +#include "canvas/evas_3d_texture.eo.h" + +#include "canvas/evas_3d_material.eo.h" + +#include "canvas/evas_3d_light.eo.h" + +#include "canvas/evas_3d_mesh.eo.h" + +#include "canvas/evas_3d_node.eo.h" + +#include "canvas/evas_3d_scene.eo.h" diff --git a/src/lib/evas/canvas/evas_3d_camera.c b/src/lib/evas/canvas/evas_3d_camera.c index fba4e7a..a9370c5 100644 --- a/src/lib/evas/canvas/evas_3d_camera.c +++ b/src/lib/evas/canvas/evas_3d_camera.c @@ -6,15 +6,19 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_CAMERA_CLASS + static void _camera_free(Evas_3D_Object *obj) { - Evas_3D_Camera *camera = (Evas_3D_Camera *)obj; + Evas_3D_Camera_Data *pd = (Evas_3D_Camera_Data *)obj; - if (camera->nodes) - eina_hash_free(camera->nodes); + if (pd->nodes) + eina_hash_free(pd->nodes); - free(camera); + //free(pd); } static Eina_Bool @@ -22,7 +26,8 @@ _camera_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data EINA_UNUSED, void *fdata) { Evas_3D_Node *n = *(Evas_3D_Node **)key; - evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_CAMERA, (Evas_3D_Object *)fdata); + Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_CAMERA, (Evas_3D_Object *)fdata); return EINA_TRUE; } @@ -30,10 +35,10 @@ static void _camera_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Camera *camera = (Evas_3D_Camera *)obj; + Evas_3D_Camera_Data *pd = (Evas_3D_Camera_Data *)obj; - if (camera->nodes) - eina_hash_foreach(camera->nodes, _camera_node_change_notify, obj); + if (pd->nodes) + eina_hash_foreach(pd->nodes, _camera_node_change_notify, obj); } static const Evas_3D_Object_Func camera_func = @@ -47,92 +52,107 @@ void evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node) { int count = 0; - - if (camera->nodes == NULL) + Evas_3D_Camera_Data *pd = eo_data_scope_get(camera, MY_CLASS); + if (pd->nodes == NULL) { - camera->nodes = eina_hash_pointer_new(NULL); + pd->nodes = eina_hash_pointer_new(NULL); - if (camera->nodes == NULL) + if (pd->nodes == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(camera->nodes, &node); + count = (int)eina_hash_find(pd->nodes, &node); - eina_hash_set(camera->nodes, &node, (const void *)(count + 1)); + eina_hash_set(pd->nodes, &node, (const void *)(count + 1)); } void evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node) { int count = 0; + Evas_3D_Camera_Data *pd = eo_data_scope_get(camera, MY_CLASS); - if (camera->nodes == NULL) + if (pd->nodes == NULL) { ERR("No node to delete."); return; } - count = (int)eina_hash_find(camera->nodes, &node); + count = (int)eina_hash_find(pd->nodes, &node); if (count == 1) - eina_hash_del(camera->nodes, &node, NULL); + eina_hash_del(pd->nodes, &node, NULL); else - eina_hash_set(camera->nodes, &node, (const void *)(count - 1)); + eina_hash_set(pd->nodes, &node, (const void *)(count - 1)); } -Evas_3D_Camera * -evas_3d_camera_new(Evas *e) -{ - Evas_3D_Camera *camera = NULL; +// Evas_3D_Camera * +// evas_3d_camera_new(Evas *e) +// { +// Evas_3D_Camera *camera = NULL; - camera = (Evas_3D_Camera *)calloc(1, sizeof(Evas_3D_Camera)); +// camera = (Evas_3D_Camera *)calloc(1, sizeof(Evas_3D_Camera)); - if (camera == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } +// if (camera == NULL) +// { +// ERR("Failed to allocate memory."); +// return NULL; +// } - evas_3d_object_init(&camera->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &camera_func); - return camera; +// evas_3d_object_init(&camera->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &camera_func); +// return camera; +// } +EOLIAN static void +_eo_evas_3d_camera_eo_base_constructor(Eo *obj, Evas_3D_Camera_Data *pd) +{ + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &camera_func); } -EAPI Evas_3D_Camera * -evas_3d_camera_add(Evas *e) +EOLIAN static void +_eo_evas_3d_camera_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd) { - return evas_3d_camera_new(e); + evas_3d_object_unreference(&pd->base); } -EAPI void -evas_3d_camera_del(Evas_3D_Camera *camera) +EAPI Evas_3D_Camera * +evas_3d_camera_add(Evas *e) { - evas_3d_object_unreference(&camera->base); + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + eo_unref(eo_obj); + return eo_obj; + //return evas_3d_camera_new(e); } -EAPI Evas * -evas_3d_camera_evas_get(const Evas_3D_Camera *camera) +EOLIAN static Evas * +_eo_evas_3d_camera_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd) { - return camera->base.evas; + return pd->base.evas; } -EAPI void -evas_3d_camera_projection_matrix_set(Evas_3D_Camera *camera, const Evas_Real *matrix) +EOLIAN static void +_eo_evas_3d_camera_projection_matrix_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, const Evas_Real *matrix) { - evas_mat4_array_set(&camera->projection, matrix); - evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); + evas_mat4_array_set(&pd->projection, matrix); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); } -EAPI void -evas_3d_camera_projection_matrix_get(const Evas_3D_Camera *camera, Evas_Real *matrix) +EOLIAN static void +_eo_evas_3d_camera_projection_matrix_get(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real *matrix) { - memcpy(matrix, &camera->projection.m[0], sizeof(Evas_Real) * 16); + memcpy(matrix, &pd->projection.m[0], sizeof(Evas_Real) * 16); } -EAPI void -evas_3d_camera_projection_perspective_set(Evas_3D_Camera *camera, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far) +EOLIAN static void +_eo_evas_3d_camera_projection_perspective_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real fovy, Evas_Real aspect, Evas_Real near, Evas_Real far) { Evas_Real xmax; Evas_Real ymax; @@ -140,20 +160,23 @@ evas_3d_camera_projection_perspective_set(Evas_3D_Camera *camera, Evas_Real fovy ymax = near * (Evas_Real)tan((double)fovy * M_PI / 360.0); xmax = ymax * aspect; - evas_mat4_frustum_set(&camera->projection, -xmax, xmax, -ymax, ymax, near, far); - evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); + evas_mat4_frustum_set(&pd->projection, -xmax, xmax, -ymax, ymax, near, far); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); } -EAPI void -evas_3d_camera_projection_frustum_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) +EOLIAN static void +_eo_evas_3d_camera_projection_frustum_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) { - evas_mat4_frustum_set(&camera->projection, left, right, bottom, top, near, far); - evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); + evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, near, far); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); } -EAPI void -evas_3d_camera_projection_ortho_set(Evas_3D_Camera *camera, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) +EOLIAN static void +_eo_evas_3d_camera_projection_ortho_set(Eo *obj EINA_UNUSED, Evas_3D_Camera_Data *pd, Evas_Real left, Evas_Real right, Evas_Real bottom, Evas_Real top, Evas_Real near, Evas_Real far) { - evas_mat4_ortho_set(&camera->projection, left, right, bottom, top, near, far); - evas_3d_object_change(&camera->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); + evas_mat4_ortho_set(&pd->projection, left, right, bottom, top, near, far); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_CAMERA_PROJECTION, NULL); } + +#include "canvas/evas_3d_camera.eo.c" + diff --git a/src/lib/evas/canvas/evas_3d_camera.eo b/src/lib/evas/canvas/evas_3d_camera.eo new file mode 100755 index 0000000..e856f97 --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_camera.eo @@ -0,0 +1,108 @@ +class EO_Evas_3D_Camera (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_camera; + data: Evas_3D_Camera_Data; + methods { + projection_matrix_set { + /*@ + Set the projection matrix of the given camera. + + @param camera The given camera. + @param matrix Pointer to the array of 16 Evas_Real values in column major order. + + Default projection matrix is identity matrix. + + @see evas_3d_camera_projection_perspective_set() + @see evas_3d_camera_projection_ortho_set() + @see evas_3d_camera_projection_frustum_set() + + @ingroup Evas_3D_Camera + */ + params { + @in const Evas_Real *matrix; /*@ Projection Matrix */ + } + } + + projection_matrix_get { + /*@ + Get the projection matrix of the given camera. + + @param camera The given camera. + @param matrix Pointer to receive the 16 Evas_Real values in column major order. + + @see evas_3d_camera_projection_matrix_set() + + @ingroup Evas_3D_Camera + */ + const; + params { + @out Evas_Real matrix; /*@ Projection Matrix */ + } + } + + projection_perspective_set { + /*@ + Set the projection matrix of the given camera with perspective projection. + + @param camera The given camera. + @param fovy Field of view angle in Y direction. + @param aspect Aspect ratio. + @param near Distance to near clipping plane. + @param far Distance to far clipping plane. + + @see evas_3d_camera_projection_matrix_set() + + @ingroup Evas_3D_Camera + */ + + params { + Evas_Real fovy; /*@ Field of view angle in Y direction. */ + Evas_Real aspect; /*@ Aspect ratio.*/ + Evas_Real near; /*@ Distance to near clipping plane. */ + Evas_Real far; /*@ Distance to far clipping plane. */ + } + } + + projection_frustum_set { + /*@ + Set the projection matrix of the given camera with frustum projection. + + @see evas_3d_camera_projection_matrix_set() + + @ingroup Evas_3D_Camera + */ + params { + Evas_Real left; /*@ Left X coordinate of the near clipping plane. */ + Evas_Real right; /*@ Right X coordinate of the near clipping plane..*/ + Evas_Real bottom; /*@ Bottom Y coordinate of the near clipping plane. */ + Evas_Real top; /*@ Top Y coordinate of the near clipping plane */ + Evas_Real near; /*@ Distance to near clipping plane. */ + Evas_Real far; /*@ Distance to far clipping plane. */ + } + } + projection_ortho_set { + /*@ + Set the projection matrix of the given camera with orthogonal projection. + + @see evas_3d_camera_projection_matrix_set() + + @ingroup Evas_3D_Camera + */ + params { + Evas_Real left; /*@ Left X coordinate of the near clipping plane. */ + Evas_Real right; /*@ Right X coordinate of the near clipping plane..*/ + Evas_Real bottom; /*@ Bottom Y coordinate of the near clipping plane. */ + Evas_Real top; /*@ Top Y coordinate of the near clipping plane */ + Evas_Real near; /*@ Distance to near clipping plane. */ + Evas_Real far; /*@ Distance to far clipping plane. */ + } + } + } + + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } + +} diff --git a/src/lib/evas/canvas/evas_3d_light.c b/src/lib/evas/canvas/evas_3d_light.c index 356e8dd..658c077 100644 --- a/src/lib/evas/canvas/evas_3d_light.c +++ b/src/lib/evas/canvas/evas_3d_light.c @@ -7,15 +7,19 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_LIGHT_CLASS + static void _light_free(Evas_3D_Object *obj) { - Evas_3D_Light *light = (Evas_3D_Light *)obj; + Evas_3D_Light_Data *light = (Evas_3D_Light_Data *)obj; if (light->nodes) eina_hash_free(light->nodes); - free(light); + //free(light); } static Eina_Bool @@ -23,7 +27,8 @@ _light_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data EINA_UNUSED, void *fdata) { Evas_3D_Node *n = *(Evas_3D_Node **)key; - evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_LIGHT, (Evas_3D_Object *)fdata); + Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_LIGHT, (Evas_3D_Object *)fdata); return EINA_TRUE; } @@ -31,7 +36,7 @@ static void _light_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Light *light = (Evas_3D_Light *)obj; + Evas_3D_Light_Data *light = (Evas_3D_Light_Data *)obj; if (light->nodes) eina_hash_foreach(light->nodes, _light_node_change_notify, obj); @@ -48,226 +53,220 @@ void evas_3d_light_node_add(Evas_3D_Light *light, Evas_3D_Node *node) { int count = 0; - - if (light->nodes == NULL) + Evas_3D_Light_Data *pd = eo_data_scope_get(light, MY_CLASS); + if (pd->nodes == NULL) { - light->nodes = eina_hash_pointer_new(NULL); + pd->nodes = eina_hash_pointer_new(NULL); - if (light->nodes == NULL) + if (pd->nodes == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(light->nodes, &node); + count = (int)eina_hash_find(pd->nodes, &node); - eina_hash_set(light->nodes, &node, (const void *)(count + 1)); + eina_hash_set(pd->nodes, &node, (const void *)(count + 1)); } void evas_3d_light_node_del(Evas_3D_Light *light, Evas_3D_Node *node) { int count = 0; - - if (light->nodes == NULL) + Evas_3D_Light_Data *pd = eo_data_scope_get(light, MY_CLASS); + if (pd->nodes == NULL) { ERR("No node to delete."); return; } - count = (int)eina_hash_find(light->nodes, &node); + count = (int)eina_hash_find(pd->nodes, &node); if (count == 1) - eina_hash_del(light->nodes, &node, NULL); + eina_hash_del(pd->nodes, &node, NULL); else - eina_hash_set(light->nodes, &node, (const void *)(count - 1)); + eina_hash_set(pd->nodes, &node, (const void *)(count - 1)); } -Evas_3D_Light * -evas_3d_light_new(Evas *e) -{ - Evas_3D_Light *light = NULL; - - light = (Evas_3D_Light *)calloc(1, sizeof(Evas_3D_Light)); - - if (light == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } - - evas_3d_object_init(&light->base, e, EVAS_3D_OBJECT_TYPE_LIGHT, &light_func); - - evas_color_set(&light->ambient, 0.0, 0.0, 0.0, 1.0); - evas_color_set(&light->diffuse, 1.0, 1.0, 1.0, 1.0); - evas_color_set(&light->specular, 1.0, 1.0, 1.0, 1.0); - - light->spot_exp = 0.0; - light->spot_cutoff = 180.0; - light->spot_cutoff_cos = -1.0; - - light->atten_const = 1.0; - light->atten_linear = 0.0; - light->atten_quad = 0.0; - - return light; -} EAPI Evas_3D_Light * evas_3d_light_add(Evas *e) { - return evas_3d_light_new(e); + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + eo_unref(eo_obj); + return eo_obj; } -EAPI void -evas_3d_light_del(Evas_3D_Light *light) +EOLIAN static void +_eo_evas_3d_light_eo_base_constructor(Eo *obj, Evas_3D_Light_Data *pd) { - evas_3d_object_unreference(&light->base); + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_LIGHT, &light_func); + evas_color_set(&pd->ambient, 0.0, 0.0, 0.0, 1.0); + evas_color_set(&pd->diffuse, 1.0, 1.0, 1.0, 1.0); + evas_color_set(&pd->specular, 1.0, 1.0, 1.0, 1.0); + + pd->spot_exp = 0.0; + pd->spot_cutoff = 180.0; + pd->spot_cutoff_cos = -1.0; + + pd->atten_const = 1.0; + pd->atten_linear = 0.0; + pd->atten_quad = 0.0; } -EAPI Evas * -evas_3d_light_evas_get(const Evas_3D_Light *light) +EOLIAN static void +_eo_evas_3d_light_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd) { - return light->base.evas; + evas_3d_object_unreference(&pd->base); } -EAPI void -evas_3d_light_directional_set(Evas_3D_Light *light, Eina_Bool directional) +EOLIAN static Evas * +_eo_evas_3d_light_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd) { - if (light->directional != directional) + return pd->base.evas; +} + +EOLIAN static void +_eo_evas_3d_light_directional_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Eina_Bool directional) +{ + if (pd->directional != directional) { - light->directional = directional; - evas_3d_object_change(&light->base, EVAS_3D_STATE_ANY, NULL); + pd->directional = directional; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_ANY, NULL); } } -EAPI Eina_Bool -evas_3d_light_directional_get(const Evas_3D_Light *light) +EOLIAN static Eina_Bool +_eo_evas_3d_light_directional_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd) { - return light->directional; + return pd->directional; } -EAPI void -evas_3d_light_ambient_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) +EOLIAN static void +_eo_evas_3d_light_ambient_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) { - light->ambient.r = r; - light->ambient.g = g; - light->ambient.b = b; - light->ambient.a = a; + pd->ambient.r = r; + pd->ambient.g = g; + pd->ambient.b = b; + pd->ambient.a = a; - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_AMBIENT, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_AMBIENT, NULL); } -EAPI void -evas_3d_light_ambient_get(const Evas_3D_Light *light, - Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) +EOLIAN static void +_eo_evas_3d_light_ambient_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) { - if (r) *r = light->ambient.r; - if (g) *g = light->ambient.g; - if (b) *b = light->ambient.b; - if (a) *a = light->ambient.a; + if (r) *r = pd->ambient.r; + if (g) *g = pd->ambient.g; + if (b) *b = pd->ambient.b; + if (a) *a = pd->ambient.a; } -EAPI void -evas_3d_light_diffuse_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) +EOLIAN static void +_eo_evas_3d_light_diffuse_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) { - light->diffuse.r = r; - light->diffuse.g = g; - light->diffuse.b = b; - light->diffuse.a = a; + pd->diffuse.r = r; + pd->diffuse.g = g; + pd->diffuse.b = b; + pd->diffuse.a = a; - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_DIFFUSE, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_DIFFUSE, NULL); } -EAPI void -evas_3d_light_diffuse_get(const Evas_3D_Light *light, - Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) +EOLIAN static void +_eo_evas_3d_light_diffuse_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) { - if (r) *r = light->diffuse.r; - if (g) *g = light->diffuse.g; - if (b) *b = light->diffuse.b; - if (a) *a = light->diffuse.a; + if (r) *r = pd->diffuse.r; + if (g) *g = pd->diffuse.g; + if (b) *b = pd->diffuse.b; + if (a) *a = pd->diffuse.a; } -EAPI void -evas_3d_light_specular_set(Evas_3D_Light *light, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) +EOLIAN static void +_eo_evas_3d_light_specular_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) { - light->specular.r = r; - light->specular.g = g; - light->specular.b = b; - light->specular.a = a; + pd->specular.r = r; + pd->specular.g = g; + pd->specular.b = b; + pd->specular.a = a; - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_SPECULAR, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_SPECULAR, NULL); } -EAPI void -evas_3d_light_specular_get(const Evas_3D_Light *light, - Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) +EOLIAN static void +_eo_evas_3d_light_specular_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) { - if (r) *r = light->specular.r; - if (g) *g = light->specular.g; - if (b) *b = light->specular.b; - if (a) *a = light->specular.a; + if (r) *r = pd->specular.r; + if (g) *g = pd->specular.g; + if (b) *b = pd->specular.b; + if (a) *a = pd->specular.a; } -EAPI void -evas_3d_light_spot_exponent_set(Evas_3D_Light *light, Evas_Real exponent) +EOLIAN static void +_eo_evas_3d_light_spot_exponent_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real exponent) { - light->spot_exp = exponent; - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_SPOT_EXP, NULL); + pd->spot_exp = exponent; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_SPOT_EXP, NULL); } -EAPI Evas_Real -evas_3d_light_spot_exponent_get(const Evas_3D_Light *light) +EOLIAN static Evas_Real +_eo_evas_3d_light_spot_exponent_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd) { - return light->spot_exp; + return pd->spot_exp; } -EAPI void -evas_3d_light_spot_cutoff_set(Evas_3D_Light *light, Evas_Real cutoff) +EOLIAN static void +_eo_evas_3d_light_spot_cutoff_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real cutoff) { - light->spot_cutoff = cutoff; - light->spot_cutoff_cos = cos(cutoff * M_PI / 180.0); - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_SPOT_CUTOFF, NULL); + pd->spot_cutoff = cutoff; + pd->spot_cutoff_cos = cos(cutoff * M_PI / 180.0); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_SPOT_CUTOFF, NULL); } -EAPI Evas_Real -evas_3d_light_spot_cutoff_get(const Evas_3D_Light *light) +EOLIAN static Evas_Real +_eo_evas_3d_light_spot_cutoff_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd) { - return light->spot_cutoff; + return pd->spot_cutoff; } -EAPI void -evas_3d_light_attenuation_set(Evas_3D_Light *light, - Evas_Real constant, Evas_Real linear, Evas_Real quadratic) +EOLIAN static void +_eo_evas_3d_light_attenuation_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real constant, Evas_Real linear, Evas_Real quadratic) { - light->atten_const = constant; - light->atten_linear = linear; - light->atten_quad = quadratic; - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL); + pd->atten_const = constant; + pd->atten_linear = linear; + pd->atten_quad = quadratic; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL); } -EAPI void -evas_3d_light_attenuation_get(const Evas_3D_Light *light, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic) +EOLIAN static void +_eo_evas_3d_light_attenuation_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic) { - if (constant) *constant = light->atten_const; - if (linear) *linear = light->atten_linear; - if (quadratic) *quadratic = light->atten_quad; + if (constant) *constant = pd->atten_const; + if (linear) *linear = pd->atten_linear; + if (quadratic) *quadratic = pd->atten_quad; } -EAPI void -evas_3d_light_attenuation_enable_set(Evas_3D_Light *light, Eina_Bool enable) +EOLIAN static void +_eo_evas_3d_light_attenuation_enable_set(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd, Eina_Bool enable) { - if (light->enable_attenuation != enable) + if (pd->enable_attenuation != enable) { - light->enable_attenuation = enable; - evas_3d_object_change(&light->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL); + pd->enable_attenuation = enable; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_LIGHT_ATTENUATION, NULL); } } -EAPI Eina_Bool -evas_3d_light_attenuation_enable_get(const Evas_3D_Light *light) +EOLIAN static Eina_Bool +_eo_evas_3d_light_attenuation_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Light_Data *pd) { - return light->enable_attenuation; + return pd->enable_attenuation; } + +#include "canvas/evas_3d_light.eo.c" \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_3d_light.eo b/src/lib/evas/canvas/evas_3d_light.eo new file mode 100755 index 0000000..079c521 --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_light.eo @@ -0,0 +1,264 @@ +class EO_Evas_3D_LIGHT (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_light; + data: Evas_3D_Light_Data; + + properties { + directional { + set { + /*@ + Set the directional flag of the given light. + + Directional light is a type of light which is infinitely far away with no + attenuation. The light direction is determined by the containing node's + forward vector (negative Z-axis). + + By default, directional is not enabled. + + @see evas_3d_node_look_at_set() + + @ingroup Evas_3D_Light + */ + } + get { + /*@ + Get the directional flag of the given light. + + @see evas_3d_light_directional_set() + + @ingroup Evas_3D_Light + */ + } + values { + Eina_Bool directional; /*@ Whether the light is directional (@c EINA_TRUE), or not (@c EINA_FALSE).*/ + } + } + + spot_exponent { + set { + /*@ + Set the spot exponent of the given light. + + Higher spot exponent means intensity at the center of the cone is relatively + stronger. Zero exponent means the light intensity is evenly distibuted. The + spot exponent has no effect when the light is not spot light (spot cutoff + angle is less than 180 degree). + + Default spot exponent is 0. + + @see evas_3d_light_spot_cutoff_set() + + @ingroup Evas_3D_Light + */ + } + get { + /*@ + Get the spot exponent of the given light. + + @see evas_3d_light_spot_exponent_set() + + @ingroup Evas_3D_Light + */ + } + values { + Evas_Real exponent; /*@ Spot exponent value..*/ + } + } + + spot_cutoff { + set { + /*@ + Set the spot cutoff angle of the given light. + + Only angle less than 180 degree will make it spot light, so that other spot + light attribute will take effect. + + Default spot cutoff angle is 180. + + @ingroup Evas_3D_Light + */ + } + get { + /*@ + Get the spot cutoff angle of the given light. + + @see evas_3d_light_spot_cutoff_set() + + @ingroup Evas_3D_Light + */ + } + values { + Evas_Real cutoff; /*@ Cutoff angle in degree..*/ + } + } + + attenuation_enable { + set { + /*@ + Set the attenuation enable flag of the given light. + + By default, light attenuation is not enabled. + + @see evas_3d_light_attenuation_set() + + @ingroup Evas_3D_Light + */ + } + get { + /*@ + Get the attenuation enable flag of the given light. + + @see evas_3d_light_attenuation_enable_set() + + @ingroup Evas_3D_Light + */ + } + values { + Eina_Bool enable; /*@ Whether to enable attenuation (@c EINA_TRUE), or not (@c EINA_FALSE)..*/ + } + } + } + methods { + ambient_set { + /*@ + Set the ambient color of the given light. + + Default ambient color is (0.0, 0.0, 0.0, 1.0). + + @ingroup Evas_3D_Light + */ + params { + @in Evas_Real r; /*@ Red component of the ambient color between [0.0, 1.0]. */ + @in Evas_Real g; /*@ Green component of the ambient color between [0.0, 1.0]. */ + @in Evas_Real b; /*@ Blue component of the ambient color between [0.0, 1.0]. */ + @in Evas_Real a; /*@ Alpha component of the ambient color between [0.0, 1.0]. */ + } + } + ambient_get { + /*@ + Get the ambient color of the given light. + + @see evas_3d_light_ambient_set() + + @ingroup Evas_3D_Light + */ + const; + params { + @out Evas_Real r; /*@ Red component of the ambient color between [0.0, 1.0]. */ + @out Evas_Real g; /*@ Green component of the ambient color between [0.0, 1.0]. */ + @out Evas_Real b; /*@ Blue component of the ambient color between [0.0, 1.0]. */ + @out Evas_Real a; /*@ Alpha component of the ambient color between [0.0, 1.0]. */ + } + } + + diffuse_set { + /*@ + Set the diffuse color of the given light. + + Default diffuse color is (1.0, 1.0, 1.0, 1.0). + + @ingroup Evas_3D_Light + */ + params { + @in Evas_Real r; /*@ Red component of the diffuse color between [0.0, 1.0]. */ + @in Evas_Real g; /*@ Green component of the diffuse color between [0.0, 1.0]. */ + @in Evas_Real b; /*@ Blue component of the diffuse color between [0.0, 1.0]. */ + @in Evas_Real a; /*@ Alpha component of the diffuse color between [0.0, 1.0]. */ + } + } + diffuse_get { + /*@ + Get the diffuse color of the given light. + + @see evas_3d_light_diffuse_set() + + @ingroup Evas_3D_Light + */ + const; + params { + @out Evas_Real r; /*@ Red component of the diffuse color between [0.0, 1.0]. */ + @out Evas_Real g; /*@ Green component of the diffuse color between [0.0, 1.0]. */ + @out Evas_Real b; /*@ Blue component of the diffuse color between [0.0, 1.0]. */ + @out Evas_Real a; /*@ Alpha component of the diffuse color between [0.0, 1.0]. */ + } + } + + specular_set { + /*@ + Set the specular color of the given light. + + Default specular color is (1.0, 1.0, 1.0, 1.0). + + @ingroup Evas_3D_Light + */ + params { + @in Evas_Real r; /*@ Red component of the specular color between [0.0, 1.0]. */ + @in Evas_Real g; /*@ Green component of the specular color between [0.0, 1.0]. */ + @in Evas_Real b; /*@ Blue component of the specular color between [0.0, 1.0]. */ + @in Evas_Real a; /*@ Alpha component of the specular color between [0.0, 1.0]. */ + } + } + specular_get { + /*@ + Get the specular color of the given light. + + @see evas_3d_light_specular_set() + + @ingroup Evas_3D_Light + */ + const; + params { + @out Evas_Real r; /*@ Red component of the specular color between [0.0, 1.0]. */ + @out Evas_Real g; /*@ Green component of the specular color between [0.0, 1.0]. */ + @out Evas_Real b; /*@ Blue component of the specular color between [0.0, 1.0]. */ + @out Evas_Real a; /*@ Alpha component of the specular color between [0.0, 1.0]. */ + } + } + + attenuation_set { + /*@ + Set the attenuation of the given light. + + Light attenuation has no effect with directional light. And the attenuation + should be enabled first to take effect. The attenuation factor is calculated + as follows. + + atten = 1.0 / constant + linear * distance + quadratic * distance * distance + + Default attenuation is constant = 1.0, linear = 0.0, quadratic = 0.0. + + @see evas_3d_light_attenuation_enable_set() + + @ingroup Evas_3D_Light + */ + params { + @in Evas_Real constant; /*@ Constant attenuation term..*/ + @in Evas_Real linear; /*@ Linear attenuation term..*/ + @in Evas_Real quadratic; /*@ Quadratic attenuation term..*/ + } + } + + attenuation_get { + /*@ + Get the attenuation of the given light. + + @see evas_3d_light_attenuation_set() + + @ingroup Evas_3D_Light + */ + const; + params { + @out Evas_Real constant; /*@ Constant attenuation term..*/ + @out Evas_Real linear; /*@ Linear attenuation term..*/ + @out Evas_Real quadratic; /*@ Quadratic attenuation term..*/ + } + } + } + + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } + +} diff --git a/src/lib/evas/canvas/evas_3d_material.c b/src/lib/evas/canvas/evas_3d_material.c index e9a131d..70a4c84 100644 --- a/src/lib/evas/canvas/evas_3d_material.c +++ b/src/lib/evas/canvas/evas_3d_material.c @@ -6,11 +6,15 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_MATERIAL_CLASS + static void _material_free(Evas_3D_Object *obj) { int i; - Evas_3D_Material *material = (Evas_3D_Material *)obj; + Evas_3D_Material_Data *material = (Evas_3D_Material_Data *)obj; if (material->meshes) eina_hash_free(material->meshes); @@ -19,12 +23,14 @@ _material_free(Evas_3D_Object *obj) { if (material->attribs[i].texture) { - evas_3d_texture_material_del(material->attribs[i].texture, material); - evas_3d_object_unreference(&material->attribs[i].texture->base); + //@FIXME + //evas_3d_texture_material_del(material->attribs[i].texture, material); + Evas_3D_Texture_Data *pd = eo_data_scope_get(material->attribs[i].texture, EO_EVAS_3D_TEXTURE_CLASS); + evas_3d_object_unreference(&pd->base); } } - free(material); + //free(material); } static Eina_Bool @@ -32,7 +38,8 @@ _material_mesh_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data EINA_UNUSED, void *fdata) { Evas_3D_Mesh *m = *(Evas_3D_Mesh **)key; - evas_3d_object_change(&m->base, EVAS_3D_STATE_MESH_MATERIAL, (Evas_3D_Object *)fdata); + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(m, EO_EVAS_3D_MESH_CLASS); + evas_3d_object_change(&pdmesh->base, EVAS_3D_STATE_MESH_MATERIAL, (Evas_3D_Object *)fdata); return EINA_TRUE; } @@ -40,7 +47,7 @@ static void _material_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Material *material = (Evas_3D_Material *)obj; + Evas_3D_Material_Data *material = (Evas_3D_Material_Data *)obj; if (material->meshes) eina_hash_foreach(material->meshes, _material_mesh_change_notify, obj); @@ -50,14 +57,17 @@ static void _material_update(Evas_3D_Object *obj) { int i; - Evas_3D_Material *material = (Evas_3D_Material *)obj; + Evas_3D_Material_Data *material = (Evas_3D_Material_Data *)obj; for (i = 0; i < EVAS_3D_MATERIAL_ATTRIB_COUNT; i++) { if (material->attribs[i].enable) { if (material->attribs[i].texture) - evas_3d_object_update(&material->attribs[i].texture->base); + { + Evas_3D_Texture_Data *pd = eo_data_scope_get(material->attribs[i].texture, EO_EVAS_3D_TEXTURE_CLASS); + evas_3d_object_update(&pd->base); + } } } } @@ -73,149 +83,148 @@ void evas_3d_material_mesh_add(Evas_3D_Material *material, Evas_3D_Mesh *mesh) { int count = 0; + Evas_3D_Material_Data *pd = eo_data_scope_get(material, MY_CLASS); - if (material->meshes == NULL) + if (pd->meshes == NULL) { - material->meshes = eina_hash_pointer_new(NULL); + pd->meshes = eina_hash_pointer_new(NULL); - if (material->meshes == NULL) + if (pd->meshes == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(material->meshes, &mesh); + count = (int)eina_hash_find(pd->meshes, &mesh); - eina_hash_set(material->meshes, &mesh, (const void *)(count + 1)); + eina_hash_set(pd->meshes, &mesh, (const void *)(count + 1)); } void evas_3d_material_mesh_del(Evas_3D_Material *material, Evas_3D_Mesh *mesh) { int count = 0; + Evas_3D_Material_Data *pd = eo_data_scope_get(material, MY_CLASS); - if (material->meshes == NULL) + if (pd->meshes == NULL) { ERR("No mesh to delete."); return; } - count = (int)eina_hash_find(material->meshes, &mesh); + count = (int)eina_hash_find(pd->meshes, &mesh); if (count == 1) - eina_hash_del(material->meshes, &mesh, NULL); + eina_hash_del(pd->meshes, &mesh, NULL); else - eina_hash_set(material->meshes, &mesh, (const void *)(count - 1)); + eina_hash_set(pd->meshes, &mesh, (const void *)(count - 1)); } -Evas_3D_Material * -evas_3d_material_new(Evas *e) -{ - Evas_3D_Material *material = NULL; - - material = (Evas_3D_Material *)calloc(1, sizeof(Evas_3D_Material)); - - if (material == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } - - evas_3d_object_init(&material->base, e, EVAS_3D_OBJECT_TYPE_MATERIAL, &material_func); - - evas_color_set(&material->attribs[EVAS_3D_MATERIAL_AMBIENT].color, 0.2, 0.2, 0.2, 1.0); - evas_color_set(&material->attribs[EVAS_3D_MATERIAL_DIFFUSE].color, 0.8, 0.8, 0.8, 1.0); - evas_color_set(&material->attribs[EVAS_3D_MATERIAL_SPECULAR].color, 1.0, 1.0, 1.0, 1.0); - evas_color_set(&material->attribs[EVAS_3D_MATERIAL_EMISSION].color, 0.0, 0.0, 0.0, 1.0); - material->shininess = 150.0; - - return material; -} EAPI Evas_3D_Material * evas_3d_material_add(Evas *e) { - return evas_3d_material_new(e); + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + eo_unref(eo_obj); + return eo_obj; +} + +EOLIAN static void +_eo_evas_3d_material_eo_base_constructor(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd) +{ + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_MATERIAL, &material_func); + + evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_AMBIENT].color, 0.2, 0.2, 0.2, 1.0); + evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_DIFFUSE].color, 0.8, 0.8, 0.8, 1.0); + evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_SPECULAR].color, 1.0, 1.0, 1.0, 1.0); + evas_color_set(&pd->attribs[EVAS_3D_MATERIAL_EMISSION].color, 0.0, 0.0, 0.0, 1.0); + pd->shininess = 150.0; } -EAPI void -evas_3d_material_del(Evas_3D_Material *material) +EOLIAN static void +_eo_evas_3d_material_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd) { - evas_3d_object_unreference(&material->base); + evas_3d_object_unreference(&pd->base); } -EAPI Evas * -evas_3d_material_evas_get(const Evas_3D_Material *material) +EOLIAN static Evas * +_eo_evas_3d_material_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd) { - return material->base.evas; + return pd->base.evas; } -EAPI void -evas_3d_material_enable_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, - Eina_Bool enable) +EOLIAN static void +_eo_evas_3d_material_enable_set(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Eina_Bool enable) { - material->attribs[attrib].enable = enable; + pd->attribs[attrib].enable = enable; } -EAPI Eina_Bool -evas_3d_material_enable_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib) +EOLIAN static Eina_Bool +_eo_evas_3d_material_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib) { - return material->attribs[attrib].enable; + return pd->attribs[attrib].enable; } -EAPI void -evas_3d_material_color_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, - Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) +EOLIAN static void +_eo_evas_3d_material_color_set(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) { - evas_color_set(&material->attribs[attrib].color, r, g, b, a); - evas_3d_object_change(&material->base, EVAS_3D_STATE_MATERIAL_COLOR, NULL); + evas_color_set(&pd->attribs[attrib].color, r, g, b, a); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MATERIAL_COLOR, NULL); } -EAPI void -evas_3d_material_color_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, - Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) +EOLIAN static void +_eo_evas_3d_material_color_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) { - if (r) *r = material->attribs[attrib].color.r; - if (g) *g = material->attribs[attrib].color.g; - if (b) *b = material->attribs[attrib].color.b; - if (a) *a = material->attribs[attrib].color.a; + if (r) *r = pd->attribs[attrib].color.r; + if (g) *g = pd->attribs[attrib].color.g; + if (b) *b = pd->attribs[attrib].color.b; + if (a) *a = pd->attribs[attrib].color.a; } -EAPI void -evas_3d_material_shininess_set(Evas_3D_Material *material, Evas_Real shininess) +EOLIAN static void +_eo_evas_3d_material_shininess_set(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_Real shininess) { - material->shininess = shininess; + pd->shininess = shininess; } -EAPI Evas_Real -evas_3d_material_shininess_get(const Evas_3D_Material *material) +EOLIAN static Evas_Real +_eo_evas_3d_material_shininess_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd) { - return material->shininess; + return pd->shininess; } -EAPI void -evas_3d_material_texture_set(Evas_3D_Material *material, Evas_3D_Material_Attrib attrib, - Evas_3D_Texture *texture) +EOLIAN static void +_eo_evas_3d_material_texture_set(Eo *obj, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib, Evas_3D_Texture *texture) { - if (material->attribs[attrib].texture != texture) + if (pd->attribs[attrib].texture != texture) { - if (material->attribs[attrib].texture) + if (pd->attribs[attrib].texture) { - evas_3d_texture_material_del(material->attribs[attrib].texture, material); - evas_3d_object_unreference(&material->attribs[attrib].texture->base); + evas_3d_texture_material_del(pd->attribs[attrib].texture, obj); + Evas_3D_Texture_Data *pdt = eo_data_scope_get(pd->attribs[attrib].texture, EO_EVAS_3D_TEXTURE_CLASS); + evas_3d_object_unreference(&pdt->base); } - material->attribs[attrib].texture = texture; - evas_3d_texture_material_add(texture, material); - evas_3d_object_reference(&texture->base); + pd->attribs[attrib].texture = texture; + evas_3d_texture_material_add(texture, obj); + Evas_3D_Texture_Data *pdt = eo_data_scope_get(texture, EO_EVAS_3D_TEXTURE_CLASS); + evas_3d_object_reference(&pdt->base); } - evas_3d_object_change(&material->base, EVAS_3D_STATE_MATERIAL_TEXTURE, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MATERIAL_TEXTURE, NULL); } -EAPI Evas_3D_Texture * -evas_3d_material_texture_get(const Evas_3D_Material *material, Evas_3D_Material_Attrib attrib) +EOLIAN static Evas_3D_Texture * +_eo_evas_3d_material_texture_get(Eo *obj EINA_UNUSED, Evas_3D_Material_Data *pd, Evas_3D_Material_Attrib attrib) { - return material->attribs[attrib].texture; + return pd->attribs[attrib].texture; } + +#include "canvas/evas_3d_material.eo.c" diff --git a/src/lib/evas/canvas/evas_3d_material.eo b/src/lib/evas/canvas/evas_3d_material.eo new file mode 100755 index 0000000..9f52a1b --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_material.eo @@ -0,0 +1,156 @@ +class EO_Evas_3D_Material (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_material; + data: Evas_3D_Material_Data; + methods { + color_set { + /* + Set the material attribute color of the given material. + + Material color is used also when texture map is enabled. The colors will be + modulated (multiplied). To controll the color contribution of a material + attribute, use gray color. Setting color value for normal attribute has no + effect. + + Default color is as follows. + + Ambient : (0.2, 0.2, 0.2, 1.0) + Diffuse : (0.8, 0.8, 0.8, 1.0) + Specular : (1.0, 1.0, 1.0, 1.0) + Emission : (0.0, 0.0, 0.0, 1.0) + Normal : Not used + + @ingroup Evas_3D_Material + */ + + params { + @in Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */ + @in Evas_Real r; /*@ Red component of the color. */ + @in Evas_Real g; /*@ Green component of the color. */ + @in Evas_Real b; /*@ Blue component of the color. */ + @in Evas_Real a; /*@ Alpha component of the color. */ + } + } + + color_get { + /* + Get the material attribute color of the given material. + + @see evas_3d_material_color_set() + + @ingroup Evas_3D_Material + */ + + const; + params { + @in Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */ + @out Evas_Real r; /*@ Pointer to receive red component of the color. */ + @out Evas_Real g; /*@ Pointer to receive green component of the color. */ + @out Evas_Real b; /*@ Pointer to receive blue component of the color. */ + @out Evas_Real a; /*@ Pointer to receive alpha component of the color. */ + } + } + } + + properties { + enable { + set { + /* + Set the material attribute enable flag of the given material. + + You might want to disable some material reflection contribution. For + example,Emission attribute is rarely used. Disabling unused attributes + might help the shading less complex so that can get speed up. + + By default, diffuse and specular is enabled. + + @ingroup Evas_3D_Material + */ + } + get { + /* + Get the material attribute enable flag of the given material. + + @see evas_3d_material_enable_set() + + @return @c EINA_TRUE if enabled, or @c EINA_FALSE if not. + @ingroup Evas_3D_Material + */ + } + keys { + Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */ + } + values { + Eina_Bool enable; /*@ Whether to enable the attribute (@c EINA_TRUE), or not (@c EINA_FALSE). */ + } + } + + shininess { + set { + /* + Set the shininess of the given material. + + Shininess is only used when specular attribute is enabled. Higher shininess + value will make the object more shiny. + + Default shininess value is 150.0. + + @see evas_3d_material_enable_set() + + @ingroup Evas_3D_Material + */ + } + get { + /* + Get the shininess of the given material. + + @see evas_3d_material_shininess_set() + + @return The shininess value. + @ingroup Evas_3D_Material + */ + } + values { + Evas_Real shininess; /*@ Shininess value. */ + } + } + + texture { + set { + /*@ + Set the texture of the given material. + + You have to enable the desired attribute first. + + @see evas_3d_material_enable_set() + + @ingroup Evas_3D_Material + */ + } + get { + /* + Get the texture of the given material. + + @see evas_3d_material_texture_set() + + @return The texture that is set to the given material attribute. + + @ingroup Evas_3D_Material + */ + } + + keys { + @in Evas_3D_Material_Attrib attrib; /*@ Material attribute ID. */ + } + values { + Evas_3D_Texture *texture; + } + } + } + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } + +} diff --git a/src/lib/evas/canvas/evas_3d_mesh.c b/src/lib/evas/canvas/evas_3d_mesh.c index 37d7671..2145679 100644 --- a/src/lib/evas/canvas/evas_3d_mesh.c +++ b/src/lib/evas/canvas/evas_3d_mesh.c @@ -6,11 +6,14 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_MESH_CLASS + static Evas_3D_Mesh_Frame * evas_3d_mesh_frame_new(Evas_3D_Mesh *mesh) { Evas_3D_Mesh_Frame *frame = NULL; - frame = (Evas_3D_Mesh_Frame *)calloc(1, sizeof(Evas_3D_Mesh_Frame)); if (frame == NULL) @@ -33,7 +36,8 @@ evas_3d_mesh_frame_free(Evas_3D_Mesh_Frame *frame) if (frame->material) { evas_3d_material_mesh_del(frame->material, frame->mesh); - evas_3d_object_unreference(&frame->material->base); + Evas_3D_Material_Data *pd = eo_data_scope_get(frame->material, EO_EVAS_3D_MATERIAL_CLASS); + evas_3d_object_unreference(&pd->base); } for (i = 0; i < EVAS_3D_VERTEX_ATTRIB_COUNT; i++) @@ -46,12 +50,12 @@ evas_3d_mesh_frame_free(Evas_3D_Mesh_Frame *frame) } static Evas_3D_Mesh_Frame * -evas_3d_mesh_frame_find(Evas_3D_Mesh *mesh, int frame) +evas_3d_mesh_frame_find(Evas_3D_Mesh_Data *pd, int frame) { Eina_List *l; Evas_3D_Mesh_Frame *f; - EINA_LIST_FOREACH(mesh->frames, l, f) + EINA_LIST_FOREACH(pd->frames, l, f) { if (f->frame == frame) return f; @@ -61,50 +65,50 @@ evas_3d_mesh_frame_find(Evas_3D_Mesh *mesh, int frame) } static inline void -_mesh_init(Evas_3D_Mesh *mesh) +_mesh_init(Evas_3D_Mesh_Data *pd) { - mesh->vertex_count = 0; - mesh->frame_count = 0; - mesh->frames = NULL; + pd->vertex_count = 0; + pd->frame_count = 0; + pd->frames = NULL; - mesh->index_format = EVAS_3D_INDEX_FORMAT_NONE; - mesh->index_count = 0; - mesh->indices = NULL; - mesh->owns_indices = EINA_FALSE; - mesh->assembly = EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES; + pd->index_format = EVAS_3D_INDEX_FORMAT_NONE; + pd->index_count = 0; + pd->indices = NULL; + pd->owns_indices = EINA_FALSE; + pd->assembly = EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES; - mesh->nodes = NULL; + pd->nodes = NULL; } static inline void -_mesh_fini(Evas_3D_Mesh *mesh) +_mesh_fini(Evas_3D_Mesh_Data *pd) { Eina_List *l; Evas_3D_Mesh_Frame *f; - if (mesh->frames) + if (pd->frames) { - EINA_LIST_FOREACH(mesh->frames, l, f) + EINA_LIST_FOREACH(pd->frames, l, f) { evas_3d_mesh_frame_free(f); } - eina_list_free(mesh->frames); + eina_list_free(pd->frames); } - if (mesh->indices && mesh->owns_indices) - free(mesh->indices); + if (pd->indices && pd->owns_indices) + free(pd->indices); - if (mesh->nodes) - eina_hash_free(mesh->nodes); + if (pd->nodes) + eina_hash_free(pd->nodes); } static void _mesh_free(Evas_3D_Object *obj) { - Evas_3D_Mesh *mesh = (Evas_3D_Mesh *)obj; + Evas_3D_Mesh_Data *mesh = (Evas_3D_Mesh_Data *)obj; _mesh_fini(mesh); - free(mesh); + //ree(mesh); } static Eina_Bool @@ -112,7 +116,8 @@ _mesh_node_geometry_change_notify(const Eina_Hash *hash EINA_UNUSED, const void void *data EINA_UNUSED, void *fdata) { Evas_3D_Node *n = *(Evas_3D_Node **)key; - evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, (Evas_3D_Object *)fdata); + Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, (Evas_3D_Object *)fdata); return EINA_TRUE; } @@ -121,14 +126,15 @@ _mesh_node_material_change_notify(const Eina_Hash *hash EINA_UNUSED, const void void *data EINA_UNUSED, void *fdata) { Evas_3D_Node *n = *(Evas_3D_Node **)key; - evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, (Evas_3D_Object *)fdata); + Evas_3D_Node_Data *pdnode = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_change(&pdnode->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, (Evas_3D_Object *)fdata); return EINA_TRUE; } static void _mesh_change(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Mesh *mesh = (Evas_3D_Mesh *)obj; + Evas_3D_Mesh_Data *mesh = (Evas_3D_Mesh_Data *)obj; if (state == EVAS_3D_STATE_MESH_MATERIAL) { @@ -147,12 +153,15 @@ _mesh_update(Evas_3D_Object *obj) { Eina_List *l; Evas_3D_Mesh_Frame *f; - Evas_3D_Mesh *mesh = (Evas_3D_Mesh *)obj; + Evas_3D_Mesh_Data *mesh = (Evas_3D_Mesh_Data *)obj; EINA_LIST_FOREACH(mesh->frames, l, f) { if (f->material) - evas_3d_object_update(&f->material->base); + { + Evas_3D_Material_Data *pdm = eo_data_scope_get(f->material, EO_EVAS_3D_MATERIAL_CLASS); + evas_3d_object_update(&pdm->base); + } } } @@ -167,111 +176,109 @@ void evas_3d_mesh_node_add(Evas_3D_Mesh *mesh, Evas_3D_Node *node) { int count = 0; - - if (mesh->nodes == NULL) + Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, MY_CLASS); + if (pd->nodes == NULL) { - mesh->nodes = eina_hash_pointer_new(NULL); + pd->nodes = eina_hash_pointer_new(NULL); - if (mesh->nodes == NULL) + if (pd->nodes == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(mesh->nodes, &node); + count = (int)eina_hash_find(pd->nodes, &node); - eina_hash_set(mesh->nodes, &node, (const void *)(count + 1)); + eina_hash_set(pd->nodes, &node, (const void *)(count + 1)); } void evas_3d_mesh_node_del(Evas_3D_Mesh *mesh, Evas_3D_Node *node) { int count = 0; - - if (mesh->nodes == NULL) + Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, MY_CLASS); + if (pd->nodes == NULL) { ERR("No node to delete."); return; } - count = (int)eina_hash_find(mesh->nodes, &node); + count = (int)eina_hash_find(pd->nodes, &node); if (count == 1) - eina_hash_del(mesh->nodes, &node, NULL); + eina_hash_del(pd->nodes, &node, NULL); else - eina_hash_set(mesh->nodes, &node, (const void *)(count - 1)); + eina_hash_set(pd->nodes, &node, (const void *)(count - 1)); } -Evas_3D_Mesh * -evas_3d_mesh_new(Evas *e) -{ - Evas_3D_Mesh *mesh = NULL; - - mesh = (Evas_3D_Mesh *)malloc(sizeof(Evas_3D_Mesh)); - - if (mesh == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } - - evas_3d_object_init(&mesh->base, e, EVAS_3D_OBJECT_TYPE_MESH, &mesh_func); - _mesh_init(mesh); - return mesh; -} EAPI Evas_3D_Mesh * evas_3d_mesh_add(Evas *e) { - return evas_3d_mesh_new(e); + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + eo_unref(eo_obj); + return eo_obj; } -EAPI void -evas_3d_mesh_del(Evas_3D_Mesh *mesh) +EOLIAN static void +_eo_evas_3d_mesh_eo_base_constructor(Eo *obj, Evas_3D_Mesh_Data *pd) { - evas_3d_object_unreference(&mesh->base); + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_MESH, &mesh_func); + _mesh_init(pd); } -EAPI Evas * -evas_3d_mesh_evas_get(const Evas_3D_Mesh *mesh) +EOLIAN static void +_eo_evas_3d_mesh_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - return mesh->base.evas; + evas_3d_object_unreference(&pd->base); } -EAPI void -evas_3d_mesh_shade_mode_set(Evas_3D_Mesh *mesh, Evas_3D_Shade_Mode mode) +EOLIAN static Evas * + _eo_evas_3d_mesh_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - if (mesh->shade_mode != mode) + return pd->base.evas; +} + +EOLIAN static void +_eo_evas_3d_mesh_shade_mode_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Shade_Mode mode) +{ + if (pd->shade_mode != mode) { - mesh->shade_mode = mode; - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_SHADE_MODE, NULL); + pd->shade_mode = mode; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_SHADE_MODE, NULL); } } -EAPI Evas_3D_Shade_Mode -evas_3d_mesh_shade_mode_get(const Evas_3D_Mesh *mesh) +EOLIAN static Evas_3D_Shade_Mode +_eo_evas_3d_mesh_shade_mode_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - return mesh->shade_mode; + return pd->shade_mode; } -EAPI void -evas_3d_mesh_vertex_count_set(Evas_3D_Mesh *mesh, unsigned int count) +EOLIAN static void +_eo_evas_3d_mesh_vertex_count_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, unsigned int count) { - mesh->vertex_count = count; - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_COUNT, NULL); + pd->vertex_count = count; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_COUNT, NULL); } -EAPI int -evas_3d_mesh_vertex_count_get(const Evas_3D_Mesh *mesh) +EOLIAN static int +_eo_evas_3d_mesh_vertex_count_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - return mesh->vertex_count; + return pd->vertex_count; } -EAPI void -evas_3d_mesh_frame_add(Evas_3D_Mesh *mesh, int frame) +EOLIAN static void +_eo_evas_3d_mesh_frame_add(Eo *obj, Evas_3D_Mesh_Data *pd, int frame) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f != NULL) { @@ -279,20 +286,20 @@ evas_3d_mesh_frame_add(Evas_3D_Mesh *mesh, int frame) return; } - f = evas_3d_mesh_frame_new(mesh); + f = evas_3d_mesh_frame_new(obj); if (f == NULL) return; f->frame = frame; - mesh->frames = eina_list_append(mesh->frames, f); - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_FRAME, NULL); + pd->frames = eina_list_append(pd->frames, f); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_FRAME, NULL); } -EAPI void -evas_3d_mesh_frame_del(Evas_3D_Mesh *mesh, int frame) +EOLIAN static void +_eo_evas_3d_mesh_frame_del(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f == NULL) { @@ -300,15 +307,15 @@ evas_3d_mesh_frame_del(Evas_3D_Mesh *mesh, int frame) return; } - mesh->frames = eina_list_remove(mesh->frames, f); + pd->frames = eina_list_remove(pd->frames, f); evas_3d_mesh_frame_free(f); - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_FRAME, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_FRAME, NULL); } -EAPI void -evas_3d_mesh_frame_material_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Material *material) +EOLIAN static void +_eo_evas_3d_mesh_frame_material_set(Eo *obj, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Material *material) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f == NULL) { @@ -321,20 +328,22 @@ evas_3d_mesh_frame_material_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Material if (f->material) { - evas_3d_material_mesh_del(f->material, mesh); - evas_3d_object_unreference(&f->material->base); + evas_3d_material_mesh_del(f->material, obj); + Evas_3D_Material_Data *pdm = eo_data_scope_get(f->material, EO_EVAS_3D_MATERIAL_CLASS); + evas_3d_object_unreference(&pdm->base); } f->material = material; - evas_3d_object_reference(&material->base); - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_MATERIAL, NULL); - evas_3d_material_mesh_add(material, mesh); + Evas_3D_Material_Data *pdm = eo_data_scope_get(material, EO_EVAS_3D_MATERIAL_CLASS); + evas_3d_object_reference(&pdm->base); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_MATERIAL, NULL); + evas_3d_material_mesh_add(material, obj); } -EAPI Evas_3D_Material * -evas_3d_mesh_frame_material_get(const Evas_3D_Mesh *mesh, int frame) +EOLIAN static Evas_3D_Material * +_eo_evas_3d_mesh_frame_material_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find((Evas_3D_Mesh *)mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f == NULL) { @@ -345,11 +354,10 @@ evas_3d_mesh_frame_material_get(const Evas_3D_Mesh *mesh, int frame) return f->material; } -EAPI void -evas_3d_mesh_frame_vertex_data_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, - int stride, const void *data) +EOLIAN static void +_eo_evas_3d_mesh_frame_vertex_data_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); int element_count; if (f == NULL) @@ -393,15 +401,13 @@ evas_3d_mesh_frame_vertex_data_set(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex f->vertices[attrib].owns_data = EINA_FALSE; f->vertices[attrib].element_count = element_count; - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL); } -EAPI void -evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, - Evas_3D_Vertex_Attrib attrib, - int stride, const void *data) +EOLIAN static void +_eo_evas_3d_mesh_frame_vertex_data_copy_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib, int stride, const void *data) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); Evas_3D_Vertex_Buffer *vb; int size, element_count; @@ -438,7 +444,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, } vb = &f->vertices[attrib]; - size = element_count * sizeof(float) * mesh->vertex_count; + size = element_count * sizeof(float) * pd->vertex_count; if (!vb->owns_data || vb->size < size) { @@ -480,7 +486,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, if (element_count == 1) { - for (i = 0; i vertex_count; i++) + for (i = 0; i vertex_count; i++) { *dst++ = src[0]; @@ -489,7 +495,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, } else if (element_count == 2) { - for (i = 0; i vertex_count; i++) + for (i = 0; i vertex_count; i++) { *dst++ = src[0]; *dst++ = src[1]; @@ -499,7 +505,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, } else if (element_count == 3) { - for (i = 0; i vertex_count; i++) + for (i = 0; i vertex_count; i++) { *dst++ = src[0]; *dst++ = src[1]; @@ -510,7 +516,7 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, } else if (element_count == 4) { - for (i = 0; i vertex_count; i++) + for (i = 0; i vertex_count; i++) { *dst++ = src[0]; *dst++ = src[1]; @@ -522,13 +528,13 @@ evas_3d_mesh_frame_vertex_data_copy_set(Evas_3D_Mesh *mesh, int frame, } } - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_DATA, NULL); } -EAPI void * -evas_3d_mesh_frame_vertex_data_map(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) +EOLIAN static void * +_eo_evas_3d_mesh_frame_vertex_data_map(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f == NULL) { @@ -546,10 +552,10 @@ evas_3d_mesh_frame_vertex_data_map(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex return f->vertices[attrib].data; } -EAPI void -evas_3d_mesh_frame_vertex_data_unmap(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib) +EOLIAN static void +_eo_evas_3d_mesh_frame_vertex_data_unmap(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f == NULL) { @@ -566,11 +572,10 @@ evas_3d_mesh_frame_vertex_data_unmap(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vert f->vertices[attrib].mapped = EINA_FALSE; } -EAPI int -evas_3d_mesh_frame_vertex_stride_get(const Evas_3D_Mesh *mesh, int frame, - Evas_3D_Vertex_Attrib attrib) +EOLIAN static int +_eo_evas_3d_mesh_frame_vertex_stride_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, int frame, Evas_3D_Vertex_Attrib attrib) { - Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find((Evas_3D_Mesh *)mesh, frame); + Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, frame); if (f == NULL) { @@ -581,24 +586,23 @@ evas_3d_mesh_frame_vertex_stride_get(const Evas_3D_Mesh *mesh, int frame, return f->vertices[attrib].stride; } -EAPI void -evas_3d_mesh_index_data_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, - const void *indices) +EOLIAN static void +_eo_evas_3d_mesh_index_data_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Index_Format format, int count, const void *indices) { - if (mesh->owns_indices && mesh->indices) - free(mesh->indices); + if (pd->owns_indices && pd->indices) + free(pd->indices); - mesh->index_format = format; - mesh->index_count = count; - mesh->index_size = 0; - mesh->indices = (void *)indices; - mesh->owns_indices = EINA_FALSE; + pd->index_format = format; + pd->index_count = count; + pd->index_size = 0; + pd->indices = (void *)indices; + pd->owns_indices = EINA_FALSE; - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_INDEX_DATA, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_INDEX_DATA, NULL); } -EAPI void -evas_3d_mesh_index_data_copy_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format, int count, const void *indices) +EOLIAN static void +_eo_evas_3d_mesh_index_data_copy_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Index_Format format, int count, const void *indices) { int size; @@ -616,86 +620,85 @@ evas_3d_mesh_index_data_copy_set(Evas_3D_Mesh *mesh, Evas_3D_Index_Format format return; } - if (!mesh->owns_indices || mesh->index_size < size) + if (!pd->owns_indices || pd->index_size < size) { - if (mesh->owns_indices && mesh->indices) - free(mesh->indices); + if (pd->owns_indices && pd->indices) + free(pd->indices); - mesh->indices = malloc(size); + pd->indices = malloc(size); - if (mesh->indices == NULL) + if (pd->indices == NULL) { ERR("Failed to allocate memory."); return; } - mesh->index_size = size; - mesh->owns_indices = EINA_TRUE; + pd->index_size = size; + pd->owns_indices = EINA_TRUE; } - mesh->index_format = format; - mesh->index_count = count; + pd->index_format = format; + pd->index_count = count; if (indices) - memcpy(mesh->indices, indices, size); + memcpy(pd->indices, indices, size); } -EAPI Evas_3D_Index_Format -evas_3d_mesh_index_format_get(const Evas_3D_Mesh *mesh) +EOLIAN static Evas_3D_Index_Format +_eo_evas_3d_mesh_index_format_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - return mesh->index_format; + return pd->index_format; } -EAPI int -evas_3d_mesh_index_count_get(const Evas_3D_Mesh *mesh) +EOLIAN static int +_eo_evas_3d_mesh_index_count_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - return mesh->index_count; + return pd->index_count; } -EAPI void * -evas_3d_mesh_index_data_map(Evas_3D_Mesh *mesh) +EOLIAN static void * +_eo_evas_3d_mesh_index_data_map(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - if (mesh->index_mapped) + if (pd->index_mapped) { ERR("Try to map alreadly mapped data."); return NULL; } - mesh->index_mapped = EINA_TRUE; - return mesh->indices; + pd->index_mapped = EINA_TRUE; + return pd->indices; } -EAPI void -evas_3d_mesh_index_data_unmap(Evas_3D_Mesh *mesh) +EOLIAN static void +_eo_evas_3d_mesh_index_data_unmap(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - if (!mesh->index_mapped) + if (!pd->index_mapped) { ERR("Try to unmap data which is not mapped yet."); return; } - mesh->index_mapped = EINA_FALSE; + pd->index_mapped = EINA_FALSE; } -EAPI void -evas_3d_mesh_vertex_assembly_set(Evas_3D_Mesh *mesh, Evas_3D_Vertex_Assembly assembly) +EOLIAN static void +_eo_evas_3d_mesh_vertex_assembly_set(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, Evas_3D_Vertex_Assembly assembly) { - mesh->assembly = assembly; - evas_3d_object_change(&mesh->base, EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY, NULL); + pd->assembly = assembly; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY, NULL); } -EAPI Evas_3D_Vertex_Assembly -evas_3d_mesh_vertex_assembly_get(const Evas_3D_Mesh *mesh) +EOLIAN static Evas_3D_Vertex_Assembly +_eo_evas_3d_mesh_vertex_assembly_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) { - return mesh->assembly; + return pd->assembly; } -EAPI void -evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type, - const char *file, const char *key EINA_UNUSED) +EOLIAN static void +_eo_evas_3d_mesh_file_set(Eo *obj, Evas_3D_Mesh_Data *pd, Evas_3D_Mesh_File_Type type, const char *file, const char *key EINA_UNUSED) { - _mesh_fini(mesh); - _mesh_init(mesh); + _mesh_fini(pd); + _mesh_init(pd); if (file == NULL) return; @@ -703,7 +706,7 @@ evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type, switch (type) { case EVAS_3D_MESH_FILE_TYPE_MD2: - evas_3d_mesh_file_md2_set(mesh, file); + evas_3d_mesh_file_md2_set(obj, file); break; default: ERR("Invalid mesh file type."); @@ -712,7 +715,7 @@ evas_3d_mesh_file_set(Evas_3D_Mesh *mesh, Evas_3D_Mesh_File_Type type, } static inline void -_mesh_frame_find(Evas_3D_Mesh *mesh, int frame, +_mesh_frame_find(Evas_3D_Mesh_Data *mesh, int frame, Eina_List **l, Eina_List **r) { Eina_List *left, *right; @@ -760,8 +763,8 @@ evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame, { Eina_List *l, *r; const Evas_3D_Mesh_Frame *f0 = NULL, *f1 = NULL; - - _mesh_frame_find(mesh, frame, &l, &r); + Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, MY_CLASS); + _mesh_frame_find(pd, frame, &l, &r); while (l) { @@ -826,3 +829,5 @@ evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame, *weight = 1.0; } } + +#include "canvas/evas_3d_mesh.eo.c" diff --git a/src/lib/evas/canvas/evas_3d_mesh.eo b/src/lib/evas/canvas/evas_3d_mesh.eo new file mode 100755 index 0000000..77a772c --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_mesh.eo @@ -0,0 +1,388 @@ +class EO_Evas_3D_Mesh (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_mesh; + data: Evas_3D_Mesh_Data; + + methods { + file_set { + /** + * Load mesh data from file. + * + * Loading a mesh from existing file is supported. Currently, only MD2 file + * format is supported. + * + * @ingroup Evas_3D_Mesh + */ + params { + @in Evas_3D_Mesh_File_Type type; /*@ The type of the mesh file. */ + @in const char *file; /*@ Path to the mesh file. */ + @in const char *key; /*@ Key in the mesh file. */ + } + } + + frame_vertex_data_set { + /*@ + Set the vertex data of the key frame of the given mesh. + + This function make evas read from the given buffer whenever it requires. + If you want to release the buffer after calling this functions, use + evas_3d_mesh_frame_vertex_data_copy_set() instead. + + After setting the vertex data, further modifications should be protected + by map/unmap pair. + + @see evas_3d_mesh_frame_vertex_data_copy_set() + @see evas_3d_mesh_frame_vertex_data_map() + @see evas_3d_mesh_frame_vertex_data_unmap() + + @ingroup Evas_3D_Mesh + */ + params { + @in int frame; /*@ The number of the key frame. */ + @in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */ + @in int stride; /*@ Stride to go to the next vertex (in bytes). */ + @in const void *data; /*@ Pointer to the vertex data buffer. */ + } + } + + frame_vertex_data_copy_set { + /*@ + Set the vertex data of the key frame of the given mesh by copying from a buffer. + This function allocates internal vertex buffer and copy from the given + buffer. So you can release the buffer. If you want to modify the vertex data + use evas_3d_mesh_frame_vertex_data_map(). After finishing the modifications, + you should call evas_3d_mesh_frame_vertex_data_unmap(). + + @see evas_3d_mesh_frame_vertex_data_set() + @see evas_3d_mesh_frame_vertex_data_map() + @see evas_3d_mesh_frame_vertex_data_unmap() + + @ingroup Evas_3D_Mesh + */ + params { + @in int frame; /*@ The number of the key frame. */ + @in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */ + @in int stride; /*@ Stride to go to the next vertex (in bytes). */ + @in const void *data; /*@ Pointer to the vertex data buffer. */ + } + } + + frame_vertex_data_map { + /*@ + Map the vertex buffer of the key frame of the given mesh. + + After manipulating the mapped buffer, evas_3d_mesh_frame_vertex_data_unmap() + should be called to properly download the data to the engine. If the data + was set using evas_3d_mesh_frame_vertex_data_set(), pointer to the original + buffer will be returned. Otherwise, the returned pointer can differ every + time calling this function. + + @see evas_3d_mesh_frame_vertex_data_unmap() + @return Starting address of the mapped vertex buffer. + + @ingroup Evas_3D_Mesh + */ + + return void *; + params { + @in int frame; /*@ The number of the key frame. */ + @in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */ + } + } + + frame_vertex_data_unmap { + /* + Unmap the vertex buffer of the key frame of the given mesh. + + @see evas_3d_mesh_frame_vertex_data_map() + + @ingroup Evas_3D_Mesh + */ + + params { + @in int frame; /*@ The number of the key frame. */ + @in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */ + } + } + + frame_vertex_stride_get { + /* + Get the vertex buffer stride of the key frame of the given mesh. + + This function returns valid stride only when the vertex buffer is mapped. + If the data was set with evas_3d_mesh_frame_vertex_data_set(), the original + stride will be returned unchanged. + + @see evas_3d_mesh_frame_vertex_data_map() + + @return Stride to go to the next vertex (in bytes). + + @ingroup Evas_3D_Mesh + */ + const; + return int ; + params { + @in int frame; /*@ The number of the key frame. */ + @in Evas_3D_Vertex_Attrib attrib; /*@ Vertex attribute ID. */ + } + } + + index_data_set { + /* + Set the vertex index data of the given mesh. + + When the index data is set, Evas 3D assembles vertices using the index data. + If you want to free the data buffer, use evas_3d_mesh_index_data_copy_set(). + Further modifications should be made within map/unmap pair. + + @see evas_3d_mesh_index_data_copy_set() + @see evas_3d_mesh_index_data_map() + @see evas_3d_mesh_index_data_unmap() + + @ingroup Evas_3D_Mesh + */ + params { + @in Evas_3D_Index_Format format; /*@ Vertex index data format. */ + @in int count; /*@ Vertex index count. */ + @in const void *indices; /*@ Pointer to the index data. */ + } + } + + + index_data_copy_set { + /* + Set the vertex index data of the given mesh by copying from a buffer. + + This function allocates internal index buffer any copy data from the given + buffer. Futher modifications can be made within map/unmap pair. + + @see evas_3d_mesh_index_data_set() + + @ingroup Evas_3D_Mesh + */ + return void ; + params { + @in Evas_3D_Index_Format format; /*@ Vertex index data format. */ + @in int count; /*@ Vertex index count. */ + @in const void *indices; /*@ Pointer to the index data. */ + } + } + + index_format_get { + /* + Get the format of the index data of the given mesh. + + + Returns valid format only when the index buffer is mapped. First map the + index buffer and then query the properties of the mapped buffer. If the index + data was set by evas_3d_mesh_index_data_set(), the original format will be + returned. Otherwise the format can differ every time you call the + evas_3d_mesh_index_data_map() function. + + @see evas_3d_mesh_index_data_map() + + @return Format of the index data. + + @ingroup Evas_3D_Mesh + */ + const; + return Evas_3D_Index_Format ; + } + + index_count_get { + /* + Get the count of the index data of the given mesh. + + This function returns the index count of the last called data_set function. + + @see evas_3d_mesh_index_data_set() + @see evas_3d_mesh_index_data_copy_set() + + @return Index data count. + + @ingroup Evas_3D_Mesh + */ + const; + return int ; + } + + index_data_map { + /* + Map the index buffer of the given mesh. + + evas_3d_mesh_index_data_unmap() should be called after modifications. If the + data was set using evas_3d_mesh_index_data_set(), the original pointer will + be returned, otherwise, the returned pointer may differ every time you call + this function. + + @see evas_3d_mesh_index_data_unmap() + + @return Pointer to the mapped buffer. + + @ingroup Evas_3D_Mesh + */ + return void * ; + } + + index_data_unmap { + /* + Unmap the index buffer of the given mesh. + + @see evas_3d_mesh_index_data_map() + + @ingroup Evas_3D_Mesh + */ + } + + frame_add { + /* + Add a key frame to the given mesh. + + @param mesh The given mesh. + @param frame The number of the key frame to be added. + + If specified frame is already exist, error message will be generated. + + @ingroup Evas_3D_Mesh + */ + params { + @in int frame; /*@ The number of the key frame to be added. */ + } + } + + frame_del { + /* + Delete a key frame from the given mesh. + + @param mesh The given mesh. + @param frame The number of the key frame to be deleted. + + @see evas_3d_mesh_frame_add() + + @ingroup Evas_3D_Mesh + */ + params { + @in int frame; /*@ The number of the key frame to be added. */ + } + } + + vertex_count_set { + /*@ + Set the vertex count of the given mesh. + + Each key frame should have same vertex count to be properly interpolated. + Key frames have their own vertex data and the data should have more vertices + than the mesh's vertex count. + + Default vertex count is 0. + + @ingroup Evas_3D_Mesh + */ + params { + @in unsigned int count; /*@ Vertex count.*/ + } + } + + vertex_count_get { + /*@ + Get the vertex count of the given mesh. + + @see evas_3d_mesh_vertex_count_set() + + @ingroup Evas_3D_Mesh + */ + const; + return int; + } + + } + properties { + shade_mode { + set { + /** + * Set the shade mode of the given mesh. + * + * Default shade mode is EVAS_3D_SHADE_MODE_VERTEX_COLOR. + * + * @ingroup Evas_3D_Mesh + */ + } + get { + /** + * Get the shade mode of the given mesh. + * + * @see eavs_3d_mesh_shade_mode_set() + * + * @ingroup Evas_3D_Mesh + */ + } + values { + Evas_3D_Shade_Mode mode; /*@ The shade mode.*/ + } + } + + frame_material { + set { + /** + Set the material of the key frame of the given mesh. + + Setting different materials for each key frame is useful for doing animations + like GIF images or color changing animationas. + + @ingroup Evas_3D_Mesh + */ + } + get { + /** + Get the material of the key frame of the given mesh. + + @see evas_3d_mesh_frame_material_set() + + @ingroup Evas_3D_Mesh + */ + } + keys { + int frame; /*@ The number of the key frame.*/ + } + values { + Evas_3D_Material *material; /*@ The material to be set to the key frame.*/ + } + } + + vertex_assembly { + set { + /* + Set the vertex assembly of the given mesh. + + Vertex assembly defines how the engine organizes vertices into geometric + primitives. + + Default vertex assembly is EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES. + + @ingroup Evas_3D_Mesh + */ + } + get { + /* + Get the vertex assembly of the given mesh. + + @see evas_3d_mesh_vertex_assembly_set() + + @return The vertex assembly. + + @ingroup Evas_3D_Mesh + */ + } + values { + Evas_3D_Vertex_Assembly assembly; /*@ Vertex assembly.*/ + } + } + + } + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } + +} diff --git a/src/lib/evas/canvas/evas_3d_node.c b/src/lib/evas/canvas/evas_3d_node.c index 90843ae..117c3d4 100644 --- a/src/lib/evas/canvas/evas_3d_node.c +++ b/src/lib/evas/canvas/evas_3d_node.c @@ -6,6 +6,11 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_NODE_CLASS +#define MY_CLASS_NAME "Evas_3D_Node" + static inline Evas_3D_Node_Mesh * _node_mesh_new(Evas_3D_Node *node, Evas_3D_Mesh *mesh) { @@ -41,7 +46,8 @@ _node_scene_root_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *ke void *data EINA_UNUSED, void *fdata) { Evas_3D_Scene *s = *(Evas_3D_Scene **)key; - evas_3d_object_change(&s->base, EVAS_3D_STATE_SCENE_ROOT_NODE, (Evas_3D_Object *)fdata); + Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(s, EO_EVAS_3D_SCENE_CLASS); + evas_3d_object_change(&pd_scene->base, EVAS_3D_STATE_SCENE_ROOT_NODE, (Evas_3D_Object *)fdata); return EINA_TRUE; } @@ -50,108 +56,115 @@ _node_scene_camera_change_notify(const Eina_Hash *hash EINA_UNUSED, const void * void *data EINA_UNUSED, void *fdata) { Evas_3D_Scene *s = *(Evas_3D_Scene **)key; - evas_3d_object_change(&s->base, EVAS_3D_STATE_SCENE_CAMERA_NODE, (Evas_3D_Object *)fdata); + Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(s, EO_EVAS_3D_SCENE_CLASS); + evas_3d_object_change(&pd_scene->base, EVAS_3D_STATE_SCENE_CAMERA_NODE, (Evas_3D_Object *)fdata); return EINA_TRUE; } static void _node_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Node *node = (Evas_3D_Node *)obj; + Evas_3D_Node_Data *pd = (Evas_3D_Node_Data *)obj; Eina_List *l; Evas_3D_Node *n; /* Notify all scenes using this node that it has changed. */ - if (node->scenes_root) - eina_hash_foreach(node->scenes_root, _node_scene_root_change_notify, obj); + if (pd->scenes_root) + eina_hash_foreach(pd->scenes_root, _node_scene_root_change_notify, obj); - if (node->scenes_camera) - eina_hash_foreach(node->scenes_camera, _node_scene_camera_change_notify, obj); + if (pd->scenes_camera) + eina_hash_foreach(pd->scenes_camera, _node_scene_camera_change_notify, obj); /* Notify parent that a member has changed. */ - if (node->parent) - evas_3d_object_change(&node->parent->base, EVAS_3D_STATE_NODE_MEMBER, obj); + if (pd->parent) + { + Evas_3D_Node_Data *pdparent = eo_data_scope_get(pd->parent, MY_CLASS); + evas_3d_object_change(&pdparent->base, EVAS_3D_STATE_NODE_MEMBER, obj); + } /* Notify members that the parent has changed. */ - EINA_LIST_FOREACH(node->members, l, n) + EINA_LIST_FOREACH(pd->members, l, n) { - evas_3d_object_change(&n->base, EVAS_3D_STATE_NODE_PARENT, obj); + Evas_3D_Node_Data *pdmember = eo_data_scope_get(n, MY_CLASS); + evas_3d_object_change(&pdmember->base, EVAS_3D_STATE_NODE_PARENT, obj); } } static Eina_Bool _node_transform_update(Evas_3D_Node *node, void *data EINA_UNUSED) { - if (evas_3d_object_dirty_get(&node->base, EVAS_3D_STATE_NODE_TRANSFORM) || - evas_3d_object_dirty_get(&node->base, EVAS_3D_STATE_NODE_PARENT)) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); + if (evas_3d_object_dirty_get(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM) || + evas_3d_object_dirty_get(&pd->base, EVAS_3D_STATE_NODE_PARENT)) { - if (node->parent) + if (pd->parent) { - const Evas_Vec3 *scale_parent = &node->parent->scale_world; - const Evas_Vec4 *orientation_parent = &node->parent->orientation_world; + Evas_3D_Node_Data *pdparent = eo_data_scope_get(pd->parent, MY_CLASS); + const Evas_Vec3 *scale_parent = &pdparent->scale_world; + const Evas_Vec4 *orientation_parent = &pdparent->orientation_world; /* Orienatation */ - if (node->orientation_inherit) + if (pd->orientation_inherit) { - evas_vec4_quaternion_multiply(&node->orientation_world, - orientation_parent, &node->orientation); + evas_vec4_quaternion_multiply(&pd->orientation_world, + orientation_parent, &pd->orientation); } else { - node->orientation_world = node->orientation; + pd->orientation_world = pd->orientation; } /* Scale */ - if (node->scale_inherit) - evas_vec3_multiply(&node->scale_world, scale_parent, &node->scale); + if (pd->scale_inherit) + evas_vec3_multiply(&pd->scale_world, scale_parent, &pd->scale); else - node->scale_world = node->scale; + pd->scale_world = pd->scale; /* Position */ - if (node->position_inherit) + if (pd->position_inherit) { - evas_vec3_multiply(&node->position_world, &node->position, scale_parent); - evas_vec3_quaternion_rotate(&node->position_world, &node->position_world, + evas_vec3_multiply(&pd->position_world, &pd->position, scale_parent); + evas_vec3_quaternion_rotate(&pd->position_world, &pd->position_world, orientation_parent); - evas_vec3_add(&node->position_world, &node->position_world, - &node->parent->position_world); + evas_vec3_add(&pd->position_world, &pd->position_world, + &pdparent->position_world); } else { - node->position_world = node->position; + pd->position_world = pd->position; } } else { - node->position_world = node->position; - node->orientation_world = node->orientation; - node->scale_world = node->scale; + pd->position_world = pd->position; + pd->orientation_world = pd->orientation; + pd->scale_world = pd->scale; } - if (node->type == EVAS_3D_NODE_TYPE_CAMERA) + if (pd->type == EVAS_3D_NODE_TYPE_CAMERA) { - evas_mat4_inverse_build(&node->data.camera.matrix_world_to_eye, - &node->position_world, &node->orientation_world, - &node->scale_world); + evas_mat4_inverse_build(&pd->data.camera.matrix_world_to_eye, + &pd->position_world, &pd->orientation_world, + &pd->scale_world); } - else if (node->type == EVAS_3D_NODE_TYPE_LIGHT) + else if (pd->type == EVAS_3D_NODE_TYPE_LIGHT) { } - else if (node->type == EVAS_3D_NODE_TYPE_MESH) + else if (pd->type == EVAS_3D_NODE_TYPE_MESH) { - evas_mat4_build(&node->data.mesh.matrix_local_to_world, - &node->position_world, &node->orientation_world, &node->scale_world); + evas_mat4_build(&pd->data.mesh.matrix_local_to_world, + &pd->position_world, &pd->orientation_world, &pd->scale_world); } /* - if (node->parent) + if (pd->parent) { - evas_mat4_nocheck_multiply(&node->matrix_local_to_world, - &node->parent->matrix_local_to_world, - &node->matrix_local_to_parent); + evas_mat4_nocheck_multiply(&pd->matrix_local_to_world, + &pd->parent->matrix_local_to_world, + &pd->matrix_local_to_parent); } else { - evas_mat4_copy(&node->matrix_local_to_world, &node->matrix_local_to_parent); + evas_mat4_copy(&pd->matrix_local_to_world, &pd->matrix_local_to_parent); }*/ } @@ -161,24 +174,31 @@ _node_transform_update(Evas_3D_Node *node, void *data EINA_UNUSED) static Eina_Bool _node_item_update(Evas_3D_Node *node, void *data EINA_UNUSED) { - if (node->type == EVAS_3D_NODE_TYPE_CAMERA) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS); + if (pd->type == EVAS_3D_NODE_TYPE_CAMERA) { - if (node->data.camera.camera) - evas_3d_object_update(&node->data.camera.camera->base); + if (pd->data.camera.camera) + { + Evas_3D_Camera_Data *pdcam = eo_data_scope_get(pd->data.camera.camera, EO_EVAS_3D_CAMERA_CLASS); + evas_3d_object_update(&pdcam->base); + } } - else if (node->type == EVAS_3D_NODE_TYPE_LIGHT) + else if (pd->type == EVAS_3D_NODE_TYPE_LIGHT) { - if (node->data.light.light) - evas_3d_object_update(&node->data.light.light->base); + if (pd->data.light.light) + { + Evas_3D_Light_Data *pdlt = eo_data_scope_get(pd->data.light.light, EO_EVAS_3D_LIGHT_CLASS); + evas_3d_object_update(&pdlt->base); + } } - else if (node->type == EVAS_3D_NODE_TYPE_MESH) + else if (pd->type == EVAS_3D_NODE_TYPE_MESH) { Eina_List *l; Evas_3D_Mesh *m; - - EINA_LIST_FOREACH(node->data.mesh.meshes, l, m) + EINA_LIST_FOREACH(pd->data.mesh.meshes, l, m) { - evas_3d_object_update(&m->base); + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(m, EO_EVAS_3D_MESH_CLASS); + evas_3d_object_update(&pdmesh->base); } } @@ -188,23 +208,25 @@ _node_item_update(Evas_3D_Node *node, void *data EINA_UNUSED) static Eina_Bool _node_aabb_update(Evas_3D_Node *node, void *data EINA_UNUSED) { - if (evas_3d_object_dirty_get(&node->base, EVAS_3D_STATE_NODE_TRANSFORM) || - evas_3d_object_dirty_get(&node->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY) || - evas_3d_object_dirty_get(&node->base, EVAS_3D_STATE_NODE_MESH_FRAME) || - evas_3d_object_dirty_get(&node->base, EVAS_3D_STATE_NODE_MEMBER)) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS); + if (evas_3d_object_dirty_get(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM) || + evas_3d_object_dirty_get(&pd->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY) || + evas_3d_object_dirty_get(&pd->base, EVAS_3D_STATE_NODE_MESH_FRAME) || + evas_3d_object_dirty_get(&pd->base, EVAS_3D_STATE_NODE_MEMBER)) { Eina_List *l; Evas_3D_Node *n; /* Update AABB of this node. */ - evas_box3_empty_set(&node->aabb); + evas_box3_empty_set(&pd->aabb); - EINA_LIST_FOREACH(node->members, l, n) + EINA_LIST_FOREACH(pd->members, l, n) { - evas_box3_union(&node->aabb, &node->aabb, &n->aabb); + Evas_3D_Node_Data *pdmember = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_box3_union(&pd->aabb, &pd->aabb, &pdmember->aabb); } - if (node->type == EVAS_3D_NODE_TYPE_MESH) + if (pd->type == EVAS_3D_NODE_TYPE_MESH) { /* TODO: */ } @@ -216,74 +238,77 @@ _node_aabb_update(Evas_3D_Node *node, void *data EINA_UNUSED) static Eina_Bool _node_update_done(Evas_3D_Node *node, void *data EINA_UNUSED) { - evas_3d_object_update_done(&node->base); + Evas_3D_Node_Data *pd = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_update_done(&pd->base); return EINA_TRUE; } static void _node_update(Evas_3D_Object *obj) { - Evas_3D_Node *node = (Evas_3D_Node *)obj; + Evas_3D_Node_Data *pd = (Evas_3D_Node_Data *)obj; /* Update transform. */ - evas_3d_node_tree_traverse(node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_FALSE, + evas_3d_node_tree_traverse(pd->hack_this, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_FALSE, _node_transform_update, NULL); /* Update AABB. */ - evas_3d_node_tree_traverse(node, EVAS_3D_TREE_TRAVERSE_POST_ORDER, EINA_FALSE, + evas_3d_node_tree_traverse(pd->hack_this, EVAS_3D_TREE_TRAVERSE_POST_ORDER, EINA_FALSE, _node_aabb_update, NULL); /* Update node item. */ - evas_3d_node_tree_traverse(node, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, + evas_3d_node_tree_traverse(pd->hack_this, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, _node_item_update, NULL); /* Mark all nodes in the tree as up-to-date. */ - evas_3d_node_tree_traverse(node, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, + evas_3d_node_tree_traverse(pd->hack_this, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, _node_update_done, NULL); } static void _node_free(Evas_3D_Object *obj) { - Evas_3D_Node *node = (Evas_3D_Node *)obj; + Evas_3D_Node_Data *pd = (Evas_3D_Node_Data *)obj; - if (node->members) + if (pd->members) { Eina_List *l; Evas_3D_Node *n; - EINA_LIST_FOREACH(node->members, l, n) + EINA_LIST_FOREACH(pd->members, l, n) { - evas_3d_object_unreference(&n->base); + Evas_3D_Node_Data *pdmember = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_unreference(&pdmember->base); } - eina_list_free(node->members); + eina_list_free(pd->members); } - if (node->data.mesh.meshes) + if (pd->data.mesh.meshes) { Eina_List *l; Evas_3D_Mesh *m; - EINA_LIST_FOREACH(node->data.mesh.meshes, l, m) + EINA_LIST_FOREACH(pd->data.mesh.meshes, l, m) { - evas_3d_mesh_node_del(m, node); - evas_3d_object_unreference(&m->base); + //evas_3d_mesh_node_del(m, node); + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(m, EO_EVAS_3D_MESH_CLASS); + evas_3d_object_unreference(&pdmesh->base); } - eina_list_free(node->data.mesh.meshes); + eina_list_free(pd->data.mesh.meshes); } - if (node->data.mesh.node_meshes) - eina_hash_free(node->data.mesh.node_meshes); + if (pd->data.mesh.node_meshes) + eina_hash_free(pd->data.mesh.node_meshes); - if (node->scenes_root) - eina_hash_free(node->scenes_root); + if (pd->scenes_root) + eina_hash_free(pd->scenes_root); - if (node->scenes_camera) - eina_hash_free(node->scenes_camera); + if (pd->scenes_camera) + eina_hash_free(pd->scenes_camera); - free(node); + //free(node); } static const Evas_3D_Object_Func node_func = @@ -297,126 +322,80 @@ void evas_3d_node_scene_root_add(Evas_3D_Node *node, Evas_3D_Scene *scene) { int count = 0; - - if (node->scenes_root == NULL) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); + if (pd->scenes_root == NULL) { - node->scenes_root = eina_hash_pointer_new(NULL); + pd->scenes_root = eina_hash_pointer_new(NULL); - if (node->scenes_root == NULL) + if (pd->scenes_root == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(node->scenes_root, &scene); + count = (int)eina_hash_find(pd->scenes_root, &scene); - eina_hash_set(node->scenes_root, &scene, (const void *)(count + 1)); + eina_hash_set(pd->scenes_root, &scene, (const void *)(count + 1)); } void evas_3d_node_scene_root_del(Evas_3D_Node *node, Evas_3D_Scene *scene) { int count = 0; - - if (node->scenes_root == NULL) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); + if (pd->scenes_root == NULL) { ERR("No scene to delete."); return; } - count = (int)eina_hash_find(node->scenes_root, &scene); + count = (int)eina_hash_find(pd->scenes_root, &scene); if (count == 1) - eina_hash_del(node->scenes_root, &scene, NULL); + eina_hash_del(pd->scenes_root, &scene, NULL); else - eina_hash_set(node->scenes_root, &scene, (const void *)(count - 1)); + eina_hash_set(pd->scenes_root, &scene, (const void *)(count - 1)); } void evas_3d_node_scene_camera_add(Evas_3D_Node *node, Evas_3D_Scene *scene) { int count = 0; - - if (node->scenes_camera == NULL) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); + if (pd->scenes_camera == NULL) { - node->scenes_camera = eina_hash_pointer_new(NULL); + pd->scenes_camera = eina_hash_pointer_new(NULL); - if (node->scenes_camera == NULL) + if (pd->scenes_camera == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(node->scenes_camera, &scene); + count = (int)eina_hash_find(pd->scenes_camera, &scene); - eina_hash_set(node->scenes_camera, &scene, (const void *)(count + 1)); + eina_hash_set(pd->scenes_camera, &scene, (const void *)(count + 1)); } void evas_3d_node_scene_camera_del(Evas_3D_Node *node, Evas_3D_Scene *scene) { int count = 0; - - if (node->scenes_camera == NULL) + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); + if (pd->scenes_camera == NULL) { ERR("No scene to delete."); return; } - count = (int)eina_hash_find(node->scenes_camera, &scene); + count = (int)eina_hash_find(pd->scenes_camera, &scene); if (count == 1) - eina_hash_del(node->scenes_camera, &scene, NULL); + eina_hash_del(pd->scenes_camera, &scene, NULL); else - eina_hash_set(node->scenes_camera, &scene, (const void *)(count - 1)); -} - -Evas_3D_Node * -evas_3d_node_new(Evas *e, Evas_3D_Node_Type type) -{ - Evas_3D_Node *node = NULL; - - node = (Evas_3D_Node *)calloc(1, sizeof(Evas_3D_Node)); - - if (node == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } - - evas_3d_object_init(&node->base, e, EVAS_3D_OBJECT_TYPE_NODE, &node_func); - - evas_vec3_set(&node->position, 0.0, 0.0, 0.0); - evas_vec4_set(&node->orientation, 0.0, 0.0, 0.0, 0.0); - evas_vec3_set(&node->scale, 1.0, 1.0, 1.0); - - evas_vec3_set(&node->position_world, 0.0, 0.0, 0.0); - evas_vec4_set(&node->orientation_world, 0.0, 0.0, 0.0, 1.0); - evas_vec3_set(&node->scale_world, 1.0, 1.0, 1.0); - - node->position_inherit = EINA_TRUE; - node->orientation_inherit = EINA_TRUE; - node->scale_inherit = EINA_TRUE; - - evas_box3_set(&node->aabb, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - - node->type = type; - - if (type == EVAS_3D_NODE_TYPE_MESH) - { - node->data.mesh.node_meshes = eina_hash_pointer_new(_node_mesh_free_func); - - if (node->data.mesh.node_meshes == NULL) - { - ERR("Failed to create node mesh table."); - _node_free(&node->base); - return NULL; - } - } - - return node; + eina_hash_set(pd->scenes_camera, &scene, (const void *)(count - 1)); } void @@ -441,8 +420,8 @@ evas_3d_node_traverse(Evas_3D_Node *from, Evas_3D_Node *to, Evas_3D_Node_Travers if (node == from) break; - - node = node->parent; + Evas_3D_Node_Data *pdnode = eo_data_scope_get(node, MY_CLASS); + node = pdnode->parent; if (node == NULL) goto error; @@ -457,8 +436,8 @@ evas_3d_node_traverse(Evas_3D_Node *from, Evas_3D_Node *to, Evas_3D_Node_Travers if (node == to) break; - - node = node->parent; + Evas_3D_Node_Data *pdnode = eo_data_scope_get(node, MY_CLASS); + node = pdnode->parent; if (node == NULL) { @@ -505,13 +484,15 @@ evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, { /* Dequeue a node. */ node = eina_list_data_get(nodes); + Evas_3D_Node_Data *pdnode = eo_data_scope_get(node, MY_CLASS); + nodes = eina_list_remove_list(nodes, nodes); /* Call node function on the node. */ if (func(node, data) || !skip) { /* Enqueue member nodes. */ - EINA_LIST_FOREACH(node->members, l, n) + EINA_LIST_FOREACH(pdnode->members, l, n) { nodes = eina_list_append(nodes, n); } @@ -527,13 +508,14 @@ evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, { /* Pop a node from the stack. */ node = eina_list_data_get(nodes); + Evas_3D_Node_Data *pdnode = eo_data_scope_get(node, MY_CLASS); nodes = eina_list_remove_list(nodes, nodes); /* Call node function on the node. */ if (func(node, data) || !skip) { /* Push member nodes into the stack. */ - EINA_LIST_REVERSE_FOREACH(node->members, l, n) + EINA_LIST_REVERSE_FOREACH(pdnode->members, l, n) { nodes = eina_list_prepend(nodes, n); } @@ -556,8 +538,8 @@ evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, { /* Peek a node from the stack. */ node = eina_list_data_get(nodes); - - if (eina_list_count(node->members) == 0) + Evas_3D_Node_Data *pdnode = eo_data_scope_get(node, MY_CLASS); + if (eina_list_count(pdnode->members) == 0) { /* The peeked node is a leaf node, * so visit it and pop from the stack. */ @@ -581,8 +563,10 @@ evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, * * Otherwise it should be a sibling of the peeked node, so we have to push * its childs into the stack. */ - - if (last && last->parent == node) + Evas_3D_Node_Data *pdlast; + if (last ) + pdlast= eo_data_scope_get(last, MY_CLASS); + if (last && pdlast->parent == node) { /* Visit the node as it doesn't have any unvisited child node. */ func(node, data); @@ -594,7 +578,7 @@ evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, else { /* Push child nodes into the stack. */ - EINA_LIST_REVERSE_FOREACH(node->members, l, n) + EINA_LIST_REVERSE_FOREACH(pdnode->members, l, n) { nodes = eina_list_prepend(nodes, n); } @@ -617,15 +601,15 @@ _node_is_visible(Evas_3D_Node *node EINA_UNUSED, Evas_3D_Node *camera_node EINA_ Eina_Bool evas_3d_node_mesh_collect(Evas_3D_Node *node, void *data) { - Evas_3D_Scene_Data *scene_data = (Evas_3D_Scene_Data *)data; - + Evas_3D_Scene_Public_Data *scene_data = (Evas_3D_Scene_Public_Data *)data; + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); if (!_node_is_visible(node, scene_data->camera_node)) { /* Skip entire sub-tree of this node. */ return EINA_FALSE; } - if (node->type == EVAS_3D_NODE_TYPE_MESH) + if (pd->type == EVAS_3D_NODE_TYPE_MESH) scene_data->mesh_nodes = eina_list_append(scene_data->mesh_nodes, node); return EINA_TRUE; @@ -634,9 +618,9 @@ evas_3d_node_mesh_collect(Evas_3D_Node *node, void *data) Eina_Bool evas_3d_node_light_collect(Evas_3D_Node *node, void *data) { - Evas_3D_Scene_Data *scene_data = (Evas_3D_Scene_Data *)data; - - if (node->type == EVAS_3D_NODE_TYPE_LIGHT) + Evas_3D_Scene_Public_Data *scene_data = (Evas_3D_Scene_Public_Data *)data; + Evas_3D_Node_Data *pd = eo_data_scope_get(node, MY_CLASS); + if (pd->type == EVAS_3D_NODE_TYPE_LIGHT) scene_data->light_nodes = eina_list_append(scene_data->light_nodes, node); return EINA_TRUE; @@ -645,118 +629,170 @@ evas_3d_node_light_collect(Evas_3D_Node *node, void *data) EAPI Evas_3D_Node * evas_3d_node_add(Evas *e, Evas_3D_Node_Type type) { - return evas_3d_node_new(e, type); + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add_custom(MY_CLASS, e, eo_evas_3d_node_constructor(type)); + eo_unref(eo_obj); + return eo_obj; } -EAPI void -evas_3d_node_del(Evas_3D_Node *node) +EOLIAN static void +_eo_evas_3d_node_constructor(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Node_Type type) { - evas_3d_object_unreference(&node->base); + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_NODE, &node_func); + + evas_vec3_set(&pd->position, 0.0, 0.0, 0.0); + evas_vec4_set(&pd->orientation, 0.0, 0.0, 0.0, 0.0); + evas_vec3_set(&pd->scale, 1.0, 1.0, 1.0); + + evas_vec3_set(&pd->position_world, 0.0, 0.0, 0.0); + evas_vec4_set(&pd->orientation_world, 0.0, 0.0, 0.0, 1.0); + evas_vec3_set(&pd->scale_world, 1.0, 1.0, 1.0); + + pd->position_inherit = EINA_TRUE; + pd->orientation_inherit = EINA_TRUE; + pd->scale_inherit = EINA_TRUE; + pd->data.mesh.node_meshes = 0; + pd->hack_this = obj; + + evas_box3_set(&pd->aabb, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + + pd->type = type; + + if (type == EVAS_3D_NODE_TYPE_MESH) + { + pd->data.mesh.node_meshes = eina_hash_pointer_new(_node_mesh_free_func); + if (pd->data.mesh.node_meshes == NULL) + { + ERR("Failed to create node mesh table."); + _node_free(&pd->base); + } + } +} + +EOLIAN static void +_eo_evas_3d_node_eo_base_constructor(Eo *obj, Evas_3D_Node_Data *pd EINA_UNUSED) +{ + eo_error_set(obj); + ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); } -EAPI Evas_3D_Node_Type -evas_3d_node_type_get(const Evas_3D_Node *node) +EOLIAN static void +_eo_evas_3d_node_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->type; + evas_3d_object_unreference(&pd->base); } -EAPI Evas * -evas_3d_node_evas_get(const Evas_3D_Node *node) +EOLIAN static Evas_3D_Node_Type +_eo_evas_3d_node_type_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->base.evas; + return pd->type; } -EAPI void -evas_3d_node_member_add(Evas_3D_Node *node, Evas_3D_Node *member) +EOLIAN static Evas * +_eo_evas_3d_node_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - if (node == member) + return pd->base.evas; +} + +EOLIAN static void +_eo_evas_3d_node_member_add(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Node *member) +{ + if (obj == member) { ERR("Failed to add a member node (adding to itself)."); return; } - - if (member->parent == node) + Evas_3D_Node_Data *pdmember = eo_data_scope_get(member, MY_CLASS); + if (pdmember->parent == obj) return; - if (member->parent) + if (pdmember->parent) { /* Detaching from previous parent. */ - member->parent->members = eina_list_remove(member->parent->members, member); + Evas_3D_Node_Data *pdmemberparent = eo_data_scope_get(pdmember->parent, MY_CLASS); + pdmemberparent->members = eina_list_remove(pdmemberparent->members, member); /* Mark changed. */ - evas_3d_object_change(&member->parent->base, EVAS_3D_STATE_NODE_MEMBER, NULL); + evas_3d_object_change(&pdmemberparent->base, EVAS_3D_STATE_NODE_MEMBER, NULL); } else { /* Should get a new reference. */ - evas_3d_object_reference(&member->base); + evas_3d_object_reference(&pdmember->base); } /* Add the member node. */ - node->members = eina_list_append(node->members, (const void *)member); - member->parent = node; + pd->members = eina_list_append(pd->members, (const void *)member); + pdmember->parent = obj; /* Mark changed. */ - evas_3d_object_change(&member->base, EVAS_3D_STATE_NODE_PARENT, NULL); - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MEMBER, NULL); + evas_3d_object_change(&pdmember->base, EVAS_3D_STATE_NODE_PARENT, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MEMBER, NULL); } -EAPI void -evas_3d_node_member_del(Evas_3D_Node *node, Evas_3D_Node *member) +EOLIAN static void +_eo_evas_3d_node_member_del(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Node *member) { - if (member->parent != node) + Evas_3D_Node_Data *pdmember = eo_data_scope_get(member, MY_CLASS); + if (pdmember->parent != obj) { ERR("Failed to delete a member node (not a member of the given node)"); return; } /* Delete the member node. */ - node->members = eina_list_remove(node->members, member); - member->parent = NULL; + pd->members = eina_list_remove(pd->members, member); + pdmember->parent = NULL; /* Mark modified object as changed. */ - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MEMBER, NULL); - evas_3d_object_change(&member->base, EVAS_3D_STATE_NODE_PARENT, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MEMBER, NULL); + evas_3d_object_change(&pdmember->base, EVAS_3D_STATE_NODE_PARENT, NULL); /* Decrease reference count. */ - evas_3d_object_unreference(&member->base); + evas_3d_object_unreference(&pdmember->base); } -EAPI Evas_3D_Node * -evas_3d_node_parent_get(const Evas_3D_Node *node) +EOLIAN static Evas_3D_Node * +_eo_evas_3d_node_parent_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->parent; + return pd->parent; } -EAPI const Eina_List * -evas_3d_node_member_list_get(const Evas_3D_Node *node) +EOLIAN static const Eina_List * +_eo_evas_3d_node_member_list_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->members; + return pd->members; } -EAPI void -evas_3d_node_position_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) +EOLIAN static void +_eo_evas_3d_node_position_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_Real x, Evas_Real y, Evas_Real z) { - node->position.x = x; - node->position.y = y; - node->position.z = z; + pd->position.x = x; + pd->position.y = y; + pd->position.z = z; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_orientation_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z, Evas_Real w) +EOLIAN static void +_eo_evas_3d_node_orientation_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_Real x, Evas_Real y, Evas_Real z, Evas_Real w) { - node->orientation.x = x; - node->orientation.y = y; - node->orientation.z = z; - node->orientation.w = w; + pd->orientation.x = x; + pd->orientation.y = y; + pd->orientation.z = z; + pd->orientation.w = w; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_orientation_angle_axis_set(Evas_3D_Node *node, +EOLIAN static void +_eo_evas_3d_node_orientation_angle_axis_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_Real angle, Evas_Real x, Evas_Real y, Evas_Real z) { Evas_Real half_angle = 0.5 * DEGREE_TO_RADIAN(angle); @@ -766,26 +802,26 @@ evas_3d_node_orientation_angle_axis_set(Evas_3D_Node *node, evas_vec3_set(&axis, x, y, z); evas_vec3_normalize(&axis, &axis); - node->orientation.w = cos(half_angle); - node->orientation.x = s * axis.x; - node->orientation.y = s * axis.y; - node->orientation.z = s * axis.z; + pd->orientation.w = cos(half_angle); + pd->orientation.x = s * axis.x; + pd->orientation.y = s * axis.y; + pd->orientation.z = s * axis.z; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_scale_set(Evas_3D_Node *node, Evas_Real x, Evas_Real y, Evas_Real z) +EOLIAN static void +_eo_evas_3d_node_scale_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_Real x, Evas_Real y, Evas_Real z) { - node->scale.x = x; - node->scale.y = y; - node->scale.z = z; + pd->scale.x = x; + pd->scale.y = y; + pd->scale.z = z; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_position_get(const Evas_3D_Node *node, Evas_3D_Space space, +EOLIAN static void +_eo_evas_3d_node_position_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z) { if (space == EVAS_3D_SPACE_LOCAL) @@ -796,22 +832,22 @@ evas_3d_node_position_get(const Evas_3D_Node *node, Evas_3D_Space space, } else if (space == EVAS_3D_SPACE_PARENT) { - if (x) *x = node->position.x; - if (y) *y = node->position.y; - if (z) *z = node->position.z; + if (x) *x = pd->position.x; + if (y) *y = pd->position.y; + if (z) *z = pd->position.z; } else if (space == EVAS_3D_SPACE_WORLD) { - evas_3d_object_update((Evas_3D_Object *)&node->base); + evas_3d_object_update((Evas_3D_Object *)&pd->base); - if (x) *x = node->position_world.x; - if (y) *y = node->position_world.y; - if (z) *z = node->position_world.z; + if (x) *x = pd->position_world.x; + if (y) *y = pd->position_world.y; + if (z) *z = pd->position_world.z; } } -EAPI void -evas_3d_node_orientation_get(const Evas_3D_Node *node, Evas_3D_Space space, +EOLIAN static void +_eo_evas_3d_node_orientation_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z, Evas_Real *w) { if (space == EVAS_3D_SPACE_LOCAL) @@ -823,25 +859,25 @@ evas_3d_node_orientation_get(const Evas_3D_Node *node, Evas_3D_Space space, } else if (space == EVAS_3D_SPACE_PARENT) { - if (x) *x = node->orientation.x; - if (y) *y = node->orientation.y; - if (z) *z = node->orientation.z; - if (w) *w = node->orientation.w; + if (x) *x = pd->orientation.x; + if (y) *y = pd->orientation.y; + if (z) *z = pd->orientation.z; + if (w) *w = pd->orientation.w; } else if (space == EVAS_3D_SPACE_WORLD) { - evas_3d_object_update((Evas_3D_Object *)&node->base); + evas_3d_object_update((Evas_3D_Object *)&pd->base); - if (x) *x = node->orientation_world.x; - if (y) *y = node->orientation_world.y; - if (z) *z = node->orientation_world.z; - if (w) *w = node->orientation_world.w; + if (x) *x = pd->orientation_world.x; + if (y) *y = pd->orientation_world.y; + if (z) *z = pd->orientation_world.z; + if (w) *w = pd->orientation_world.w; } } -EAPI void -evas_3d_node_scale_get(const Evas_3D_Node *node, Evas_3D_Space space, +EOLIAN static void +_eo_evas_3d_node_scale_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Space space, Evas_Real *x, Evas_Real *y, Evas_Real *z) { if (space == EVAS_3D_SPACE_LOCAL) @@ -852,61 +888,61 @@ evas_3d_node_scale_get(const Evas_3D_Node *node, Evas_3D_Space space, } else if (space == EVAS_3D_SPACE_PARENT) { - if (x) *x = node->scale.x; - if (y) *y = node->scale.y; - if (z) *z = node->scale.z; + if (x) *x = pd->scale.x; + if (y) *y = pd->scale.y; + if (z) *z = pd->scale.z; } else if (space == EVAS_3D_SPACE_WORLD) { - evas_3d_object_update((Evas_3D_Object *)&node->base); + evas_3d_object_update((Evas_3D_Object *)&pd->base); - if (x) *x = node->scale_world.x; - if (y) *y = node->scale_world.y; - if (z) *z = node->scale_world.z; + if (x) *x = pd->scale_world.x; + if (y) *y = pd->scale_world.y; + if (z) *z = pd->scale_world.z; } } -EAPI void -evas_3d_node_position_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) +EOLIAN static void +_eo_evas_3d_node_position_inherit_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Eina_Bool inherit) { - node->position_inherit = inherit; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + pd->position_inherit = inherit; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_orientation_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) +EOLIAN static void +_eo_evas_3d_node_orientation_inherit_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Eina_Bool inherit) { - node->orientation_inherit = inherit; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + pd->orientation_inherit = inherit; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_scale_inherit_set(Evas_3D_Node *node, Eina_Bool inherit) +EOLIAN static void +_eo_evas_3d_node_scale_inherit_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Eina_Bool inherit) { - node->scale_inherit = inherit; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + pd->scale_inherit = inherit; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI Eina_Bool -evas_3d_node_position_inherit_get(const Evas_3D_Node *node) +EOLIAN static Eina_Bool +_eo_evas_3d_node_position_inherit_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->position_inherit; + return pd->position_inherit; } -EAPI Eina_Bool -evas_3d_node_orientation_inherit_get(const Evas_3D_Node *node) +EOLIAN static Eina_Bool +_eo_evas_3d_node_orientation_inherit_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->orientation_inherit; + return pd->orientation_inherit; } -EAPI Eina_Bool -evas_3d_node_scale_inherit_get(const Evas_3D_Node *node) +EOLIAN static Eina_Bool +_eo_evas_3d_node_scale_inherit_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->scale_inherit; + return pd->scale_inherit; } -EAPI void -evas_3d_node_look_at_set(Evas_3D_Node *node, +EOLIAN static void +_eo_evas_3d_node_look_at_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Space target_space, Evas_Real tx, Evas_Real ty, Evas_Real tz, Evas_3D_Space up_space, Evas_Real ux, Evas_Real uy, Evas_Real uz) { @@ -937,8 +973,9 @@ evas_3d_node_look_at_set(Evas_3D_Node *node, if (up_space == EVAS_3D_SPACE_LOCAL) { - ERR("TODO:"); - return; + evas_vec3_set(&up, ux, uy, uz); + //ERR("TODO:"); + //return; } else if (up_space == EVAS_3D_SPACE_PARENT) { @@ -956,7 +993,7 @@ evas_3d_node_look_at_set(Evas_3D_Node *node, } /* From now on, everything takes place in parent space. */ - evas_vec3_subtract(&z, &node->position, &target); + evas_vec3_subtract(&z, &pd->position, &target); evas_vec3_normalize(&z, &z); evas_vec3_cross_product(&x, &up, &z); @@ -975,219 +1012,225 @@ evas_3d_node_look_at_set(Evas_3D_Node *node, Evas_Real t = x.x + y.y + z.z + 1.0; Evas_Real s = evas_reciprocal_sqrt(t) * 0.5; - node->orientation.w = s * t; - node->orientation.z = (x.y - y.x) * s; - node->orientation.y = (z.x - x.z) * s; - node->orientation.x = (y.z - z.y) * s; + pd->orientation.w = s * t; + pd->orientation.z = (x.y - y.x) * s; + pd->orientation.y = (z.x - x.z) * s; + pd->orientation.x = (y.z - z.y) * s; } else if (x.x > y.y && x.x > z.z) { Evas_Real t = x.x - y.y - z.z + 1.0; Evas_Real s = evas_reciprocal_sqrt(t) * 0.5; - node->orientation.x = s * t; - node->orientation.y = (x.y + y.x) * s; - node->orientation.z = (z.x + x.z) * s; - node->orientation.w = (y.z - z.y) * s; + pd->orientation.x = s * t; + pd->orientation.y = (x.y + y.x) * s; + pd->orientation.z = (z.x + x.z) * s; + pd->orientation.w = (y.z - z.y) * s; } else if (y.y > z.z) { Evas_Real t = -x.x + y.y - z.z + 1.0; Evas_Real s = evas_reciprocal_sqrt(t) * 0.5; - node->orientation.y = s * t; - node->orientation.x = (x.y + y.x) * s; - node->orientation.w = (z.x - x.z) * s; - node->orientation.z = (y.z + z.y) * s; + pd->orientation.y = s * t; + pd->orientation.x = (x.y + y.x) * s; + pd->orientation.w = (z.x - x.z) * s; + pd->orientation.z = (y.z + z.y) * s; } else { Evas_Real t = -x.x - y.y + z.z + 1.0; Evas_Real s = evas_reciprocal_sqrt(t) * 0.5; - node->orientation.z = s * t; - node->orientation.w = (x.y - y.x) * s; - node->orientation.x = (z.x + x.z) * s; - node->orientation.y = (y.z + z.y) * s; + pd->orientation.z = s * t; + pd->orientation.w = (x.y - y.x) * s; + pd->orientation.x = (z.x + x.z) * s; + pd->orientation.y = (y.z + z.y) * s; } - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_TRANSFORM, NULL); } -EAPI void -evas_3d_node_camera_set(Evas_3D_Node *node, Evas_3D_Camera *camera) +EOLIAN static void +_eo_evas_3d_node_camera_set(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Camera *camera) { - if (node->type != EVAS_3D_NODE_TYPE_CAMERA) + if (pd->type != EVAS_3D_NODE_TYPE_CAMERA) { ERR("Node type mismatch."); return; } - if (node->data.camera.camera == camera) + if (pd->data.camera.camera == camera) return; - if (node->data.camera.camera) + if (pd->data.camera.camera) { /* Detach previous camera object. */ - evas_3d_camera_node_del(node->data.camera.camera, node); - evas_3d_object_unreference(&node->data.camera.camera->base); + evas_3d_camera_node_del(pd->data.camera.camera, obj); + Evas_3D_Camera_Data *pdcamera = eo_data_scope_get(pd->data.camera.camera, EO_EVAS_3D_CAMERA_CLASS); + evas_3d_object_unreference(&pdcamera->base); } - node->data.camera.camera = camera; - evas_3d_object_reference(&camera->base); + pd->data.camera.camera = camera; + Evas_3D_Camera_Data *pdcamera = eo_data_scope_get(camera, EO_EVAS_3D_CAMERA_CLASS); + evas_3d_object_reference(&pdcamera->base); /* Register change notification on the camera for this node. */ - evas_3d_camera_node_add(camera, node); + evas_3d_camera_node_add(camera, obj); /* Mark changed. */ - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_CAMERA, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_CAMERA, NULL); } -EAPI Evas_3D_Camera * -evas_3d_node_camera_get(const Evas_3D_Node *node) +EOLIAN static Evas_3D_Camera * +_eo_evas_3d_node_camera_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->data.camera.camera; + return pd->data.camera.camera; } -EAPI void -evas_3d_node_light_set(Evas_3D_Node *node, Evas_3D_Light *light) +EOLIAN static void +_eo_evas_3d_node_light_set(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Light *light) { - if (node->type != EVAS_3D_NODE_TYPE_LIGHT) + if (pd->type != EVAS_3D_NODE_TYPE_LIGHT) { ERR("Node type mismatch."); return; } - if (node->data.light.light == light) + if (pd->data.light.light == light) return; - if (node->data.light.light) + if (pd->data.light.light) { + Evas_3D_Light_Data *pdl = eo_data_scope_get(pd->data.light.light, EO_EVAS_3D_LIGHT_CLASS); /* Detach previous light object. */ - evas_3d_light_node_del(node->data.light.light, node); - evas_3d_object_unreference(&node->data.light.light->base); + evas_3d_light_node_del(pd->data.light.light, obj); + evas_3d_object_unreference(&pdl->base); } - node->data.light.light = light; - evas_3d_object_reference(&light->base); + pd->data.light.light = light; + Evas_3D_Light_Data *pdl = eo_data_scope_get(light, EO_EVAS_3D_LIGHT_CLASS); + evas_3d_object_reference(&pdl->base); /* Register change notification on the light for this node. */ - evas_3d_light_node_add(light, node); + evas_3d_light_node_add(light, obj); /* Mark changed. */ - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_LIGHT, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_LIGHT, NULL); } -EAPI Evas_3D_Light * -evas_3d_node_light_get(const Evas_3D_Node *node) +EOLIAN static Evas_3D_Light * +_eo_evas_3d_node_light_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->data.light.light; + return pd->data.light.light; } -EAPI void -evas_3d_node_mesh_add(Evas_3D_Node *node, Evas_3D_Mesh *mesh) +EOLIAN static void +_eo_evas_3d_node_mesh_add(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Mesh *mesh) { Evas_3D_Node_Mesh *nm = NULL; - if (node->type != EVAS_3D_NODE_TYPE_MESH) + if (pd->type != EVAS_3D_NODE_TYPE_MESH) { ERR("Node type mismatch."); return; } - if (eina_hash_find(node->data.mesh.node_meshes, mesh) != NULL) + if (eina_hash_find(pd->data.mesh.node_meshes, &mesh) != NULL) { ERR("The mesh is already added to the node."); return; } - if ((nm = _node_mesh_new(node, mesh)) == NULL) + if ((nm = _node_mesh_new(obj, mesh)) == NULL) { ERR("Failed to create node mesh."); return; } /* TODO: Find node mesh and add if it does not exist. */ - if (!eina_hash_add(node->data.mesh.node_meshes, mesh, nm)) + if (!eina_hash_add(pd->data.mesh.node_meshes, &mesh, nm)) { ERR("Failed to add a mesh to mesh table."); _node_mesh_free(nm); return; } - node->data.mesh.meshes = eina_list_append(node->data.mesh.meshes, mesh); - evas_3d_object_reference(&mesh->base); + pd->data.mesh.meshes = eina_list_append(pd->data.mesh.meshes, mesh); + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS); + evas_3d_object_reference(&pdmesh->base); /* Register change notification. */ - evas_3d_mesh_node_add(mesh, node); + evas_3d_mesh_node_add(mesh, obj); /* Mark changed. */ - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, NULL); - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, NULL); } -EAPI void -evas_3d_node_mesh_del(Evas_3D_Node *node, Evas_3D_Mesh *mesh) +EOLIAN static void +_eo_evas_3d_node_mesh_del(Eo *obj, Evas_3D_Node_Data *pd, Evas_3D_Mesh *mesh) { - if (node->type != EVAS_3D_NODE_TYPE_MESH) + if (pd->type != EVAS_3D_NODE_TYPE_MESH) { ERR("Node type mismatch."); return; } - if (!eina_hash_del(node->data.mesh.node_meshes, mesh, NULL)) + if (!eina_hash_del(pd->data.mesh.node_meshes, &mesh, NULL)) { ERR("The given mesh doesn't belong to this node."); return; } - node->data.mesh.meshes = eina_list_remove(node->data.mesh.meshes, mesh); - evas_3d_mesh_node_del(mesh, node); - evas_3d_object_unreference(&mesh->base); + pd->data.mesh.meshes = eina_list_remove(pd->data.mesh.meshes, mesh); + evas_3d_mesh_node_del(mesh, obj); + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS); + evas_3d_object_unreference(&pdmesh->base); - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, NULL); - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MESH_GEOMETRY, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MESH_MATERIAL, NULL); } -EAPI const Eina_List * -evas_3d_node_mesh_list_get(const Evas_3D_Node *node) +EOLIAN static const Eina_List * +_eo_evas_3d_node_mesh_list_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd) { - return node->data.mesh.meshes; + return pd->data.mesh.meshes; } -EAPI void -evas_3d_node_mesh_frame_set(Evas_3D_Node *node, Evas_3D_Mesh *mesh, int frame) +EOLIAN static void +_eo_evas_3d_node_mesh_frame_set(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Mesh *mesh, int frame) { Evas_3D_Node_Mesh *nm = NULL; - if (node->type != EVAS_3D_NODE_TYPE_MESH) + if (pd->type != EVAS_3D_NODE_TYPE_MESH) { ERR("Node type mismatch."); return; } - if ((nm = eina_hash_find(node->data.mesh.node_meshes, mesh)) == NULL) + if ((nm = eina_hash_find(pd->data.mesh.node_meshes, &mesh)) == NULL) { ERR("The given mesh doesn't belongs to this node."); return; } nm->frame = frame; - evas_3d_object_change(&node->base, EVAS_3D_STATE_NODE_MESH_FRAME, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_NODE_MESH_FRAME, NULL); } -EAPI int -evas_3d_node_mesh_frame_get(const Evas_3D_Node *node, Evas_3D_Mesh *mesh) +EOLIAN static int +_eo_evas_3d_node_mesh_frame_get(Eo *obj EINA_UNUSED, Evas_3D_Node_Data *pd, Evas_3D_Mesh *mesh) { Evas_3D_Node_Mesh *nm = NULL; - if (node->type != EVAS_3D_NODE_TYPE_MESH) + if (pd->type != EVAS_3D_NODE_TYPE_MESH) { ERR("Node type mismatch."); return 0; } - if ((nm = eina_hash_find(node->data.mesh.node_meshes, mesh)) == NULL) + if ((nm = eina_hash_find(pd->data.mesh.node_meshes, &mesh)) == NULL) { ERR("The given mesh doesn't belongs to this node."); return 0; @@ -1195,3 +1238,5 @@ evas_3d_node_mesh_frame_get(const Evas_3D_Node *node, Evas_3D_Mesh *mesh) return nm->frame; } + +#include "canvas/evas_3d_node.eo.c" diff --git a/src/lib/evas/canvas/evas_3d_node.eo b/src/lib/evas/canvas/evas_3d_node.eo new file mode 100755 index 0000000..c578b3e --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_node.eo @@ -0,0 +1,548 @@ +class EO_Evas_3D_Node (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_node; + data: Evas_3D_Node_Data; + constructors { + constructor { + /*@ Contructor. */ + params { + @in Evas_3D_Node_Type type; + } + } + } + methods { + type_get { + /* + Get the type of the given node. + + @return The type of the given node. + + @see evas_3d_node_add() + + @ingroup Evas_3D_Node + */ + const; + return Evas_3D_Node_Type ; + } + member_add { + /* + Add a member node to the given node. + + Nodes can be constructed into N-ary tree structure like other ordinary scene + graph. Basically a node inherit transforms from its parent. + + @see evas_3d_node_parent_get() + + @ingroup Evas_3D_Node + */ + + params { + @in Evas_3D_Node *member; /*@ Node object to be added. */ + } + } + member_del { + /* + Delete a member node from the given node. + + @see evas_3d_node_member_add() + + @ingroup Evas_3D_Node + */ + + params { + @in Evas_3D_Node *member; /*@ Member node to be deleted from the given node. */ + } + } + + parent_get { + /* + Get the parent node of the given node. + + @return The parent node of the given node. + + @see evas_3d_node_member_add() + + @ingroup Evas_3D_Node + */ + const; + return Evas_3D_Node * ; + } + + member_list_get { + /* + Get the list of member nodes of the given node. + + @return The list of member nodes if any or @c NULL if there are none. + + @see evas_3d_node_member_add() + + @ingroup Evas_3D_Node + */ + const; + return const Eina_List * ; + } + position_set { + + /* + Set the position of the given node. + + According to the inheritance flag, (x, y, z) can be a world space position or + parent space position. + + Default position is (0.0, 0.0, 0.0). + + @see evas_3d_node_position_inherit_set() + + @ingroup Evas_3D_Node_Transform + */ + params { + @in Evas_Real x; /*@ X coordinate of the position. */ + @in Evas_Real y; /*@ Y coordinate of the position. */ + @in Evas_Real z; /*@ Z coordinate of the position. */ + } + } + orientation_set { + /* + Set the orientation of the given node using quaternion. + + According the the inheritance flag, (w, x, y, z) can be a world space + orientation or parent space orientation. + + Default orientation is (1.0, 0.0, 0.0, 0.0) (identity quaternion). + + @see evas_3d_node_orientation_inherit_set() + + @ingroup Evas_3D_Node_Transform + */ + params { + @in Evas_Real x; /*@ X term of the orientation quaternion (w, x, y, z) */ + @in Evas_Real y; /*@ Y term of the orientation quaternion (w, x, y, z) */ + @in Evas_Real z; /*@ Z term of the orientation quaternion (w, x, y, z) */ + @in Evas_Real w; /*@ W term of the orientation quaternion (w, x, y, z) */ + } + } + + orientation_angle_axis_set { + /* + Set the orientation of the given node using axis-angle. + + @param node The given node. + @param angle Rotation angle. + @param x X term of the rotation axis. + @param y Y term of the rotation axis. + @param z Z term of the rotation axis. + + @see evas_3d_node_orientation_set() + + @ingroup Evas_3D_Node_Transform + */ + params { + @in Evas_Real angle; /*@ Rotation angle.*/ + @in Evas_Real x; /*@ X term of the rotation axis.*/ + @in Evas_Real y; /*@ Y term of the rotation axis.*/ + @in Evas_Real z; /*@ Z term of the rotation axis.*/ + } + } + + scale_set { + /* + Set the scale of the given node. + + @param node The given node. + @param x Scale factor along X-axis. + @param y Scale factor along Y-axis. + @param z Scale factor along Z-axis. + + According to the inheritance flag, (x, y, z) can be a world space scale or + parent space scale. Be careful when using non-uniform scale factor with + inheritance, each transform attributes are not affected by other attributes. + + Default scale is (1.0, 1.0, 1.0). + + @see evas_3d_node_scale_inherit_set() + + @ingroup Evas_3D_Node_Transform + */ + params { + @in Evas_Real x; /*@ Scale factor along X-axis.*/ + @in Evas_Real y; /*@ Scale factor along Y-axis.*/ + @in Evas_Real z; /*@ Scale factor along Z-axis.*/ + } + } + + position_get { + /* + Get the position of the given node. + + @param node The given node. + @param x Pointer to receive X coordinate of the position. + @param y Pointer to receive Y coordinate of the position. + @param z Pointer to receive Z coordinate of the position. + + @see evas_3d_node_position_set() + + @ingroup Evas_3D_Node_Transform + */ + const; + params { + @in Evas_3D_Space space; /*@ */ + @out Evas_Real x; /*@ Pointer to receive X coordinate of the position.*/ + @out Evas_Real y; /*@ Pointer to receive Y coordinate of the position.*/ + @out Evas_Real z; /*@ Pointer to receive Z coordinate of the position.*/ + } + } + + orientation_get { + /* + Get the orientation of the given node as quaternion. + + @param node The given node. + @param x Pointer to receive X term of the orientation quaternion. + @param y Pointer to receive Y term of the orientation quaternion. + @param z Pointer to receive Z term of the orientation quaternion. + @param w Pointer to receive W term of the orientation quaternion. + + @see evas_3d_node_orientation_set() + + @ingroup Evas_3D_Node_Transform + */ + const; + params { + @in Evas_3D_Space space; /*@ */ + @out Evas_Real x; /*@ Pointer to receive X term of the orientation quaternion.*/ + @out Evas_Real y; /*@ Pointer to receive Y term of the orientation quaternion.*/ + @out Evas_Real z; /*@ Pointer to receive Z term of the orientation quaternion.*/ + @out Evas_Real w; /*@ Pointer to receive W term of the orientation quaternion.*/ + } + } + + scale_get { + /* + Get the scale of the given node. + + @param node The given node. + @param x Pointer to receive Scale factor along X-axis. + @param y Pointer to receive Scale factor along Y-axis. + @param z Pointer to receive Scale factor along Z-axis. + + @see evas_3d_node_scale_get() + + @ingroup Evas_3D_Node_Transform + */ + const; + params { + @in Evas_3D_Space space; /*@ */ + @out Evas_Real x; /*@ Pointer to receive Scale factor along X-axis.*/ + @out Evas_Real y; /*@ Pointer to receive Scale factor along X-axis.*/ + @out Evas_Real z; /*@ Pointer to receive Scale factor along X-axis.*/ + } + } + + look_at_set { + /* + Rotate the given node to look at desired position. + + @param node The given node. + @param target_space Space where the target position belongs to. + @param x X coordinate of the target position. + @param y Y coordinate of the target position. + @param z Z coordinate of the target position. + @param up_space Space where the up vector belongs to. + @param ux X term of the up vector. + @param uy Y term of the up vector. + @param uz Z term of the up vector. + + This function rotate the given node so that its forward vector (negative + Z-axis) points to the desired position and the up vector coincide with the + given up vector. + + @see evas_3d_node_orientation_set() + + @ingroup Evas_3D_Node_Transform + */ + + params { + @in Evas_3D_Space target_space; /*@ Space where the target position belongs to. */ + @in Evas_Real x; /*@ X coordinate of the target position. */ + @in Evas_Real y; /*@ Y coordinate of the target position. */ + @in Evas_Real z; /*@ Z coordinate of the target position. */ + @in Evas_3D_Space up_space; /*@ Space where the up vector belongs to. */ + @in Evas_Real ux; /*@ X term of the up vector. */ + @in Evas_Real uy; /*@ Y term of the up vector. */ + @in Evas_Real uz; /*@ Z term of the up vector. */ + } + } + + mesh_add { + /* + Add a mesh to the given node. + + @param node The given node. + @param mesh The mesh to be added. + + If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be + generated and nothing happens. + + @see evas_3d_node_add() + + @ingroup Evas_3D_Node + */ + params { + @in Evas_3D_Mesh *mesh; /*@ The mesh to be added.*/ + } + } + + mesh_del { + /* + Delete a mesh from the given node. + + @param node The given node. + @param mesh The mesh to be deleted. + + If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not + belong to the given node, error message will be gnerated and nothing happens. + + @see evas_3d_node_mesh_add() + + @ingroup Evas_3D_Node + */ + params { + @in Evas_3D_Mesh *mesh; /*@ The mesh to be deleted.*/ + } + } + + mesh_list_get { + /* + Get the list of meshes of the given node. + + @param node The given node. + @return The list of meshes if any, or @c NULL if there're none. + + If the node is not of type EVAS_3D_NODE_TYPE_MESH, error message will be + generated and @c NULL will be returned. If there're no meshes in the given + node, @c NULL will be returned. + + @see evas_3d_node_mesh_add() + + @ingroup Evas_3D_Node + */ + const; + return const Eina_List *; + } + + } + + properties { + + position_inherit { + set { + /* + Set the position inheritance flag of the given node. + + @param node The given node. + @param inherit Whether to inherit parent position @c EINA_TRUE or not @c EINA_FALSE. + + When inheritance is enabled, a node's world space position is determined by + adding the parent node's world position and the node's position, otherwise, + the node's position will be the world space position. + + @ingroup Evas_3D_Node_Transform + */ + } + get { + /* + Get the position inheritance flag of the given node. + + @param node The given node. + @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. + + @see evas_3d_node_position_inherit_set() + + @ingroup Evas_3D_Node_Transform + */ + } + values { + Eina_Bool inherit; /*@ Whether to inherit parent position*/ + } + } + + orientation_inherit { + set { + /* + Set the orientation inheritance flag of the given node. + + @param node The given node. + @param inherit Whether to inherit parent orientation @c EINA_TRUE or not @c EINA_FALSE. + + When inheritance is enabled, a node's world space orientation is determined + by multiplying the parent node's world orientation and the node's + orientation, otherwise, the node's orientation will be the world space + orientation. + + @ingroup Evas_3D_Node_Transform + */ + } + get { + /* + Get the orientation inheritance flag of the given node. + + @param node The given node. + @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. + + @see evas_3d_node_orientation_inherit_set() + + @ingroup Evas_3D_Node_Transform + */ + } + values { + Eina_Bool inherit; /*@ Whether to inherit parent orientation*/ + } + } + + scale_inherit { + set { + /* + Set the scale inheritance flag of the given node. + + @param node The given node. + @param inherit Whether to inherit parent scale @c EINA_TRUE or not @c EINA_FALSE. + + When inheritance is enabled, a node's world space scale is determined by + multiplying the parent node's world scale and the node's scale, otherwise, + the node's scale will be the world space scale. + + @ingroup Evas_3D_Node_Transform + */ + } + get { + /* + Get the scale inheritance flag of the given node. + + @param node The given node. + @return @c EINA_TRUE if inheritance is enabled, or @c EINA_FALSE if not. + + @see evas_3d_node_scale_inherit_set() + + @ingroup Evas_3D_Node_Transform + */ + } + values { + Eina_Bool inherit; /*@ Whether to inherit parent scale*/ + } + } + + camera { + set { + /* + Set a camera to the given node. + + @param node The given node. + @param camera The camera to be set. + + If the node is not of type EVAS_3D_NODE_TYPE_CAMERA, error message will be + generated and nothing happens. + + @see evas_3d_node_add() + + @ingroup Evas_3D_Node + */ + } + get { + /* + Get the camera of the given node. + + @param node The given node. + @return The camera of the given node if any, or @c NULL if there're none. + + @see evas_3d_node_camera_set() + + @ingroup Evas_3D_Node + */ + } + values { + Evas_3D_Camera *camera; /*@ The camera */ + } + } + + light { + set { + /* + Set the light of the given node. + + @param node The given node. + @param light The light to be set. + + If the node is not of type EVAS_3D_NODE_TYPE_LIGHT, error message will be + generated and nothing happens. + + @see evas_3d_node_add() + + @ingroup Evas_3D_Node + */ + } + get { + /* + Get the light of the given node. + + @param node The given node. + @return The light of the given node if any, or @c NULL if there're none. + + @see evas_3d_node_light_set() + + @ingroup Evas_3D_Node + */ + } + values { + Evas_3D_Light *light; /*@ The light */ + } + } + + mesh_frame { + set { + /* + Set the animation frame number of the given node for the given mesh. + + @param node The given node. + @param mesh The given mesh. + @param frame The animation frame number. + + If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not + belong to the given mesh error mesh will be generated and nothing happens. + + Default mesh frame is 0. + + @see evas_3d_node_mesh_add() + + @ingroup Evas_3D_Node + */ + } + get { + /* + Set the animation frame number of the given node for the given mesh. + + @param node The given node. + @param mesh The given mesh. + @param frame The animation frame number. + + If the node is not of type EVAS_3D_NODE_TYPE_MESH or the given mesh does not + belong to the given mesh error mesh will be generated and nothing happens. + + @see evas_3d_node_mesh_add() + + @ingroup Evas_3D_Node + */ + } + keys { + Evas_3D_Mesh *mesh; /*@ The given mesh.*/ + } + values { + int frame; /*@ The animation frame number.*/ + } + } + } + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } +} diff --git a/src/lib/evas/canvas/evas_3d_scene.c b/src/lib/evas/canvas/evas_3d_scene.c index 3327fee..2f32ec2 100644 --- a/src/lib/evas/canvas/evas_3d_scene.c +++ b/src/lib/evas/canvas/evas_3d_scene.c @@ -6,8 +6,12 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_SCENE_CLASS + void -evas_3d_scene_data_init(Evas_3D_Scene_Data *data) +evas_3d_scene_data_init(Evas_3D_Scene_Public_Data *data) { data->camera_node = NULL; data->light_nodes = NULL; @@ -15,7 +19,7 @@ evas_3d_scene_data_init(Evas_3D_Scene_Data *data) } void -evas_3d_scene_data_fini(Evas_3D_Scene_Data *data) +evas_3d_scene_data_fini(Evas_3D_Scene_Public_Data *data) { if (data->light_nodes) eina_list_free(data->light_nodes); @@ -27,7 +31,7 @@ evas_3d_scene_data_fini(Evas_3D_Scene_Data *data) static void _scene_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Scene *scene = (Evas_3D_Scene *)obj; + Evas_3D_Scene_Data *scene = (Evas_3D_Scene_Data *)obj; Eina_List *l; Evas_Object *eo; @@ -41,36 +45,45 @@ _scene_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Obje static void _scene_update(Evas_3D_Object *obj) { - Evas_3D_Scene *scene = (Evas_3D_Scene *)obj; + Evas_3D_Scene_Data *scene = (Evas_3D_Scene_Data *)obj; if (scene->root_node) - evas_3d_object_update(&scene->root_node->base); + { + Evas_3D_Node_Data *pd_root_node = eo_data_scope_get(scene->root_node, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_update(&pd_root_node->base); + } if (scene->camera_node) - evas_3d_object_update(&scene->camera_node->base); + { + Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(scene->camera_node, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_update(&pd_camera_node->base); + } } static void _scene_free(Evas_3D_Object *obj) { - Evas_3D_Scene *scene = (Evas_3D_Scene *)obj; + Evas_3D_Scene_Data *scene = (Evas_3D_Scene_Data *)obj; if (scene->root_node) { - evas_3d_node_scene_root_del(scene->root_node, scene); - evas_3d_object_unreference(&scene->root_node->base); + Evas_3D_Node_Data *pd_root_node = eo_data_scope_get(scene->root_node, EO_EVAS_3D_NODE_CLASS); + //@FIXME + evas_3d_node_scene_root_del(scene->root_node, scene->hack_this); + evas_3d_object_unreference(&pd_root_node->base); } if (scene->camera_node) { - evas_3d_node_scene_camera_del(scene->camera_node, scene); - evas_3d_object_unreference(&scene->camera_node->base); + Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(scene->camera_node, EO_EVAS_3D_NODE_CLASS); + evas_3d_node_scene_camera_del(scene->camera_node, scene->hack_this); + evas_3d_object_unreference(&pd_camera_node->base); } if (scene->images) eina_list_free(scene->images); - - free(scene); + eo_del(scene->hack_this); + //free(scene); } static const Evas_3D_Object_Func scene_func = @@ -80,132 +93,132 @@ static const Evas_3D_Object_Func scene_func = _scene_update, }; -Evas_3D_Scene * -evas_3d_scene_new(Evas *e) +EAPI Evas_3D_Scene * +evas_3d_scene_add(Evas *e) { - Evas_3D_Scene *scene = NULL; - - scene = (Evas_3D_Scene *)calloc(1, sizeof(Evas_3D_Scene)); - - if (scene == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } - - evas_3d_object_init(&scene->base, e, EVAS_3D_OBJECT_TYPE_SCENE, &scene_func); - evas_color_set(&scene->bg_color, 0.0, 0.0, 0.0, 0.0); - - return scene; + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + eo_unref(eo_obj); + return eo_obj; } -EAPI Evas_3D_Scene * -evas_3d_scene_add(Evas *e) +EOLIAN static void +_eo_evas_3d_scene_eo_base_constructor(Eo *obj, Evas_3D_Scene_Data *pd) { - return evas_3d_scene_new(e); + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_SCENE, &scene_func); + evas_color_set(&pd->bg_color, 0.0, 0.0, 0.0, 0.0); } -EAPI void -evas_3d_scene_del(Evas_3D_Scene *scene) +EOLIAN static void +_eo_evas_3d_scene_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd) { - evas_3d_object_unreference(&scene->base); + //evas_3d_object_unreference(&pd->base); } -EAPI Evas * -evas_3d_scene_evas_get(const Evas_3D_Scene *scene) +EOLIAN static Evas * +_eo_evas_3d_scene_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd) { - return scene->base.evas; + return pd->base.evas; } -EAPI void -evas_3d_scene_root_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node) +EOLIAN static void +_eo_evas_3d_scene_root_node_set(Eo *obj, Evas_3D_Scene_Data *pd, Evas_3D_Node *node) { - if (scene->root_node == node) + if (pd->root_node == node) return; - if (scene->root_node) + if (pd->root_node) { - evas_3d_node_scene_root_del(scene->root_node, scene); - evas_3d_object_unreference(&scene->root_node->base); + Evas_3D_Node_Data *pd_root_node = eo_data_scope_get(pd->root_node, EO_EVAS_3D_NODE_CLASS); + evas_3d_node_scene_root_del(pd->root_node, obj); + evas_3d_object_unreference(&pd_root_node->base); } - scene->root_node = node; + pd->root_node = node; if (node) { - evas_3d_object_reference(&node->base); - evas_3d_node_scene_root_add(node, scene); + Evas_3D_Node_Data *pd_node = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_reference(&pd_node->base); + evas_3d_node_scene_root_add(node, obj); } - evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_ROOT_NODE, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_ROOT_NODE, NULL); } -EAPI Evas_3D_Node * -evas_3d_scene_root_node_get(const Evas_3D_Scene *scene) +EOLIAN static Evas_3D_Node * +_eo_evas_3d_scene_root_node_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd) { - return scene->root_node; + return pd->root_node; } -EAPI void -evas_3d_scene_camera_node_set(Evas_3D_Scene *scene, Evas_3D_Node *node) +EOLIAN static void +_eo_evas_3d_scene_camera_node_set(Eo *obj, Evas_3D_Scene_Data *pd, Evas_3D_Node *node) { - if (scene->camera_node == node) + if (pd->camera_node == node) return; - if (scene->camera_node) + if (pd->camera_node) { - evas_3d_node_scene_camera_del(scene->camera_node, scene); - evas_3d_object_unreference(&scene->camera_node->base); + Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(pd->camera_node, EO_EVAS_3D_NODE_CLASS); + evas_3d_node_scene_camera_del(pd->camera_node, obj); + evas_3d_object_unreference(&pd_camera_node->base); } - scene->camera_node = node; + pd->camera_node = node; if (node) { - evas_3d_object_reference(&node->base); - evas_3d_node_scene_camera_add(node, scene); + Evas_3D_Node_Data *pd_node = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS); + evas_3d_object_reference(&pd_node->base); + evas_3d_node_scene_camera_add(node, obj); } - evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_CAMERA_NODE, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_CAMERA_NODE, NULL); } -EAPI Evas_3D_Node * -evas_3d_scene_camera_node_get(const Evas_3D_Scene *scene) +EOLIAN static Evas_3D_Node * +_eo_evas_3d_scene_camera_node_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd) { - return scene->camera_node; + return pd->camera_node; } -EAPI void -evas_3d_scene_size_set(Evas_3D_Scene *scene, int w, int h) +EOLIAN static void +_eo_evas_3d_scene_size_set(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, int w, int h) { - scene->w = w; - scene->h = h; - evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_SIZE, NULL); + pd->w = w; + pd->h = h; + evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_SIZE, NULL); } -EAPI void -evas_3d_scene_size_get(const Evas_3D_Scene *scene, int *w, int *h) +EOLIAN static void +_eo_evas_3d_scene_size_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, int *w, int *h) { - if (w) *w = scene->w; - if (h) *h = scene->h; + if (w) *w = pd->w; + if (h) *h = pd->h; } -EAPI void -evas_3d_scene_background_color_set(Evas_3D_Scene *scene, +EOLIAN static void +_eo_evas_3d_scene_background_color_set(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a) { - evas_color_set(&scene->bg_color, r, g, b, a); - evas_3d_object_change(&scene->base, EVAS_3D_STATE_SCENE_BACKGROUND_COLOR, NULL); + evas_color_set(&pd->bg_color, r, g, b, a); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_SCENE_BACKGROUND_COLOR, NULL); } -EAPI void -evas_3d_scene_background_color_get(const Evas_3D_Scene *scene, +EOLIAN static void +_eo_evas_3d_scene_background_color_get(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a) { - if (r) *r = scene->bg_color.r; - if (g) *g = scene->bg_color.g; - if (b) *b = scene->bg_color.b; - if (a) *a = scene->bg_color.a; + if (r) *r = pd->bg_color.r; + if (g) *g = pd->bg_color.g; + if (b) *b = pd->bg_color.b; + if (a) *a = pd->bg_color.a; } static inline Eina_Bool @@ -362,26 +375,26 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray, evas_3d_mesh_interpolate_vertex_buffer_get(mesh, frame, EVAS_3D_VERTEX_TEXCOORD, &tex0, &tex1, &tex_weight); - - if (mesh->indices) + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS); + if (pdmesh->indices) { unsigned int i0, i1, i2; - if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES) + if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES) { - for (i = 0; i < mesh->index_count; i += 3) + for (i = 0; i < pdmesh->index_count; i += 3) { - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) { - i0 = ((unsigned short *)mesh->indices)[i]; - i1 = ((unsigned short *)mesh->indices)[i + 1]; - i2 = ((unsigned short *)mesh->indices)[i + 2]; + i0 = ((unsigned short *)pdmesh->indices)[i]; + i1 = ((unsigned short *)pdmesh->indices)[i + 1]; + i2 = ((unsigned short *)pdmesh->indices)[i + 2]; } else { - i0 = ((unsigned char *)mesh->indices)[i]; - i1 = ((unsigned char *)mesh->indices)[i + 1]; - i2 = ((unsigned char *)mesh->indices)[i + 2]; + i0 = ((unsigned char *)pdmesh->indices)[i]; + i1 = ((unsigned char *)pdmesh->indices)[i + 1]; + i2 = ((unsigned char *)pdmesh->indices)[i + 2]; } _position_get(&tri.p0, &pos0, &pos1, pos_weight, i0); @@ -396,45 +409,45 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray, } } } - else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP) + else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP) { - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) { - i1 = ((unsigned short *)mesh->indices)[0]; - i2 = ((unsigned short *)mesh->indices)[1]; + i1 = ((unsigned short *)pdmesh->indices)[0]; + i2 = ((unsigned short *)pdmesh->indices)[1]; } else { - i1 = ((unsigned char *)mesh->indices)[0]; - i2 = ((unsigned char *)mesh->indices)[1]; + i1 = ((unsigned char *)pdmesh->indices)[0]; + i2 = ((unsigned char *)pdmesh->indices)[1]; } _position_get(&tri.p1, &pos0, &pos1, pos_weight, i1); _position_get(&tri.p2, &pos0, &pos1, pos_weight, i2); - for (i = 0; i < mesh->index_count - 2; i++) + for (i = 0; i < pdmesh->index_count - 2; i++) { tri.p0 = tri.p1; tri.p1 = tri.p2; - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) - i2 = ((unsigned short *)mesh->indices)[i + 2]; + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + i2 = ((unsigned short *)pdmesh->indices)[i + 2]; else - i2 = ((unsigned char *)mesh->indices)[i + 2]; + i2 = ((unsigned char *)pdmesh->indices)[i + 2]; _position_get(&tri.p2, &pos0, &pos1, pos_weight, i2); if (_pick_data_triangle_add(data, ray, &tri)) { - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) { - i0 = ((unsigned short *)mesh->indices)[i]; - i1 = ((unsigned short *)mesh->indices)[i + 1]; + i0 = ((unsigned short *)pdmesh->indices)[i]; + i1 = ((unsigned short *)pdmesh->indices)[i + 1]; } else { - i0 = ((unsigned char *)mesh->indices)[i]; - i1 = ((unsigned char *)mesh->indices)[i + 1]; + i0 = ((unsigned char *)pdmesh->indices)[i]; + i1 = ((unsigned char *)pdmesh->indices)[i + 1]; } _pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2); @@ -443,39 +456,39 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray, } } } - else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN) + else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN) { - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) { - i0 = ((unsigned short *)mesh->indices)[0]; - i2 = ((unsigned short *)mesh->indices)[1]; + i0 = ((unsigned short *)pdmesh->indices)[0]; + i2 = ((unsigned short *)pdmesh->indices)[1]; } else { - i0 = ((unsigned char *)mesh->indices)[0]; - i2 = ((unsigned char *)mesh->indices)[1]; + i0 = ((unsigned char *)pdmesh->indices)[0]; + i2 = ((unsigned char *)pdmesh->indices)[1]; } _position_get(&tri.p0, &pos0, &pos1, pos_weight, i0); _position_get(&tri.p2, &pos0, &pos1, pos_weight, i2); - for (i = 1; i < mesh->index_count - 1; i++) + for (i = 1; i < pdmesh->index_count - 1; i++) { tri.p1 = tri.p2; - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) - i2 = ((unsigned short *)mesh->indices)[i + 1]; + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + i2 = ((unsigned short *)pdmesh->indices)[i + 1]; else - i2 = ((unsigned char *)mesh->indices)[i + 1]; + i2 = ((unsigned char *)pdmesh->indices)[i + 1]; _position_get(&tri.p2, &pos0, &pos1, pos_weight, i2); if (_pick_data_triangle_add(data, ray, &tri)) { - if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) - i1 = ((unsigned short *)mesh->indices)[i]; + if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT) + i1 = ((unsigned short *)pdmesh->indices)[i]; else - i1 = ((unsigned char *)mesh->indices)[i]; + i1 = ((unsigned char *)pdmesh->indices)[i]; _pick_data_texcoord_update(data, &tex0, &tex1, tex_weight, i0, i1, i2); data->mesh = mesh; @@ -484,11 +497,11 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray, } } } - else if (mesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_BYTE) + else if (pdmesh->index_format == EVAS_3D_INDEX_FORMAT_UNSIGNED_BYTE) { - if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES) + if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES) { - for (i = 0; i < mesh->index_count; i += 3) + for (i = 0; i < pdmesh->index_count; i += 3) { _position_get(&tri.p0, &pos0, &pos1, pos_weight, i); _position_get(&tri.p1, &pos0, &pos1, pos_weight, i + 1); @@ -502,12 +515,12 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray, } } } - else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP) + else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_STRIP) { _position_get(&tri.p1, &pos0, &pos1, pos_weight, 0); _position_get(&tri.p2, &pos0, &pos1, pos_weight, 1); - for (i = 0; i < mesh->index_count - 2; i++) + for (i = 0; i < pdmesh->index_count - 2; i++) { tri.p0 = tri.p1; tri.p1 = tri.p2; @@ -522,12 +535,12 @@ _pick_data_mesh_add(Evas_3D_Pick_Data *data, const Evas_Ray3 *ray, } } } - else if (mesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN) + else if (pdmesh->assembly == EVAS_3D_VERTEX_ASSEMBLY_TRIANGLE_FAN) { _position_get(&tri.p0, &pos0, &pos1, pos_weight, 0); _position_get(&tri.p2, &pos0, &pos1, pos_weight, 1); - for (i = 1; i < mesh->index_count - 1; i++) + for (i = 1; i < pdmesh->index_count - 1; i++) { tri.p1 = tri.p2; @@ -550,23 +563,24 @@ _node_pick(Evas_3D_Node *node, void *data) Evas_Ray3 ray; Evas_3D_Pick_Data *pick = (Evas_3D_Pick_Data *)data; Evas_Mat4 mvp; + Evas_3D_Node_Data *pd_node = eo_data_scope_get(node, EO_EVAS_3D_NODE_CLASS); - if (! evas_box3_ray3_intersect(&node->aabb, &pick->ray_world)) + if (! evas_box3_ray3_intersect(&pd_node->aabb, &pick->ray_world)) { /* Skip entire subtree. */ return EINA_FALSE; } - if (node->type == EVAS_3D_NODE_TYPE_MESH) + if (pd_node->type == EVAS_3D_NODE_TYPE_MESH) { Eina_Iterator *itr; void *ptr; /* Transform ray into local coordinate space. */ - evas_mat4_multiply(&mvp, &pick->matrix_vp, &node->data.mesh.matrix_local_to_world); + evas_mat4_multiply(&mvp, &pick->matrix_vp, &pd_node->data.mesh.matrix_local_to_world); evas_ray3_init(&ray, pick->x, pick->y, &mvp); - itr = eina_hash_iterator_data_new(node->data.mesh.node_meshes); + itr = eina_hash_iterator_data_new(pd_node->data.mesh.node_meshes); while (eina_iterator_next(itr, &ptr)) { @@ -578,16 +592,16 @@ _node_pick(Evas_3D_Node *node, void *data) return EINA_TRUE; } -EAPI Eina_Bool -evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y, +EOLIAN static Eina_Bool +_eo_evas_3d_scene_pick(Eo *obj EINA_UNUSED, Evas_3D_Scene_Data *pd, Evas_Real x, Evas_Real y, Evas_3D_Node **node, Evas_3D_Mesh **mesh, Evas_Real *s, Evas_Real *t) { /* TODO: Use H/W picking if availabe. */ Evas_3D_Pick_Data data; - data.x = ((x * 2.0) / (Evas_Real)scene->w) - 1.0; - data.y = (((scene->h - y - 1) * 2.0) / ((Evas_Real)scene->h)) - 1.0; + data.x = ((x * 2.0) / (Evas_Real)pd->w) - 1.0; + data.y = (((pd->h - y - 1) * 2.0) / ((Evas_Real)pd->h)) - 1.0; data.picked = EINA_FALSE; data.z = 1.0; @@ -597,17 +611,18 @@ evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y, data.t = 0.0; /* Update the scene graph. */ - evas_3d_object_update((Evas_3D_Object *)&scene->base); - + evas_3d_object_update((Evas_3D_Object *)&pd->base); + Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(pd->camera_node, EO_EVAS_3D_NODE_CLASS); + Evas_3D_Camera_Data *pd_camera = eo_data_scope_get(pd_camera_node->data.camera.camera, EO_EVAS_3D_CAMERA_CLASS); evas_mat4_multiply(&data.matrix_vp, - &scene->camera_node->data.camera.camera->projection, - &scene->camera_node->data.camera.matrix_world_to_eye); + &pd_camera->projection, + &pd_camera_node->data.camera.matrix_world_to_eye); evas_ray3_init(&data.ray_world, data.x, data.y, &data.matrix_vp); /* Traverse tree while adding meshes into pick data structure. */ - evas_3d_node_tree_traverse(scene->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE, + evas_3d_node_tree_traverse(pd->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE, _node_pick, &data); if (!data.picked) @@ -620,3 +635,5 @@ evas_3d_scene_pick(const Evas_3D_Scene *scene, Evas_Real x, Evas_Real y, return EINA_TRUE; } + +#include "canvas/evas_3d_scene.eo.c" \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_3d_scene.eo b/src/lib/evas/canvas/evas_3d_scene.eo new file mode 100755 index 0000000..887ff38 --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_scene.eo @@ -0,0 +1,145 @@ +class EO_Evas_3D_Scene (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_scene; + data: Evas_3D_Scene_Data; + methods { + size_set { + /* + Set the resolution of a scene. + + A scene should be rendered to be displayed through an image objects. The + resolution defines size of the internal surface holding the rendered result. + + @ingroup Evas_3D_Scene + */ + params { + @in int w; /*@ Width of the resolution. */ + @in int h; /*@ Height of the resolution. */ + } + } + + size_get { + /* + Get the internal resolution of a scene. + + @ingroup Evas_3D_Scene + */ + const; + params { + @out int w; /*@ Pointer to receive width of the resolution. */ + @out int h; /*@ Pointer to receive height of the resolution. */ + } + } + + background_color_set { + /* + Set the background color of a scene. + + Background color defines initial color of pixels before a scene is rendered. + If you want to display a scene with background evas objects are still + remaining as if it was the background, set the alpha term to 0.0. + + Default background color is (0.0, 0.0, 0.0, 0.0). + + @ingroup Evas_3D_Scene + */ + params { + @in Evas_Real r; /*@ Red component of the background color. */ + @in Evas_Real g; /*@ Green component of the background color. */ + @in Evas_Real b; /*@ Blue component of the background color. */ + @in Evas_Real a; /*@ Alpha component of the background color. */ + } + } + + background_color_get { + /* + Get the background color of a scene. + + @ingroup Evas_3D_Scene + */ + + const; + params { + @out Evas_Real r; /*@ Pointer to receive red component of the background color.*/ + @out Evas_Real g; /*@ Pointer to receive green component of the background color. */ + @out Evas_Real b; /*@ Pointer to receive blue component of the background color. */ + @out Evas_Real a; /*@ Pointer to receive alpha component of the background color. */ + } + } + + pick { + /* + Get information on the most front visible mesh for the given position. + + (x, y) is the screen coordinate of the given scene. That is, left-top is + (0, 0) and right-bottom is (w, h) where (w, h) is the size of the scene. + The texture coordinate is useful when using proxy texture source. + + @ingroup Evas_3D_Scene + */ + const; + return Eina_Bool ; + params { + @in Evas_Real x; /*@ X coordinate of the picking position. */ + @in Evas_Real y; /*@ Y coordinate of the picking position. */ + @out Evas_3D_Node *node; /*@ Pointer to receive the node contains the picked mesh. */ + @out Evas_3D_Mesh *mesh; /*@ Pointer to receive the picked mesh. */ + @out Evas_Real s; /*@ Pointer to receive the texture "s" coordinate. */ + @out Evas_Real t; /*@ Pointer to receive the texture "t" coordinate. */ + } + } + + } + properties { + + root_node { + set { + /* + Set the root node of a scene. + + @ingroup Evas_3D_Scene + */ + } + get { + /* + Get the root node of a scene. + + @return The root node of the given scene. + + @ingroup Evas_3D_Scene + */ + } + values { + Evas_3D_Node *node; /*@ A node which will be used as a root node for the scene. */ + } + } + + camera_node { + set { + /* + Set the camera node of a scene. + + @ingroup Evas_3D_Scene + */ + } + get { + /* + Get the camera node of a scene. + + @return The camera node of the given scene. + + @ingroup Evas_3D_Scene + */ + } + values { + Evas_3D_Node *node; /*@ A node which will be used as a camera node for the scene. */ + } + } + } + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } + +} diff --git a/src/lib/evas/canvas/evas_3d_texture.c b/src/lib/evas/canvas/evas_3d_texture.c index 3b075e7..1805091 100644 --- a/src/lib/evas/canvas/evas_3d_texture.c +++ b/src/lib/evas/canvas/evas_3d_texture.c @@ -6,21 +6,26 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "Eo.h" + +#define MY_CLASS EO_EVAS_3D_TEXTURE_CLASS + static inline void _texture_proxy_set(Evas_3D_Texture *texture, Evas_Object *eo_src, Evas_Object_Protected_Data *src) { + Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, MY_CLASS); EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, src->proxy, Evas_Object_Proxy_Data, proxy_src) { - proxy_src->proxy_textures = eina_list_append(proxy_src->proxy_textures, texture); + proxy_src->proxy_textures = eina_list_append(proxy_src->proxy_textures, pd); proxy_src->redraw = EINA_TRUE; } EINA_COW_WRITE_END(evas_object_proxy_cow, src->proxy, proxy_src); - texture->source = eo_src; + pd->source = eo_src; } static inline void -_texture_proxy_unset(Evas_3D_Texture *texture) +_texture_proxy_unset(Evas_3D_Texture_Data *texture) { Evas_Object_Protected_Data *src = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS); @@ -53,7 +58,7 @@ _texture_proxy_unset(Evas_3D_Texture *texture) } static inline void -_texture_proxy_subrender(Evas_3D_Texture *texture) +_texture_proxy_subrender(Evas_3D_Texture_Data *texture) { /* Code taken from _proxy_subrender() in file evas_object_image.c */ @@ -160,7 +165,7 @@ _texture_proxy_subrender(Evas_3D_Texture *texture) } static void -_texture_fini(Evas_3D_Texture *texture) +_texture_fini(Evas_3D_Texture_Data *texture) { if (texture->engine_data) { @@ -184,10 +189,10 @@ _texture_fini(Evas_3D_Texture *texture) static void _texture_free(Evas_3D_Object *obj) { - Evas_3D_Texture *texture = (Evas_3D_Texture *)obj; + Evas_3D_Texture_Data *texture = (Evas_3D_Texture_Data *)obj; _texture_fini(texture); - free(texture); + //free(texture); } static Eina_Bool @@ -195,7 +200,8 @@ _texture_material_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *k void *data EINA_UNUSED, void *fdata) { Evas_3D_Material *m = *(Evas_3D_Material **)key; - evas_3d_object_change(&m->base, EVAS_3D_STATE_MATERIAL_TEXTURE, (Evas_3D_Object *)fdata); + Evas_3D_Material_Data *pdm = eo_data_scope_get(m, EO_EVAS_3D_MATERIAL_CLASS); + evas_3d_object_change(&pdm->base, EVAS_3D_STATE_MATERIAL_TEXTURE, (Evas_3D_Object *)fdata); return EINA_TRUE; } @@ -203,7 +209,7 @@ static void _texture_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, Evas_3D_Object *ref EINA_UNUSED) { - Evas_3D_Texture *texture = (Evas_3D_Texture *)obj; + Evas_3D_Texture_Data *texture = (Evas_3D_Texture_Data *)obj; if (texture->materials) eina_hash_foreach(texture->materials, _texture_material_change_notify, obj); @@ -212,7 +218,7 @@ _texture_change(Evas_3D_Object *obj, Evas_3D_State state EINA_UNUSED, static void _texture_update(Evas_3D_Object *obj) { - Evas_3D_Texture *texture = (Evas_3D_Texture *)obj; + Evas_3D_Texture_Data *texture = (Evas_3D_Texture_Data *)obj; if (texture->source) { @@ -258,119 +264,135 @@ void evas_3d_texture_material_add(Evas_3D_Texture *texture, Evas_3D_Material *material) { int count = 0; - - if (texture->materials == NULL) + Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, MY_CLASS); + if (pd->materials == NULL) { - texture->materials = eina_hash_pointer_new(NULL); + pd->materials = eina_hash_pointer_new(NULL); - if (texture->materials == NULL) + if (pd->materials == NULL) { ERR("Failed to create hash table."); return; } } else - count = (int)eina_hash_find(texture->materials, &material); + count = (int)eina_hash_find(pd->materials, &material); /* Increase reference count or add new one if not exist. */ - eina_hash_set(texture->materials, &material, (const void *)(count + 1)); + eina_hash_set(pd->materials, &material, (const void *)(count + 1)); } void evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *material) { int count = 0; - - if (texture->materials == NULL) + Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, MY_CLASS); + if (pd->materials == NULL) { ERR("No material to delete."); return; } - count = (int)eina_hash_find(texture->materials, &material); + count = (int)eina_hash_find(pd->materials, &material); if (count == 1) - eina_hash_del(texture->materials, &material, NULL); + eina_hash_del(pd->materials, &material, NULL); else - eina_hash_set(texture->materials, &material, (const void *)(count - 1)); + eina_hash_set(pd->materials, &material, (const void *)(count - 1)); } -Evas_3D_Texture * -evas_3d_texture_new(Evas *e) -{ - Evas_3D_Texture *texture = NULL; +// Evas_3D_Texture * +// evas_3d_texture_new(Evas *e) +// { +// Evas_3D_Texture *texture = NULL; - texture = (Evas_3D_Texture *)calloc(1, sizeof(Evas_3D_Texture)); +// texture = (Evas_3D_Texture *)calloc(1, sizeof(Evas_3D_Texture_Data)); - if (texture == NULL) - { - ERR("Failed to allocate memory."); - return NULL; - } +// if (texture == NULL) +// { +// ERR("Failed to allocate memory."); +// return NULL; +// } - evas_3d_object_init(&texture->base, e, EVAS_3D_OBJECT_TYPE_TEXTURE, &texture_func); - return texture; -} +// evas_3d_object_init(&texture->base, e, EVAS_3D_OBJECT_TYPE_TEXTURE, &texture_func); +// return texture; +// } EAPI Evas_3D_Texture * evas_3d_texture_add(Evas *e) { - return evas_3d_texture_new(e); + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + eo_unref(eo_obj); + return eo_obj; + //return evas_3d_texture_new(e); } -EAPI void -evas_3d_texture_del(Evas_3D_Texture *texture) + +EOLIAN static void +_eo_evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd) { - evas_3d_object_unreference(&texture->base); + Eo *e; + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, e = eo_parent_get()); + evas_3d_object_init(&pd->base, e, EVAS_3D_OBJECT_TYPE_CAMERA, &texture_func); } -EAPI Evas * -evas_3d_texture_evas_get(const Evas_3D_Texture *texture) +EOLIAN static void +_eo_evas_3d_texture_eo_base_destructor(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) { - return texture->base.evas; + evas_3d_object_unreference(&pd->base); } -EAPI void -evas_3d_texture_data_set(Evas_3D_Texture *texture, Evas_3D_Color_Format color_format, - Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data) +EOLIAN static Evas * +_eo_evas_3d_texture_evas_common_interface_evas_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); + return pd->base.evas; +} + +EOLIAN static void +_eo_evas_3d_texture_data_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Color_Format color_format, + Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data) +{ + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); - if (texture->engine_data == NULL) - texture->engine_data = e->engine.func->texture_new(e->engine.data.output); + if (pd->engine_data == NULL) + pd->engine_data = e->engine.func->texture_new(e->engine.data.output); - e->engine.func->texture_data_set(e->engine.data.output, texture->engine_data, + e->engine.func->texture_data_set(e->engine.data.output, pd->engine_data, color_format, pixel_format, w, h, data); - evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); } -EAPI void -evas_3d_texture_file_set(Evas_3D_Texture *texture, const char *file, const char *key) +EOLIAN static void +_eo_evas_3d_texture_file_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, const char *file, const char *key) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); - if (texture->engine_data == NULL) - texture->engine_data = e->engine.func->texture_new(e->engine.data.output); + if (pd->engine_data == NULL) + pd->engine_data = e->engine.func->texture_new(e->engine.data.output); - e->engine.func->texture_file_set(e->engine.data.output, texture->engine_data, file, key); - evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); + e->engine.func->texture_file_set(e->engine.data.output, pd->engine_data, file, key); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); } EAPI void -evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source) +_eo_evas_3d_texture_source_set(Eo *obj , Evas_3D_Texture_Data *pd, Evas_Object *source) { Evas_Object_Protected_Data *src; - if (source == texture->source) + if (source == pd->source) return; - _texture_fini(texture); + _texture_fini(pd); if (source == NULL) return; - if (evas_object_evas_get(source) != texture->base.evas) + if (evas_object_evas_get(source) != pd->base.evas) { ERR("Not matching canvas."); return; @@ -390,19 +412,19 @@ evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source) return; } - _texture_proxy_set(texture, source, src); - evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); + _texture_proxy_set(obj, source, src); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); } -EAPI void -evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible) +EOLIAN static void +_eo_evas_3d_texture_source_visible_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Eina_Bool visible) { Evas_Object_Protected_Data *src_obj; - if (texture->source == NULL) + if (pd->source == NULL) return; - src_obj = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS); + src_obj = eo_data_scope_get(pd->source, EVAS_OBJ_CLASS); if (src_obj->proxy->src_invisible == !visible) return; @@ -412,69 +434,66 @@ evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible) EINA_COW_WRITE_END(evas_object_proxy_cow, src_obj->proxy, proxy_write); src_obj->changed_src_visible = EINA_TRUE; - evas_object_smart_member_cache_invalidate(texture->source, EINA_FALSE, EINA_FALSE, EINA_TRUE); - evas_object_change(texture->source, src_obj); + evas_object_smart_member_cache_invalidate(pd->source, EINA_FALSE, EINA_FALSE, EINA_TRUE); + evas_object_change(pd->source, src_obj); } -EAPI Eina_Bool -evas_3d_texture_source_visible_get(const Evas_3D_Texture *texture) +EOLIAN static Eina_Bool +_eo_evas_3d_texture_source_visible_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) { Evas_Object_Protected_Data *src_obj; - if (texture->source == NULL) + if (pd->source == NULL) return EINA_FALSE; - src_obj = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS); + src_obj = eo_data_scope_get(pd->source, EVAS_OBJ_CLASS); return !src_obj->proxy->src_invisible; } -EAPI Evas_3D_Color_Format -evas_3d_texture_color_format_get(const Evas_3D_Texture *texture) +EOLIAN static Evas_3D_Color_Format +_eo_evas_3d_texture_color_format_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); Evas_3D_Color_Format format; - - e->engine.func->texture_color_format_get(e->engine.data.output, texture->engine_data, &format); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); + e->engine.func->texture_color_format_get(e->engine.data.output, pd->engine_data, &format); return format; } -EAPI void -evas_3d_texture_size_get(const Evas_3D_Texture *texture, int *w, int *h) +EOLIAN static void +_eo_evas_3d_texture_size_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, int *w, int *h) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); - e->engine.func->texture_size_get(e->engine.data.output, texture->engine_data, w, h); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); + e->engine.func->texture_size_get(e->engine.data.output, pd->engine_data, w, h); } -EAPI void -evas_3d_texture_wrap_set(Evas_3D_Texture *texture, - Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t) +EOLIAN static void +_eo_evas_3d_texture_wrap_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); - e->engine.func->texture_wrap_set(e->engine.data.output, texture->engine_data, s, t); - evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_WRAP, NULL); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); + e->engine.func->texture_wrap_set(e->engine.data.output, pd->engine_data, s, t); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_WRAP, NULL); } -EAPI void -evas_3d_texture_wrap_get(const Evas_3D_Texture *texture, - Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t) +EOLIAN static void +_eo_evas_3d_texture_wrap_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); - e->engine.func->texture_wrap_get(e->engine.data.output, texture->engine_data, s, t); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); + e->engine.func->texture_wrap_get(e->engine.data.output, pd->engine_data, s, t); } -EAPI void -evas_3d_texture_filter_set(Evas_3D_Texture *texture, - Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag) +EOLIAN static void +_eo_evas_3d_texture_filter_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); - e->engine.func->texture_filter_set(e->engine.data.output, texture->engine_data, min, mag); - evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_FILTER, NULL); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); + e->engine.func->texture_filter_set(e->engine.data.output, pd->engine_data, min, mag); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_FILTER, NULL); } -EAPI void -evas_3d_texture_filter_get(const Evas_3D_Texture *texture, - Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag) +EOLIAN static void +_eo_evas_3d_texture_filter_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag) { - Evas_Public_Data *e = eo_data_scope_get(texture->base.evas, EVAS_CLASS); - e->engine.func->texture_filter_get(e->engine.data.output, texture->engine_data, min, mag); + Evas_Public_Data *e = eo_data_scope_get(pd->base.evas, EVAS_CLASS); + e->engine.func->texture_filter_get(e->engine.data.output, pd->engine_data, min, mag); } + +#include "canvas/evas_3d_texture.eo.c" \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_3d_texture.eo b/src/lib/evas/canvas/evas_3d_texture.eo new file mode 100755 index 0000000..5e55eca --- /dev/null +++ b/src/lib/evas/canvas/evas_3d_texture.eo @@ -0,0 +1,199 @@ +class EO_Evas_3D_Texture (Eo_Base, Evas_Common_Interface) +{ + legacy_prefix: evas_3d_texture; + data : Evas_3D_Texture_Data; + properties { + source_visible { + set { + /* + Set the visibility flag of the source evas object of the given texture. + + Recommend to call evas_object_show() on the source object and controll the + visibility using this function. + + By default, source object is visible. + + @see evas_3d_texture_source_set() + + @ingroup Evas_3D_Texture + */ + } + get { + /* + Get the visibility flag of the source evas object of the given texture. + + @see evas_3d_texture_source_visible_set() + + @ingroup Evas_3D_Texture + */ + } + values { + Eina_Bool visible; /*@ @c EINA_TRUE for visible, @c EINA_FALSE for invisible.*/ + } + } + } + methods { + data_set { + /* + Set the data of the given texture. + + @see evas_3d_texture_file_set() + + @ingroup Evas_3D_Texture + */ + + params { + @in Evas_3D_Color_Format color_format; /*@ Color format of the texture. */ + @in Evas_3D_Pixel_Format pixel_format; /*@ Pixel format of the data. */ + @in int w; /*@ Width of the data. */ + @in int h; /*@ Height of the data. */ + @in const void *data; /*@ Pointer to the data. */ + } + } + + file_set { + /* + Set the data of the given texture from file. + + Only PNG format is supported. + + @ingroup Evas_3D_Texture + */ + + return void ; + params { + @in const char *file; /*@ Path to the image file. */ + @in const char *key; /*@ Key in the image file. */ + } + } + + source_set { + /* + Set the data of the given texture from an evas object. + + Evas 3D support using existing evas object as a texture source. This feature + make it possible using any exisiting evas object inside 3D scene. + + @see evas_3d_texture_source_visible_set + + @ingroup Evas_3D_Texture + */ + + return void ; + params { + @in Evas_Object *source; /*@ Source evas object to be used as the texture data. */ + } + } + + color_format_get { + /* + Get the color format of the given texture. + + EVAS_3D_COLOR_FORMAT_RGBA will be returned if the texture has source object. + Otherwise, the color format of the data will be returned. + + @see evas_3d_texture_data_set() + @see evas_3d_texture_file_set() + @see evas_3d_texture_source_set() + + @ingroup Evas_3D_Texture + */ + const; + return Evas_3D_Color_Format ; + } + + size_get { + /* + Get the size of the given texture. + + If the texture has source object, the size of the source object will be + returned. Otherwise, the size of the data (or image file) will be returned. + + @see evas_3d_texture_data_set() + @see evas_3d_texture_file_set() + @see evas_3d_texture_source_set() + + @ingroup Evas_3D_Texture + */ + const; + params { + @out int w; /*@ Pointer to receive the width of the texture size. */ + @out int h; /*@ Pointer to receive the height of the texture size. */ + } + } + + wrap_set { + /* + Set the wrap mode of the given texture. + If the texture coordinate exceed range [0.0, 1.0] the values are modified + according to the wrap mode. + + Default wrap modes are both EVAS_3D_WRAP_MODE_CLAMP for s and t. + + @ingroup Evas_3D_Texture + */ + params { + @in Evas_3D_Wrap_Mode s; /*@ Wrap mode for S-axis. */ + @in Evas_3D_Wrap_Mode t; /*@ Wrap mode for T-axis. */ + } + } + + wrap_get { + /* + Get the wrap mode of the given texture. + + @see evas_3d_texture_wrap_set() + + @ingroup Evas_3D_Texture + */ + + return void ; + params { + @out Evas_3D_Wrap_Mode s; /*@ Pointer to receive S-axis wrap mode. */ + @out Evas_3D_Wrap_Mode t; /*@ Pointer to receive T-axis wrap mode. */ + } + } + + filter_set { + /* + Set the filter of the given texture. + + Default filters are both EVAS_3D_TEXTURE_FILTER_NEAREST for s and t. + + @ingroup Evas_3D_Texture + */ + + params { + @in Evas_3D_Texture_Filter min; /*@ Minification filter used when down-scaling. */ + @in Evas_3D_Texture_Filter mag; /*@ Magnification filter used when up-scaling. */ + } + } + + filter_get { + /* + Get the filter of the given texture. + + @param texture The given texture. + @param min Pointer to receive the minification filter. + @param mag Pointer to receive the magnification filter. + + @see evas_3d_texture_filter_set() + + @ingroup Evas_3D_Texture + */ + + const; + params { + @out Evas_3D_Texture_Filter min; /*@ Pointer to receive the minification filter. */ + @out Evas_3D_Texture_Filter mag; /*@ Pointer to receive the magnification filter. */ + } + } + } + + implements { + Eo_Base::constructor; + Eo_Base::destructor; + Evas_Common_Interface::evas::get; + } + +} diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index ea9f45c..7d406e5 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -442,7 +442,7 @@ _image_init_set(const Eina_File *f, const char *file, const char *key, } EINA_COW_WRITE_END(evas_object_image_state_cow, o->prev, state_write); } - + if (o->engine_data) { if (o->preloading) @@ -1371,7 +1371,7 @@ _evas_image_data_update_add(Eo *eo_obj, Evas_Image_Data *o, int x, int y, int w, if (r) pixi_write->pixel_updates = eina_list_append(pixi_write->pixel_updates, r); EINA_COW_PIXEL_WRITE_END(o, pixi_write); } - + o->changed = EINA_TRUE; Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); evas_object_change(eo_obj, obj); @@ -2421,6 +2421,7 @@ _3d_set(Evas_Object *eo_obj, Evas_3D_Scene *scene) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); Evas_Image_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); + Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(scene, EO_EVAS_3D_SCENE_CLASS); evas_object_image_file_set(eo_obj, NULL, NULL); @@ -2429,7 +2430,7 @@ _3d_set(Evas_Object *eo_obj, Evas_3D_Scene *scene) data->surface = NULL; data->w = 0; data->h = 0; - evas_3d_object_reference(&scene->base); + evas_3d_object_reference(&pd_scene->base); } EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); @@ -2439,7 +2440,7 @@ _3d_set(Evas_Object *eo_obj, Evas_3D_Scene *scene) } EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); - scene->images = eina_list_append(scene->images, eo_obj); + pd_scene->images = eina_list_append(pd_scene->images, eo_obj); } static void @@ -2449,9 +2450,11 @@ _3d_unset(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas if (o->cur->scene) { + Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(o->cur->scene, EO_EVAS_3D_SCENE_CLASS); EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) - o->cur->scene->images = eina_list_remove(o->cur->scene->images, eo_obj); - evas_3d_object_unreference(&state_write->scene->base); + pd_scene->images = eina_list_remove(pd_scene->images, eo_obj); + Evas_3D_Scene_Data *pd_scene_state_write = eo_data_scope_get(state_write->scene, EO_EVAS_3D_SCENE_CLASS); + evas_3d_object_unreference(&pd_scene_state_write->base); state_write->scene = NULL; EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); } @@ -2487,35 +2490,36 @@ _3d_render(Evas *eo_e, Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Da { Evas_Public_Data *e; Eina_Bool need_native_set = EINA_FALSE; - Evas_3D_Scene_Data scene_data; + Evas_3D_Scene_Public_Data scene_data; if (scene == NULL) return; + Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(scene, EO_EVAS_3D_SCENE_CLASS); - if((scene->w == 0) || (scene->h == 0)) + if((pd_scene->w == 0) || (pd_scene->h == 0)) return; e = eo_data_scope_get(eo_e, EVAS_CLASS); - if (scene->surface != NULL) + if (pd_scene->surface != NULL) { int w, h; - e->engine.func->drawable_size_get(e->engine.data.output, scene->surface, &w, &h); + e->engine.func->drawable_size_get(e->engine.data.output, pd_scene->surface, &w, &h); - if ((w != scene->w) || (h != scene->h)) + if ((w != pd_scene->w) || (h != pd_scene->h)) { - e->engine.func->drawable_free(e->engine.data.output, scene->surface); - scene->surface = NULL; + e->engine.func->drawable_free(e->engine.data.output, pd_scene->surface); + pd_scene->surface = NULL; need_native_set = EINA_TRUE; } } - if (scene->surface == NULL) + if (pd_scene->surface == NULL) { /* TODO: Hard-coded alpha on. */ - scene->surface = e->engine.func->drawable_new(e->engine.data.output, - scene->w, scene->h, 1); + pd_scene->surface = e->engine.func->drawable_new(e->engine.data.output, + pd_scene->w, pd_scene->h, 1); need_native_set = EINA_TRUE; } @@ -2524,32 +2528,32 @@ _3d_render(Evas *eo_e, Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Da if (need_native_set) { data->surface = e->engine.func->image_drawable_set(e->engine.data.output, - data->surface, scene->surface); + data->surface, pd_scene->surface); } - data->w = scene->w; - data->h = scene->h; + data->w = pd_scene->w; + data->h = pd_scene->h; } EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); evas_3d_scene_data_init(&scene_data); - scene_data.bg_color = scene->bg_color; - scene_data.camera_node = scene->camera_node; + scene_data.bg_color = pd_scene->bg_color; + scene_data.camera_node = pd_scene->camera_node; /* Phase 1 - Update scene graph tree. */ - evas_3d_object_update(&scene->base); + evas_3d_object_update(&pd_scene->base); /* Phase 2 - Do frustum culling and get visible model nodes. */ - evas_3d_node_tree_traverse(scene->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE, + evas_3d_node_tree_traverse(pd_scene->root_node, EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE, evas_3d_node_mesh_collect, &scene_data); /* Phase 3 - Collect active light nodes in the scene graph tree. */ - evas_3d_node_tree_traverse(scene->root_node, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, + evas_3d_node_tree_traverse(pd_scene->root_node, EVAS_3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, evas_3d_node_light_collect, &scene_data); /* Phase 5 - Draw the scene. */ - e->engine.func->drawable_scene_render(e->engine.data.output, scene->surface, &scene_data); + e->engine.func->drawable_scene_render(e->engine.data.output, pd_scene->surface, &scene_data); /* Clean up temporary resources. */ evas_3d_scene_data_fini(&scene_data); @@ -2900,17 +2904,17 @@ evas_process_dirty_pixels(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, (direct_override)) && (!direct_force_off) ) { - + if (obj->layer->evas->engine.func->gl_get_pixels_set) { obj->layer->evas->engine.func->gl_get_pixels_set(output, o->pixels->func.get_pixels, o->pixels->func.get_pixels_data, eo_obj); } - + o->direct_render = EINA_TRUE; } else o->direct_render = EINA_FALSE; - + } if ( (ns) && @@ -2924,7 +2928,7 @@ evas_process_dirty_pixels(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, x = obj->cur->geometry.x; y = obj->cur->geometry.y; w = obj->cur->geometry.w; - h = obj->cur->geometry.h; + h = obj->cur->geometry.h; if (!o->direct_render) o->pixels->func.get_pixels(o->pixels->func.get_pixels_data, eo_obj); @@ -3371,8 +3375,8 @@ evas_object_image_render_pre(Evas_Object *eo_obj, else if (o->cur->scene) { Evas_3D_Scene *scene = o->cur->scene; - - if (evas_3d_object_dirty_get(&scene->base, EVAS_3D_STATE_ANY)) + Evas_3D_Scene_Data *pd_scene = eo_data_scope_get(scene, EO_EVAS_3D_SCENE_CLASS); + if (evas_3d_object_dirty_get(&pd_scene->base, EVAS_3D_STATE_ANY)) { evas_object_render_pre_prev_cur_add(&e->clip_changes, eo_obj, obj); goto done; @@ -4181,7 +4185,7 @@ evas_object_image_is_inside(Evas_Object *eo_obj, break; } // | - // .## + // .## inx = bl; iny = imh - bb; inw = imw - bl - br; inh = bb; outx = ox + bsl; outy = oy + ih - bsb; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index d6809f7..94b4a26 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -246,7 +246,8 @@ evas_object_change(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) } EINA_LIST_FOREACH(obj->proxy->proxy_textures, l, texture) { - evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); + Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, EO_EVAS_3D_TEXTURE_CLASS); + evas_3d_object_change(&pd->base, EVAS_3D_STATE_TEXTURE_DATA, NULL); } if (obj->smart.parent) { diff --git a/src/lib/evas/include/evas_3d_private.h b/src/lib/evas/include/evas_3d_private.h index e30dacf..9e5f5f8 100644 --- a/src/lib/evas/include/evas_3d_private.h +++ b/src/lib/evas/include/evas_3d_private.h @@ -1,377 +1,7 @@ -#ifndef EVAS_PRIVATE_H -# error You shall not include this header directly -#endif -#include "Evas_3D.h" -#include "evas_3d_utils.h" -#define EVAS_3D_VERTEX_ATTRIB_COUNT 5 -#define EVAS_3D_MATERIAL_ATTRIB_COUNT 5 -typedef struct _Evas_3D_Object Evas_3D_Object; -typedef struct _Evas_3D_Scene_Data Evas_3D_Scene_Data; -typedef struct _Evas_3D_Vertex_Buffer Evas_3D_Vertex_Buffer; -typedef struct _Evas_3D_Mesh_Frame Evas_3D_Mesh_Frame; -typedef struct _Evas_3D_Node_Mesh Evas_3D_Node_Mesh; -typedef struct _Evas_3D_Object_Func Evas_3D_Object_Func; -typedef struct _Evas_3D_Pick_Data Evas_3D_Pick_Data; -typedef struct _Evas_3D_Interpolate_Vertex_Buffer Evas_3D_Interpolate_Vertex_Buffer; -typedef Eina_Bool (*Evas_3D_Node_Func)(Evas_3D_Node *, void *data); -typedef enum _Evas_3D_Object_Type -{ - EVAS_3D_OBJECT_TYPE_INVALID = 0, - EVAS_3D_OBJECT_TYPE_SCENE, - EVAS_3D_OBJECT_TYPE_NODE, - EVAS_3D_OBJECT_TYPE_CAMERA, - EVAS_3D_OBJECT_TYPE_LIGHT, - EVAS_3D_OBJECT_TYPE_MODEL, - EVAS_3D_OBJECT_TYPE_MESH, - EVAS_3D_OBJECT_TYPE_TEXTURE, - EVAS_3D_OBJECT_TYPE_MATERIAL, -} Evas_3D_Object_Type; -typedef enum _Evas_3D_State -{ - EVAS_3D_STATE_MAX = 16, - EVAS_3D_STATE_ANY = 0, - - EVAS_3D_STATE_SCENE_ROOT_NODE = 1, - EVAS_3D_STATE_SCENE_CAMERA_NODE, - EVAS_3D_STATE_SCENE_BACKGROUND_COLOR, - EVAS_3D_STATE_SCENE_SIZE, - - EVAS_3D_STATE_TEXTURE_DATA = 1, - EVAS_3D_STATE_TEXTURE_WRAP, - EVAS_3D_STATE_TEXTURE_FILTER, - - EVAS_3D_STATE_MATERIAL_ID = 1, - EVAS_3D_STATE_MATERIAL_COLOR, - EVAS_3D_STATE_MATERIAL_TEXTURE, - - EVAS_3D_STATE_MESH_VERTEX_COUNT = 1, - EVAS_3D_STATE_MESH_FRAME, - EVAS_3D_STATE_MESH_MATERIAL, - EVAS_3D_STATE_MESH_TRANSFORM, - EVAS_3D_STATE_MESH_VERTEX_DATA, - EVAS_3D_STATE_MESH_INDEX_DATA, - EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY, - EVAS_3D_STATE_MESH_SHADE_MODE, - - EVAS_3D_STATE_CAMERA_PROJECTION = 1, - - EVAS_3D_STATE_LIGHT_AMBIENT = 1, - EVAS_3D_STATE_LIGHT_DIFFUSE, - EVAS_3D_STATE_LIGHT_SPECULAR, - EVAS_3D_STATE_LIGHT_SPOT_DIR, - EVAS_3D_STATE_LIGHT_SPOT_EXP, - EVAS_3D_STATE_LIGHT_SPOT_CUTOFF, - EVAS_3D_STATE_LIGHT_ATTENUATION, - - EVAS_3D_STATE_NODE_TRANSFORM = 1, - EVAS_3D_STATE_NODE_MESH_GEOMETRY, - EVAS_3D_STATE_NODE_MESH_MATERIAL, - EVAS_3D_STATE_NODE_MESH_FRAME, - EVAS_3D_STATE_NODE_MESH_SHADE_MODE, - EVAS_3D_STATE_NODE_MESH_MATERIAL_ID, - EVAS_3D_STATE_NODE_LIGHT, - EVAS_3D_STATE_NODE_CAMERA, - EVAS_3D_STATE_NODE_PARENT, - EVAS_3D_STATE_NODE_MEMBER, -} Evas_3D_State; - -typedef enum _Evas_3D_Node_Traverse_Type -{ - EVAS_3D_NODE_TRAVERSE_DOWNWARD, - EVAS_3D_NODE_TRAVERSE_UPWARD, -} Evas_3D_Node_Traverse_Type; - -typedef enum _Evas_3D_Tree_Traverse_Type -{ - EVAS_3D_TREE_TRAVERSE_PRE_ORDER, - EVAS_3D_TREE_TRAVERSE_ANY_ORDER = EVAS_3D_TREE_TRAVERSE_PRE_ORDER, - EVAS_3D_TREE_TRAVERSE_POST_ORDER, - EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, -} Evas_3D_Tree_Traverse_Type; - -struct _Evas_3D_Object_Func -{ - void (*free)(Evas_3D_Object *obj); - void (*change)(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref); - void (*update)(Evas_3D_Object *obj); -}; - -struct _Evas_3D_Object -{ - Evas *evas; - - Evas_3D_Object_Type type; - int ref_count; - Evas_3D_Object_Func func; - - Eina_Bool dirty[EVAS_3D_STATE_MAX]; -}; - -struct _Evas_3D_Scene -{ - Evas_3D_Object base; - - Evas_3D_Node *root_node; - Evas_3D_Node *camera_node; - Evas_Color bg_color; - - void *surface; - int w, h; - Eina_List *images; -}; - -struct _Evas_3D_Node_Mesh -{ - Evas_3D_Node *node; - Evas_3D_Mesh *mesh; - int frame; -}; - -struct _Evas_3D_Node -{ - Evas_3D_Object base; - - Eina_List *members; - Evas_3D_Node *parent; - - Evas_Vec3 position; - Evas_Vec4 orientation; - Evas_Vec3 scale; - - Evas_Vec3 position_world; - Evas_Vec4 orientation_world; - Evas_Vec3 scale_world; - - Eina_Bool position_inherit; - Eina_Bool orientation_inherit; - Eina_Bool scale_inherit; - - Evas_Box3 aabb; - - Evas_3D_Node_Type type; - - /* Camera node. */ - union { - struct { - Evas_3D_Camera *camera; - Evas_Mat4 matrix_world_to_eye; - } camera; - - struct { - Evas_3D_Light *light; - Evas_Mat4 matrix_local_to_world; - } light; - - struct { - Eina_List *meshes; - Eina_Hash *node_meshes; - Evas_Mat4 matrix_local_to_world; - } mesh; - } data; - - /* Scene using this node as root. */ - Eina_Hash *scenes_root; - - /* Scene using this node as camera. */ - Eina_Hash *scenes_camera; -}; - -struct _Evas_3D_Camera -{ - Evas_3D_Object base; - - Evas_Mat4 projection; - Eina_Hash *nodes; -}; - -struct _Evas_3D_Light -{ - Evas_3D_Object base; - - Evas_Color ambient; - Evas_Color diffuse; - Evas_Color specular; - - Eina_Bool directional; - Evas_Real spot_exp; - Evas_Real spot_cutoff; - Evas_Real spot_cutoff_cos; - - Eina_Bool enable_attenuation; - Evas_Real atten_const; - Evas_Real atten_linear; - Evas_Real atten_quad; - - Eina_Hash *nodes; -}; - -struct _Evas_3D_Vertex_Buffer -{ - int element_count; - int stride; - void *data; - int size; - Eina_Bool owns_data; - Eina_Bool mapped; -}; - -struct _Evas_3D_Interpolate_Vertex_Buffer -{ - void *data0; - int stride0; - int size0; - - void *data1; - int stride1; - int size1; - - Evas_Real weight; -}; - -struct _Evas_3D_Mesh_Frame -{ - Evas_3D_Mesh *mesh; - - int frame; - Evas_3D_Material *material; - Evas_Box3 aabb; - - Evas_3D_Vertex_Buffer vertices[EVAS_3D_VERTEX_ATTRIB_COUNT]; -}; - -struct _Evas_3D_Mesh -{ - Evas_3D_Object base; - - Evas_3D_Shade_Mode shade_mode; - - int vertex_count; - int frame_count; - Eina_List *frames; - - Evas_3D_Index_Format index_format; - int index_count; - void *indices; - int index_size; - Eina_Bool owns_indices; - Eina_Bool index_mapped; - - Evas_3D_Vertex_Assembly assembly; - - Eina_Hash *nodes; -}; - -struct _Evas_3D_Texture -{ - Evas_3D_Object base; - - /* List of materials using this texture. */ - Eina_Hash *materials; - - /* Proxy data. */ - Evas_Object *source; - Eina_Bool proxy_rendering; - void *proxy_surface; - - /* Engine-side object. */ - void *engine_data; -}; - -struct _Evas_3D_Material -{ - Evas_3D_Object base; - - struct { - Eina_Bool enable; - Evas_Color color; - Evas_3D_Texture *texture; - } attribs[EVAS_3D_MATERIAL_ATTRIB_COUNT]; - - Evas_Real shininess; - - Eina_Hash *meshes; -}; - -struct _Evas_3D_Scene_Data -{ - Evas_Color bg_color; - Evas_3D_Node *camera_node; - Eina_List *light_nodes; - Eina_List *mesh_nodes; -}; - -struct _Evas_3D_Pick_Data -{ - /* Input */ - Evas_Real x, y; - Evas_Mat4 matrix_vp; - Evas_Ray3 ray_world; - - /* Output */ - Eina_Bool picked; - Evas_Real z; - Evas_3D_Node *node; - Evas_3D_Mesh *mesh; - Evas_Real u, v; - Evas_Real s, t; -}; - -/* Object generic functions. */ -void evas_3d_object_init(Evas_3D_Object *obj, Evas *e, Evas_3D_Object_Type type, const Evas_3D_Object_Func *func); -Evas *evas_3d_object_evas_get(const Evas_3D_Object *obj); -Evas_3D_Object_Type evas_3d_object_type_get(const Evas_3D_Object *obj); - -void evas_3d_object_reference(Evas_3D_Object *obj); -void evas_3d_object_unreference(Evas_3D_Object *obj); -int evas_3d_object_reference_count_get(const Evas_3D_Object *obj); - -void evas_3d_object_change(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref); -Eina_Bool evas_3d_object_dirty_get(const Evas_3D_Object *obj, Evas_3D_State state); -void evas_3d_object_update(Evas_3D_Object *obj); -void evas_3d_object_update_done(Evas_3D_Object *obj); - -/* Node functions. */ -void evas_3d_node_traverse(Evas_3D_Node *from, Evas_3D_Node *to, Evas_3D_Node_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data); -void evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data); -Eina_Bool evas_3d_node_mesh_collect(Evas_3D_Node *node, void *data); -Eina_Bool evas_3d_node_light_collect(Evas_3D_Node *node, void *data); - -void evas_3d_node_scene_root_add(Evas_3D_Node *node, Evas_3D_Scene *scene); -void evas_3d_node_scene_root_del(Evas_3D_Node *node, Evas_3D_Scene *scene); -void evas_3d_node_scene_camera_add(Evas_3D_Node *node, Evas_3D_Scene *scene); -void evas_3d_node_scene_camera_del(Evas_3D_Node *node, Evas_3D_Scene *scene); - -/* Camera functions. */ -void evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node); -void evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node); - -/* Light functions. */ -void evas_3d_light_node_add(Evas_3D_Light *light, Evas_3D_Node *node); -void evas_3d_light_node_del(Evas_3D_Light *light, Evas_3D_Node *node); - -/* Mesh functions. */ -void evas_3d_mesh_node_add(Evas_3D_Mesh *mesh, Evas_3D_Node *node); -void evas_3d_mesh_node_del(Evas_3D_Mesh *mesh, Evas_3D_Node *node); - -void evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, Evas_3D_Vertex_Buffer *buffer0, Evas_3D_Vertex_Buffer *buffer1, Evas_Real *weight); - -void evas_3d_mesh_file_md2_set(Evas_3D_Mesh *mesh, const char *file); - -/* Texture functions. */ -void evas_3d_texture_material_add(Evas_3D_Texture *texture, Evas_3D_Material *material); -void evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *material); - -/* Material functions. */ -void evas_3d_material_mesh_add(Evas_3D_Material *material, Evas_3D_Mesh *mesh); -void evas_3d_material_mesh_del(Evas_3D_Material *material, Evas_3D_Mesh *mesh); - -/* Scene functions. */ -void evas_3d_scene_data_init(Evas_3D_Scene_Data *data); -void evas_3d_scene_data_fini(Evas_3D_Scene_Data *data); diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index f93962b..e71a5fd 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -16,7 +16,7 @@ #include "../common/language/evas_bidi_utils.h" #include "../common/language/evas_language_utils.h" -#include "evas_3d_private.h" +#include "evas_3d_utils.h" #define RENDER_METHOD_INVALID 0x00000000 @@ -52,6 +52,341 @@ typedef struct _Evas_Object_3D_Data Evas_Object_3D_Data; typedef struct _Evas_Object_Protected_State Evas_Object_Protected_State; typedef struct _Evas_Object_Protected_Data Evas_Object_Protected_Data; +// 3D stuff + +#define EVAS_3D_VERTEX_ATTRIB_COUNT 5 +#define EVAS_3D_MATERIAL_ATTRIB_COUNT 5 + +typedef struct _Evas_3D_Object Evas_3D_Object; +typedef struct _Evas_3D_Scene_Public_Data Evas_3D_Scene_Public_Data; +typedef struct _Evas_3D_Vertex_Buffer Evas_3D_Vertex_Buffer; +typedef struct _Evas_3D_Mesh_Frame Evas_3D_Mesh_Frame; +typedef struct _Evas_3D_Node_Mesh Evas_3D_Node_Mesh; +typedef struct _Evas_3D_Object_Func Evas_3D_Object_Func; +typedef struct _Evas_3D_Pick_Data Evas_3D_Pick_Data; +typedef struct _Evas_3D_Interpolate_Vertex_Buffer Evas_3D_Interpolate_Vertex_Buffer; + +typedef struct _Evas_3D_Scene Evas_3D_Scene_Data; +typedef struct _Evas_3D_Node Evas_3D_Node_Data; +typedef struct _Evas_3D_Mesh Evas_3D_Mesh_Data; +typedef struct _Evas_3D_Camera Evas_3D_Camera_Data; +typedef struct _Evas_3D_Light Evas_3D_Light_Data; +typedef struct _Evas_3D_Material Evas_3D_Material_Data; +typedef struct _Evas_3D_Texture Evas_3D_Texture_Data; + + + + +typedef Eina_Bool (*Evas_3D_Node_Func)(Evas_3D_Node *, void *data); + +typedef enum _Evas_3D_Object_Type +{ + EVAS_3D_OBJECT_TYPE_INVALID = 0, + EVAS_3D_OBJECT_TYPE_SCENE, + EVAS_3D_OBJECT_TYPE_NODE, + EVAS_3D_OBJECT_TYPE_CAMERA, + EVAS_3D_OBJECT_TYPE_LIGHT, + EVAS_3D_OBJECT_TYPE_MODEL, + EVAS_3D_OBJECT_TYPE_MESH, + EVAS_3D_OBJECT_TYPE_TEXTURE, + EVAS_3D_OBJECT_TYPE_MATERIAL, +} Evas_3D_Object_Type; + +typedef enum _Evas_3D_State +{ + EVAS_3D_STATE_MAX = 16, + + EVAS_3D_STATE_ANY = 0, + + EVAS_3D_STATE_SCENE_ROOT_NODE = 1, + EVAS_3D_STATE_SCENE_CAMERA_NODE, + EVAS_3D_STATE_SCENE_BACKGROUND_COLOR, + EVAS_3D_STATE_SCENE_SIZE, + + EVAS_3D_STATE_TEXTURE_DATA = 1, + EVAS_3D_STATE_TEXTURE_WRAP, + EVAS_3D_STATE_TEXTURE_FILTER, + + EVAS_3D_STATE_MATERIAL_ID = 1, + EVAS_3D_STATE_MATERIAL_COLOR, + EVAS_3D_STATE_MATERIAL_TEXTURE, + + EVAS_3D_STATE_MESH_VERTEX_COUNT = 1, + EVAS_3D_STATE_MESH_FRAME, + EVAS_3D_STATE_MESH_MATERIAL, + EVAS_3D_STATE_MESH_TRANSFORM, + EVAS_3D_STATE_MESH_VERTEX_DATA, + EVAS_3D_STATE_MESH_INDEX_DATA, + EVAS_3D_STATE_MESH_VERTEX_ASSEMBLY, + EVAS_3D_STATE_MESH_SHADE_MODE, + + EVAS_3D_STATE_CAMERA_PROJECTION = 1, + + EVAS_3D_STATE_LIGHT_AMBIENT = 1, + EVAS_3D_STATE_LIGHT_DIFFUSE, + EVAS_3D_STATE_LIGHT_SPECULAR, + EVAS_3D_STATE_LIGHT_SPOT_DIR, + EVAS_3D_STATE_LIGHT_SPOT_EXP, + EVAS_3D_STATE_LIGHT_SPOT_CUTOFF, + EVAS_3D_STATE_LIGHT_ATTENUATION, + + EVAS_3D_STATE_NODE_TRANSFORM = 1, + EVAS_3D_STATE_NODE_MESH_GEOMETRY, + EVAS_3D_STATE_NODE_MESH_MATERIAL, + EVAS_3D_STATE_NODE_MESH_FRAME, + EVAS_3D_STATE_NODE_MESH_SHADE_MODE, + EVAS_3D_STATE_NODE_MESH_MATERIAL_ID, + EVAS_3D_STATE_NODE_LIGHT, + EVAS_3D_STATE_NODE_CAMERA, + EVAS_3D_STATE_NODE_PARENT, + EVAS_3D_STATE_NODE_MEMBER, +} Evas_3D_State; + +typedef enum _Evas_3D_Node_Traverse_Type +{ + EVAS_3D_NODE_TRAVERSE_DOWNWARD, + EVAS_3D_NODE_TRAVERSE_UPWARD, +} Evas_3D_Node_Traverse_Type; + +typedef enum _Evas_3D_Tree_Traverse_Type +{ + EVAS_3D_TREE_TRAVERSE_PRE_ORDER, + EVAS_3D_TREE_TRAVERSE_ANY_ORDER = EVAS_3D_TREE_TRAVERSE_PRE_ORDER, + EVAS_3D_TREE_TRAVERSE_POST_ORDER, + EVAS_3D_TREE_TRAVERSE_LEVEL_ORDER, +} Evas_3D_Tree_Traverse_Type; + +struct _Evas_3D_Object_Func +{ + void (*free)(Evas_3D_Object *obj); + void (*change)(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref); + void (*update)(Evas_3D_Object *obj); +}; + +struct _Evas_3D_Object +{ + Evas *evas; + + Evas_3D_Object_Type type; + int ref_count; + Evas_3D_Object_Func func; + + Eina_Bool dirty[EVAS_3D_STATE_MAX]; +}; + +struct _Evas_3D_Scene +{ + Evas_3D_Object base; + + Evas_3D_Node *root_node; + Evas_3D_Node *camera_node; + //@FIXME + Evas_3D_Scene *hack_this; + Evas_Color bg_color; + + void *surface; + int w, h; + Eina_List *images; +}; + +struct _Evas_3D_Node_Mesh +{ + Evas_3D_Node *node; + Evas_3D_Mesh *mesh; + int frame; +}; + +struct _Evas_3D_Node +{ + Evas_3D_Object base; + + Eina_List *members; + Evas_3D_Node *parent; + //@FIXME + Evas_3D_Node *hack_this; + + Evas_Vec3 position; + Evas_Vec4 orientation; + Evas_Vec3 scale; + + Evas_Vec3 position_world; + Evas_Vec4 orientation_world; + Evas_Vec3 scale_world; + + Eina_Bool position_inherit; + Eina_Bool orientation_inherit; + Eina_Bool scale_inherit; + + Evas_Box3 aabb; + + Evas_3D_Node_Type type; + + /* Camera node. */ + union { + struct { + Evas_3D_Camera *camera; + Evas_Mat4 matrix_world_to_eye; + } camera; + + struct { + Evas_3D_Light *light; + Evas_Mat4 matrix_local_to_world; + } light; + + struct { + Eina_List *meshes; + Eina_Hash *node_meshes; + Evas_Mat4 matrix_local_to_world; + } mesh; + } data; + + /* Scene using this node as root. */ + Eina_Hash *scenes_root; + + /* Scene using this node as camera. */ + Eina_Hash *scenes_camera; +}; + +struct _Evas_3D_Camera +{ + Evas_3D_Object base; + + Evas_Mat4 projection; + Eina_Hash *nodes; +}; + +struct _Evas_3D_Light +{ + Evas_3D_Object base; + + Evas_Color ambient; + Evas_Color diffuse; + Evas_Color specular; + + Eina_Bool directional; + Evas_Real spot_exp; + Evas_Real spot_cutoff; + Evas_Real spot_cutoff_cos; + + Eina_Bool enable_attenuation; + Evas_Real atten_const; + Evas_Real atten_linear; + Evas_Real atten_quad; + + Eina_Hash *nodes; +}; + +struct _Evas_3D_Vertex_Buffer +{ + int element_count; + int stride; + void *data; + int size; + Eina_Bool owns_data; + Eina_Bool mapped; +}; + +struct _Evas_3D_Interpolate_Vertex_Buffer +{ + void *data0; + int stride0; + int size0; + + void *data1; + int stride1; + int size1; + + Evas_Real weight; +}; + +struct _Evas_3D_Mesh_Frame +{ + Evas_3D_Mesh *mesh; + + int frame; + Evas_3D_Material *material; + Evas_Box3 aabb; + + Evas_3D_Vertex_Buffer vertices[EVAS_3D_VERTEX_ATTRIB_COUNT]; +}; + +struct _Evas_3D_Mesh +{ + Evas_3D_Object base; + + Evas_3D_Shade_Mode shade_mode; + + int vertex_count; + int frame_count; + Eina_List *frames; + + Evas_3D_Index_Format index_format; + int index_count; + void *indices; + int index_size; + Eina_Bool owns_indices; + Eina_Bool index_mapped; + + Evas_3D_Vertex_Assembly assembly; + + Eina_Hash *nodes; +}; + +struct _Evas_3D_Texture +{ + Evas_3D_Object base; + + /* List of materials using this texture. */ + Eina_Hash *materials; + + /* Proxy data. */ + Evas_Object *source; + Eina_Bool proxy_rendering; + void *proxy_surface; + + /* Engine-side object. */ + void *engine_data; +}; + +struct _Evas_3D_Material +{ + Evas_3D_Object base; + + struct { + Eina_Bool enable; + Evas_Color color; + Evas_3D_Texture *texture; + } attribs[EVAS_3D_MATERIAL_ATTRIB_COUNT]; + + Evas_Real shininess; + + Eina_Hash *meshes; +}; + +struct _Evas_3D_Scene_Public_Data +{ + Evas_Color bg_color; + Evas_3D_Node *camera_node; + Eina_List *light_nodes; + Eina_List *mesh_nodes; +}; + +struct _Evas_3D_Pick_Data +{ + /* Input */ + Evas_Real x, y; + Evas_Mat4 matrix_vp; + Evas_Ray3 ray_world; + + /* Output */ + Eina_Bool picked; + Evas_Real z; + Evas_3D_Node *node; + Evas_3D_Mesh *mesh; + Evas_Real u, v; + Evas_Real s, t; +}; + enum _Evas_Font_Style { EVAS_FONT_STYLE_SLANT, @@ -432,7 +767,7 @@ struct _Evas_Public_Data Eina_List *touch_points; Eina_List *devices; Eina_Array *cur_device; - + Eina_List *outputs; unsigned char changed : 1; @@ -526,7 +861,7 @@ struct _Evas_Object_Proxy_Data struct _Evas_Object_Map_Data { - struct { + struct { Evas_Map *map; Evas_Object *map_parent; @@ -1240,6 +1575,63 @@ void _canvas_objects_in_rectangle_get(Eo *obj, void *_pd, va_list *list); void _canvas_smart_objects_calculate(Eo *e, void *_pd, va_list *list); void _canvas_smart_objects_calculate_count_get(Eo *e, void *_pd, va_list *list); +/* Object generic functions. 3D function*/ +void evas_3d_object_init(Evas_3D_Object *obj, Evas *e, Evas_3D_Object_Type type, const Evas_3D_Object_Func *func); +Evas *evas_3d_object_evas_get(const Evas_3D_Object *obj); +Evas_3D_Object_Type evas_3d_object_type_get(const Evas_3D_Object *obj); + +void evas_3d_object_reference(Evas_3D_Object *obj); +void evas_3d_object_unreference(Evas_3D_Object *obj); +int evas_3d_object_reference_count_get(const Evas_3D_Object *obj); + +void evas_3d_object_change(Evas_3D_Object *obj, Evas_3D_State state, Evas_3D_Object *ref); +Eina_Bool evas_3d_object_dirty_get(const Evas_3D_Object *obj, Evas_3D_State state); +void evas_3d_object_update(Evas_3D_Object *obj); +void evas_3d_object_update_done(Evas_3D_Object *obj); + +/* Node functions. */ +void evas_3d_node_traverse(Evas_3D_Node *from, Evas_3D_Node *to, Evas_3D_Node_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data); +void evas_3d_node_tree_traverse(Evas_3D_Node *root, Evas_3D_Tree_Traverse_Type type, Eina_Bool skip, Evas_3D_Node_Func func, void *data); +Eina_Bool evas_3d_node_mesh_collect(Evas_3D_Node *node, void *data); +Eina_Bool evas_3d_node_light_collect(Evas_3D_Node *node, void *data); + +void evas_3d_node_scene_root_add(Evas_3D_Node *node, Evas_3D_Scene *scene); +void evas_3d_node_scene_root_del(Evas_3D_Node *node, Evas_3D_Scene *scene); +void evas_3d_node_scene_camera_add(Evas_3D_Node *node, Evas_3D_Scene *scene); +void evas_3d_node_scene_camera_del(Evas_3D_Node *node, Evas_3D_Scene *scene); + +/* Camera functions. */ +void evas_3d_camera_node_add(Evas_3D_Camera *camera, Evas_3D_Node *node); +void evas_3d_camera_node_del(Evas_3D_Camera *camera, Evas_3D_Node *node); + + +/* Light functions. */ +void evas_3d_light_node_add(Evas_3D_Light *light, Evas_3D_Node *node); +void evas_3d_light_node_del(Evas_3D_Light *light, Evas_3D_Node *node); + +/* Mesh functions. */ +void evas_3d_mesh_node_add(Evas_3D_Mesh *mesh, Evas_3D_Node *node); +void evas_3d_mesh_node_del(Evas_3D_Mesh *mesh, Evas_3D_Node *node); + +void evas_3d_mesh_interpolate_vertex_buffer_get(Evas_3D_Mesh *mesh, int frame, Evas_3D_Vertex_Attrib attrib, Evas_3D_Vertex_Buffer *buffer0, Evas_3D_Vertex_Buffer *buffer1, Evas_Real *weight); + +void evas_3d_mesh_file_md2_set(Evas_3D_Mesh *mesh, const char *file); + +/* Texture functions. */ +void evas_3d_texture_material_add(Evas_3D_Texture *texture, Evas_3D_Material *material); +void evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *material); + + +/* Material functions. */ +void evas_3d_material_mesh_add(Evas_3D_Material *material, Evas_3D_Mesh *mesh); +void evas_3d_material_mesh_del(Evas_3D_Material *material, Evas_3D_Mesh *mesh); + +/* Scene functions. */ +void evas_3d_scene_data_init(Evas_3D_Scene_Public_Data *data); +void evas_3d_scene_data_fini(Evas_3D_Scene_Public_Data *data); + + + extern int _evas_alloc_error; extern int _evas_event_counter; @@ -1310,7 +1702,7 @@ void _evas_device_cleanup(Evas *e); Evas_Device *_evas_device_top_get(const Evas *e); void _evas_device_ref(Evas_Device *dev); void _evas_device_unref(Evas_Device *dev); - + extern Eina_Cow *evas_object_proxy_cow; extern Eina_Cow *evas_object_map_cow; extern Eina_Cow *evas_object_state_cow; @@ -1336,7 +1728,7 @@ extern Eina_Cow *evas_object_image_state_cow; /********************/ #define MPOOL 1 -#ifdef MPOOL +#ifdef MPOOL typedef struct _Evas_Mempool Evas_Mempool; struct _Evas_Mempool diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d.c b/src/modules/evas/engines/gl_common/evas_gl_3d.c index c41ffbf..71173d5 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c @@ -702,7 +702,8 @@ e3d_drawable_format_get(E3D_Drawable *drawable) static inline GLuint _texture_id_get(Evas_3D_Texture *texture) { - E3D_Texture *tex = (E3D_Texture *)texture->engine_data; + Evas_3D_Texture_Data *pd = eo_data_scope_get(texture, EO_EVAS_3D_TEXTURE_CLASS); + E3D_Texture *tex = (E3D_Texture *)pd->engine_data; return tex->tex; } @@ -713,8 +714,9 @@ _mesh_frame_find(Evas_3D_Mesh *mesh, int frame, { Eina_List *left, *right; Evas_3D_Mesh_Frame *f0, *f1; + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS); - left = mesh->frames; + left = pdmesh->frames; right = eina_list_next(left); while (right) @@ -940,8 +942,12 @@ _material_color_build(E3D_Draw_Data *data, int frame, { f0 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(l); - if (f0->material && f0->material->attribs[attrib].enable) - break; + if (f0->material) + { + Evas_3D_Material_Data *pdm = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS); + if (pdm->attribs[attrib].enable) + break; + } l = eina_list_prev(l); f0 = NULL; @@ -951,8 +957,12 @@ _material_color_build(E3D_Draw_Data *data, int frame, { f1 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(r); - if (f1->material && f1->material->attribs[attrib].enable) - break; + if (f1->material) + { + Evas_3D_Material_Data *pdm = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS); + if (pdm->attribs[attrib].enable) + break; + } r = eina_list_next(r); f1 = NULL; @@ -978,28 +988,29 @@ _material_color_build(E3D_Draw_Data *data, int frame, f1 = NULL; } } - + Evas_3D_Material_Data *pdmf0 = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS); if (f1 == NULL) { - data->materials[attrib].color = f0->material->attribs[attrib].color; + data->materials[attrib].color = pdmf0->attribs[attrib].color; if (attrib == EVAS_3D_MATERIAL_SPECULAR) - data->shininess = f0->material->shininess; + data->shininess = pdmf0->shininess; } else { Evas_Real weight; + Evas_3D_Material_Data *pdmf1 = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS); weight = (f1->frame - frame) / (Evas_Real)(f1->frame - f0->frame); evas_color_blend(&data->materials[attrib].color, - &f0->material->attribs[attrib].color, - &f1->material->attribs[attrib].color, + &pdmf0->attribs[attrib].color, + &pdmf0->attribs[attrib].color, weight); if (attrib == EVAS_3D_MATERIAL_SPECULAR) { - data->shininess = f0->material->shininess * weight + - f1->material->shininess * (1.0 - weight); + data->shininess = pdmf0->shininess * weight + + pdmf1->shininess * (1.0 - weight); } } @@ -1018,10 +1029,12 @@ _material_texture_build(E3D_Draw_Data *data, int frame, { f0 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(l); - if (f0->material && - f0->material->attribs[attrib].enable && - f0->material->attribs[attrib].texture != NULL) - break; + if (f0->material) + { + Evas_3D_Material_Data *pdm = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS); + if (pdm->attribs[attrib].enable && pdm->attribs[attrib].texture != NULL) + break; + } l = eina_list_prev(l); f0 = NULL; @@ -1031,10 +1044,12 @@ _material_texture_build(E3D_Draw_Data *data, int frame, { f1 = (const Evas_3D_Mesh_Frame *)eina_list_data_get(r); - if (f1->material && - f1->material->attribs[attrib].enable && - f1->material->attribs[attrib].texture != NULL) - break; + if (f1->material) + { + Evas_3D_Material_Data *pdm = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS); + if (pdm->attribs[attrib].enable && pdm->attribs[attrib].texture != NULL) + break; + } r = eina_list_next(r); f1 = NULL; @@ -1061,24 +1076,26 @@ _material_texture_build(E3D_Draw_Data *data, int frame, } } + Evas_3D_Material_Data *pdmf0 = eo_data_scope_get(f0->material, EO_EVAS_3D_MATERIAL_CLASS); data->materials[attrib].sampler0 = data->texture_count++; - data->materials[attrib].tex0 = - (E3D_Texture *)f0->material->attribs[attrib].texture->engine_data; + Evas_3D_Texture_Data *pd = eo_data_scope_get(pdmf0->attribs[attrib].texture, EO_EVAS_3D_TEXTURE_CLASS); + data->materials[attrib].tex0 = (E3D_Texture *)pd->engine_data; if (f1) { + Evas_3D_Material_Data *pdmf1 = eo_data_scope_get(f1->material, EO_EVAS_3D_MATERIAL_CLASS); Evas_Real weight = (f1->frame - frame) / (Evas_Real)(f1->frame - f0->frame); data->materials[attrib].sampler1 = data->texture_count++; - data->materials[attrib].tex1 = - (E3D_Texture *)f1->material->attribs[attrib].texture->engine_data; + Evas_3D_Texture_Data *pd = eo_data_scope_get(pdmf1->attribs[attrib].texture, EO_EVAS_3D_TEXTURE_CLASS); + data->materials[attrib].tex1 = (E3D_Texture *)pd->engine_data; data->materials[attrib].texture_weight = weight; if (attrib == EVAS_3D_MATERIAL_SPECULAR) { - data->shininess = f0->material->shininess * weight + - f1->material->shininess * (1.0 - weight); + data->shininess = pdmf0->shininess * weight + + pdmf1->shininess * (1.0 - weight); } _material_texture_flag_add(data, attrib, EINA_TRUE); @@ -1086,7 +1103,7 @@ _material_texture_build(E3D_Draw_Data *data, int frame, else { if (attrib == EVAS_3D_MATERIAL_SPECULAR) - data->shininess = f0->material->shininess; + data->shininess = pdmf0->shininess; _material_texture_flag_add(data, attrib, EINA_FALSE); } @@ -1099,20 +1116,22 @@ _light_build(E3D_Draw_Data *data, const Evas_3D_Node *light, const Evas_Mat4 *matrix_eye) { - Evas_3D_Light *l = light->data.light.light; + Evas_3D_Node_Data *pd_light_node = eo_data_scope_get(light, EO_EVAS_3D_NODE_CLASS); + Evas_3D_Light *l = pd_light_node->data.light.light; + Evas_3D_Light_Data *pdl = eo_data_scope_get(l, EO_EVAS_3D_LIGHT_CLASS); Evas_Vec3 pos, dir; - if (l == NULL) + if (pdl == NULL) return; /* Get light node's position. */ - if (l->directional) + if (pdl->directional) { data->flags |= E3D_SHADER_FLAG_LIGHT_DIRECTIONAL; /* Negative Z. */ evas_vec3_set(&dir, 0.0, 0.0, 1.0); - evas_vec3_quaternion_rotate(&dir, &dir, &light->orientation); + evas_vec3_quaternion_rotate(&dir, &dir, &pd_light_node->orientation); /* Transform to eye space. */ evas_vec3_homogeneous_direction_transform(&dir, &dir, matrix_eye); @@ -1125,7 +1144,7 @@ _light_build(E3D_Draw_Data *data, } else { - evas_vec3_copy(&pos, &light->position_world); + evas_vec3_copy(&pos, &pd_light_node->position_world); evas_vec3_homogeneous_position_transform(&pos, &pos, matrix_eye); data->light.position.x = pos.x; @@ -1133,31 +1152,31 @@ _light_build(E3D_Draw_Data *data, data->light.position.z = pos.z; data->light.position.w = 1.0; - if (l->enable_attenuation) + if (pdl->enable_attenuation) { data->flags |= E3D_SHADER_FLAG_LIGHT_ATTENUATION; - data->light.atten.x = l->atten_const; - data->light.atten.x = l->atten_linear; - data->light.atten.x = l->atten_quad; + data->light.atten.x = pdl->atten_const; + data->light.atten.x = pdl->atten_linear; + data->light.atten.x = pdl->atten_quad; } - if (l->spot_cutoff < 180.0) + if (pdl->spot_cutoff < 180.0) { data->flags |= E3D_SHADER_FLAG_LIGHT_SPOT; evas_vec3_set(&dir, 0.0, 0.0, -1.0); - evas_vec3_quaternion_rotate(&dir, &dir, &light->orientation); + evas_vec3_quaternion_rotate(&dir, &dir, &pd_light_node->orientation); evas_vec3_homogeneous_direction_transform(&dir, &dir, matrix_eye); data->light.spot_dir = dir; - data->light.spot_exp = l->spot_exp; - data->light.spot_cutoff_cos = l->spot_cutoff_cos; + data->light.spot_exp = pdl->spot_exp; + data->light.spot_cutoff_cos = pdl->spot_cutoff_cos; } } - data->light.ambient = l->ambient; - data->light.diffuse = l->diffuse; - data->light.specular = l->specular; + data->light.ambient = pdl->ambient; + data->light.diffuse = pdl->diffuse; + data->light.specular = pdl->specular; } static inline Eina_Bool @@ -1169,16 +1188,17 @@ _mesh_draw_data_build(E3D_Draw_Data *data, const Evas_3D_Node *light) { Eina_List *l, *r; + Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(mesh, EO_EVAS_3D_MESH_CLASS); - if (mesh->frames == NULL) + if (pdmesh->frames == NULL) return EINA_FALSE; - data->mode = mesh->shade_mode; - data->assembly = mesh->assembly; - data->vertex_count = mesh->vertex_count; - data->index_count = mesh->index_count; - data->index_format = mesh->index_format; - data->indices = mesh->indices; + data->mode = pdmesh->shade_mode; + data->assembly = pdmesh->assembly; + data->vertex_count = pdmesh->vertex_count; + data->index_count = pdmesh->index_count; + data->index_format = pdmesh->index_format; + data->indices = pdmesh->indices; evas_mat4_copy(&data->matrix_mvp, matrix_mvp); evas_mat4_copy(&data->matrix_mv, matrix_mv); @@ -1195,12 +1215,12 @@ _mesh_draw_data_build(E3D_Draw_Data *data, } \ } while (0) - if (mesh->shade_mode == EVAS_3D_SHADE_MODE_VERTEX_COLOR) + if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_VERTEX_COLOR) { BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); BUILD(vertex_attrib, VERTEX_COLOR, EINA_TRUE); } - else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_DIFFUSE) + else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_DIFFUSE) { BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); BUILD(material_color, MATERIAL_DIFFUSE, EINA_TRUE); @@ -1209,7 +1229,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data, if (_flags_need_tex_coord(data->flags)) BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE); } - else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_FLAT) + else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_FLAT) { BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); BUILD(vertex_attrib, VERTEX_NORMAL, EINA_TRUE); @@ -1230,7 +1250,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data, if (_flags_need_tex_coord(data->flags)) BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE); } - else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_PHONG) + else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_PHONG) { BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); BUILD(vertex_attrib, VERTEX_NORMAL, EINA_TRUE); @@ -1251,7 +1271,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data, if (_flags_need_tex_coord(data->flags)) BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE); } - else if (mesh->shade_mode == EVAS_3D_SHADE_MODE_NORMAL_MAP) + else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_NORMAL_MAP) { BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); BUILD(vertex_attrib, VERTEX_NORMAL, EINA_TRUE); @@ -1289,7 +1309,7 @@ _mesh_draw(E3D_Renderer *renderer, Evas_3D_Mesh *mesh, int frame, Evas_3D_Node * } void -e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Data *data) +e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data) { Eina_List *l; Evas_3D_Node *n; @@ -1301,7 +1321,10 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3 e3d_renderer_clear(renderer, &data->bg_color); /* Get eye matrix. */ - matrix_eye = &data->camera_node->data.camera.matrix_world_to_eye; + Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(data->camera_node, EO_EVAS_3D_NODE_CLASS); + matrix_eye = &pd_camera_node->data.camera.matrix_world_to_eye; + + Evas_3D_Camera_Data *pd = eo_data_scope_get(pd_camera_node->data.camera.camera, EO_EVAS_3D_CAMERA_CLASS); EINA_LIST_FOREACH(data->mesh_nodes, l, n) { @@ -1309,15 +1332,16 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3 Evas_Mat4 matrix_mvp; Eina_Iterator *it; void *ptr; - - evas_mat4_multiply(&matrix_mv, matrix_eye, &n->data.mesh.matrix_local_to_world); - evas_mat4_multiply(&matrix_mvp, &data->camera_node->data.camera.camera->projection, + Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EO_EVAS_3D_NODE_CLASS); + evas_mat4_multiply(&matrix_mv, matrix_eye, &pd_mesh_node->data.mesh.matrix_local_to_world); + evas_mat4_multiply(&matrix_mvp, matrix_eye, &matrix_mv); + evas_mat4_multiply(&matrix_mvp, &pd->projection, &matrix_mv); /* TODO: Get most effective light node. */ light = eina_list_data_get(data->light_nodes); - it = eina_hash_iterator_data_new(n->data.mesh.node_meshes); + it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes); while (eina_iterator_next(it, &ptr)) { diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_common.h b/src/modules/evas/engines/gl_common/evas_gl_3d_common.h index 3f93ad5..ceba63e 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_3d_common.h @@ -27,7 +27,7 @@ void e3d_texture_filter_get(const E3D_Texture *texture, Evas_3D_ /* Drawable */ E3D_Drawable *e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_format); void e3d_drawable_free(E3D_Drawable *drawable); -void e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Data *data); +void e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data); void e3d_drawable_size_get(E3D_Drawable *drawable, int *w, int *h); GLuint e3d_drawable_texture_id_get(E3D_Drawable *drawable); GLenum e3d_drawable_format_get(E3D_Drawable *drawable); diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c b/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c index a9f63ec..c96f856 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c @@ -1251,15 +1251,27 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data) { switch (u) { - case E3D_UNIFORM_MATRIX_MVP: - glUniformMatrix4fv(loc, 1, EINA_FALSE, &data->matrix_mvp.m[0]); + case E3D_UNIFORM_MATRIX_MVP: { + float m[16]; + for(int i = 0 ; i <16 ; i++) + m[i] = data->matrix_mvp.m[i]; + glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]); break; - case E3D_UNIFORM_MATRIX_MV: - glUniformMatrix4fv(loc, 1, EINA_FALSE, &data->matrix_mv.m[0]); + } + case E3D_UNIFORM_MATRIX_MV: { + float m[16]; + for(int i = 0 ; i <16 ; i++) + m[i] = data->matrix_mv.m[i]; + glUniformMatrix4fv(loc, 1, EINA_FALSE, &m[0]); break; - case E3D_UNIFORM_MATRIX_NORMAL: - glUniformMatrix3fv(loc, 1, EINA_FALSE, &data->matrix_normal.m[0]); + } + case E3D_UNIFORM_MATRIX_NORMAL: { + float m[9]; + for(int i = 0 ; i <9 ; i++) + m[i] = data->matrix_normal.m[i]; + glUniformMatrix3fv(loc, 1, EINA_FALSE, &m[0]); break; + } case E3D_UNIFORM_POSITION_WEIGHT: glUniform1f(loc, data->vertices[EVAS_3D_VERTEX_POSITION].weight); break;