summaryrefslogtreecommitdiff
path: root/src/examples/evas/shooter/evas-3d-shooter-header.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/shooter/evas-3d-shooter-header.c')
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter-header.c95
1 files changed, 37 insertions, 58 deletions
diff --git a/src/examples/evas/shooter/evas-3d-shooter-header.c b/src/examples/evas/shooter/evas-3d-shooter-header.c
index 894df54..ee608ba 100644
--- a/src/examples/evas/shooter/evas-3d-shooter-header.c
+++ b/src/examples/evas/shooter/evas-3d-shooter-header.c
@@ -14,7 +14,7 @@ evas_box3_set(Box3 *box, Evas_Real x0, Evas_Real y0, Evas_Real z0, Evas_Real x1,
14void 14void
15_scale(Evas_Canvas3D_Node *node, Evas_Real scale) 15_scale(Evas_Canvas3D_Node *node, Evas_Real scale)
16{ 16{
17 eo_do(node, evas_canvas3d_node_scale_set(1.0 * scale, 1.0 * scale, 1.0 * scale)); 17 evas_canvas3d_node_scale_set(node, 1.0 * scale, 1.0 * scale, 1.0 * scale);
18} 18}
19 19
20float 20float
@@ -27,21 +27,17 @@ void
27_camera_setup(Scene_Data *data) 27_camera_setup(Scene_Data *data)
28{ 28{
29 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 29 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
30 eo_do(data->camera, 30 evas_canvas3d_camera_projection_perspective_set(data->camera, 65.0, 1.0, 1.0, 300.0);
31 evas_canvas3d_camera_projection_perspective_set(65.0, 1.0, 1.0, 300.0));
32 31
33 data->mediator_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 32 data->mediator_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
34 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE)); 33 data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
35 data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
36 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA));
37 34
38 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mediator_node)); 35 evas_canvas3d_node_member_add(data->root_node, data->mediator_node);
39 eo_do(data->mediator_node, evas_canvas3d_node_member_add(data->camera_node)); 36 evas_canvas3d_node_member_add(data->mediator_node, data->camera_node);
40 37
41 eo_do(data->camera_node, 38 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
42 evas_canvas3d_node_camera_set(data->camera), 39 evas_canvas3d_node_position_set(data->camera_node, 20.0, 80.0, 30.0);
43 evas_canvas3d_node_position_set(20.0, 80.0, 30.0); 40 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);
44 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));
45} 41}
46 42
47void 43void
@@ -49,21 +45,18 @@ _light_setup(Scene_Data *data)
49{ 45{
50 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 46 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
51 47
52 eo_do(data->light, 48 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
53 evas_canvas3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), 49 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
54 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 50 evas_canvas3d_light_specular_set(data->light, 0.2, 0.2, 0.2, 1.0);
55 evas_canvas3d_light_specular_set(0.2, 0.2, 0.2, 1.0), 51 evas_canvas3d_light_projection_perspective_set(data->light, 100.0, 1.0, 1.0, 200.0);
56 evas_canvas3d_light_projection_perspective_set(100.0, 1.0, 1.0, 200.0));
57 52
58 data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 53 data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
59 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT));
60 54
61 eo_do(data->light_node, 55 evas_canvas3d_node_light_set(data->light_node, data->light);
62 evas_canvas3d_node_light_set(data->light), 56 evas_canvas3d_node_position_set(data->light_node, -30.0, 70.0, 0.0);
63 evas_canvas3d_node_position_set(-30.0, 70.0, 0.0), 57 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);
64 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));
65 58
66 eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node)); 59 evas_canvas3d_node_member_add(data->root_node, data->light_node);
67} 60}
68 61
69Eina_Bool _mesh_aabb(Evas_Canvas3D_Mesh **mesh, Scene_Data *scene, int index) 62Eina_Bool _mesh_aabb(Evas_Canvas3D_Mesh **mesh, Scene_Data *scene, int index)
@@ -96,15 +89,12 @@ Eina_Bool _mesh_aabb(Evas_Canvas3D_Mesh **mesh, Scene_Data *scene, int index)
96 else if (fmod(index, 12) == 11) 89 else if (fmod(index, 12) == 11)
97 node = scene->mesh_node_snake; 90 node = scene->mesh_node_snake;
98 91
99 eo_do(node, 92 evas_canvas3d_node_bounding_sphere_get(node, &x0, &y0, &z0, &r);
100 evas_canvas3d_node_bounding_sphere_get(&x0, &y0, &z0, &r));
101 93
102 eo_do(scene->mesh_node_ball, 94 evas_canvas3d_node_scale_set(scene->mesh_node_ball, r, r, r);
103 evas_canvas3d_node_scale_set(r, r, r), 95 evas_canvas3d_node_position_set(scene->mesh_node_ball, x0, y0, z0);
104 evas_canvas3d_node_position_set(x0, y0, z0));
105 96
106 eo_do(node, 97 evas_canvas3d_node_bounding_box_get(node, &x0, &y0, &z0, &x1, &y1, &z1);
107 evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
108 98
109 float vertixes[] = 99 float vertixes[] =
110 { 100 {
@@ -151,10 +141,9 @@ Eina_Bool _mesh_aabb(Evas_Canvas3D_Mesh **mesh, Scene_Data *scene, int index)
151 141
152 if (*mesh) 142 if (*mesh)
153 { 143 {
154 eo_do(*mesh, 144 evas_canvas3d_mesh_vertex_assembly_set(*mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES);
155 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES), 145 evas_canvas3d_mesh_frame_vertex_data_copy_set(*mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 6 * sizeof(float), &vertixes[ 0]);
156 evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 6 * sizeof(float), &vertixes[ 0]), 146 evas_canvas3d_mesh_index_data_copy_set(*mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, 48, &indixes[0]);
157 evas_canvas3d_mesh_index_data_copy_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, 48, &indixes[0]));
158 147
159 return EINA_TRUE; 148 return EINA_TRUE;
160 } 149 }
@@ -183,8 +172,7 @@ Eina_Bool _horizontal_circle_resolution(Evas_Canvas3D_Node *node, Evas_Real x, E
183{ 172{
184 Evas_Real x0, y0, z0, x1, y1, z1; 173 Evas_Real x0, y0, z0, x1, y1, z1;
185 174
186 eo_do(node, 175 evas_canvas3d_node_bounding_box_get(node, &x0, &y0, &z0, &x1, &y1, &z1);
187 evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
188 176
189 if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE; 177 if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE;
190 if (((x0 - x) * (x0 - x)) + ((z1 - z) * (z1 - z)) < r * r) return EINA_FALSE; 178 if (((x0 - x) * (x0 - x)) + ((z1 - z) * (z1 - z)) < r * r) return EINA_FALSE;
@@ -207,10 +195,8 @@ Eina_Bool _horizontal_circle_object_resolution(Evas_Canvas3D_Node *node, Evas_Ca
207{ 195{
208 Evas_Real x0, y0, z0, x1, y1, z1, x, y, z; 196 Evas_Real x0, y0, z0, x1, y1, z1, x, y, z;
209 197
210 eo_do(node2, 198 evas_canvas3d_node_position_get(node2, EVAS_CANVAS3D_SPACE_WORLD, &x, &y, &z);
211 evas_canvas3d_node_position_get(EVAS_CANVAS3D_SPACE_WORLD, &x, &y, &z)); 199 evas_canvas3d_node_bounding_box_get(node, &x0, &y0, &z0, &x1, &y1, &z1);
212 eo_do(node,
213 evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
214 200
215 if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE; 201 if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE;
216 if (((x0 - x) * (x0 - x)) + ((z1 - z) * (z1 - z)) < r * r) return EINA_FALSE; 202 if (((x0 - x) * (x0 - x)) + ((z1 - z) * (z1 - z)) < r * r) return EINA_FALSE;
@@ -233,8 +219,7 @@ Eina_Bool _horizontal_circle_position_resolution(Evas_Canvas3D_Node *node, Evas_
233{ 219{
234 Evas_Real x0, y0, z0; 220 Evas_Real x0, y0, z0;
235 221
236 eo_do(node, 222 evas_canvas3d_node_position_get(node, EVAS_CANVAS3D_SPACE_PARENT, &x0, &y0, &z0);
237 evas_canvas3d_node_position_get(EVAS_CANVAS3D_SPACE_PARENT, &x0, &y0, &z0));
238 223
239 if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE; 224 if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE;
240 225
@@ -245,8 +230,7 @@ Eina_Bool _horizontal_position_resolution(Evas_Canvas3D_Node *node, Evas_Real x,
245{ 230{
246 Evas_Real x0, y0, z0, x1, y1, z1; 231 Evas_Real x0, y0, z0, x1, y1, z1;
247 232
248 eo_do(node, 233 evas_canvas3d_node_bounding_box_get(node, &x0, &y0, &z0, &x1, &y1, &z1);
249 evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
250 234
251 if ((x > x0) && (x < x1) && (z > z0) && (z < z1)) 235 if ((x > x0) && (x < x1) && (z > z0) && (z < z1))
252 return EINA_FALSE; 236 return EINA_FALSE;
@@ -266,8 +250,7 @@ Eina_Bool _horizontal_object_resolution(Evas_Canvas3D_Node *node, Evas_Real x1,
266{ 250{
267 Evas_Real x3, y3, z3, x4, y4, z4; 251 Evas_Real x3, y3, z3, x4, y4, z4;
268 252
269 eo_do(node, 253 evas_canvas3d_node_bounding_box_get(node, &x3, &y3, &z3, &x4, &y4, &z4);
270 evas_canvas3d_node_bounding_box_get(&x3, &y3, &z3, &x4, &y4, &z4));
271 254
272 if ((x4 + x_move < x1) || (x4 + x_move > x2) || 255 if ((x4 + x_move < x1) || (x4 + x_move > x2) ||
273 (z4 + z_move < z1) || (z4 + z_move > z2)) 256 (z4 + z_move < z1) || (z4 + z_move > z2))
@@ -285,8 +268,7 @@ Eina_Bool _horizontal_frame_resolution(Evas_Canvas3D_Node *node, Evas_Real x1, E
285 *x_move = 0; 268 *x_move = 0;
286 *z_move = 0; 269 *z_move = 0;
287 270
288 eo_do(node, 271 evas_canvas3d_node_bounding_box_get(node, &x3, &y3, &z3, &x4, &y4, &z4);
289 evas_canvas3d_node_bounding_box_get(&x3, &y3, &z3, &x4, &y4, &z4));
290 272
291 if (x3 < x1) 273 if (x3 < x1)
292 *x_move = x1 - x3; 274 *x_move = x1 - x3;
@@ -364,14 +346,11 @@ _set_ball(Eo *mesh, int p)
364 346
365 _generate_square_grid(indices, p); 347 _generate_square_grid(indices, p);
366 348
367 eo_do(mesh, evas_canvas3d_mesh_vertex_count_set(vcount), 349 evas_canvas3d_mesh_vertex_count_set(mesh, vcount);
368 evas_canvas3d_mesh_frame_add(0); 350 evas_canvas3d_mesh_frame_add(mesh, 0);
369 evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 351 evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, sizeof(vec3), &vertices[0]);
370 sizeof(vec3), &vertices[0]); 352 evas_canvas3d_mesh_frame_vertex_data_copy_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, sizeof(vec3), &normals[0]);
371 evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 353 evas_canvas3d_mesh_index_data_copy_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, icount, &indices[0]);
372 sizeof(vec3), &normals[0]);
373 evas_canvas3d_mesh_index_data_copy_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT,
374 icount , &indices[0]));
375 354
376 free(vertices); 355 free(vertices);
377 free(normals); 356 free(normals);