summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-blending.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-blending.c')
-rw-r--r--src/examples/evas/evas-3d-blending.c128
1 files changed, 53 insertions, 75 deletions
diff --git a/src/examples/evas/evas-3d-blending.c b/src/examples/evas/evas-3d-blending.c
index 98bd74a..db7c7a1 100644
--- a/src/examples/evas/evas-3d-blending.c
+++ b/src/examples/evas/evas-3d-blending.c
@@ -102,7 +102,7 @@ _on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void
102 func2 = EVAS_CANVAS3D_BLEND_FUNC_SRC_ALPHA_SATURATE; 102 func2 = EVAS_CANVAS3D_BLEND_FUNC_SRC_ALPHA_SATURATE;
103 if(func2 > EVAS_CANVAS3D_BLEND_FUNC_SRC_ALPHA_SATURATE) 103 if(func2 > EVAS_CANVAS3D_BLEND_FUNC_SRC_ALPHA_SATURATE)
104 func2 = EVAS_CANVAS3D_BLEND_FUNC_ZERO; 104 func2 = EVAS_CANVAS3D_BLEND_FUNC_ZERO;
105 eo_do(scene->mesh1, evas_canvas3d_mesh_blending_func_set(func1, func2)); 105 evas_canvas3d_mesh_blending_func_set(scene->mesh1, func1, func2);
106 printf("sfactor = %s, dfactor = %s\n", blend_func_names[func1], blend_func_names[func2]); 106 printf("sfactor = %s, dfactor = %s\n", blend_func_names[func1], blend_func_names[func2]);
107} 107}
108 108
@@ -121,8 +121,8 @@ _on_canvas_resize(Ecore_Evas *ee)
121 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 121 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
122 122
123 evas_object_resize(background, w, h); 123 evas_object_resize(background, w, h);
124 eo_do(background, efl_gfx_size_set(w, h)); 124 efl_gfx_size_set(background, w, h);
125 eo_do(image, efl_gfx_size_set(w, h)); 125 efl_gfx_size_set(image, w, h);
126} 126}
127 127
128static Eina_Bool 128static Eina_Bool
@@ -133,8 +133,7 @@ _animate_scene(void *data)
133 133
134 angle += 0.02; 134 angle += 0.02;
135 135
136 eo_do(scene->mesh_node, 136 evas_canvas3d_node_position_set(scene->mesh_node, 3 * sin(angle), 0.0, 3 * cos(angle));
137 evas_canvas3d_node_position_set(3 * sin(angle), 0.0, 3 * cos(angle)));
138 137
139 if (angle > 2 * M_PI) angle = 0; 138 if (angle > 2 * M_PI) angle = 0;
140 139
@@ -146,49 +145,40 @@ _camera_setup(Scene_Data *data)
146{ 145{
147 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 146 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
148 147
149 eo_do(data->camera, 148 evas_canvas3d_camera_projection_perspective_set(data->camera, 60.0, 1.0, 2.0, 50.0);
150 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0));
151 149
152 data->camera_node = 150 data->camera_node =
153 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 151 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
154 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA));
155 152
156 eo_do(data->camera_node, 153 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
157 evas_canvas3d_node_camera_set(data->camera), 154 evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 10.0);
158 evas_canvas3d_node_position_set(0.0, 0.0, 10.0), 155 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_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
160 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
161 156
162 eo_do(data->root_node, evas_canvas3d_node_member_add(data->camera_node)); 157 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
163} 158}
164 159
165static void 160static void
166_light_setup(Scene_Data *data) 161_light_setup(Scene_Data *data)
167{ 162{
168 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 163 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
169 eo_do(data->light, 164 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
170 evas_canvas3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), 165 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
171 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 166 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
172 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0));
173 167
174 data->light_node = 168 data->light_node =
175 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 169 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)); 170 evas_canvas3d_node_light_set(data->light_node, data->light);
177 eo_do(data->light_node, 171 evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
178 evas_canvas3d_node_light_set(data->light), 172 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);
179 evas_canvas3d_node_position_set(0.0, 0.0, 10.0), 173 evas_canvas3d_node_member_add(data->root_node, data->light_node);
180 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
181 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
182 eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node));
183} 174}
184 175
185static void 176static void
186_set_ball(Eo *mesh, Eo *sphere, Evas_Canvas3D_Material *material) 177_set_ball(Eo *mesh, Eo *sphere, Evas_Canvas3D_Material *material)
187{ 178{
188 eo_do(mesh, 179 evas_canvas3d_mesh_from_primitive_set(mesh, 0, sphere);
189 evas_canvas3d_mesh_from_primitive_set(0, sphere), 180 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
190 evas_canvas3d_mesh_frame_material_set(0, material), 181 evas_canvas3d_mesh_shade_mode_set(mesh, EVAS_CANVAS3D_SHADE_MODE_PHONG);
191 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG));
192} 182}
193 183
194static void 184static void
@@ -196,32 +186,27 @@ _mesh_setup(Scene_Data *data)
196{ 186{
197 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 187 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
198 188
199 eo_do(data->material, 189 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
200 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 190 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
201 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 191 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
202 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 192 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 1.0, 0.2, 0.2, 0.2);
203 193 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 0.0, 0.0, 0.2);
204 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 1.0, 0.2, 0.2, 0.2), 194 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 0.2);
205 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 0.0, 0.0, 0.2), 195 evas_canvas3d_material_shininess_set(data->material, 100.0);
206 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 0.2),
207 evas_canvas3d_material_shininess_set(100.0));
208 196
209 data->material1 = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 197 data->material1 = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
210 198
211 eo_do(data->material1, 199 evas_canvas3d_material_enable_set(data->material1, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
212 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 200 evas_canvas3d_material_enable_set(data->material1, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
213 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 201 evas_canvas3d_material_enable_set(data->material1, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
214 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 202 evas_canvas3d_material_color_set(data->material1, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.0, 0.2, 0.2, 0.2);
215 203 evas_canvas3d_material_color_set(data->material1, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.0, 0.0, 1.0, 0.2);
216 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.0, 0.2, 0.2, 0.2), 204 evas_canvas3d_material_color_set(data->material1, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 0.2);
217 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.0, 0.0, 1.0, 0.2), 205 evas_canvas3d_material_shininess_set(data->material1, 100.0);
218 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 0.2),
219 evas_canvas3d_material_shininess_set(100.0));
220 206
221 data->sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 207 data->sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
222 eo_do(data->sphere, 208 evas_canvas3d_primitive_form_set(data->sphere, EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE);
223 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE), 209 evas_canvas3d_primitive_precision_set(data->sphere, 50);
224 evas_canvas3d_primitive_precision_set(50));
225 210
226 data->mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 211 data->mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
227 data->mesh1 = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 212 data->mesh1 = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
@@ -230,27 +215,23 @@ _mesh_setup(Scene_Data *data)
230 _set_ball(data->mesh1, data->sphere, data->material1); 215 _set_ball(data->mesh1, data->sphere, data->material1);
231 216
232 data->mesh_node = 217 data->mesh_node =
233 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 218 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
234 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
235 219
236 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node)); 220 evas_canvas3d_node_member_add(data->root_node, data->mesh_node);
237 eo_do(data->mesh_node, evas_canvas3d_node_mesh_add(data->mesh)); 221 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh);
238 222
239 data->mesh_node1 = 223 data->mesh_node1 =
240 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 224 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
241 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
242 225
243 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node1)); 226 evas_canvas3d_node_member_add(data->root_node, data->mesh_node1);
244 eo_do(data->mesh_node1, evas_canvas3d_node_mesh_add(data->mesh1)); 227 evas_canvas3d_node_mesh_add(data->mesh_node1, data->mesh1);
245 228
246 eo_do(data->mesh1, evas_canvas3d_mesh_blending_enable_set(EINA_TRUE), 229 evas_canvas3d_mesh_blending_enable_set(data->mesh1, EINA_TRUE);
247 evas_canvas3d_mesh_blending_func_set(func1, func2)); 230 evas_canvas3d_mesh_blending_func_set(data->mesh1, func1, func2);
248 231
249 eo_do(data->mesh_node, 232 evas_canvas3d_node_scale_set(data->mesh_node, 2.0, 2.0, 2.0);
250 evas_canvas3d_node_scale_set(2.0, 2.0, 2.0));
251 233
252 eo_do(data->mesh_node1, 234 evas_canvas3d_node_scale_set(data->mesh_node1, 5.0, 5.0, 5.0);
253 evas_canvas3d_node_scale_set(5.0, 5.0, 5.0));
254} 235}
255 236
256static void 237static void
@@ -258,21 +239,18 @@ _scene_setup(Scene_Data *data)
258{ 239{
259 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 240 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
260 241
261 eo_do(data->scene, 242 evas_canvas3d_scene_size_set(data->scene, WIDTH, HEIGHT);
262 evas_canvas3d_scene_size_set(WIDTH, HEIGHT); 243 evas_canvas3d_scene_background_color_set(data->scene, 0.5, 0.5, 0.5, 1);
263 evas_canvas3d_scene_background_color_set(0.5, 0.5, 0.5, 1));
264 244
265 data->root_node = 245 data->root_node =
266 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 246 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
267 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
268 247
269 _camera_setup(data); 248 _camera_setup(data);
270 _light_setup(data); 249 _light_setup(data);
271 _mesh_setup(data); 250 _mesh_setup(data);
272 251
273 eo_do(data->scene, 252 evas_canvas3d_scene_root_node_set(data->scene, data->root_node);
274 evas_canvas3d_scene_root_node_set(data->root_node), 253 evas_canvas3d_scene_camera_node_set(data->scene, data->camera_node);
275 evas_canvas3d_scene_camera_node_set(data->camera_node));
276} 254}
277 255
278int 256int
@@ -312,7 +290,7 @@ main(void)
312 evas_object_focus_set(image, EINA_TRUE); 290 evas_object_focus_set(image, EINA_TRUE);
313 291
314 /* Set the image object as render target for 3D scene. */ 292 /* Set the image object as render target for 3D scene. */
315 eo_do(image, evas_obj_image_scene_set(data.scene)); 293 evas_obj_image_scene_set(image, data.scene);
316 294
317 295
318 /* Add animation timer callback. */ 296 /* Add animation timer callback. */