aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/extantz/Evas_3D_demo.c2
-rw-r--r--src/extantz/scenri.c27
2 files changed, 17 insertions, 12 deletions
diff --git a/src/extantz/Evas_3D_demo.c b/src/extantz/Evas_3D_demo.c
index 46d2693..669fbba 100644
--- a/src/extantz/Evas_3D_demo.c
+++ b/src/extantz/Evas_3D_demo.c
@@ -448,7 +448,7 @@ static void _earth_setup(globals *ourGlobals, Scene_Data *scene)
448 448
449void Evas_3D_Demo_add(globals *ourGlobals) 449void Evas_3D_Demo_add(globals *ourGlobals)
450{ 450{
451 ourGlobals->scene = scenriAdd(ourGlobals->evas, ourGlobals->win); 451 ourGlobals->scene = scenriAdd(ourGlobals->win);
452 452
453 _cube_setup(ourGlobals, ourGlobals->scene); 453 _cube_setup(ourGlobals, ourGlobals->scene);
454 _sonic_setup(ourGlobals, ourGlobals->scene); 454 _sonic_setup(ourGlobals, ourGlobals->scene);
diff --git a/src/extantz/scenri.c b/src/extantz/scenri.c
index 8258cf4..af4897a 100644
--- a/src/extantz/scenri.c
+++ b/src/extantz/scenri.c
@@ -85,11 +85,14 @@ static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void
85 ev->output.x, ev->output.y, ev->canvas.x, ev->canvas.y, obj_x, obj_y, scene_x, scene_y, s, t, n, name, m); 85 ev->output.x, ev->output.y, ev->canvas.x, ev->canvas.y, obj_x, obj_y, scene_x, scene_y, s, t, n, name, m);
86} 86}
87 87
88Scene_Data *scenriAdd(Evas *evas, Evas_Object *win) 88Scene_Data *scenriAdd(Evas_Object *win)
89{ 89{
90 Scene_Data *scene; 90 Scene_Data *scene;
91 Evas_Object *obj, *temp; 91 Evas_Object *evas, *temp;
92 int w, h;
92 93
94 evas = evas_object_evas_get(win);
95 eo_do(win, evas_obj_size_get(&w, &h));
93 scene = calloc(1, sizeof(Scene_Data)); 96 scene = calloc(1, sizeof(Scene_Data));
94 97
95 // TODO - I have no idea how this should work. 98 // TODO - I have no idea how this should work.
@@ -97,23 +100,26 @@ Scene_Data *scenriAdd(Evas *evas, Evas_Object *win)
97// scene->root_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_NODE); 100// scene->root_node = eo_add(EVAS_3D_NODE_CLASS, evas, EVAS_3D_NODE_TYPE_NODE);
98 scene->root_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_NODE); 101 scene->root_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_NODE);
99 102
103 // -TODO - set the size based on the size of the enclosing window.
100 scene->scene = eo_add(EVAS_3D_SCENE_CLASS, evas, 104 scene->scene = eo_add(EVAS_3D_SCENE_CLASS, evas,
101 evas_3d_scene_root_node_set(scene->root_node), 105 evas_3d_scene_root_node_set(scene->root_node),
102 evas_3d_scene_size_set(512, 512), 106 evas_3d_scene_size_set(w, h),
103 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0) 107 evas_3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0)
104 ); 108 );
105 109
106 // Add an image object for 3D scene rendering. 110 // Add an image object for 3D scene rendering.
107 obj = eo_add(ELM_OBJ_IMAGE_CLASS, win, 111 // Any colour or texture applied to this window gets applied to the scene, including transparency.
112 // Interestingly enough, the position and size of the render seems to NOT depend on the position and size of this image?
113 // Note that we can't reuse the windows background image, Evas_3D needs both images.
114 scene->image = eo_add(ELM_OBJ_IMAGE_CLASS, win,
108 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 115 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
109 elm_obj_image_fill_outside_set(EINA_TRUE), 116 elm_obj_image_fill_outside_set(EINA_TRUE),
110 evas_obj_visibility_set(EINA_TRUE), 117 evas_obj_visibility_set(EINA_TRUE),
111 temp = elm_obj_image_object_get() 118 temp = elm_obj_image_object_get()
112 ); 119 );
113 elm_object_tooltip_text_set(obj, ""); 120 elm_object_tooltip_text_set(scene->image, "");
114 elm_object_tooltip_hide(obj); 121 elm_object_tooltip_hide(scene->image);
115 scene->image = obj; 122 scene->camera_node = cameraAdd(evas, scene, scene->image);
116 scene->camera_node = cameraAdd(evas, scene, obj);
117 123
118 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, evas, 124 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, evas,
119 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 125 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0),
@@ -121,22 +127,21 @@ Scene_Data *scenriAdd(Evas *evas, Evas_Object *win)
121 evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0), 127 evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0),
122 evas_3d_light_directional_set(EINA_TRUE) 128 evas_3d_light_directional_set(EINA_TRUE)
123 ); 129 );
124
125 scene->light_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_LIGHT); 130 scene->light_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_LIGHT);
126 eo_do(scene->light_node, 131 eo_do(scene->light_node,
127 evas_3d_node_light_set(scene->light), 132 evas_3d_node_light_set(scene->light),
128 evas_3d_node_position_set(1000.0, 0.0, 1000.0), 133 evas_3d_node_position_set(1000.0, 0.0, 1000.0),
129 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) 134 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)
130 ); 135 );
131
132 eo_do(scene->root_node, evas_3d_node_member_add(scene->light_node)); 136 eo_do(scene->root_node, evas_3d_node_member_add(scene->light_node));
133 137
134 eo_do(temp, evas_obj_image_scene_set(scene->scene)); 138 eo_do(temp, evas_obj_image_scene_set(scene->scene));
139
135 // Elm can't seem to be able to tell us WHERE an image was clicked, so use raw Evas calbacks instead. 140 // Elm can't seem to be able to tell us WHERE an image was clicked, so use raw Evas calbacks instead.
136 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move, scene); 141 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move, scene);
137 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, scene); 142 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, scene);
138 143
139 elm_win_resize_object_add(win, obj); 144 elm_win_resize_object_add(win, scene->image);
140 145
141 return scene; 146 return scene;
142} 147}