summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-frustum.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-frustum.c')
-rw-r--r--src/examples/evas/evas-3d-frustum.c229
1 files changed, 97 insertions, 132 deletions
diff --git a/src/examples/evas/evas-3d-frustum.c b/src/examples/evas/evas-3d-frustum.c
index 94d43f2..4e1323f 100644
--- a/src/examples/evas/evas-3d-frustum.c
+++ b/src/examples/evas/evas-3d-frustum.c
@@ -100,18 +100,17 @@ _redraw_bounding_object(void *data)
100 Eo *current_mesh; 100 Eo *current_mesh;
101 Eina_List *meshes = NULL, *l; 101 Eina_List *meshes = NULL, *l;
102 102
103 eo_do(scene->mesh_node, meshes = (Eina_List *)evas_canvas3d_node_mesh_list_get()); 103 meshes = (Eina_List *)evas_canvas3d_node_mesh_list_get(scene->mesh_node);
104 EINA_LIST_FOREACH(meshes, l, current_mesh) 104 EINA_LIST_FOREACH(meshes, l, current_mesh)
105 { 105 {
106 eo_do(scene->mesh_node, evas_canvas3d_node_mesh_del(current_mesh)); 106 evas_canvas3d_node_mesh_del(scene->mesh_node, current_mesh);
107 } 107 }
108 108
109 switch (key) 109 switch (key)
110 { 110 {
111 case EVAS_CANVAS3D_FRUSTUM_MODE_BSPHERE: 111 case EVAS_CANVAS3D_FRUSTUM_MODE_BSPHERE:
112 { 112 {
113 eo_do(scene->mesh_node_model, 113 evas_canvas3d_node_bounding_sphere_get(scene->mesh_node_model, &x0, &y0, &z0, &rad);
114 evas_canvas3d_node_bounding_sphere_get(&x0, &y0, &z0, &rad));
115 current_mesh = scene->mesh_sphere; 114 current_mesh = scene->mesh_sphere;
116 px = x0; 115 px = x0;
117 py = y0; 116 py = y0;
@@ -121,9 +120,7 @@ _redraw_bounding_object(void *data)
121 } 120 }
122 case EVAS_CANVAS3D_FRUSTUM_MODE_AABB: 121 case EVAS_CANVAS3D_FRUSTUM_MODE_AABB:
123 { 122 {
124 eo_do(scene->mesh_node_model, 123 evas_canvas3d_node_bounding_box_get(scene->mesh_node_model, &x0, &y0, &z0, &x1, &y1, &z1);
125 evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0,
126 &x1, &y1, &z1));
127 current_mesh = scene->mesh_aabb; 124 current_mesh = scene->mesh_aabb;
128 px = (x1 + x0) / 2; 125 px = (x1 + x0) / 2;
129 py = (y1 + y0) / 2; 126 py = (y1 + y0) / 2;
@@ -135,8 +132,7 @@ _redraw_bounding_object(void *data)
135 } 132 }
136 case EVAS_CANVAS3D_FRUSTUM_MODE_CENTRAL_POINT: 133 case EVAS_CANVAS3D_FRUSTUM_MODE_CENTRAL_POINT:
137 { 134 {
138 eo_do(scene->mesh_node_model, 135 evas_canvas3d_node_bounding_sphere_get(scene->mesh_node_model, &x0, &y0, &z0, &rad);
139 evas_canvas3d_node_bounding_sphere_get(&x0, &y0, &z0, &rad));
140 current_mesh = scene->mesh_sphere; 136 current_mesh = scene->mesh_sphere;
141 px = x0; 137 px = x0;
142 py = y0; 138 py = y0;
@@ -148,10 +144,9 @@ _redraw_bounding_object(void *data)
148 return ECORE_CALLBACK_RENEW; 144 return ECORE_CALLBACK_RENEW;
149 } 145 }
150 146
151 eo_do(scene->mesh_node, 147 evas_canvas3d_node_mesh_add(scene->mesh_node, current_mesh);
152 evas_canvas3d_node_mesh_add(current_mesh), 148 evas_canvas3d_node_position_set(scene->mesh_node, px, py, pz);
153 evas_canvas3d_node_position_set(px, py, pz), 149 evas_canvas3d_node_scale_set(scene->mesh_node, sx, sy, sz);
154 evas_canvas3d_node_scale_set(sx, sy, sz));
155 150
156 return ECORE_CALLBACK_RENEW; 151 return ECORE_CALLBACK_RENEW;
157} 152}
@@ -166,109 +161,97 @@ _on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void
166 if (!strcmp("w", ev->key)) 161 if (!strcmp("w", ev->key))
167 { 162 {
168 ffar += 20; 163 ffar += 20;
169 eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar)); 164 evas_canvas3d_camera_projection_frustum_set(scene->camera, fleft, fright, fbottom, fup, fnear, ffar);
170 } 165 }
171 else if(!strcmp("s", ev->key)) 166 else if(!strcmp("s", ev->key))
172 { 167 {
173 ffar -= 20; 168 ffar -= 20;
174 eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar)); 169 evas_canvas3d_camera_projection_frustum_set(scene->camera, fleft, fright, fbottom, fup, fnear, ffar);
175 } 170 }
176 else if(!strcmp("t", ev->key)) 171 else if(!strcmp("t", ev->key))
177 { 172 {
178 fnear += 2; 173 fnear += 2;
179 eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar)); 174 evas_canvas3d_camera_projection_frustum_set(scene->camera, fleft, fright, fbottom, fup, fnear, ffar);
180 } 175 }
181 else if(!strcmp("g", ev->key)) 176 else if(!strcmp("g", ev->key))
182 { 177 {
183 fnear -= 2; 178 fnear -= 2;
184 eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar)); 179 evas_canvas3d_camera_projection_frustum_set(scene->camera, fleft, fright, fbottom, fup, fnear, ffar);
185 } 180 }
186 else if(!strcmp("i", ev->key)) 181 else if(!strcmp("i", ev->key))
187 { 182 {
188 obj_y++; 183 obj_y++;
189 eo_do(scene->mesh_node_model, 184 evas_canvas3d_node_position_set(scene->mesh_node_model, obj_x, obj_y, obj_z);
190 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
191 } 185 }
192 else if(!strcmp("k", ev->key)) 186 else if(!strcmp("k", ev->key))
193 { 187 {
194 obj_y--; 188 obj_y--;
195 eo_do(scene->mesh_node_model, 189 evas_canvas3d_node_position_set(scene->mesh_node_model, obj_x, obj_y, obj_z);
196 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
197 } 190 }
198 else if(!strcmp("o", ev->key)) 191 else if(!strcmp("o", ev->key))
199 { 192 {
200 obj_z++; 193 obj_z++;
201 eo_do(scene->mesh_node_model, 194 evas_canvas3d_node_position_set(scene->mesh_node_model, obj_x, obj_y, obj_z);
202 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
203 } 195 }
204 else if(!strcmp("u", ev->key)) 196 else if(!strcmp("u", ev->key))
205 { 197 {
206 obj_z--; 198 obj_z--;
207 eo_do(scene->mesh_node_model, 199 evas_canvas3d_node_position_set(scene->mesh_node_model, obj_x, obj_y, obj_z);
208 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
209 } 200 }
210 else if(!strcmp("l", ev->key)) 201 else if(!strcmp("l", ev->key))
211 { 202 {
212 obj_x++; 203 obj_x++;
213 eo_do(scene->mesh_node_model, 204 evas_canvas3d_node_position_set(scene->mesh_node_model, obj_x, obj_y, obj_z);
214 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
215 } 205 }
216 else if(!strcmp("j", ev->key)) 206 else if(!strcmp("j", ev->key))
217 { 207 {
218 obj_x--; 208 obj_x--;
219 eo_do(scene->mesh_node_model, 209 evas_canvas3d_node_position_set(scene->mesh_node_model, obj_x, obj_y, obj_z);
220 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
221 } 210 }
222 else if(!strcmp("z", ev->key)) 211 else if(!strcmp("z", ev->key))
223 { 212 {
224 obj_sc_y+=0.02; 213 obj_sc_y+=0.02;
225 eo_do(scene->mesh_node_model, 214 evas_canvas3d_node_scale_set(scene->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
226 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
227 } 215 }
228 else if(!strcmp("Z", ev->key)) 216 else if(!strcmp("Z", ev->key))
229 { 217 {
230 obj_sc_y-=0.02; 218 obj_sc_y-=0.02;
231 eo_do(scene->mesh_node_model, 219 evas_canvas3d_node_scale_set(scene->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
232 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
233 } 220 }
234 else if(!strcmp("x", ev->key)) 221 else if(!strcmp("x", ev->key))
235 { 222 {
236 obj_sc_z+=0.02; 223 obj_sc_z+=0.02;
237 eo_do(scene->mesh_node_model, 224 evas_canvas3d_node_scale_set(scene->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
238 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
239 } 225 }
240 else if(!strcmp("X", ev->key)) 226 else if(!strcmp("X", ev->key))
241 { 227 {
242 obj_sc_z-=0.02; 228 obj_sc_z-=0.02;
243 eo_do(scene->mesh_node_model, 229 evas_canvas3d_node_scale_set(scene->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
244 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
245 } 230 }
246 else if(!strcmp("c", ev->key)) 231 else if(!strcmp("c", ev->key))
247 { 232 {
248 obj_sc_x+=0.02; 233 obj_sc_x+=0.02;
249 eo_do(scene->mesh_node_model, 234 evas_canvas3d_node_scale_set(scene->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
250 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
251 } 235 }
252 else if(!strcmp("C", ev->key)) 236 else if(!strcmp("C", ev->key))
253 { 237 {
254 obj_sc_x-=0.02; 238 obj_sc_x-=0.02;
255 eo_do(scene->mesh_node_model, 239 evas_canvas3d_node_scale_set(scene->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
256 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
257 } 240 }
258 else if(!strcmp("Return", ev->key)) 241 else if(!strcmp("Return", ev->key))
259 { 242 {
260 eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar)); 243 evas_canvas3d_camera_projection_frustum_set(scene->camera, fleft, fright, fbottom, fup, fnear, ffar);
261 } 244 }
262 else if (!strcmp("1", ev->key)) 245 else if (!strcmp("1", ev->key))
263 { 246 {
264 eo_do(scene->camera_node, evas_canvas3d_node_position_set(0.0, 0.0, 300.0), 247 evas_canvas3d_node_position_set(scene->camera_node, 0.0, 0.0, 300.0);
265 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)); 248 evas_canvas3d_node_look_at_set(scene->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
266 fprintf(stdout, "Changed position and view of camera\n"); 249 fprintf(stdout, "Changed position and view of camera\n");
267 } 250 }
268 else if (!strcmp("2", ev->key)) 251 else if (!strcmp("2", ev->key))
269 { 252 {
270 eo_do(scene->camera_node, evas_canvas3d_node_position_set(300.0, 300.0, 300.0); 253 evas_canvas3d_node_position_set(scene->camera_node, 300.0, 300.0, 300.0);
271 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)); 254 evas_canvas3d_node_look_at_set(scene->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
272 fprintf(stdout, "Changed position and view of camera\n"); 255 fprintf(stdout, "Changed position and view of camera\n");
273 } 256 }
274 else if (!strcmp("3", ev->key)) 257 else if (!strcmp("3", ev->key))
@@ -289,7 +272,7 @@ _on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void
289 } 272 }
290 273
291 _redraw_bounding_object(data); 274 _redraw_bounding_object(data);
292 eo_do(scene->camera, frustum = evas_canvas3d_camera_node_visible_get(scene->camera_node, scene->mesh_node_model, key)); 275 frustum = evas_canvas3d_camera_node_visible_get(scene->camera, scene->camera_node, scene->mesh_node_model, key);
293 fprintf(stdout, "far - %f frustum - %d radius - %f\n", ffar, frustum, radius); 276 fprintf(stdout, "far - %f frustum - %d radius - %f\n", ffar, frustum, radius);
294} 277}
295 278
@@ -297,35 +280,30 @@ static void
297_camera_setup(Scene_Data *data) 280_camera_setup(Scene_Data *data)
298{ 281{
299 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 282 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
300 data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 283 data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
301 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 284 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
302 eo_do(data->camera_node, 285 evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 300.0);
303 evas_canvas3d_node_camera_set(data->camera), 286 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);
304 evas_canvas3d_node_position_set(0.0, 0.0, 300.0);
305 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));
306 287
307 eo_do(data->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar)); 288 evas_canvas3d_camera_projection_frustum_set(data->camera, fleft, fright, fbottom, fup, fnear, ffar);
308 289
309 eo_do(data->root_node, evas_canvas3d_node_member_add(data->camera_node)); 290 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
310} 291}
311 292
312static void 293static void
313_light_setup(Scene_Data *data) 294_light_setup(Scene_Data *data)
314{ 295{
315 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 296 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
316 eo_do(data->light, 297 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
317 evas_canvas3d_light_ambient_set( 0.2, 0.2, 0.2, 1.0), 298 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
318 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 299 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
319 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0)); 300
320 301 data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
321 data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS,evas, 302 evas_canvas3d_node_light_set(data->light_node, data->light);
322 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 303 evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 200.0);
323 eo_do(data->light_node, 304 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, 0.0, 1.0);
324 evas_canvas3d_node_light_set(data->light), 305
325 evas_canvas3d_node_position_set(0.0, 0.0, 200.0), 306 evas_canvas3d_node_member_add(data->root_node, data->light_node);
326 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));
327
328 eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node));
329} 307}
330 308
331static void 309static void
@@ -333,43 +311,37 @@ _mesh_setup(Scene_Data *data)
333{ 311{
334 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 312 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
335 313
336 eo_do(data->material, 314 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
337 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 315 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
338 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 316 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
339 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 317 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0);
340 318 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
341 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0), 319 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
342 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0), 320 evas_canvas3d_material_shininess_set(data->material, 100.0);
343 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0),
344 evas_canvas3d_material_shininess_set(100.0));
345 321
346 data->cube = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 322 data->cube = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
347 eo_do(data->cube, 323 evas_canvas3d_primitive_form_set(data->cube, EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE);
348 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE));
349 324
350 data->sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 325 data->sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
351 eo_do(data->sphere, 326 evas_canvas3d_primitive_form_set(data->sphere, EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE);
352 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE), 327 evas_canvas3d_primitive_precision_set(data->sphere, 20);
353 evas_canvas3d_primitive_precision_set(20));
354 328
355 data->mesh_aabb = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 329 data->mesh_aabb = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
356 eo_do(data->mesh_aabb, 330 evas_canvas3d_mesh_from_primitive_set(data->mesh_aabb, 0, data->cube);
357 evas_canvas3d_mesh_from_primitive_set(0, data->cube), 331 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_aabb, EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES);
358 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES), 332 evas_canvas3d_mesh_shade_mode_set(data->mesh_aabb, EVAS_CANVAS3D_SHADE_MODE_DIFFUSE);
359 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE), 333 evas_canvas3d_mesh_frame_material_set(data->mesh_aabb, 0, data->material);
360 evas_canvas3d_mesh_frame_material_set(0, data->material));
361 334
362 data->mesh_sphere = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 335 data->mesh_sphere = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
363 eo_do(data->mesh_sphere, 336 evas_canvas3d_mesh_from_primitive_set(data->mesh_sphere, 0, data->sphere);
364 evas_canvas3d_mesh_from_primitive_set(0, data->sphere), 337 evas_canvas3d_mesh_vertex_assembly_set(data->mesh_sphere, EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES);
365 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES), 338 evas_canvas3d_mesh_shade_mode_set(data->mesh_sphere, EVAS_CANVAS3D_SHADE_MODE_DIFFUSE);
366 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE), 339 evas_canvas3d_mesh_frame_material_set(data->mesh_sphere, 0, data->material);
367 evas_canvas3d_mesh_frame_material_set(0, data->material));
368 340
369 data->mesh_node = 341 data->mesh_node =
370 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 342 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
371 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node)); 343 evas_canvas3d_node_member_add(data->root_node, data->mesh_node);
372 eo_do(data->mesh_node, evas_canvas3d_node_mesh_add(data->mesh_aabb)); 344 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh_aabb);
373} 345}
374 346
375static void 347static void
@@ -379,27 +351,24 @@ _mesh_setup_model(Scene_Data *data)
379 data->material_model = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 351 data->material_model = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
380 data->texture_model = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); 352 data->texture_model = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
381 353
382 eo_do(data->texture_model, 354 evas_canvas3d_texture_file_set(data->texture_model, texture_path, NULL);
383 evas_canvas3d_texture_file_set(texture_path, NULL), 355 evas_canvas3d_texture_filter_set(data->texture_model, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST);
384 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), 356 evas_canvas3d_texture_wrap_set(data->texture_model, EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT);
385 evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT)); 357
386 358 evas_canvas3d_material_enable_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
387 eo_do(data->material_model, 359 evas_canvas3d_material_enable_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
388 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE), 360 evas_canvas3d_material_enable_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
389 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 361 evas_canvas3d_material_enable_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
390 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 362 evas_canvas3d_material_enable_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
391 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE); 363 evas_canvas3d_material_color_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0);
392 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE), 364 evas_canvas3d_material_color_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
393 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0), 365 evas_canvas3d_material_color_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
394 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0), 366 evas_canvas3d_material_texture_set(data->material_model, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, data->texture_model);
395 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0), 367 evas_canvas3d_material_shininess_set(data->material_model, 100.0);
396 evas_canvas3d_material_texture_set( EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, data->texture_model), 368
397 evas_canvas3d_material_shininess_set(100.0)); 369 efl_file_set(data->mesh_model, mesh_path, NULL);
398 370 evas_canvas3d_mesh_frame_material_set(data->mesh_model, 0, data->material_model);
399 eo_do(data->mesh_model, 371 evas_canvas3d_mesh_shade_mode_set(data->mesh_model, EVAS_CANVAS3D_SHADE_MODE_DIFFUSE);
400 efl_file_set(mesh_path, NULL),
401 evas_canvas3d_mesh_frame_material_set(0, data->material_model),
402 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE));
403} 372}
404 373
405static void 374static void
@@ -407,29 +376,25 @@ _scene_setup(Scene_Data *data)
407{ 376{
408 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 377 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
409 378
410 data->root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 379 data->root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
411 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
412 380
413 _light_setup(data); 381 _light_setup(data);
414 _mesh_setup_model(data); 382 _mesh_setup_model(data);
415 _camera_setup(data); 383 _camera_setup(data);
416 384
417 data->mesh_node_model = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 385 data->mesh_node_model = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
418 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 386 evas_canvas3d_node_position_set(data->mesh_node_model, obj_x, obj_y, obj_z);
419 eo_do(data->mesh_node_model, 387 evas_canvas3d_node_orientation_angle_axis_set(data->mesh_node_model, -90, 1.0, 0.0, 0.0);
420 evas_canvas3d_node_position_set(obj_x, obj_y, obj_z), 388 evas_canvas3d_node_scale_set(data->mesh_node_model, obj_sc_x, obj_sc_y, obj_sc_z);
421 evas_canvas3d_node_orientation_angle_axis_set(-90, 1.0, 0.0, 0.0), 389 evas_canvas3d_node_member_add(data->root_node, data->mesh_node_model);
422 evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z)); 390 evas_canvas3d_node_mesh_add(data->mesh_node_model, data->mesh_model);
423 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node_model));
424 eo_do(data->mesh_node_model, evas_canvas3d_node_mesh_add(data->mesh_model));
425 391
426 _mesh_setup(data); 392 _mesh_setup(data);
427 393
428 eo_do(data->scene, 394 evas_canvas3d_scene_size_set(data->scene, WIDTH, HEIGHT);
429 evas_canvas3d_scene_size_set( WIDTH, HEIGHT), 395 evas_canvas3d_scene_background_color_set(data->scene, 0.5, 0.5, 0.5, 0.0);
430 evas_canvas3d_scene_background_color_set(0.5, 0.5, 0.5, 0.0), 396 evas_canvas3d_scene_root_node_set(data->scene, data->root_node);
431 evas_canvas3d_scene_root_node_set(data->root_node); 397 evas_canvas3d_scene_camera_node_set(data->scene, data->camera_node);
432 evas_canvas3d_scene_camera_node_set(data->camera_node));
433} 398}
434 399
435int 400int
@@ -466,7 +431,7 @@ main(void)
466 evas_object_show(image); 431 evas_object_show(image);
467 432
468 evas_object_focus_set(image, EINA_TRUE); 433 evas_object_focus_set(image, EINA_TRUE);
469 eo_do(image, evas_obj_image_scene_set(data.scene)); 434 evas_obj_image_scene_set(image, data.scene);
470 435
471 _redraw_bounding_object(&data); 436 _redraw_bounding_object(&data);
472 _show_help(); 437 _show_help();