summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-cube2.c
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2014-05-01 11:01:56 +0200
committerCedric Bail <cedric.bail@free.fr>2014-05-01 12:05:32 +0200
commitbcfae42b3ce7399b96ebba65e9ed5eda8a979224 (patch)
treeadfb9dc2ec0ee45e67a179d0730f3fafa85d09fb /src/examples/evas/evas-3d-cube2.c
parent07c3edec4abd838fbd0c411e75cda7eef6c60f37 (diff)
evas: fix Evas_3D examples to use Eo API.
Diffstat (limited to 'src/examples/evas/evas-3d-cube2.c')
-rw-r--r--src/examples/evas/evas-3d-cube2.c99
1 files changed, 45 insertions, 54 deletions
diff --git a/src/examples/evas/evas-3d-cube2.c b/src/examples/evas/evas-3d-cube2.c
index 7c90d1d..ac0bbdc 100644
--- a/src/examples/evas/evas-3d-cube2.c
+++ b/src/examples/evas/evas-3d-cube2.c
@@ -163,13 +163,12 @@ _camera_setup(Scene_Data *data)
163// eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_CAMERA); 163// eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_CAMERA);
164 data->camera_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_CAMERA); 164 data->camera_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_CAMERA);
165 eo_do(data->camera_node, 165 eo_do(data->camera_node,
166 evas_3d_node_camera_set(data->camera)); 166 evas_3d_node_camera_set(data->camera),
167 eo_do(data->root_node,
168 evas_3d_node_member_add(data->camera_node));
169 eo_do(data->camera_node,
170 evas_3d_node_position_set(0.0, 0.0, 10.0), 167 evas_3d_node_position_set(0.0, 0.0, 10.0),
171 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, 168 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
172 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0)); 169 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
170 eo_do(data->root_node,
171 evas_3d_node_member_add(data->camera_node));
173} 172}
174 173
175static void 174static void
@@ -184,13 +183,11 @@ _light_setup(Scene_Data *data)
184// data->light_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_LIGHT); 183// data->light_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_LIGHT);
185 data->light_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_LIGHT); 184 data->light_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_LIGHT);
186 eo_do(data->light_node, 185 eo_do(data->light_node,
187 evas_3d_node_light_set(data->light)); 186 evas_3d_node_light_set(data->light),
188 eo_do(data->root_node,
189 evas_3d_node_member_add(data->light_node));
190 eo_do(data->light_node,
191 evas_3d_node_position_set(0.0, 0.0, 10.0), 187 evas_3d_node_position_set(0.0, 0.0, 10.0),
192 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, 188 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
193 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0)); 189 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
190 eo_do(data->root_node, evas_3d_node_member_add(data->light_node));
194} 191}
195 192
196static void 193static void
@@ -198,92 +195,86 @@ _mesh_setup(Scene_Data *data)
198{ 195{
199 /* Setup material. */ 196 /* Setup material. */
200 data->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, evas); 197 data->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
198 data->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
199
201 eo_do(data->material0, 200 eo_do(data->material0,
202 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 201 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
203 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 202 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
204 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE); 203 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
205 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 204 evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE),
206 0.2, 0.2, 0.2, 1.0), 205
207 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 206 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0),
208 0.8, 0.8, 0.8, 1.0), 207 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0),
209 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 208 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0),
210 1.0, 1.0, 1.0, 1.0),
211 evas_3d_material_shininess_set(100.0)); 209 evas_3d_material_shininess_set(100.0));
212 210
213 data->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
214 eo_do(data->material1, 211 eo_do(data->material1,
215 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), 212 evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE),
216 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 213 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
217 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), 214 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
218 evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE); 215 evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE),
219 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 216
220 0.2, 0.2, 0.2, 1.0), 217 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0),
221 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 218 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0),
222 0.8, 0.8, 0.8, 1.0), 219 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0),
223 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR,
224 1.0, 1.0, 1.0, 1.0),
225 evas_3d_material_shininess_set(100.0)); 220 evas_3d_material_shininess_set(100.0));
226 221
227 /* Texture 1 */
228 data->texture0 = eo_add(EVAS_3D_TEXTURE_CLASS, evas); 222 data->texture0 = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
229 eo_do(data->texture0, evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA,
230 EVAS_3D_PIXEL_FORMAT_8888, 4,
231 4, &pixels0[0]));
232 eo_do(data->material0, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE,
233 data->texture0));
234 /* Texture 2 */
235 data->texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, evas); 223 data->texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
236 eo_do(data->texture1, evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA,
237 EVAS_3D_PIXEL_FORMAT_8888, 4,
238 4, &pixels1[0]));
239 eo_do(data->material1, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE,
240 data->texture1));
241 /* Normal texture */
242 data->texture_normal = eo_add(EVAS_3D_TEXTURE_CLASS, evas); 224 data->texture_normal = eo_add(EVAS_3D_TEXTURE_CLASS, evas);
243 225
244 eo_do(data->texture_normal, evas_3d_texture_file_set("normal_lego.png", 226 eo_do(data->texture0,
245 NULL)); 227 evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA,
228 EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels0[0]));
229 eo_do(data->texture1,
230 evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA,
231 EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]));
232 eo_do(data->texture_normal, evas_3d_texture_file_set("normal_lego.png", NULL));
233
234 eo_do(data->material0,
235 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, data->texture0));
236 eo_do(data->material1,
237 evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, data->texture1));
238 eo_do(data->material1,
239 evas_3d_material_texture_set(EVAS_3D_MATERIAL_NORMAL, data->texture_normal));
246 240
247 eo_do(data->material1, evas_3d_material_texture_set(EVAS_3D_MATERIAL_NORMAL,
248 data->texture_normal));
249 /* Setup mesh. */ 241 /* Setup mesh. */
250 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas); 242 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
251 eo_do(data->mesh, 243 eo_do(data->mesh,
252 evas_3d_mesh_vertex_count_set(24), 244 evas_3d_mesh_vertex_count_set(24),
253 evas_3d_mesh_frame_add(0), 245 evas_3d_mesh_frame_add(0),
246
254 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, 247 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION,
255 12 * sizeof(float), 248 12 * sizeof(float), &cube_vertices[0]),
256 &cube_vertices[0]),
257 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL, 249 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL,
258 12 * sizeof(float), 250 12 * sizeof(float), &cube_vertices[3]),
259 &cube_vertices[3]),
260 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR, 251 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR,
261 12 * sizeof(float), 252 12 * sizeof(float), &cube_vertices[6]),
262 &cube_vertices[6]),
263 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, 253 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD,
264 12 * sizeof(float), 254 12 * sizeof(float), &cube_vertices[10]),
265 &cube_vertices[10]), 255
266 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 256 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
267 36, &cube_indices[0]), 257 36, &cube_indices[0]),
268 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES), 258 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
259
269 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP), 260 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP),
261
270 evas_3d_mesh_frame_material_set(0, data->material0), 262 evas_3d_mesh_frame_material_set(0, data->material0),
263
271 evas_3d_mesh_frame_add(20), 264 evas_3d_mesh_frame_add(20),
272 evas_3d_mesh_frame_material_set(20, data->material1)); 265 evas_3d_mesh_frame_material_set(20, data->material1));
273 266
274// data->mesh_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_MESH);
275 data->mesh_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_MESH); 267 data->mesh_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_MESH);
276 eo_do(data->root_node, 268 eo_do(data->root_node, evas_3d_node_member_add(data->mesh_node));
277 evas_3d_node_member_add(data->mesh_node)); 269 eo_do(data->mesh_node, evas_3d_node_mesh_add(data->mesh));
278 eo_do(data->mesh_node,
279 evas_3d_node_mesh_add(data->mesh));
280} 270}
281 271
282static void 272static void
283_scene_setup(Scene_Data *data) 273_scene_setup(Scene_Data *data)
284{ 274{
285 data->scene = eo_add(EVAS_3D_SCENE_CLASS, evas); 275 data->scene = eo_add(EVAS_3D_SCENE_CLASS, evas);
286 eo_do(data->scene, evas_3d_scene_size_set(WIDTH, HEIGHT), 276 eo_do(data->scene,
277 evas_3d_scene_size_set(WIDTH, HEIGHT),
287 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0)); 278 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0));
288 279
289// data->root_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_NODE); 280// data->root_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_NODE);