/**
* This example shows how to get and draw axis-aligned bounding box.
*
- * @see _mesh_aabb(Evas_3D_Mesh **mesh_b, const Evas_3D_Node *node);
+ * @see _redraw_aabb();
* Rotate axises (keys 1-4) for model and bounding box view from another angle.
*
* @verbatim
- * gcc -o evas-3d-aabb evas-3d-aabb.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`
+ * gcc -o evas-3d-aabb evas-3d-aabb.c evas-3d-primitives.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo` -lm
* @endverbatim
*/
#include <Ecore.h>
#include <Ecore_Evas.h>
#include "evas-common.h"
+#include "evas-3d-primitives.h"
#define WIDTH 400
#define HEIGHT 400
static Eina_Bool
-_mesh_aabb(Evas_3D_Mesh **mesh_b);
+_redraw_aabb();
static Eina_Bool
_animate_scene(void *data)
eo_do((Evas_3D_Node *)data, evas_3d_node_mesh_frame_set(mesh, frame));
- _mesh_aabb(&mesh_box);
+ _redraw_aabb();
frame += 32;
}
static Eina_Bool
-_mesh_aabb(Evas_3D_Mesh **mesh_b)
+_redraw_aabb()
{
Evas_Real x0, y0, z0, x1, y1, z1;
eo_do(mesh_node, evas_3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
-
- float vertices[] =
- {
- x0, y0, z1,
- x0, y1, z1,
- x1, y1, z1,
- x1, y0, z1,
-
- x0, y0, z0,
- x1, y0, z0,
- x0, y1, z0,
- x1, y1, z0,
-
- x0, y0, z0,
- x0, y1, z0,
- x0, y0, z1,
- x0, y1, z1,
-
- x1, y0, z0,
- x1, y1, z0,
- x1, y1, z1,
- x1, y0, z1,
-
- x0, y1, z0,
- x1, y1, z0,
- x0, y1, z1,
- x1, y1, z1,
-
- x0, y0, z0,
- x1, y0, z0,
- x1, y0, z1,
- x0, y0, z1
- };
-
- unsigned short indices[] =
- {
- 0, 1, 2, 3, 1, 2, 0, 3,
- 4, 5, 5, 7, 7, 6, 6, 4,
- 8, 9, 9, 11, 11, 10, 10, 8,
- 12, 13, 13, 14, 14, 15, 15, 12,
- 16, 17, 17, 19, 19, 18, 18, 16,
- 20, 21, 21, 22, 22, 23, 23, 20
- };
-
- float *cube_vertices = (float *) malloc(1 * sizeof(vertices));
- unsigned short *cube_indices = (unsigned short *) malloc(1 * sizeof(indices));
- memcpy(cube_vertices, vertices, sizeof(vertices));
- memcpy(cube_indices, indices, sizeof(indices));
-
- eo_do(*mesh_b,
- evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_POSITION,
- 3 * sizeof(float),
- &cube_vertices[ 0]),
- evas_3d_mesh_index_data_copy_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
- 48, &cube_indices[0]));
- free(cube_vertices);
- free(cube_indices);
+ eo_do(mesh_box_node, evas_3d_node_position_set((x0 + x1)/2, (y0 + y1)/2, (z0 + z1)/2),
+ evas_3d_node_scale_set(x1 - x0, y1 - y0, z1 - z0));
return EINA_TRUE;
}
material_box = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(material_box, evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE));
- mesh_box = eo_add(EVAS_3D_MESH_CLASS, evas);
- eo_do(mesh_box,
- evas_3d_mesh_vertex_count_set(24),
- evas_3d_mesh_frame_add(0),
+ mesh_box = eo_add(EVAS_3D_MESH_CLASS, evas);
+ evas_3d_add_cube_frame(mesh_box, 0);
+ eo_do(mesh_box,
evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_LINES),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_DIFFUSE),
evas_3d_mesh_frame_material_set(0, material_box));
- _mesh_aabb(&mesh_box);
+ _redraw_aabb();
eo_do(root_node,
evas_3d_node_member_add(mesh_box_node));