* by interpolation between frames.
*
* @verbatim
- * gcc -o evas-3d-cube2 evas-3d-cube2.c `pkg-config --libs --cflags evas ecore ecore-evas eo`
+ * gcc -o evas-3d-cube2 evas-3d-cube2.c evas-3d-primitives.c `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm
* @endverbatim
*/
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
+#include "evas-3d-primitives.h"
#include "evas-common.h"
#define WIDTH 400
static Eo *background = NULL;
static Eo *image = NULL;
-static const float cube_vertices[] =
-{
- /* Front */
- -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0,
- 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
- -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
- 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0,
-
- /* Back */
- 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
- -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0,
- 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0,
- -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0,
-
- /* Left */
- -1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 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.0, 1.0, 0.0, 1.0, 1.0, 1.0,
- -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0,
- -1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0,
-
- /* Right */
- 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0,
- 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0,
- 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
- 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
-
- /* Top */
- -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
- 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
- -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
- 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
-
- /* Bottom */
- 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
- -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
- 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
- -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
-};
-
-static const unsigned short cube_indices[] =
-{
- /* Front */
- 0, 1, 2, 2, 1, 3,
-
- /* Back */
- 4, 5, 6, 6, 5, 7,
-
- /* Left */
- 8, 9, 10, 10, 9, 11,
-
- /* Right */
- 12, 13, 14, 14, 13, 15,
-
- /* Top */
- 16, 17, 18, 18, 17, 19,
-
- /* Bottom */
- 20, 21, 22, 22, 21, 23
-};
-
static const unsigned int pixels0[] =
{
0xff0000ff, 0xff0000ff, 0xffff0000, 0xffff0000,
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA));
eo_do(data->camera_node,
evas_3d_node_camera_set(data->camera),
- evas_3d_node_position_set(0.0, 0.0, 10.0),
+ evas_3d_node_position_set(0.0, 0.0, 3.0),
evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
eo_do(data->root_node,
/* Setup mesh. */
data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
+ evas_3d_add_cube_frame(data->mesh, 0);
eo_do(data->mesh,
- evas_3d_mesh_vertex_count_set(24),
- evas_3d_mesh_frame_add(0),
-
- evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION,
- 12 * sizeof(float), &cube_vertices[0]),
- evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL,
- 12 * sizeof(float), &cube_vertices[3]),
- evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR,
- 12 * sizeof(float), &cube_vertices[6]),
- evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD,
- 12 * sizeof(float), &cube_vertices[10]),
-
- evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
- 36, &cube_indices[0]),
- evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
-
- evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP),
-
evas_3d_mesh_frame_material_set(0, data->material0),
-
evas_3d_mesh_frame_add(20),
- evas_3d_mesh_frame_material_set(20, data->material1));
+ evas_3d_mesh_frame_material_set(20, data->material1),
+ evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP));
data->mesh_node =
eo_add(EVAS_3D_NODE_CLASS, evas,