summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-pick.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-pick.c')
-rw-r--r--src/examples/evas/evas-3d-pick.c97
1 files changed, 39 insertions, 58 deletions
diff --git a/src/examples/evas/evas-3d-pick.c b/src/examples/evas/evas-3d-pick.c
index db8389a..1ae79a8 100644
--- a/src/examples/evas/evas-3d-pick.c
+++ b/src/examples/evas/evas-3d-pick.c
@@ -51,8 +51,7 @@ _animate_scene(void *data)
51 51
52 angle += 0.3; 52 angle += 0.3;
53 53
54 eo_do((Evas_Canvas3D_Node *)data, 54 evas_canvas3d_node_orientation_angle_axis_set((Evas_Canvas3D_Node *)data, angle, 0.0, 1.0, 0.0);
55 evas_canvas3d_node_orientation_angle_axis_set(angle, 0.0, 1.0, 0.0));
56 55
57 /* Rotate */ 56 /* Rotate */
58 if (angle > 360.0) angle -= 360.0f; 57 if (angle > 360.0) angle -= 360.0f;
@@ -96,12 +95,12 @@ _on_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
96 obj_x = ev->canvas.x - x; 95 obj_x = ev->canvas.x - x;
97 obj_y = ev->canvas.y - y; 96 obj_y = ev->canvas.y - y;
98 97
99 eo_do(scene, evas_canvas3d_scene_size_get(&scene_w, &scene_h)); 98 evas_canvas3d_scene_size_get(scene, &scene_w, &scene_h);
100 99
101 scene_x = obj_x * scene_w / (Evas_Real)w; 100 scene_x = obj_x * scene_w / (Evas_Real)w;
102 scene_y = obj_y * scene_h / (Evas_Real)h; 101 scene_y = obj_y * scene_h / (Evas_Real)h;
103 102
104 eo_do(scene, pick = evas_canvas3d_scene_pick(scene_x, scene_y, &n, &m, &s, &t)); 103 pick = evas_canvas3d_scene_pick(scene, scene_x, scene_y, &n, &m, &s, &t);
105 if (pick) printf("Picked : "); 104 if (pick) printf("Picked : ");
106 else printf("Not picked : "); 105 else printf("Not picked : ");
107 106
@@ -136,80 +135,62 @@ main(void)
136 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 135 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
137 136
138 /* Add the root node for the scene. */ 137 /* Add the root node for the scene. */
139 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 138 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
140 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
141 139
142 /* Add the camera. */ 140 /* Add the camera. */
143 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 141 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
144 eo_do(camera, 142 evas_canvas3d_camera_projection_perspective_set(camera, 30.0, 1.0, 1.0, 100.0);
145 evas_canvas3d_camera_projection_perspective_set(30.0, 1.0, 1.0, 100.0));
146 143
147 camera_node = 144 camera_node =
148 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 145 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
149 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 146 evas_canvas3d_node_camera_set(camera_node, camera);
150 eo_do(camera_node, 147 evas_canvas3d_node_position_set(camera_node, 0.0, 0.0, 2.5);
151 evas_canvas3d_node_camera_set(camera), 148 evas_canvas3d_node_look_at_set(camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
152 evas_canvas3d_node_position_set(0.0, 0.0, 2.5), 149 evas_canvas3d_node_member_add(root_node, camera_node);
153 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
154 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
155 eo_do(root_node, evas_canvas3d_node_member_add(camera_node));
156 150
157 sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 151 sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
158 eo_do(sphere, 152 evas_canvas3d_primitive_form_set(sphere, EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE);
159 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE), 153 evas_canvas3d_primitive_precision_set(sphere, 50);
160 evas_canvas3d_primitive_precision_set(50));
161 154
162 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 155 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
163 eo_do(mesh, evas_canvas3d_mesh_from_primitive_set(0, sphere)); 156 evas_canvas3d_mesh_from_primitive_set(mesh, 0, sphere);
164 157
165 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 158 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
166 159
167 texture_diffuse = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); 160 texture_diffuse = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
168 eo_do(texture_diffuse, 161 evas_canvas3d_texture_file_set(texture_diffuse, image_path, NULL);
169 evas_canvas3d_texture_file_set(image_path, NULL), 162 evas_canvas3d_texture_filter_set(texture_diffuse, EVAS_CANVAS3D_TEXTURE_FILTER_LINEAR, EVAS_CANVAS3D_TEXTURE_FILTER_LINEAR);
170 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_LINEAR, 163 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture_diffuse);
171 EVAS_CANVAS3D_TEXTURE_FILTER_LINEAR)); 164 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
172 eo_do(material, 165 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
173 evas_canvas3d_material_texture_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 166 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
174 texture_diffuse), 167 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0);
175 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 168 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
176 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 169 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
177 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 170 evas_canvas3d_material_shininess_set(material, 50.0);
178 171
179 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 172 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
180 1.0), 173
181 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 174 evas_canvas3d_node_member_add(root_node, mesh_node);
182 1.0), 175 evas_canvas3d_node_mesh_add(mesh_node, mesh);
183 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 176 evas_canvas3d_mesh_shade_mode_set(mesh, EVAS_CANVAS3D_SHADE_MODE_DIFFUSE);
184 1.0), 177 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
185 evas_canvas3d_material_shininess_set(50.0));
186
187 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
188 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
189
190 eo_do(root_node, evas_canvas3d_node_member_add(mesh_node));
191 eo_do(mesh_node, evas_canvas3d_node_mesh_add(mesh));
192 eo_do(mesh, evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE),
193 evas_canvas3d_mesh_frame_material_set(0, material));
194 178
195 /* Set up scene. */ 179 /* Set up scene. */
196 eo_do(scene, 180 evas_canvas3d_scene_root_node_set(scene, root_node);
197 evas_canvas3d_scene_root_node_set(root_node), 181 evas_canvas3d_scene_camera_node_set(scene, camera_node);
198 evas_canvas3d_scene_camera_node_set(camera_node), 182 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
199 evas_canvas3d_scene_size_set(WIDTH, HEIGHT));
200 183
201 /* Add evas objects. */ 184 /* Add evas objects. */
202 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 185 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
203 eo_do(background, 186 efl_gfx_color_set(background, 0, 0, 0, 255);
204 efl_gfx_color_set(0, 0, 0, 255), 187 efl_gfx_size_set(background, WIDTH, HEIGHT);
205 efl_gfx_size_set(WIDTH, HEIGHT), 188 efl_gfx_visible_set(background, EINA_TRUE);
206 efl_gfx_visible_set(EINA_TRUE));
207 189
208 image = evas_object_image_filled_add(evas); 190 image = evas_object_image_filled_add(evas);
209 eo_do(image, 191 evas_obj_image_scene_set(image, scene);
210 evas_obj_image_scene_set(scene), 192 efl_gfx_size_set(image, WIDTH, HEIGHT);
211 efl_gfx_size_set(WIDTH, HEIGHT), 193 efl_gfx_visible_set(image, EINA_TRUE);
212 efl_gfx_visible_set(EINA_TRUE));
213 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN, 194 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN,
214 _on_mouse_down, NULL); 195 _on_mouse_down, NULL);
215 196