summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-03-18 14:36:52 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-18 15:22:20 +0100
commit0f86d692e701397d3813015c4dc7118305f7c049 (patch)
tree6412df9b67557abb9f35c325677188ffb8e2f979
parent1b534d5497e471d841bc2e541b74a152dd76150f (diff)
evas: cube-rotate example uses cube primitives.
Reviewers: Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2165 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/examples/evas/evas-3d-cube-rotate.c80
1 files changed, 4 insertions, 76 deletions
diff --git a/src/examples/evas/evas-3d-cube-rotate.c b/src/examples/evas/evas-3d-cube-rotate.c
index 4a45aedf19..f691fe904d 100644
--- a/src/examples/evas/evas-3d-cube-rotate.c
+++ b/src/examples/evas/evas-3d-cube-rotate.c
@@ -8,7 +8,7 @@
8 * is pressed. Note, that rotation is taking place around one axis only. 8 * is pressed. Note, that rotation is taking place around one axis only.
9 * 9 *
10 * @verbatim 10 * @verbatim
11 * gcc -o evas-3d-cube-rotate evas-3d-cube-rotate.c -g `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm 11 * gcc -o evas-3d-cube-rotate evas-3d-cube-rotate.c evas-3d-primitives.c -g `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm
12 * @endverbatim 12 * @endverbatim
13 */ 13 */
14 14
@@ -19,6 +19,7 @@
19#include <Ecore_Evas.h> 19#include <Ecore_Evas.h>
20#include <Evas.h> 20#include <Evas.h>
21#include <Eo.h> 21#include <Eo.h>
22#include "evas-3d-primitives.h"
22 23
23 24
24#define WIDTH 400 25#define WIDTH 400
@@ -57,67 +58,6 @@ int mouse_old_x = 0;
57int mouse_old_y = 0; 58int mouse_old_y = 0;
58int indicator = 0; 59int indicator = 0;
59 60
60
61static const float cube_vertices[] =
62{
63 /* Front */
64 -1.0, 1.0, 1.0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88 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
89 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
90 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
91 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
92
93 /* Bottom */
94 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
95 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
96 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
97 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
98};
99
100static const unsigned short cube_indices[] =
101{
102 /* Front */
103 0, 1, 2, 2, 1, 3,
104
105 /* Back */
106 4, 5, 6, 6, 5, 7,
107
108 /* Left */
109 8, 9, 10, 10, 9, 11,
110
111 /* Right */
112 12, 13, 14, 14, 13, 15,
113
114 /* Top */
115 16, 17, 18, 18, 17, 19,
116
117 /* Bottom */
118 20, 21, 22, 22, 21, 23
119};
120
121static void 61static void
122_on_delete(Ecore_Evas *ee EINA_UNUSED) 62_on_delete(Ecore_Evas *ee EINA_UNUSED)
123{ 63{
@@ -218,7 +158,7 @@ _camera_setup(Scene_Data *data)
218{ 158{
219 data->camera = eo_add(EVAS_3D_CAMERA_CLASS, evas); 159 data->camera = eo_add(EVAS_3D_CAMERA_CLASS, evas);
220 eo_do(data->camera, 160 eo_do(data->camera,
221 evas_3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0)); 161 evas_3d_camera_projection_perspective_set(20.0, 1.0, 2.0, 50.0));
222 162
223 data->camera_node = eo_add(EVAS_3D_NODE_CLASS, evas, 163 data->camera_node = eo_add(EVAS_3D_NODE_CLASS, evas,
224 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA)); 164 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA));
@@ -269,20 +209,8 @@ _mesh_setup(Scene_Data *data)
269 209
270 /* Setup mesh. */ 210 /* Setup mesh. */
271 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas); 211 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
212 evas_3d_add_cube_frame(data->mesh, 0);
272 eo_do(data->mesh, 213 eo_do(data->mesh,
273 evas_3d_mesh_vertex_count_set(24),
274 evas_3d_mesh_frame_add(0),
275 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION,
276 12 * sizeof(float), &cube_vertices[ 0]),
277 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL,
278 12 * sizeof(float), &cube_vertices[ 3]),
279 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR,
280 12 * sizeof(float), &cube_vertices[ 6]),
281 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD,
282 12 * sizeof(float), &cube_vertices[10]),
283
284 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]),
285 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
286 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), 214 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG),
287 evas_3d_mesh_frame_material_set(0, data->material)); 215 evas_3d_mesh_frame_material_set(0, data->material));
288 216