evas: Evas_3d proxy example uses cube primitives.

Reviewers: Hermet, raster, cedric

Reviewed By: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2172

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Bogdan Devichev 2015-03-18 14:48:50 +01:00 committed by Cedric BAIL
parent db7d448ca2
commit 4c0f37b93c
1 changed files with 4 additions and 79 deletions

View File

@ -4,7 +4,7 @@
* Data which will be used as texture can be generated directly in application.
*
* @verbatim
* gcc -o evas-3d-proxy evas-3d-proxy.c `pkg-config --libs --cflags evas ecore ecore-evas eo`
* gcc -o evas-3d-proxy evas-3d-proxy.c evas-3d-primitives.c `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm
* @endverbatim
*/
@ -15,6 +15,7 @@
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Evas.h>
#include "evas-3d-primitives.h"
#define WIDTH 400
#define HEIGHT 400
@ -43,66 +44,6 @@ static Eo *background = NULL;
static Eo *image = NULL;
static Eo *source = 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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{
/* 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 void
_on_delete(Ecore_Evas *ee EINA_UNUSED)
{
@ -168,7 +109,7 @@ _camera_setup(Scene_Data *data)
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, 5.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,
@ -220,25 +161,9 @@ _mesh_setup(Scene_Data *data)
/* 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_FLAT),
evas_3d_mesh_frame_material_set(0, data->material));
data->mesh_node =