summaryrefslogtreecommitdiff
path: root/src/lib/evas/common3d/primitives
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/evas/common3d/primitives')
-rw-r--r--src/lib/evas/common3d/primitives/meson.build5
-rw-r--r--src/lib/evas/common3d/primitives/primitive_common.c203
-rw-r--r--src/lib/evas/common3d/primitives/primitive_common.h62
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/cone.c140
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/cylinder.c136
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/meson.build6
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/sphere.c189
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/torus.c67
-rw-r--r--src/lib/evas/common3d/primitives/surfaces/meson.build4
-rw-r--r--src/lib/evas/common3d/primitives/surfaces/surface.c91
-rw-r--r--src/lib/evas/common3d/primitives/surfaces/terrain.c86
-rw-r--r--src/lib/evas/common3d/primitives/tabulated_primitives/cube.c57
-rw-r--r--src/lib/evas/common3d/primitives/tabulated_primitives/meson.build4
-rw-r--r--src/lib/evas/common3d/primitives/tabulated_primitives/square.c18
14 files changed, 0 insertions, 1068 deletions
diff --git a/src/lib/evas/common3d/primitives/meson.build b/src/lib/evas/common3d/primitives/meson.build
deleted file mode 100644
index 2888869bf8..0000000000
--- a/src/lib/evas/common3d/primitives/meson.build
+++ /dev/null
@@ -1,5 +0,0 @@
-subdir('solids_of_revolution')
-subdir('surfaces')
-subdir('tabulated_primitives')
-
-evas_src += files(['primitive_common.c']) \ No newline at end of file
diff --git a/src/lib/evas/common3d/primitives/primitive_common.c b/src/lib/evas/common3d/primitives/primitive_common.c
deleted file mode 100644
index 1bea0682c6..0000000000
--- a/src/lib/evas/common3d/primitives/primitive_common.c
+++ /dev/null
@@ -1,203 +0,0 @@
-#include "primitive_common.h"
-
-void _set_vertex_data_from_array(Evas_Canvas3D_Mesh *mesh,
- int frame,
- const float *data,
- Evas_Canvas3D_Vertex_Attrib attr,
- int start,
- int attr_count,
- int line,
- int vcount)
-{
- float *address, *out;
- int stride, i, j;
- evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, frame, attr, 0, NULL);
- address = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, frame, attr);
- stride = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, frame, attr);
- if (stride == 0) stride = sizeof(float) * attr_count;
- for (i = 0; i < vcount; i++)
- {
- out = (float *)((char *)address + stride * i);
- for (j = 0; j < attr_count; j++)
- out[j] = data[start + (line * i) + j];
- }
- evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, attr);
-}
-
-void
-_set_vec3_vertex_data(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int vcount,
- Eina_Vector3 *data,
- Evas_Canvas3D_Vertex_Attrib attr)
-{
- float *address, *out;
- int stride, i;
- evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, frame, attr, 0, NULL);
- address = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, frame, attr);
- stride = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, frame, attr);
- if (stride == 0) stride = sizeof(float) * 3;
- for (i = 0; i < vcount; i++)
- {
- out = (float *)((char *)address + stride * i);
- out[0] = data[i].x;
- out[1] = data[i].y;
- out[2] = data[i].z;
- }
- free(data);
- evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, attr);
-}
-
-void
-_set_vec2_vertex_data(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int vcount,
- Eina_Vector2 *data,
- Evas_Canvas3D_Vertex_Attrib attr)
-{
- float *address, *out;
- int stride, i;
- evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, frame, attr, 0, NULL);
- address = (float *)evas_canvas3d_mesh_frame_vertex_data_map(mesh, frame, attr);
- stride = evas_canvas3d_mesh_frame_vertex_stride_get(mesh, frame, attr);
- if (stride == 0) stride = sizeof(float) * 2;
- for (i = 0; i < vcount; i++)
- {
- out = (float *)((char *)address + stride * i);
- out[0] = data[i].x;
- out[1] = data[i].y;
- }
- free(data);
- evas_canvas3d_mesh_frame_vertex_data_unmap(mesh, frame, attr);
-}
-
-void
-_generate_indices(unsigned short *indices, int a, int b)
-{
- int i, j, a1 = a + 1;
- unsigned short *index = &indices[0];
-
- for (i = 0; i < b; i++)
- {
- for (j = 0; j < a; j++)
- {
- *index++ = j + a1 * i;
- *index++ = j + a1 * (i + 1);
- *index++ = j + 1 + a1 * (i + 1);
-
- *index++ = j + a1 * i;
- *index++ = j + 1 + a1 * i;
- *index++ = j + a1 * (i + 1) + 1;
- }
- }
-}
-
-void
-_primitives_vec3_copy(Eina_Vector3 *dst, const Eina_Vector3 *src)
-{
- dst->x = src->x;
- dst->y = src->y;
- dst->z = src->z;
-}
-
-void
-_primitives_vec3_subtract(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b)
-{
- out->x = a->x - b->x;
- out->y = a->y - b->y;
- out->z = a->z - b->z;
-}
-
-void
-_primitives_vec3_cross_product(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b)
-{
- Eina_Vector3 tmp;
-
- tmp.x = a->y * b->z - a->z * b->y;
- tmp.y = a->z * b->x - a->x * b->z;
- tmp.z = a->x * b->y - a->y * b->x;
-
- _primitives_vec3_copy(out, &tmp);
-}
-
-void
-_primitives_vec3_normalize(Eina_Vector3 *out)
-{
- Evas_Real size = out->x * out->x + out->y *out->y + out->z * out->z;
- size = sqrt(size);
- out->x /= size;
- out->y /= size;
- out->z /= size;
-}
-
-void
-evas_common_set_model_from_primitive(Evas_Canvas3D_Mesh *model,
- int frame,
- Evas_Canvas3D_Primitive_Data *primitive)
-{
- Evas_Real ratio = primitive->ratio;
- int precision = primitive->precision;
- Evas_Canvas3D_Surface_Func *surface = primitive->surface;
- Eina_Vector2 tex_scale = primitive->tex_scale;
- Evas_Canvas3D_Primitive_Mode mode = primitive->mode;
-
- switch (primitive->form)
- {
- case EVAS_CANVAS3D_MESH_PRIMITIVE_NONE:
- case EVAS_CANVAS3D_MESH_PRIMITIVE_COUNT:
- {
- ERR("Primitive with this type cannot be set to mesh.");
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_SQUARE:
- {
- evas_model_set_from_square_primitive(model, frame);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE:
- {
- evas_model_set_from_cube_primitive(model, frame);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_CYLINDER:
- {
- evas_model_set_from_cylinder_primitive(model, frame, mode,
- precision, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_CONE:
- {
- evas_model_set_from_cone_primitive(model, frame, mode,
- precision, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE:
- {
- evas_model_set_from_sphere_primitive(model, frame, mode,
- precision, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_TORUS:
- {
- evas_model_set_from_torus_primitive(model, frame,
- ratio, precision, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_SURFACE:
- {
- evas_model_set_from_surface_primitive(model, frame,
- surface, precision, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_MESH_PRIMITIVE_TERRAIN:
- {
- evas_model_set_from_terrain_primitive(model, frame,
- precision, tex_scale);
- break;
- }
- default:
- {
- ERR("Unknown type of primitive");
- }
- }
-}
diff --git a/src/lib/evas/common3d/primitives/primitive_common.h b/src/lib/evas/common3d/primitives/primitive_common.h
deleted file mode 100644
index 1cf4d916fb..0000000000
--- a/src/lib/evas/common3d/primitives/primitive_common.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif //HAVE_CONFIG_H
-
-#ifndef PRIMITIVE_COMMON
-#define PRIMITIVE_COMMON
-#include "evas_options.h"
-
-#include "evas_common_private.h"
-#include "evas_private.h"
-
-#define ALLOCATE_VERTEX_DATA \
- Eina_Vector3 *vertices = malloc(sizeof(Eina_Vector3) * vcount); \
- Eina_Vector3 *normals = malloc(sizeof(Eina_Vector3) * vcount); \
- Eina_Vector2 *tex_coord = malloc(sizeof(Eina_Vector2) * vcount); \
- Eina_Vector3 *tangents = malloc(sizeof(Eina_Vector3) * vcount); \
- unsigned short *indices = malloc(sizeof(short) * icount);
-
-#define SET_VERTEX_DATA(frame) \
- Eina_Bool frame_exist; \
- frame_exist = evas_canvas3d_mesh_frame_exist(mesh, frame); \
- if (!frame_exist) \
- evas_canvas3d_mesh_frame_add(mesh, frame); \
- evas_canvas3d_mesh_vertex_count_set(mesh, vcount); \
- evas_canvas3d_mesh_index_data_copy_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
- icount, &indices[0]); \
- _set_vec3_vertex_data(mesh, frame, vcount, vertices, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION); \
- _set_vec3_vertex_data(mesh, frame, vcount, normals, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL); \
- _set_vec2_vertex_data(mesh, frame, vcount, tex_coord, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD); \
- _set_vec3_vertex_data(mesh, frame, vcount, tangents, EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT); \
- free(indices);
-
-#define SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, varray, vcount, indices, icount) \
- Eina_Bool frame_exist; \
- frame_exist = evas_canvas3d_mesh_frame_exist(mesh, frame); \
- if (!frame_exist) \
- evas_canvas3d_mesh_frame_add(mesh, frame); \
- evas_canvas3d_mesh_vertex_count_set(mesh, vcount); \
- evas_canvas3d_mesh_index_data_copy_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
- icount, &indices[0]); \
- _set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, \
- 0, 3, 15, vcount); \
- _set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, \
- 3, 3, 15, vcount); \
- _set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, \
- 6, 4, 15, vcount); \
- _set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, \
- 10, 2, 15, vcount); \
- _set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT, \
- 12, 3, 15, vcount);
-
-void _generate_indices(unsigned short *indices, int count, int width);
-void _set_vec3_vertex_data(Evas_Canvas3D_Mesh *mesh, int frame, int vcount, Eina_Vector3 *data, Evas_Canvas3D_Vertex_Attrib attr);
-void _set_vec2_vertex_data(Evas_Canvas3D_Mesh *mesh, int frame, int vcount, Eina_Vector2 *data, Evas_Canvas3D_Vertex_Attrib attr);
-void _set_vertex_data_from_array(Evas_Canvas3D_Mesh *mesh, int frame, const float *data, Evas_Canvas3D_Vertex_Attrib attr, int start, int attr_count, int line, int vcount);
-
-void _primitives_vec3_copy(Eina_Vector3 *dst, const Eina_Vector3 *src);
-void _primitives_vec3_subtract(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b);
-void _primitives_vec3_cross_product(Eina_Vector3 *out, const Eina_Vector3 *a, const Eina_Vector3 *b);
-void _primitives_vec3_normalize(Eina_Vector3 *out);
-
-#endif //PRIMITIVE_COMMON
diff --git a/src/lib/evas/common3d/primitives/solids_of_revolution/cone.c b/src/lib/evas/common3d/primitives/solids_of_revolution/cone.c
deleted file mode 100644
index a2852bb374..0000000000
--- a/src/lib/evas/common3d/primitives/solids_of_revolution/cone.c
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "../primitive_common.h"
-
-void
-_set_default_cone(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i, j, num;
- double dfi, fi, sinfi, cosfi, nplane, nz;
-
- icount = p * 18;
- vccount = p + 1;
- vcount = 4 * vccount;
-
- dfi = 2.0 * M_PI / p;
- nz = sqrt(1.0 / 3.0);
- nplane = sqrt(2.0 / 3.0);
-
- ALLOCATE_VERTEX_DATA
-
- for (i = 0; i < vccount; i++)
- {
- fi = i * dfi;
- sinfi = sin(fi);
- cosfi = cos(fi);
-
- vertices[i].x = 0.0;
- vertices[i].y = 0.0;
- vertices[i].z = -0.5;
- vertices[i + vccount].x = sinfi / 2.0;
- vertices[i + vccount].y = cosfi / 2.0;
- vertices[i + vccount].z = -0.5;
- vertices[i + 2 * vccount] = vertices[i + vccount];
- vertices[i + 3 * vccount].x = 0.0;
- vertices[i + 3 * vccount].y = 0.0;
- vertices[i + 3 * vccount].z = 0.5;
-
- normals[i].x = normals[i].y = 0.0;
- normals[i].z = -1.0;
- normals[i + vccount] = normals[i];
- normals[i + 2 * vccount].x = sinfi * nplane;
- normals[i + 2 * vccount].y = cosfi * nplane;
- normals[i + 2 * vccount].z = nz;
- normals[i + 3 * vccount] = normals[i + 2 * vccount];
-
- for (j = 0; j < 4; j++)
- {
- num = i + j * vccount;
-
- tangents[num].x = cosfi;
- tangents[num].y = -sinfi;
- tangents[num].z = 0.0;
-
- tex_coord[num].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[num].y = ((j + 1) / 2.0) * tex_scale.y / 2.0;
- }
- }
-
- _generate_indices(indices, p, 3);
-
- SET_VERTEX_DATA(frame)
-}
-
-void
-_set_cone_without_base(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i;
- double dfi, fi, sinfi, cosfi, nplane, nz;
-
- icount = p * 6;
- vccount = p + 1;
- vcount = 2 * vccount;
-
- dfi = 2.0 * M_PI / p;
- nz = sqrt(1.0 / 3.0);
- nplane = sqrt(2.0 / 3.0);
-
- ALLOCATE_VERTEX_DATA
-
- for (i = 0; i < vccount; i++)
- {
- fi = i * dfi;
- sinfi = sin(fi);
- cosfi = cos(fi);
- vertices[i].x = sinfi / 2.0;
- vertices[i].y = cosfi / 2.0;
- vertices[i].z = -0.5;
- vertices[i + vccount].x = 0;
- vertices[i + vccount].y = 0;
- vertices[i + vccount].z = 0.5;
-
- normals[i + vccount].x = normals[i].x = sinfi * nplane;
- normals[i + vccount].y = normals[i].y = cosfi * nplane;
- normals[i + vccount].z = normals[i].z = nz;
-
- tangents[i + vccount].x = tangents[i].x = cosfi;
- tangents[i + vccount].y = tangents[i].y = -sinfi;
- tangents[i + vccount].z = tangents[i].z = 0;
-
- tex_coord[i].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[i].y = 0;
- tex_coord[i + vccount].x = tex_coord[i].x;
- tex_coord[i + vccount].y = tex_scale.y;
- }
-
- _generate_indices(indices, p, 1);
-
- SET_VERTEX_DATA(frame)
-}
-
-void
-evas_model_set_from_cone_primitive(Evas_Canvas3D_Mesh *mesh,
- int frame,
- Evas_Canvas3D_Primitive_Mode mode,
- int p,
- Eina_Vector2 tex_scale)
-{
- switch (mode)
- {
- case EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT:
- case EVAS_CANVAS3D_PRIMITIVE_MODE_ALTERNATIVE_UV:
- {
- _set_default_cone(mesh, frame, p, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_PRIMITIVE_MODE_WITHOUT_BASE:
- {
- _set_cone_without_base(mesh, frame, p, tex_scale);
- break;
- }
- default:
- {
- ERR("Unknown mode of primitive");
- }
- }
-}
diff --git a/src/lib/evas/common3d/primitives/solids_of_revolution/cylinder.c b/src/lib/evas/common3d/primitives/solids_of_revolution/cylinder.c
deleted file mode 100644
index fc0d3d1d92..0000000000
--- a/src/lib/evas/common3d/primitives/solids_of_revolution/cylinder.c
+++ /dev/null
@@ -1,136 +0,0 @@
-#include "../primitive_common.h"
-
-void
-_set_default_cylinder(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i, j, num;
- icount = p * 30;
- vccount = p + 1;
- vcount = 6 * vccount;
-
- ALLOCATE_VERTEX_DATA
-
- double dfi, fi, sinfi, cosfi;
- dfi = 2 * M_PI / p;
-
- for (i = 0; i < vccount; i++)
- {
- fi = i * dfi;
- sinfi = sin(fi);
- cosfi = cos(fi);
-
- for (j = 0; j < 6; j++)
- {
- num = i + j * vccount;
-
- vertices[num].z = -0.5 + j / 3.0;
- if ((j == 0) || (j == 5))
- {
- vertices[num].x = vertices[num].y = 0.0;
- }
- else
- {
- vertices[num].x = sinfi / 2.0;
- vertices[num].y = cosfi / 2.0;
- }
-
- if ((j == 2) || (j == 3))
- {
- normals[num].x = sinfi;
- normals[num].y = cosfi;
- normals[num].z = 0.0;
- }
- else
- {
- normals[num].x = normals[num].y = 0.0;
- normals[num].z = -1.0 + j / 2.0;
- }
-
- tangents[num].x = cosfi;
- tangents[num].y = -sinfi;
- tangents[num].z = 0.0;
-
- tex_coord[num].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[num].y = ((j + 1) / 2.0) * tex_scale.y / 3.0;
- }
- }
-
- _generate_indices(indices, p, 5);
-
- SET_VERTEX_DATA(frame)
-}
-
-void
-_set_cylinder_without_bases(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i;
- icount = p * 6;
- vccount = p + 1;
- vcount = 2 * vccount;
-
- ALLOCATE_VERTEX_DATA
-
- double dfi, fi, sinfi, cosfi;
- dfi = 2 * M_PI / p;
-
- for (i = 0; i < vccount; i++)
- {
- fi = i * dfi;
- sinfi = sin(fi);
- cosfi = cos(fi);
- vertices[i + vccount].x = vertices[i].x = sinfi / 2.0;
- vertices[i + vccount].y = vertices[i].y = cosfi / 2.0;
- vertices[i].z = -0.5;
- vertices[i + vccount].z = 0.5;
-
- normals[i + vccount].x = normals[i].x = sinfi;
- normals[i + vccount].y = normals[i].y = cosfi;
- normals[i + vccount].z = normals[i].z = 0;
-
- tangents[i + vccount].x = tangents[i].x = cosfi;
- tangents[i + vccount].y = tangents[i].y = -sinfi;
- tangents[i + vccount].z = tangents[i].z = 0;
-
- tex_coord[i].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[i].y = 0;
- tex_coord[i + vccount].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[i + vccount].y = tex_scale.y;
- }
-
- _generate_indices(indices, p, 1);
-
- SET_VERTEX_DATA(frame)
-}
-
-void
-evas_model_set_from_cylinder_primitive(Evas_Canvas3D_Mesh *mesh,
- int frame,
- Evas_Canvas3D_Primitive_Mode mode,
- int p,
- Eina_Vector2 tex_scale)
-{
- switch (mode)
- {
- case EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT:
- case EVAS_CANVAS3D_PRIMITIVE_MODE_ALTERNATIVE_UV:
- {
- _set_default_cylinder(mesh, frame, p, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_PRIMITIVE_MODE_WITHOUT_BASE:
- {
- _set_cylinder_without_bases(mesh, frame, p, tex_scale);
- break;
- }
- default:
- {
- ERR("Unknown mode of primitive");
- }
- }
-}
diff --git a/src/lib/evas/common3d/primitives/solids_of_revolution/meson.build b/src/lib/evas/common3d/primitives/solids_of_revolution/meson.build
deleted file mode 100644
index ac35b05093..0000000000
--- a/src/lib/evas/common3d/primitives/solids_of_revolution/meson.build
+++ /dev/null
@@ -1,6 +0,0 @@
-evas_src += files([
- 'cone.c',
- 'cylinder.c',
- 'sphere.c',
- 'torus.c'
-]) \ No newline at end of file
diff --git a/src/lib/evas/common3d/primitives/solids_of_revolution/sphere.c b/src/lib/evas/common3d/primitives/solids_of_revolution/sphere.c
deleted file mode 100644
index f2e81b0bf5..0000000000
--- a/src/lib/evas/common3d/primitives/solids_of_revolution/sphere.c
+++ /dev/null
@@ -1,189 +0,0 @@
-#include "../primitive_common.h"
-
-void
-_set_default_sphere(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i, j;
- icount = p * p * 6;
- vccount = p + 1;
- vcount = vccount * vccount;
-
- ALLOCATE_VERTEX_DATA
-
- double dtheta, dfi, sinth, costh, fi, theta, sinfi, cosfi;
- dtheta = M_PI / p;
- dfi = 2 * M_PI / p;
-
- for (j = 0; j < vccount; j++)
- {
- theta = j * dtheta;
- sinth = sin(theta);
- costh = cos(theta);
- for (i = 0; i < vccount; i++)
- {
- fi = i * dfi;
- sinfi = sin(fi);
- cosfi = cos(fi);
- normals[i + j * vccount].x = sinth * sinfi;
- normals[i + j * vccount].y = sinth * cosfi;
- normals[i + j * vccount].z = costh;
-
- vertices[i + j * vccount].x = normals[i + j * vccount].x / 2;
- vertices[i + j * vccount].y = normals[i + j * vccount].y / 2;
- vertices[i + j * vccount].z = normals[i + j * vccount].z / 2;
-
- tangents[i + j * vccount].x = -sinth * cosfi;
- tangents[i + j * vccount].y = sinth * sinfi;
- tangents[i + j * vccount].z = 0;
-
- _primitives_vec3_normalize(&tangents[i + j * vccount]);
-
- tex_coord[i + j * vccount].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[i + j *vccount].y = tex_scale.y - j / (float)(vccount - 1) * tex_scale.y;
- }
- }
-
- _generate_indices(indices, p, p);
-
- SET_VERTEX_DATA(frame)
-}
-
-void
-_set_sphere_with_alternative_uv(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i, j;
-
- vccount = p + 1;
- vcount = vccount * vccount;
- icount = p * p * 6;
-
- ALLOCATE_VERTEX_DATA
-
- /* Calculate vertices position of the sphere mesh by using
- splitting of sphere by latitude and longitude. */
- for (i = 0; i <= p; i++)
- {
- double lati, z, r, point_r;
-
- point_r = 0.00001;//non-zero little value for correct tangents calculation.
-
- lati = ((M_PI - 2 * point_r) * (double)i) / (double)p;
- z = cos(lati + point_r);
- r = fabs(sin(lati + point_r));
-
- for (j = 0; j <= p; j++)
- {
- double longi;
- int num = (i * (p + 1)) + j;
-
- longi = (M_PI * 2.0 * (double)j) / (double)p;
-
- normals[num].x = r * sin(longi);
- normals[num].y = r * cos(longi);
- normals[num].z = z;
-
- vertices[num].x = normals[num].x / 2;
- vertices[num].y = normals[num].y / 2;
- vertices[num].z = normals[num].z / 2;
-
- if (vertices[num].x > 0.0)
- {
- tangents[num].x = -normals[num].z;
- tangents[num].y = normals[num].y;
- tangents[num].z = normals[num].x;
- }
- else
- {
- tangents[num].x = normals[num].z;
- tangents[num].y = normals[num].y;
- tangents[num].z = -normals[num].x;
- }
-
- tex_coord[num].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[num].y = tex_scale.y - j / (float)(vccount - 1) * tex_scale.y;
- }
- }
-
- _generate_indices(indices, p, p);
-
- /* Triangulation of sphere mesh in appliance with buffer of indices. */
- for (i = 0; i < icount; i += 3)
- {
- Eina_Vector3 e1, e2;
- float du1, du2, dv1, dv2, f;
- Eina_Vector3 tangent;
- int num0, num1, num2;
-
- num0 = indices[i + 0];
- num1 = indices[i + 1];
- num2 = indices[i + 2];
-
- e1.x = vertices[num1].x - vertices[num0].x;
- e1.y = vertices[num1].y - vertices[num0].y;
- e1.z = vertices[num1].z - vertices[num0].z;
-
- e2.x = vertices[num2].x - vertices[num0].x;
- e2.y = vertices[num2].y - vertices[num0].y;
- e2.z = vertices[num2].z - vertices[num0].z;
-
- du1 = tex_coord[num1].x - tex_coord[num0].x;
- dv1 = tex_coord[num1].y - tex_coord[num0].y;
-
- du2 = tex_coord[num2].x - tex_coord[num0].x;
- dv2 = tex_coord[num2].y - tex_coord[num0].y;
-
- f = 1.0 / ((du1 * dv2) - (du2 * dv1));
-
- tangent.x = f * ((dv2 * e1.x) - (dv1 * e2.x));
- tangent.y = f * ((dv2 * e1.y) - (dv1 * e2.y));
- tangent.z = f * ((dv2 * e1.z) - (dv1 * e2.z));
-
- tangents[num0] = tangent;
- }
-
- /* Coupling between vertices by calculation of tangent parametr correct value. */
- for (i = 0; i <= p; i++)
- {
- for (j = 0; j <= p; j++)
- {
- if (j == p)
- {
- tangents[(i * (p + 1)) + j] = tangents[i * (p + 1)];
- }
- }
- }
- SET_VERTEX_DATA(frame)
-}
-
-void
-evas_model_set_from_sphere_primitive(Evas_Canvas3D_Mesh *mesh,
- int frame,
- Evas_Canvas3D_Primitive_Mode mode,
- int p,
- Eina_Vector2 tex_scale)
-{
- switch (mode)
- {
- case EVAS_CANVAS3D_PRIMITIVE_MODE_DEFAULT:
- case EVAS_CANVAS3D_PRIMITIVE_MODE_WITHOUT_BASE:
- {
- _set_default_sphere(mesh, frame, p, tex_scale);
- break;
- }
- case EVAS_CANVAS3D_PRIMITIVE_MODE_ALTERNATIVE_UV:
- {
- _set_sphere_with_alternative_uv(mesh, frame, p, tex_scale);
- break;
- }
- default:
- {
- ERR("Unknown mode of primitive");
- }
- }
-}
diff --git a/src/lib/evas/common3d/primitives/solids_of_revolution/torus.c b/src/lib/evas/common3d/primitives/solids_of_revolution/torus.c
deleted file mode 100644
index 99016c620a..0000000000
--- a/src/lib/evas/common3d/primitives/solids_of_revolution/torus.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "../primitive_common.h"
-
-void
-evas_model_set_from_torus_primitive(Evas_Canvas3D_Mesh *mesh,
- int frame,
- Evas_Real ratio,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i, j;
- icount = p * p * 6;
- vccount = p + 1;
- vcount = vccount * vccount;
-
- ALLOCATE_VERTEX_DATA
-
- double d, sinth, costh, fi, theta, sinfi, cosfi;
-
- d = 2 * M_PI / p;
-
- float rratio;
-
- if ((ratio < 1.0))
- {
- printf("Ratio of torus should be greater than or equal 1.0.\n");
- printf("Ratio = %f is a bad value, so 3.0 is used like default ratio.\n",
- ratio);
- rratio = 1.0 / 3.0;
- }
- else
- {
- rratio = 1.0 / ratio;
- }
-
- for (j = 0; j < vccount; j++)
- {
- theta = j * d;
- sinth = sin(theta);
- costh = cos(theta);
- for (i = 0; i < vccount; i++)
- {
- fi = i * d;
- sinfi = sin(fi);
- cosfi = cos(fi);
- vertices[i + j * vccount].x = (1.0 - rratio + rratio * cosfi) * costh * 0.5;
- vertices[i + j * vccount].y = (1.0 - rratio + rratio * cosfi) * sinth * 0.5;
- vertices[i + j * vccount].z = rratio * sinfi * 0.5;
-
- normals[i + j * vccount].x = cosfi * costh;
- normals[i + j * vccount].y = cosfi * sinth;
- normals[i + j * vccount].z = sinfi;
-
- tangents[i + j * vccount].x = -sinfi * costh;
- tangents[i + j * vccount].y = -sinfi * sinth;
- tangents[i + j * vccount].z = cosfi;
-
- _primitives_vec3_normalize(&normals[i + j * vccount]);
-
- tex_coord[i + j * vccount].x = i / (float)(vccount - 1) * tex_scale.x;
- tex_coord[i + j *vccount].y = tex_scale.y - j / (float)(vccount - 1) * tex_scale.y;
- }
- }
-
- _generate_indices(indices, p, p);
-
- SET_VERTEX_DATA(frame)
-}
diff --git a/src/lib/evas/common3d/primitives/surfaces/meson.build b/src/lib/evas/common3d/primitives/surfaces/meson.build
deleted file mode 100644
index 398996f148..0000000000
--- a/src/lib/evas/common3d/primitives/surfaces/meson.build
+++ /dev/null
@@ -1,4 +0,0 @@
-evas_src += files([
- 'surface.c',
- 'terrain.c'
-]) \ No newline at end of file
diff --git a/src/lib/evas/common3d/primitives/surfaces/surface.c b/src/lib/evas/common3d/primitives/surfaces/surface.c
deleted file mode 100644
index 7698ba5fb6..0000000000
--- a/src/lib/evas/common3d/primitives/surfaces/surface.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "../primitive_common.h"
-
-Eina_Vector3 _get_func_normal(Evas_Canvas3D_Surface_Func *func, Evas_Real x, Evas_Real y)
-{
- Eina_Vector3 v00, v01, v10, d1, d2, normal;
-
- func(&v00.x, &v00.y, &v00.z, x, y);
- func(&v01.x, &v01.y, &v01.z, x, y + 0.01);
- func(&v10.x, &v10.y, &v10.z, x + 0.01, y);
- _primitives_vec3_subtract(&d1, &v00, &v01);
- _primitives_vec3_subtract(&d2, &v01, &v10);
-
- _primitives_vec3_cross_product(&normal, &d1, &d2);
-
- _primitives_vec3_normalize(&normal);
-
- return normal;
-}
-
-void
-_normalize(Eina_Vector3 *vertices, Eina_Vector3 *normals, int vcount)
-{
- int i;
- Eina_Vector3 min, max;
- min = max = vertices[0];
-
-#define CHECK_MIN_AND_MAX(coord) \
- if (min.coord > vertices[i].coord) \
- min.coord = vertices[i].coord; \
- else if (max.coord < vertices[i].coord) \
- max.coord = vertices[i].coord;
- for (i = 1; i < vcount; i++)
- {
- CHECK_MIN_AND_MAX(x)
- CHECK_MIN_AND_MAX(y)
- CHECK_MIN_AND_MAX(z)
- }
-#undef CHECK_MIN_AND_MAX
-
- for (i = 0; i < vcount; i++)
- {
- vertices[i].x = (vertices[i].x - min.x) / (max.x - min.x) - 0.5;
- vertices[i].y = (vertices[i].y - min.y) / (max.y - min.y) - 0.5;
- vertices[i].z = (vertices[i].z - min.z) / (max.z - min.z) - 0.5;
-
- normals[i].x = normals[i].x / (max.x - min.x);
- normals[i].y = normals[i].y / (max.y - min.y);
- normals[i].z = normals[i].z / (max.z - min.z);
- }
-}
-
-void
-evas_model_set_from_surface_primitive(Evas_Canvas3D_Mesh *mesh,
- int frame,
- Evas_Canvas3D_Surface_Func func,
- int p,
- Eina_Vector2 tex_scale)
-{
- int vcount, icount, vccount, i, j, num;
- icount = p * p * 6;
- vccount = p + 1;
- vcount = vccount * vccount;
-
- ALLOCATE_VERTEX_DATA
-
- Evas_Real v, u, d = 1.0 / p;
-
- for (j = 0; j < vccount; j++)
- {
- u = j * d - 0.5;
- for (i = 0; i < vccount; i++)
- {
- v = i * d - 0.5;
- num = i + j * vccount;
- func(&vertices[num].x,
- &vertices[num].y,
- &vertices[num].z,
- v, u);
- normals[num] = _get_func_normal(func, v, u);
-
- tangents[num].x = tangents[num].y = tangents[num].z = 0;
-
- tex_coord[num].x = i / ((vccount - 1) * tex_scale.x);
- tex_coord[num].y = tex_scale.y - j / ((vccount - 1) * tex_scale.y);
- }
- }
-
- _normalize(vertices, normals, vcount);
- _generate_indices(indices, p, p);
- SET_VERTEX_DATA(frame)
-}
diff --git a/src/lib/evas/common3d/primitives/surfaces/terrain.c b/src/lib/evas/common3d/primitives/surfaces/terrain.c
deleted file mode 100644
index 1f83c089ef..0000000000
--- a/src/lib/evas/common3d/primitives/surfaces/terrain.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "../primitive_common.h"
-
-static Evas_Real
-_random(int x, int y)
-{
- int k = x + y * 57;
- k = (k << 13) ^ k;
- return (1.0f - ((k * (k * k * 15731 + 789221) + 1376312589) & 0x7fffffff) /
- 1073741824.0f);
-}
-
-static Evas_Real
-_smooth(Evas_Real x, Evas_Real y)
-{
- Evas_Real res;
- res = (_random(x - 1, y - 1) + _random(x + 1, y - 1) +
- _random(x - 1, y + 1) + _random(x + 1, y + 1)) / 16;
- res += (_random(x - 1, y) + _random(x + 1, y) +
- _random(x, y - 1) + _random(x, y + 1)) / 8;
- res += _random(x, y) / 4;
- return res;
-}
-
-static Evas_Real
-_interpolate(Evas_Real a, Evas_Real b, Evas_Real x)
-{
- Evas_Real ft = x * M_PI;
- Evas_Real f = (1 - cosf(ft)) * 0.5;
- return a * (1 - f) + b * f;
-}
-
-static Evas_Real _noise(Evas_Real x, Evas_Real y)
-{
- Evas_Real ix = (int)(x);
- Evas_Real fx = x - ix;
- Evas_Real iy = (int)(y);
- Evas_Real fy = y - iy;
-
- Evas_Real v1 = _smooth(ix, iy);
- Evas_Real v2 = _smooth(ix + 1, iy);
- Evas_Real v3 = _smooth(ix, iy + 1);
- Evas_Real v4 = _smooth(ix + 1, iy + 1);
-
- Evas_Real i1 = _interpolate(v1, v2, fx);
- Evas_Real i2 = _interpolate(v3, v4, fx);
-
- return _interpolate(i1, i2, fy);
-}
-
-static void
-_perlin_terrain(Evas_Real *out_x,
- Evas_Real *out_y,
- Evas_Real *out_z,
- Evas_Real x,
- Evas_Real y)
-{
- Evas_Real persistence = 0.5f;
- Evas_Real frequency = 5;
- Evas_Real amplitude = 1;
- int i = 0;
- int octaves = 5;
-
- *out_x = x;
- x += 0.5;
- *out_y = y;
- y += 0.5;
- *out_z = 0;
-
- for(i = 0; i < octaves; i++)
- {
- *out_z += _noise(x * frequency, y * frequency) * amplitude;
-
- amplitude *= persistence;
- frequency *= 2;
- }
-}
-
-void
-evas_model_set_from_terrain_primitive(Evas_Canvas3D_Mesh *mesh,
- int frame,
- int p,
- Eina_Vector2 tex_scale)
-{
- evas_model_set_from_surface_primitive(mesh, frame, _perlin_terrain, p, tex_scale);
-}
-
diff --git a/src/lib/evas/common3d/primitives/tabulated_primitives/cube.c b/src/lib/evas/common3d/primitives/tabulated_primitives/cube.c
deleted file mode 100644
index 85d49beaaa..0000000000
--- a/src/lib/evas/common3d/primitives/tabulated_primitives/cube.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "../primitive_common.h"
-
-const float vertices_of_cube[] =
-{
- /* positions normals vertex_color tex_coords tangents */
- /* Front */
- 0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0,
- -0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, -1.0, 0.0, 0.0,
- -0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 0.0,
- 0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0,
-
- /* Left */
- -0.5, -0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0,
- -0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0,
- -0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0,
- -0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
-
- /* Back */
- -0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
- 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
- 0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
- -0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
-
- /* Right */
- 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0,
- 0.5, -0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0,
- 0.5, -0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, -1.0,
- 0.5, 0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0,
-
- /* Top */
- -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
- -0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
- 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
- 0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-
- /* Bottom */
- -0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, -1.0, 0.0, 0.0,
- -0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 0.0,
- 0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0,
- 0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0,
-};
-
-const unsigned short indices_of_cube[] =
-{
- 0, 1, 2, 6, 7, 4,
- 4, 5, 6, 10, 11, 8,
- 8, 9, 10, 14, 15, 12,
- 12, 13, 14, 2, 3, 0,
- 19, 16, 17, 17, 18, 19,
- 23, 20, 21, 21, 22, 23
-};
-
-void
-evas_model_set_from_cube_primitive(Evas_Canvas3D_Mesh *mesh, int frame)
-{
- SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, vertices_of_cube, 24, indices_of_cube, 36)
-}
diff --git a/src/lib/evas/common3d/primitives/tabulated_primitives/meson.build b/src/lib/evas/common3d/primitives/tabulated_primitives/meson.build
deleted file mode 100644
index a24df304d1..0000000000
--- a/src/lib/evas/common3d/primitives/tabulated_primitives/meson.build
+++ /dev/null
@@ -1,4 +0,0 @@
-evas_src += files([
- 'cube.c',
- 'square.c'
-]) \ No newline at end of file
diff --git a/src/lib/evas/common3d/primitives/tabulated_primitives/square.c b/src/lib/evas/common3d/primitives/tabulated_primitives/square.c
deleted file mode 100644
index e34e2b0dbb..0000000000
--- a/src/lib/evas/common3d/primitives/tabulated_primitives/square.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "../primitive_common.h"
-
-const float vertices_of_square[] =
-{
- /* positions normals vertex_color tex_coords tangents */
- -0.5, 0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
- 0.5, 0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
- -0.5, -0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
- 0.5, -0.5, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
-};
-
-const unsigned short indices_of_square[] = {0, 1, 2, 2, 1, 3};
-
-void
-evas_model_set_from_square_primitive(Evas_Canvas3D_Mesh *mesh, int frame)
-{
- SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, vertices_of_square, 4, indices_of_square, 6)
-}