diff options
-rw-r--r-- | media/normal_lego.png | bin | 0 -> 3166 bytes | |||
-rw-r--r-- | src/GuiLua/GuiLua.c | 405 |
2 files changed, 219 insertions, 186 deletions
diff --git a/media/normal_lego.png b/media/normal_lego.png new file mode 100644 index 0000000..6a74ad9 --- /dev/null +++ b/media/normal_lego.png | |||
Binary files differ | |||
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 00b7d83..7560a77 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c | |||
@@ -149,20 +149,24 @@ EAPI Evas_3D_Node *evas_3d_node_add(Evas *e, Evas_3D_Node_Type type); | |||
149 | 149 | ||
150 | typedef struct _Scene_Data | 150 | typedef struct _Scene_Data |
151 | { | 151 | { |
152 | Evas_3D_Scene *scene; | 152 | Evas_3D_Scene *scene; |
153 | Evas_3D_Node *root_node; | 153 | Evas_3D_Node *root_node; |
154 | Evas_3D_Node *camera_node; | 154 | Evas_3D_Node *camera_node; |
155 | Evas_3D_Node *light_node; | 155 | Evas_3D_Node *light_node; |
156 | Evas_3D_Node *mesh_node; | 156 | Evas_3D_Node *mesh_node; |
157 | Evas_3D_Node *mesh2_node; | 157 | Evas_3D_Node *mesh2_node; |
158 | 158 | ||
159 | Evas_3D_Camera *camera; | 159 | Evas_3D_Camera *camera; |
160 | Evas_3D_Light *light; | 160 | Evas_3D_Light *light; |
161 | Evas_3D_Mesh *mesh; | 161 | Evas_3D_Mesh *mesh; |
162 | Evas_3D_Material *material; | 162 | Evas_3D_Material *material0; |
163 | Evas_3D_Mesh *mesh2; | 163 | Evas_3D_Material *material1; |
164 | Evas_3D_Material *material2; | 164 | Evas_3D_Texture *texture0; |
165 | Evas_3D_Texture *texture2; | 165 | Evas_3D_Texture *texture1; |
166 | Evas_3D_Texture *texture_normal; | ||
167 | Evas_3D_Mesh *mesh2; | ||
168 | Evas_3D_Material *material2; | ||
169 | Evas_3D_Texture *texture2; | ||
166 | } Scene_Data; | 170 | } Scene_Data; |
167 | 171 | ||
168 | static const float cube_vertices[] = | 172 | static const float cube_vertices[] = |
@@ -225,6 +229,22 @@ static const unsigned short cube_indices[] = | |||
225 | 20, 21, 22, 22, 21, 23 | 229 | 20, 21, 22, 22, 21, 23 |
226 | }; | 230 | }; |
227 | 231 | ||
232 | static const unsigned int pixels0[] = | ||
233 | { | ||
234 | 0xff0000ff, 0xff0000ff, 0xffff0000, 0xffff0000, | ||
235 | 0xff0000ff, 0xff0000ff, 0xffff0000, 0xffff0000, | ||
236 | 0xff00ff00, 0xff00ff00, 0xff000000, 0xff000000, | ||
237 | 0xff00ff00, 0xff00ff00, 0xff000000, 0xff000000, | ||
238 | }; | ||
239 | |||
240 | static const unsigned int pixels1[] = | ||
241 | { | ||
242 | 0xffff0000, 0xffff0000, 0xff00ff00, 0xff00ff00, | ||
243 | 0xffff0000, 0xffff0000, 0xff00ff00, 0xff00ff00, | ||
244 | 0xff0000ff, 0xff0000ff, 0xffffffff, 0xffffffff, | ||
245 | 0xff0000ff, 0xff0000ff, 0xffffffff, 0xffffffff, | ||
246 | }; | ||
247 | |||
228 | 248 | ||
229 | globals ourGlobals; | 249 | globals ourGlobals; |
230 | static const char *globName = "ourGlobals"; | 250 | static const char *globName = "ourGlobals"; |
@@ -235,209 +255,222 @@ static Scene_Data ourScene; | |||
235 | static Eina_Bool | 255 | static Eina_Bool |
236 | _animate_scene(void *data) | 256 | _animate_scene(void *data) |
237 | { | 257 | { |
238 | static float angle = 0.0f; | 258 | static float angle = 0.0f; |
239 | static int frame = 0; | 259 | static int frame = 0; |
260 | static int inc = 1; | ||
261 | static int sonicFrame = 0; | ||
240 | 262 | ||
241 | Scene_Data *scene = (Scene_Data *)data; | 263 | Scene_Data *scene = (Scene_Data *)data; |
242 | 264 | ||
243 | angle += 0.5; | 265 | // Rotate cube |
266 | angle += 0.5; | ||
267 | if (angle > 360.0) angle -= 360.0f; | ||
244 | 268 | ||
245 | eo_do(scene->mesh_node, | 269 | frame += inc; |
246 | evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0) | ||
247 | ); | ||
248 | 270 | ||
249 | eo_do(scene->mesh2_node, | 271 | if (frame >= 20) inc = -1; |
250 | evas_3d_node_mesh_frame_set(scene->mesh2, frame) | 272 | else if (frame <= 0) inc = 1; |
251 | ); | ||
252 | 273 | ||
253 | /* Rotate */ | 274 | eo_do(scene->mesh_node, |
254 | if (angle > 360.0) angle -= 360.0f; | 275 | evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0), |
276 | evas_3d_node_mesh_frame_set(scene->mesh, frame) | ||
277 | ); | ||
255 | 278 | ||
256 | frame += 32; | 279 | // Animate sonic. |
257 | if (frame > 256 * 50) frame = 0; | 280 | sonicFrame += 32; |
281 | if (sonicFrame > 256 * 50) sonicFrame = 0; | ||
282 | eo_do(scene->mesh2_node, | ||
283 | evas_3d_node_mesh_frame_set(scene->mesh2, sonicFrame) | ||
284 | ); | ||
258 | 285 | ||
259 | return EINA_TRUE; | 286 | return EINA_TRUE; |
260 | } | 287 | } |
261 | 288 | ||
262 | #define DO_CUBE 1 | ||
263 | 289 | ||
264 | static void | 290 | static void |
265 | _camera_setup(globals *ourGlobals, Scene_Data *scene) | 291 | _camera_setup(globals *ourGlobals, Scene_Data *scene) |
266 | { | 292 | { |
267 | scene->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas); | 293 | scene->camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas); |
268 | eo_do(scene->camera, | 294 | eo_do(scene->camera, |
269 | #if DO_CUBE | 295 | evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0) |
270 | evas_3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0) | 296 | ); |
271 | #else | 297 | |
272 | evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0) | 298 | scene->camera_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA); |
273 | #endif | 299 | eo_do(scene->camera_node, |
274 | ); | 300 | evas_3d_node_camera_set(scene->camera) |
275 | 301 | ); | |
276 | scene->camera_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA); | 302 | eo_do(scene->root_node, evas_3d_node_member_add(scene->camera_node)); |
277 | eo_do(scene->camera_node, | 303 | eo_do(scene->camera_node, |
278 | evas_3d_node_camera_set(scene->camera) | 304 | evas_3d_node_position_set(50.0, 0.0, 20.0), |
279 | ); | 305 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 20.0, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0) |
280 | eo_do(scene->root_node, | 306 | ); |
281 | evas_3d_node_member_add(scene->camera_node) | ||
282 | ); | ||
283 | eo_do(scene->camera_node, | ||
284 | #if DO_CUBE | ||
285 | evas_3d_node_position_set(0.0, 0.0, 10.0), | ||
286 | 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) | ||
287 | #else | ||
288 | evas_3d_node_position_set(100.0, 0.0, 20.0), | ||
289 | evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 20.0, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0) | ||
290 | #endif | ||
291 | ); | ||
292 | } | 307 | } |
293 | 308 | ||
294 | static void | 309 | static void |
295 | _light_setup(globals *ourGlobals, Scene_Data *scene) | 310 | _light_setup(globals *ourGlobals, Scene_Data *scene) |
296 | { | 311 | { |
297 | scene->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas); | 312 | scene->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas); |
298 | eo_do(scene->light, | 313 | eo_do(scene->light, |
299 | #if DO_CUBE | 314 | evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), |
300 | evas_3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), | 315 | evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), |
301 | #else | 316 | evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0), |
302 | evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), | 317 | evas_3d_light_directional_set(EINA_TRUE) |
303 | #endif | 318 | ); |
304 | evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), | 319 | |
305 | evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0), | 320 | scene->light_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_LIGHT); |
306 | evas_3d_light_directional_set(EINA_TRUE) | 321 | eo_do(scene->light_node, |
307 | ); | 322 | evas_3d_node_light_set(scene->light) |
308 | 323 | ); | |
309 | scene->light_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_LIGHT); | 324 | eo_do(scene->root_node, |
310 | eo_do(scene->light_node, | 325 | evas_3d_node_member_add(scene->light_node) |
311 | evas_3d_node_light_set(scene->light) | 326 | ); |
312 | ); | 327 | eo_do(scene->light_node, |
313 | eo_do(scene->root_node, | 328 | evas_3d_node_position_set(1000.0, 0.0, 1000.0), |
314 | evas_3d_node_member_add(scene->light_node) | 329 | 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) |
315 | ); | 330 | ); |
316 | eo_do(scene->light_node, | ||
317 | #if DO_CUBE | ||
318 | evas_3d_node_position_set(0.0, 0.0, 10.0), | ||
319 | #else | ||
320 | evas_3d_node_position_set(1000.0, 0.0, 1000.0), | ||
321 | #endif | ||
322 | 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) | ||
323 | ); | ||
324 | } | 331 | } |
325 | 332 | ||
326 | static void | 333 | static void |
327 | _mesh_setup(globals *ourGlobals, Scene_Data *scene) | 334 | _mesh_setup(globals *ourGlobals, Scene_Data *scene) |
328 | { | 335 | { |
329 | /* Setup material. */ | 336 | // Setup cube materials. |
330 | scene->material = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | 337 | scene->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
331 | eo_do(scene->material, | 338 | scene->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
332 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | 339 | |
333 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | 340 | eo_do(scene->material0, |
334 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), | 341 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), |
335 | 342 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | |
336 | evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0), | 343 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), |
337 | evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0), | 344 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), |
338 | evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), | 345 | |
339 | evas_3d_material_shininess_set(100.0) | 346 | evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0), |
340 | ); | 347 | evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0), |
341 | 348 | evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), | |
342 | /* Setup mesh. */ | 349 | evas_3d_material_shininess_set(100.0) |
343 | scene->mesh = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); | 350 | ); |
344 | eo_do(scene->mesh, | 351 | |
345 | evas_3d_mesh_vertex_count_set(24), | 352 | eo_do(scene->material1, |
346 | evas_3d_mesh_frame_add(0), | 353 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), |
347 | 354 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | |
348 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, 12 * sizeof(float), &cube_vertices[ 0]), | 355 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), |
349 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL, 12 * sizeof(float), &cube_vertices[ 3]), | 356 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), |
350 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR, 12 * sizeof(float), &cube_vertices[ 6]), | 357 | |
351 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, 12 * sizeof(float), &cube_vertices[10]), | 358 | evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0), |
352 | 359 | evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0), | |
353 | evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]), | 360 | evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), |
354 | evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES), | 361 | evas_3d_material_shininess_set(100.0) |
355 | 362 | ); | |
356 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), | 363 | |
357 | 364 | scene->texture0 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); | |
358 | evas_3d_mesh_frame_material_set(0, scene->material) | 365 | scene->texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); |
359 | 366 | scene->texture_normal = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); | |
360 | ); | 367 | |
361 | scene->mesh_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); | 368 | eo_do(scene->texture0, |
362 | eo_do(scene->root_node, | 369 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels0[0]) |
363 | evas_3d_node_member_add(scene->mesh_node) | 370 | ); |
364 | ); | 371 | eo_do(scene->texture1, |
365 | eo_do(scene->mesh_node, | 372 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) |
366 | evas_3d_node_mesh_add(scene->mesh) | 373 | ); |
367 | ); | 374 | eo_do(scene->texture_normal, evas_3d_texture_file_set("../../media/normal_lego.png", NULL)); |
368 | 375 | ||
369 | #if DO_CUBE | 376 | eo_do(scene->material0, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture0)); |
370 | #else | 377 | eo_do(scene->material1, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture1)); |
371 | // Setup an MD2 mesh. | 378 | eo_do(scene->material1, evas_3d_material_texture_set(EVAS_3D_MATERIAL_NORMAL, scene->texture_normal)); |
372 | scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); | 379 | |
373 | eo_do(scene->mesh2, | 380 | // Setup CUBE mesh. |
374 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "../../media/sonic.md2", NULL) | 381 | scene->mesh = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); |
375 | ); | 382 | eo_do(scene->mesh, |
376 | 383 | evas_3d_mesh_vertex_count_set(24), | |
377 | scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | 384 | evas_3d_mesh_frame_add(0), |
378 | eo_do(scene->mesh2, | 385 | |
379 | evas_3d_mesh_frame_material_set(0, scene->material2) | 386 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, 12 * sizeof(float), &cube_vertices[ 0]), |
380 | ); | 387 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL, 12 * sizeof(float), &cube_vertices[ 3]), |
381 | 388 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR, 12 * sizeof(float), &cube_vertices[ 6]), | |
382 | scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); | 389 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, 12 * sizeof(float), &cube_vertices[10]), |
383 | eo_do(scene->texture2, | 390 | |
384 | // evas_3d_texture_file_set("../../media/sonic.png", NULL), | 391 | evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]), |
385 | // evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), | 392 | evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES), |
386 | // evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT) | 393 | |
387 | ); | 394 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP), |
388 | 395 | ||
389 | eo_do(scene->material2, | 396 | evas_3d_mesh_frame_material_set(0, scene->material0), |
390 | // evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture2), | 397 | |
391 | 398 | evas_3d_mesh_frame_add(20), | |
392 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | 399 | evas_3d_mesh_frame_material_set(20, scene->material1) |
393 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | 400 | ); |
394 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), | 401 | scene->mesh_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); |
395 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), | 402 | eo_do(scene->root_node, evas_3d_node_member_add(scene->mesh_node)); |
396 | 403 | eo_do(scene->mesh_node, evas_3d_node_mesh_add(scene->mesh)); | |
397 | evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.01, 0.01, 0.01, 1.0), | 404 | |
398 | evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 1.0, 1.0, 1.0, 1.0), | 405 | |
399 | evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), | 406 | // Setup an MD2 mesh. |
400 | evas_3d_material_shininess_set(50.0) | 407 | scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); |
401 | ); | 408 | eo_do(scene->mesh2, |
402 | 409 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "../../media/sonic.md2", NULL) | |
403 | 410 | ); | |
404 | scene->mesh2_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); | 411 | |
405 | eo_do(scene->root_node, | 412 | scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
406 | evas_3d_node_member_add(scene->mesh2_node) | 413 | eo_do(scene->mesh2, |
407 | ); | 414 | evas_3d_mesh_frame_material_set(0, scene->material2) |
408 | eo_do(scene->mesh2_node, | 415 | ); |
409 | evas_3d_node_mesh_add(scene->mesh2) | 416 | |
410 | ); | 417 | scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); |
411 | 418 | eo_do(scene->texture2, | |
412 | eo_do(scene->mesh2, | 419 | evas_3d_texture_file_set("../../media/sonic.png", NULL), |
413 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG) | 420 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), |
414 | ); | 421 | evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT) |
415 | #endif | 422 | ); |
423 | |||
424 | eo_do(scene->material2, | ||
425 | evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture2), | ||
426 | |||
427 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | ||
428 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | ||
429 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), | ||
430 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), | ||
431 | |||
432 | evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.01, 0.01, 0.01, 1.0), | ||
433 | evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 1.0, 1.0, 1.0, 1.0), | ||
434 | evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), | ||
435 | evas_3d_material_shininess_set(50.0) | ||
436 | ); | ||
437 | |||
438 | scene->mesh2_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_MESH); | ||
439 | eo_do(scene->root_node, | ||
440 | evas_3d_node_member_add(scene->mesh2_node) | ||
441 | ); | ||
442 | eo_do(scene->mesh2_node, | ||
443 | evas_3d_node_mesh_add(scene->mesh2) | ||
444 | ); | ||
445 | |||
446 | eo_do(scene->mesh2, | ||
447 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG) | ||
448 | ); | ||
416 | } | 449 | } |
417 | 450 | ||
418 | 451 | ||
419 | static void | 452 | static void |
420 | _scene_setup(globals *ourGlobals, Scene_Data *scene) | 453 | _scene_setup(globals *ourGlobals, Scene_Data *scene) |
421 | { | 454 | { |
422 | scene->scene = eo_add(EVAS_3D_SCENE_CLASS, ourGlobals->evas); | 455 | scene->scene = eo_add(EVAS_3D_SCENE_CLASS, ourGlobals->evas); |
423 | eo_do(scene->scene, | 456 | eo_do(scene->scene, |
424 | // evas_3d_scene_size_set(1024, 1024), | 457 | evas_3d_scene_size_set(1024, 1024), |
425 | evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0) | 458 | evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0) |
426 | ); | 459 | ); |
427 | 460 | ||
428 | // TODO - I have no idea how this should work. | 461 | // TODO - I have no idea how this should work. |
429 | // scene->root_node = eo_add(EVAS_3D_NODE_CLASS, ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE); | 462 | // It seems the people that wrote the examples don't know either. lol |
430 | scene->root_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE); | 463 | // scene->root_node = eo_add(EVAS_3D_NODE_CLASS, ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE); |
431 | 464 | scene->root_node = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_NODE); | |
432 | _camera_setup(ourGlobals, scene); | 465 | |
433 | _light_setup(ourGlobals, scene); | 466 | _camera_setup(ourGlobals, scene); |
434 | _mesh_setup(ourGlobals, scene); | 467 | _light_setup(ourGlobals, scene); |
435 | 468 | _mesh_setup(ourGlobals, scene); | |
436 | eo_do(scene->scene, | 469 | |
437 | evas_3d_scene_root_node_set(scene->root_node), | 470 | eo_do(scene->scene, |
438 | evas_3d_scene_camera_node_set(scene->camera_node), | 471 | evas_3d_scene_root_node_set(scene->root_node), |
439 | evas_3d_scene_size_set(1024, 1024) | 472 | evas_3d_scene_camera_node_set(scene->camera_node) |
440 | ); | 473 | ); |
441 | } | 474 | } |
442 | 475 | ||
443 | /* Sooo, how to do this - | 476 | /* Sooo, how to do this - |