summaryrefslogtreecommitdiff
path: root/src/lib/evas/common3d/primitives/primitive_common.h
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-05-26 18:49:15 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-27 00:31:07 +0200
commit6dac83e643934573a734491d97b549a6b235c0f5 (patch)
treea5272df551b3c77107e79910cb0f9bde2f8ca6cc /src/lib/evas/common3d/primitives/primitive_common.h
parentabc1eabecb6da1bf77b530132814a2427bfb44fb (diff)
evas: add API for creation Evas_3D node primitives.
Summary: Now mechanism of creation of primitives is similar to model loading. Reviewers: Oleksander, Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2516 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/evas/common3d/primitives/primitive_common.h')
-rw-r--r--src/lib/evas/common3d/primitives/primitive_common.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/lib/evas/common3d/primitives/primitive_common.h b/src/lib/evas/common3d/primitives/primitive_common.h
new file mode 100644
index 0000000..c2b47f3
--- /dev/null
+++ b/src/lib/evas/common3d/primitives/primitive_common.h
@@ -0,0 +1,58 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif //HAVE_CONFIG_H
4
5#ifndef PRIMITIVE_COMMON
6#define PRIMITIVE_COMMON
7#include "evas_options.h"
8
9#include "evas_common_private.h"
10#include "evas_private.h"
11
12#define ALLOCATE_VERTEX_DATA \
13 Evas_Vec3 *vertices = malloc(sizeof(Evas_Vec3) * vcount); \
14 Evas_Vec3 *normals = malloc(sizeof(Evas_Vec3) * vcount); \
15 Evas_Vec2 *tex_coord = malloc(sizeof(Evas_Vec2) * vcount); \
16 Evas_Vec3 *tangents = malloc(sizeof(Evas_Vec3) * vcount); \
17 unsigned short *indices = malloc(sizeof(short) * icount);
18
19#define SET_VERTEX_DATA(frame) \
20 eo_do(mesh, \
21 evas_3d_mesh_vertex_count_set(vcount), \
22 evas_3d_mesh_frame_add(frame), \
23 evas_3d_mesh_index_data_copy_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, \
24 icount, &indices[0])); \
25 _set_vec3_vertex_data(mesh, frame, vcount, vertices, EVAS_3D_VERTEX_POSITION); \
26 _set_vec3_vertex_data(mesh, frame, vcount, normals, EVAS_3D_VERTEX_NORMAL); \
27 _set_vec2_vertex_data(mesh, frame, vcount, tex_coord, EVAS_3D_VERTEX_TEXCOORD); \
28 _set_vec3_vertex_data(mesh, frame, vcount, tangents, EVAS_3D_VERTEX_TANGENT); \
29 free(indices);
30
31#define SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, varray, vcount, indices, icount) \
32 eo_do(mesh, \
33 evas_3d_mesh_vertex_count_set(vcount), \
34 evas_3d_mesh_frame_add(frame), \
35 evas_3d_mesh_index_data_copy_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, \
36 icount, &indices[0])); \
37 _set_vertex_data_from_array(mesh, frame, varray, EVAS_3D_VERTEX_POSITION, \
38 0, 3, 15, vcount); \
39 _set_vertex_data_from_array(mesh, frame, varray, EVAS_3D_VERTEX_NORMAL, \
40 3, 3, 15, vcount); \
41 _set_vertex_data_from_array(mesh, frame, varray, EVAS_3D_VERTEX_COLOR, \
42 6, 4, 15, vcount); \
43 _set_vertex_data_from_array(mesh, frame, varray, EVAS_3D_VERTEX_TEXCOORD, \
44 10, 2, 15, vcount); \
45 _set_vertex_data_from_array(mesh, frame, varray, EVAS_3D_VERTEX_TANGENT, \
46 12, 3, 15, vcount);
47
48void _generate_indices(unsigned short *indices, int count, int width);
49void _set_vec3_vertex_data(Evas_3D_Mesh *mesh, int frame, int vcount, Evas_Vec3 *data, Evas_3D_Vertex_Attrib attr);
50void _set_vec2_vertex_data(Evas_3D_Mesh *mesh, int frame, int vcount, Evas_Vec2 *data, Evas_3D_Vertex_Attrib attr);
51void _set_vertex_data_from_array(Evas_3D_Mesh *mesh, int frame, const float *data, Evas_3D_Vertex_Attrib attr, int start, int attr_count, int line, int vcount);
52
53void _primitives_vec3_copy(Evas_Vec3 *dst, const Evas_Vec3 *src);
54void _primitives_vec3_subtract(Evas_Vec3 *out, const Evas_Vec3 *a, const Evas_Vec3 *b);
55void _primitives_vec3_cross_product(Evas_Vec3 *out, const Evas_Vec3 *a, const Evas_Vec3 *b);
56void _primitives_vec3_normalize(Evas_Vec3 *out);
57
58#endif //PRIMITIVE_COMMON