summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-cube-rotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-cube-rotate.c')
-rw-r--r--src/examples/evas/evas-3d-cube-rotate.c91
1 files changed, 38 insertions, 53 deletions
diff --git a/src/examples/evas/evas-3d-cube-rotate.c b/src/examples/evas/evas-3d-cube-rotate.c
index eec0234..e393c14 100644
--- a/src/examples/evas/evas-3d-cube-rotate.c
+++ b/src/examples/evas/evas-3d-cube-rotate.c
@@ -89,7 +89,7 @@ _rotate_x_reload(Evas_Canvas3D_Scene *eo_scene, Evas_Event_Mouse_Down *ev, Evas_
89 Evas_Real s, t; 89 Evas_Real s, t;
90 int mouse_diff; 90 int mouse_diff;
91 91
92 eo_do(eo_scene, evas_canvas3d_scene_pick(ev->canvas.x, ev->canvas.y, &n, &m, &s, &t)); 92 evas_canvas3d_scene_pick(eo_scene, ev->canvas.x, ev->canvas.y, &n, &m, &s, &t);
93 93
94 if ((n == node) && (m == mesh)) 94 if ((n == node) && (m == mesh))
95 { 95 {
@@ -140,7 +140,7 @@ _animate_scene(void *data)
140 140
141 angle += sc->angle; 141 angle += sc->angle;
142 142
143 eo_do(sc->mesh_node, evas_canvas3d_node_orientation_angle_axis_set(angle, 0, 1.0, 0.0)); 143 evas_canvas3d_node_orientation_angle_axis_set(sc->mesh_node, angle, 0, 1.0, 0.0);
144 144
145 return EINA_TRUE; 145 return EINA_TRUE;
146} 146}
@@ -149,39 +149,32 @@ static void
149_camera_setup(Scene_Data *data) 149_camera_setup(Scene_Data *data)
150{ 150{
151 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 151 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
152 eo_do(data->camera, 152 evas_canvas3d_camera_projection_perspective_set(data->camera, 20.0, 1.0, 2.0, 50.0);
153 evas_canvas3d_camera_projection_perspective_set(20.0, 1.0, 2.0, 50.0));
154 153
155 data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 154 data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
156 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 155 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
157 eo_do(data->camera_node, 156 evas_canvas3d_node_position_set(data->camera_node, 3.0, 3.0, 10.0);
158 evas_canvas3d_node_camera_set(data->camera), 157 evas_canvas3d_node_look_at_set(data->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
159 evas_canvas3d_node_position_set(3.0, 3.0, 10.0),
160 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
161 158
162 eo_do(data->root_node, evas_canvas3d_node_member_add(data->camera_node)); 159 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
163} 160}
164 161
165static void 162static void
166_light_setup(Scene_Data *data) 163_light_setup(Scene_Data *data)
167{ 164{
168 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS,evas); 165 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
169 166
170 eo_do(data->light, 167 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
171 evas_canvas3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), 168 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
172 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 169 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
173 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0));
174 170
175 data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 171 data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
176 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT));
177 172
178 eo_do(data->light_node, 173 evas_canvas3d_node_light_set(data->light_node, data->light);
179 evas_canvas3d_node_light_set(data->light), 174 evas_canvas3d_node_position_set(data->light_node, 5.0, 5.0, 10.0);
180 evas_canvas3d_node_position_set(5.0, 5.0, 10.0), 175 evas_canvas3d_node_look_at_set(data->light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
181 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
182 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
183 176
184 eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node)); 177 evas_canvas3d_node_member_add(data->root_node, data->light_node);
185} 178}
186 179
187static void 180static void
@@ -190,51 +183,44 @@ _mesh_setup(Scene_Data *data)
190 /* Setup material. */ 183 /* Setup material. */
191 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 184 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
192 185
193 eo_do(data->material, 186 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
194 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 187 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
195 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 188 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
196 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 189 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0);
197 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0), 190 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
198 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0), 191 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
199 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0), 192 evas_canvas3d_material_shininess_set(data->material, 100.0);
200 evas_canvas3d_material_shininess_set(100.0));
201 193
202 /* Setup primitive */ 194 /* Setup primitive */
203 data->cube = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 195 data->cube = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
204 eo_do(data->cube, 196 evas_canvas3d_primitive_form_set(data->cube, EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE);
205 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE));
206 197
207 /* Setup mesh. */ 198 /* Setup mesh. */
208 data->mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 199 data->mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
209 eo_do(data->mesh, 200 evas_canvas3d_mesh_from_primitive_set(data->mesh, 0, data->cube);
210 evas_canvas3d_mesh_from_primitive_set(0, data->cube), 201 evas_canvas3d_mesh_shade_mode_set(data->mesh, EVAS_CANVAS3D_SHADE_MODE_PHONG);
211 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG), 202 evas_canvas3d_mesh_frame_material_set(data->mesh, 0, data->material);
212 evas_canvas3d_mesh_frame_material_set(0, data->material)); 203
213 204 data->mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
214 data->mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 205 evas_canvas3d_node_member_add(data->root_node, data->mesh_node);
215 eo_do(data->root_node, 206 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh);
216 evas_canvas3d_node_member_add(data->mesh_node));
217 eo_do(data->mesh_node, evas_canvas3d_node_mesh_add(data->mesh));
218} 207}
219 208
220static void 209static void
221_scene_setup(Scene_Data *data) 210_scene_setup(Scene_Data *data)
222{ 211{
223 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 212 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
224 data->root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 213 data->root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
225 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
226 214
227 eo_do(scene, 215 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
228 evas_canvas3d_scene_size_set(WIDTH, HEIGHT), 216 evas_canvas3d_scene_background_color_set(scene, 0.0, 0.0, 0.0, 0.0);
229 evas_canvas3d_scene_background_color_set(0.0, 0.0, 0.0, 0.0));
230 217
231 _camera_setup(data); 218 _camera_setup(data);
232 _light_setup(data); 219 _light_setup(data);
233 _mesh_setup(data); 220 _mesh_setup(data);
234 221
235 eo_do(scene, 222 evas_canvas3d_scene_root_node_set(scene, data->root_node);
236 evas_canvas3d_scene_root_node_set(data->root_node), 223 evas_canvas3d_scene_camera_node_set(scene, data->camera_node);
237 evas_canvas3d_scene_camera_node_set(data->camera_node));
238 224
239 data->mouse_old_x = 0; 225 data->mouse_old_x = 0;
240 data->mouse_diff_x = 0; 226 data->mouse_diff_x = 0;
@@ -276,8 +262,7 @@ main(void)
276 evas_object_show(image); 262 evas_object_show(image);
277 263
278 /* Set the image object as render target for 3D scene. */ 264 /* Set the image object as render target for 3D scene. */
279 eo_do(image, 265 evas_obj_image_scene_set(image, scene);
280 evas_obj_image_scene_set(scene));
281 266
282 evas_object_focus_set(image, EINA_TRUE); 267 evas_object_focus_set(image, EINA_TRUE);
283 268