diff options
Diffstat (limited to '')
-rw-r--r-- | src/extantz/scenri.c | 213 |
1 files changed, 196 insertions, 17 deletions
diff --git a/src/extantz/scenri.c b/src/extantz/scenri.c index 4ebc64a..e7d30c4 100644 --- a/src/extantz/scenri.c +++ b/src/extantz/scenri.c | |||
@@ -1,11 +1,85 @@ | |||
1 | // scenri.c, deals with the in world scenery. | ||
2 | |||
3 | /* TODO - I can see this growing to be very big, so should start to split it up at some point. | ||
4 | Base stuff - | ||
5 | scenriAdd/Del() | ||
6 | mouse hover showing tooltips | ||
7 | mouse click on objects | ||
8 | world animator that calls animators for stuffs | ||
9 | addStuffs/Materials() setupStuffs() | ||
10 | |||
11 | Scripting hooks | ||
12 | Lua hooks | ||
13 | LSL wrappers around Lua hooks | ||
14 | Lua file loader, maybe have this in libg3d? | ||
15 | |||
16 | Basic mesh stuff (likely just libg3d) - | ||
17 | create cube, sphere, etc | ||
18 | load meshes | ||
19 | |||
20 | In world editing | ||
21 | |||
22 | */ | ||
23 | |||
1 | #include "extantz.h" | 24 | #include "extantz.h" |
2 | 25 | ||
3 | 26 | ||
27 | #define SKANG "skang" | ||
28 | #define THINGASM "thingasm" | ||
29 | |||
30 | |||
31 | |||
32 | static void _animateCube(ExtantzStuffs *stuffs) | ||
33 | { | ||
34 | static float angle = 0.0f; | ||
35 | static int frame = 0; | ||
36 | static int inc = 1; | ||
37 | Evas_3D_Mesh *m; | ||
38 | |||
39 | eina_accessor_data_get(stuffs->aMesh, 0, (void **) &m); | ||
40 | |||
41 | angle += 0.5; | ||
42 | if (angle > 360.0) angle -= 360.0f; | ||
43 | |||
44 | frame += inc; | ||
45 | if (frame >= 20) inc = -1; | ||
46 | else if (frame <= 0) inc = 1; | ||
47 | |||
48 | eo_do(stuffs->mesh_node, | ||
49 | evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0), | ||
50 | evas_3d_node_mesh_frame_set(m, frame) | ||
51 | ); | ||
52 | } | ||
53 | |||
54 | static void _animateSphere(ExtantzStuffs *stuffs) | ||
55 | { | ||
56 | static float earthAngle = 0.0f; | ||
57 | |||
58 | earthAngle += 0.3; | ||
59 | if (earthAngle > 360.0) earthAngle -= 360.0f; | ||
60 | eo_do(stuffs->mesh_node, | ||
61 | evas_3d_node_orientation_angle_axis_set(earthAngle, 0.0, 1.0, 0.0) | ||
62 | ); | ||
63 | } | ||
64 | |||
65 | static void _animateSonic(ExtantzStuffs *stuffs) | ||
66 | { | ||
67 | static int sonicFrame = 0; | ||
68 | Evas_3D_Mesh *m; | ||
69 | |||
70 | eina_accessor_data_get(stuffs->aMesh, 0, (void **) &m); | ||
71 | sonicFrame += 32; | ||
72 | if (sonicFrame > 256 * 50) sonicFrame = 0; | ||
73 | eo_do(stuffs->mesh_node, | ||
74 | evas_3d_node_mesh_frame_set(m, sonicFrame) | ||
75 | ); | ||
76 | } | ||
77 | |||
4 | Eina_Bool animateScene(globals *ourGlobals) | 78 | Eina_Bool animateScene(globals *ourGlobals) |
5 | { | 79 | { |
6 | ExtantzStuffs *e; | 80 | ExtantzStuffs *e; |
7 | 81 | ||
8 | EINA_CLIST_FOR_EACH_ENTRY(e, &ourGlobals->stuffs, ExtantzStuffs, node) | 82 | EINA_CLIST_FOR_EACH_ENTRY(e, &ourGlobals->scene->stuffs, ExtantzStuffs, node) |
9 | { | 83 | { |
10 | if (e->animateStuffs) e->animateStuffs(e); | 84 | if (e->animateStuffs) e->animateStuffs(e); |
11 | } | 85 | } |
@@ -99,6 +173,52 @@ static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void | |||
99 | 173 | ||
100 | } | 174 | } |
101 | 175 | ||
176 | static int _addStuffsL(lua_State *L) | ||
177 | { | ||
178 | ExtantzStuffs *result = NULL; | ||
179 | char *uuid, *name, *description, *owner, *file; | ||
180 | int type; | ||
181 | double px, py, pz, rx, ry, rz, rw; | ||
182 | |||
183 | pull_lua(L, 1, "$ $ $ $ $ % # # # # # # #", &uuid, &name, &description, &owner, &file, &type, &px, &py, &pz, &rx, &ry, &rz, &rw); | ||
184 | result = addStuffs(uuid, name, description, owner, file, type, px, py, pz, rx, ry, rz, rw); | ||
185 | if (result) | ||
186 | { | ||
187 | lua_getfield(L, LUA_REGISTRYINDEX, "sceneData"); | ||
188 | result->scene = (Scene_Data *) lua_touserdata(L, -1); | ||
189 | |||
190 | lua_pushlightuserdata(L, (void *) result); | ||
191 | return 1; | ||
192 | } | ||
193 | |||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static int _addMaterialL(lua_State *L) | ||
198 | { | ||
199 | ExtantzStuffs *e = NULL; | ||
200 | int face, type; | ||
201 | char *file; | ||
202 | |||
203 | pull_lua(L, 1, "* % % $", &e, &face, &type, &file); | ||
204 | if (e) | ||
205 | addMaterial(e, face, type, file); | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | static int _stuffsSetupL(lua_State *L) | ||
211 | { | ||
212 | ExtantzStuffs *e = NULL; | ||
213 | int fake; | ||
214 | |||
215 | pull_lua(L, 1, "* %", &e, &fake); | ||
216 | if (e) | ||
217 | stuffsSetup(e, e->scene, fake); | ||
218 | |||
219 | return 0; | ||
220 | } | ||
221 | |||
102 | Scene_Data *scenriAdd(Evas_Object *win) | 222 | Scene_Data *scenriAdd(Evas_Object *win) |
103 | { | 223 | { |
104 | Scene_Data *scene; | 224 | Scene_Data *scene; |
@@ -108,6 +228,8 @@ Scene_Data *scenriAdd(Evas_Object *win) | |||
108 | evas = evas_object_evas_get(win); | 228 | evas = evas_object_evas_get(win); |
109 | eo_do(win, evas_obj_size_get(&w, &h)); | 229 | eo_do(win, evas_obj_size_get(&w, &h)); |
110 | scene = calloc(1, sizeof(Scene_Data)); | 230 | scene = calloc(1, sizeof(Scene_Data)); |
231 | scene->evas = evas; | ||
232 | eina_clist_init(&(scene->stuffs)); | ||
111 | 233 | ||
112 | scene->root_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_NODE)); | 234 | scene->root_node = eo_add_custom(EVAS_3D_NODE_CLASS, evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_NODE)); |
113 | 235 | ||
@@ -152,11 +274,61 @@ Scene_Data *scenriAdd(Evas_Object *win) | |||
152 | 274 | ||
153 | elm_win_resize_object_add(win, scene->image); | 275 | elm_win_resize_object_add(win, scene->image); |
154 | 276 | ||
277 | scene->L = luaL_newstate(); | ||
278 | if (scene->L) | ||
279 | { | ||
280 | char buf[PATH_MAX]; | ||
281 | int skang, scenriLua; | ||
282 | |||
283 | luaL_openlibs(scene->L); | ||
284 | lua_getglobal(scene->L, "require"); | ||
285 | lua_pushstring(scene->L, "scenriLua"); | ||
286 | lua_call(scene->L, 1, 1); | ||
287 | |||
288 | // Shove our structure into the registry. | ||
289 | lua_pushlightuserdata(scene->L, scene); | ||
290 | lua_setfield(scene->L, LUA_REGISTRYINDEX, "sceneData"); | ||
291 | |||
292 | // The skang module should have been loaded by now, so we can just grab it out of package.loaded[]. | ||
293 | lua_getglobal(scene->L, "package"); | ||
294 | lua_getfield(scene->L, lua_gettop(scene->L), "loaded"); | ||
295 | lua_remove(scene->L, -2); // Removes "package" | ||
296 | lua_getfield(scene->L, lua_gettop(scene->L), SKANG); | ||
297 | lua_remove(scene->L, -2); // Removes "loaded" | ||
298 | lua_setfield(scene->L, LUA_REGISTRYINDEX, SKANG); | ||
299 | lua_getfield(scene->L, LUA_REGISTRYINDEX, SKANG); // Puts the skang table back on the stack. | ||
300 | skang = lua_gettop(scene->L); | ||
301 | |||
302 | // Same for the scenriLua module, we just loaded it. | ||
303 | lua_getglobal(scene->L, "package"); | ||
304 | lua_getfield(scene->L, lua_gettop(scene->L), "loaded"); | ||
305 | lua_remove(scene->L, -2); // Removes "package" | ||
306 | lua_getfield(scene->L, lua_gettop(scene->L), "scenriLua"); | ||
307 | lua_remove(scene->L, -2); // Removes "loaded" | ||
308 | scenriLua = lua_gettop(scene->L); | ||
309 | |||
310 | // Define our functions. | ||
311 | push_lua(scene->L, "@ ( = $ $ & $ )", skang, THINGASM, scenriLua, "addStuffs", "Add an in world stuffs.", _addStuffsL, | ||
312 | "string,string,string,string,string,number,number,number,number,number,number,number,number", 0); | ||
313 | push_lua(scene->L, "@ ( = $ $ & $ )", skang, THINGASM, scenriLua, "addMaterial", "Add a material to an in world stuffs.", _addMaterialL, | ||
314 | "userdata,number,number,string", 0); | ||
315 | push_lua(scene->L, "@ ( = $ $ & $ )", skang, THINGASM, scenriLua, "stuffsSetup", "Render the stuffs.", _stuffsSetupL, | ||
316 | "userdata,number", 0); | ||
317 | |||
318 | // Pass the enums to scenriLua. | ||
319 | sprintf(buf, "MeshType = {cube = %d, mesh = %d, sphere = %d}", MT_CUBE, MT_MESH, MT_SPHERE); | ||
320 | doLuaString(scene->L, buf, "scenriLua"); | ||
321 | sprintf(buf, "TextureType = {face = %d, normal = %d}", TT_FACE, TT_NORMAL); | ||
322 | doLuaString(scene->L, buf, "scenriLua"); | ||
323 | } | ||
324 | |||
155 | return scene; | 325 | return scene; |
156 | } | 326 | } |
157 | 327 | ||
158 | void scenriDel(Scene_Data *scene) | 328 | void scenriDel(Scene_Data *scene) |
159 | { | 329 | { |
330 | lua_close(scene->L); | ||
331 | |||
160 | // TODO - I should probably free up all this Evas_3D stuff. Oddly Eo doesn't bitch about it, only valgrind. | 332 | // TODO - I should probably free up all this Evas_3D stuff. Oddly Eo doesn't bitch about it, only valgrind. |
161 | // Eo bitches if they are unref'd here. | 333 | // Eo bitches if they are unref'd here. |
162 | // So either Eo or valgrind bitches, depending on what I do. I'll leave them commented out, let valgrind bitch, and blame Evas_3D. | 334 | // So either Eo or valgrind bitches, depending on what I do. I'll leave them commented out, let valgrind bitch, and blame Evas_3D. |
@@ -257,8 +429,8 @@ static vertex *sphere_vertices = NULL; | |||
257 | static int index_count = 0; | 429 | static int index_count = 0; |
258 | static unsigned short *sphere_indices = NULL; | 430 | static unsigned short *sphere_indices = NULL; |
259 | 431 | ||
260 | static inline vec3 | 432 | |
261 | _normalize(const vec3 *v) | 433 | static inline vec3 _normalize(const vec3 *v) |
262 | { | 434 | { |
263 | double l = sqrt(v->x * v->x + v->y * v->y + v->z * v->z); | 435 | double l = sqrt(v->x * v->x + v->y * v->y + v->z * v->z); |
264 | vec3 vec; | 436 | vec3 vec; |
@@ -270,7 +442,6 @@ _normalize(const vec3 *v) | |||
270 | return vec; | 442 | return vec; |
271 | } | 443 | } |
272 | 444 | ||
273 | |||
274 | static void _sphere_init(int precision) | 445 | static void _sphere_init(int precision) |
275 | { | 446 | { |
276 | int i, j; | 447 | int i, j; |
@@ -405,7 +576,7 @@ static void _sphere_init(int precision) | |||
405 | } | 576 | } |
406 | 577 | ||
407 | 578 | ||
408 | void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, int fake) | 579 | void stuffsSetup(ExtantzStuffs *stuffs, Scene_Data *scene, int fake) |
409 | { | 580 | { |
410 | char buf[PATH_MAX]; | 581 | char buf[PATH_MAX]; |
411 | Material *m; | 582 | Material *m; |
@@ -419,12 +590,12 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
419 | // Textures | 590 | // Textures |
420 | if (1 == fake) | 591 | if (1 == fake) |
421 | { | 592 | { |
422 | t = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, | 593 | t = eo_add(EVAS_3D_TEXTURE_CLASS, scene->evas, |
423 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels0[0]) | 594 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels0[0]) |
424 | ); | 595 | ); |
425 | eina_array_push(stuffs->textures, t); | 596 | eina_array_push(stuffs->textures, t); |
426 | 597 | ||
427 | t1 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, | 598 | t1 = eo_add(EVAS_3D_TEXTURE_CLASS, scene->evas, |
428 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) | 599 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) |
429 | ); | 600 | ); |
430 | eina_array_push(stuffs->textures, t1); | 601 | eina_array_push(stuffs->textures, t1); |
@@ -433,7 +604,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
433 | EINA_INARRAY_FOREACH(stuffs->stuffs.details.mesh->materials, m) | 604 | EINA_INARRAY_FOREACH(stuffs->stuffs.details.mesh->materials, m) |
434 | { | 605 | { |
435 | snprintf(buf, sizeof(buf), "%s/%s", prefix_data_get(), m->texture); | 606 | snprintf(buf, sizeof(buf), "%s/%s", prefix_data_get(), m->texture); |
436 | ti = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas, | 607 | ti = eo_add(EVAS_3D_TEXTURE_CLASS, scene->evas, |
437 | evas_3d_texture_file_set(buf, NULL), | 608 | evas_3d_texture_file_set(buf, NULL), |
438 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR), // Only for sphere originally. | 609 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR), // Only for sphere originally. |
439 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), // Only for sonic originally. | 610 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), // Only for sonic originally. |
@@ -446,7 +617,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
446 | if (1 == fake) | 617 | if (1 == fake) |
447 | { | 618 | { |
448 | eina_accessor_data_get(stuffs->aTexture, 0, (void **) &t); | 619 | eina_accessor_data_get(stuffs->aTexture, 0, (void **) &t); |
449 | mi = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, | 620 | mi = eo_add(EVAS_3D_MATERIAL_CLASS, scene->evas, |
450 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | 621 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), |
451 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | 622 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), |
452 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), | 623 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), |
@@ -462,7 +633,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
462 | 633 | ||
463 | eina_accessor_data_get(stuffs->aTexture, 1, (void **) &t1); | 634 | eina_accessor_data_get(stuffs->aTexture, 1, (void **) &t1); |
464 | eina_accessor_data_get(stuffs->aTexture, 2, (void **) &ti); | 635 | eina_accessor_data_get(stuffs->aTexture, 2, (void **) &ti); |
465 | mj = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, | 636 | mj = eo_add(EVAS_3D_MATERIAL_CLASS, scene->evas, |
466 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | 637 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), |
467 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), | 638 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), |
468 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), | 639 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), |
@@ -481,7 +652,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
481 | else | 652 | else |
482 | { | 653 | { |
483 | eina_accessor_data_get(stuffs->aTexture, 0, (void **) &t); | 654 | eina_accessor_data_get(stuffs->aTexture, 0, (void **) &t); |
484 | mi = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas, | 655 | mi = eo_add(EVAS_3D_MATERIAL_CLASS, scene->evas, |
485 | evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, t), | 656 | evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, t), |
486 | 657 | ||
487 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), | 658 | evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), |
@@ -503,7 +674,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
503 | { | 674 | { |
504 | eina_accessor_data_get(stuffs->aMaterial, 0, (void **) &mi); | 675 | eina_accessor_data_get(stuffs->aMaterial, 0, (void **) &mi); |
505 | eina_accessor_data_get(stuffs->aMaterial, 1, (void **) &mj); | 676 | eina_accessor_data_get(stuffs->aMaterial, 1, (void **) &mj); |
506 | me = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, | 677 | me = eo_add(EVAS_3D_MESH_CLASS, scene->evas, |
507 | evas_3d_mesh_vertex_count_set(24), | 678 | evas_3d_mesh_vertex_count_set(24), |
508 | evas_3d_mesh_frame_add(0), | 679 | evas_3d_mesh_frame_add(0), |
509 | 680 | ||
@@ -529,7 +700,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
529 | _sphere_init(100); | 700 | _sphere_init(100); |
530 | 701 | ||
531 | eina_accessor_data_get(stuffs->aMaterial, 0, (void **) &mi); | 702 | eina_accessor_data_get(stuffs->aMaterial, 0, (void **) &mi); |
532 | me = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, | 703 | me = eo_add(EVAS_3D_MESH_CLASS, scene->evas, |
533 | evas_3d_mesh_vertex_count_set(vertex_count), | 704 | evas_3d_mesh_vertex_count_set(vertex_count), |
534 | evas_3d_mesh_frame_add(0), | 705 | evas_3d_mesh_frame_add(0), |
535 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, sizeof(vertex), &sphere_vertices[0].position), | 706 | evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, sizeof(vertex), &sphere_vertices[0].position), |
@@ -550,7 +721,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
550 | { | 721 | { |
551 | eina_accessor_data_get(stuffs->aMaterial, 0, (void **) &mi); | 722 | eina_accessor_data_get(stuffs->aMaterial, 0, (void **) &mi); |
552 | snprintf(buf, sizeof(buf), "%s/%s", prefix_data_get(), stuffs->stuffs.details.mesh->fileName); | 723 | snprintf(buf, sizeof(buf), "%s/%s", prefix_data_get(), stuffs->stuffs.details.mesh->fileName); |
553 | me = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas, | 724 | me = eo_add(EVAS_3D_MESH_CLASS, scene->evas, |
554 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, buf, NULL), | 725 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, buf, NULL), |
555 | evas_3d_mesh_frame_material_set(0, mi), | 726 | evas_3d_mesh_frame_material_set(0, mi), |
556 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG) | 727 | evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG) |
@@ -559,7 +730,7 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
559 | } | 730 | } |
560 | 731 | ||
561 | eina_accessor_data_get(stuffs->aMesh, 0, (void **) &me); | 732 | eina_accessor_data_get(stuffs->aMesh, 0, (void **) &me); |
562 | stuffs->mesh_node = eo_add_custom(EVAS_3D_NODE_CLASS, ourGlobals->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH), | 733 | stuffs->mesh_node = eo_add_custom(EVAS_3D_NODE_CLASS, scene->evas, evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH), |
563 | eo_key_data_set("Name", stuffs->stuffs.name, NULL), | 734 | eo_key_data_set("Name", stuffs->stuffs.name, NULL), |
564 | evas_3d_node_position_set(stuffs->stuffs.details.mesh->pos.x, stuffs->stuffs.details.mesh->pos.y, stuffs->stuffs.details.mesh->pos.z), | 735 | evas_3d_node_position_set(stuffs->stuffs.details.mesh->pos.x, stuffs->stuffs.details.mesh->pos.y, stuffs->stuffs.details.mesh->pos.z), |
565 | evas_3d_node_orientation_set(stuffs->stuffs.details.mesh->rot.x, stuffs->stuffs.details.mesh->rot.y, stuffs->stuffs.details.mesh->rot.z, stuffs->stuffs.details.mesh->rot.w), | 736 | evas_3d_node_orientation_set(stuffs->stuffs.details.mesh->rot.x, stuffs->stuffs.details.mesh->rot.y, stuffs->stuffs.details.mesh->rot.z, stuffs->stuffs.details.mesh->rot.w), |
@@ -567,11 +738,19 @@ void stuffsSetup(ExtantzStuffs *stuffs, globals *ourGlobals, Scene_Data *scene, | |||
567 | ); | 738 | ); |
568 | 739 | ||
569 | eo_do(scene->root_node, evas_3d_node_member_add(stuffs->mesh_node)); | 740 | eo_do(scene->root_node, evas_3d_node_member_add(stuffs->mesh_node)); |
570 | eina_clist_add_head(&(ourGlobals->stuffs), &(stuffs->node)); | 741 | eina_clist_add_head(&(scene->stuffs), &(stuffs->node)); |
742 | |||
743 | if (1 == fake) | ||
744 | stuffs->animateStuffs = (aniStuffs) _animateCube; | ||
745 | else if (2 == fake) | ||
746 | stuffs->animateStuffs = (aniStuffs) _animateSphere; | ||
747 | else if (3 == fake) | ||
748 | stuffs->animateStuffs = (aniStuffs) _animateSonic; | ||
749 | |||
571 | } | 750 | } |
572 | 751 | ||
573 | ExtantzStuffs *addStuffs(char *uuid, char *name, char *description, char *owner, | 752 | ExtantzStuffs *addStuffs(char *uuid, char *name, char *description, char *owner, |
574 | char *file, MeshType type, float px, float py, float pz, float rx, float ry, float rz, float rw) | 753 | char *file, MeshType type, double px, double py, double pz, double rx, double ry, double rz, double rw) |
575 | { | 754 | { |
576 | ExtantzStuffs *result = calloc(1, sizeof(ExtantzStuffs)); | 755 | ExtantzStuffs *result = calloc(1, sizeof(ExtantzStuffs)); |
577 | 756 | ||