summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-cube2.c
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-03-18 14:35:37 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-18 15:22:20 +0100
commit1b534d5497e471d841bc2e541b74a152dd76150f (patch)
tree5e8a49a509c19bc93bac90300ec34d86d7b84537 /src/examples/evas/evas-3d-cube2.c
parente1b4303df3cdd36b5fb33fcc9a0a39a41233784a (diff)
evas: cube2 example uses cube primitives.
Reviewers: Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2164 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples/evas/evas-3d-cube2.c')
-rw-r--r--src/examples/evas/evas-3d-cube2.c88
1 files changed, 6 insertions, 82 deletions
diff --git a/src/examples/evas/evas-3d-cube2.c b/src/examples/evas/evas-3d-cube2.c
index ead599a..4a1afaa 100644
--- a/src/examples/evas/evas-3d-cube2.c
+++ b/src/examples/evas/evas-3d-cube2.c
@@ -3,7 +3,7 @@
3 * by interpolation between frames. 3 * by interpolation between frames.
4 * 4 *
5 * @verbatim 5 * @verbatim
6 * gcc -o evas-3d-cube2 evas-3d-cube2.c `pkg-config --libs --cflags evas ecore ecore-evas eo` 6 * gcc -o evas-3d-cube2 evas-3d-cube2.c evas-3d-primitives.c `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm
7 * @endverbatim 7 * @endverbatim
8 */ 8 */
9 9
@@ -19,6 +19,7 @@
19#include <Evas.h> 19#include <Evas.h>
20#include <Ecore.h> 20#include <Ecore.h>
21#include <Ecore_Evas.h> 21#include <Ecore_Evas.h>
22#include "evas-3d-primitives.h"
22#include "evas-common.h" 23#include "evas-common.h"
23 24
24#define WIDTH 400 25#define WIDTH 400
@@ -50,66 +51,6 @@ static Evas *evas = NULL;
50static Eo *background = NULL; 51static Eo *background = NULL;
51static Eo *image = NULL; 52static Eo *image = NULL;
52 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0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
78
79 /* Top */
80 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
81 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
82 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
83 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
84
85 /* Bottom */
86 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
87 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
88 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
89 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
90};
91
92static const unsigned short cube_indices[] =
93{
94 /* Front */
95 0, 1, 2, 2, 1, 3,
96
97 /* Back */
98 4, 5, 6, 6, 5, 7,
99
100 /* Left */
101 8, 9, 10, 10, 9, 11,
102
103 /* Right */
104 12, 13, 14, 14, 13, 15,
105
106 /* Top */
107 16, 17, 18, 18, 17, 19,
108
109 /* Bottom */
110 20, 21, 22, 22, 21, 23
111};
112
113static const unsigned int pixels0[] = 54static const unsigned int pixels0[] =
114{ 55{
115 0xff0000ff, 0xff0000ff, 0xffff0000, 0xffff0000, 56 0xff0000ff, 0xff0000ff, 0xffff0000, 0xffff0000,
@@ -180,7 +121,7 @@ _camera_setup(Scene_Data *data)
180 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA)); 121 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA));
181 eo_do(data->camera_node, 122 eo_do(data->camera_node,
182 evas_3d_node_camera_set(data->camera), 123 evas_3d_node_camera_set(data->camera),
183 evas_3d_node_position_set(0.0, 0.0, 10.0), 124 evas_3d_node_position_set(0.0, 0.0, 3.0),
184 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, 125 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
185 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0)); 126 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
186 eo_do(data->root_node, 127 eo_do(data->root_node,
@@ -258,29 +199,12 @@ _mesh_setup(Scene_Data *data)
258 199
259 /* Setup mesh. */ 200 /* Setup mesh. */
260 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas); 201 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
202 evas_3d_add_cube_frame(data->mesh, 0);
261 eo_do(data->mesh, 203 eo_do(data->mesh,
262 evas_3d_mesh_vertex_count_set(24),
263 evas_3d_mesh_frame_add(0),
264
265 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION,
266 12 * sizeof(float), &cube_vertices[0]),
267 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL,
268 12 * sizeof(float), &cube_vertices[3]),
269 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR,
270 12 * sizeof(float), &cube_vertices[6]),
271 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD,
272 12 * sizeof(float), &cube_vertices[10]),
273
274 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
275 36, &cube_indices[0]),
276 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
277
278 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP),
279
280 evas_3d_mesh_frame_material_set(0, data->material0), 204 evas_3d_mesh_frame_material_set(0, data->material0),
281
282 evas_3d_mesh_frame_add(20), 205 evas_3d_mesh_frame_add(20),
283 evas_3d_mesh_frame_material_set(20, data->material1)); 206 evas_3d_mesh_frame_material_set(20, data->material1),
207 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP));
284 208
285 data->mesh_node = 209 data->mesh_node =
286 eo_add(EVAS_3D_NODE_CLASS, evas, 210 eo_add(EVAS_3D_NODE_CLASS, evas,