summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-ply.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-ply.c')
-rw-r--r--src/examples/evas/evas-3d-ply.c132
1 files changed, 53 insertions, 79 deletions
diff --git a/src/examples/evas/evas-3d-ply.c b/src/examples/evas/evas-3d-ply.c
index 25e3288..b34b2cc 100644
--- a/src/examples/evas/evas-3d-ply.c
+++ b/src/examples/evas/evas-3d-ply.c
@@ -78,7 +78,7 @@ _animate_scene(void *data)
78{ 78{
79 angle += 0.2; 79 angle += 0.2;
80 80
81 eo_do((Evas_Canvas3D_Node *)data, evas_canvas3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0)); 81 evas_canvas3d_node_orientation_angle_axis_set((Evas_Canvas3D_Node *)data, angle, 1.0, 1.0, 1.0);
82 82
83 /* Rotate */ 83 /* Rotate */
84 if (angle > 360.0) angle -= 360.0f; 84 if (angle > 360.0) angle -= 360.0f;
@@ -98,8 +98,8 @@ _on_canvas_resize(Ecore_Evas *ee)
98 int w, h; 98 int w, h;
99 99
100 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 100 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
101 eo_do(background, efl_gfx_size_set(w, h)); 101 efl_gfx_size_set(background, w, h);
102 eo_do(image, efl_gfx_size_set(w, h)); 102 efl_gfx_size_set(image, w, h);
103} 103}
104 104
105int 105int
@@ -133,63 +133,44 @@ main(void)
133 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 133 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
134 134
135 /* Add the root node for the scene. */ 135 /* Add the root node for the scene. */
136 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 136 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
137 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
138 137
139 /* Add the camera. */ 138 /* Add the camera. */
140 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 139 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
141 eo_do(camera, 140 evas_canvas3d_camera_projection_perspective_set(camera, 60.0, 1.0, 1.0, 500.0);
142 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0)); 141
143 142 camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
144 camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 143 evas_canvas3d_node_camera_set(camera_node, camera);
145 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 144 evas_canvas3d_node_member_add(root_node, camera_node);
146 eo_do(camera_node, 145 evas_canvas3d_node_position_set(camera_node, 15.0, 0.0, 0.0);
147 evas_canvas3d_node_camera_set(camera)); 146 evas_canvas3d_node_look_at_set(camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0);
148 eo_do(root_node,
149 evas_canvas3d_node_member_add(camera_node));
150 eo_do(camera_node,
151 evas_canvas3d_node_position_set(15.0, 0.0, 0.0),
152 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
153 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));
154 /* Add the light. */ 147 /* Add the light. */
155 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 148 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
156 eo_do(light, 149 evas_canvas3d_light_ambient_set(light, 1.0, 1.0, 1.0, 1.0);
157 evas_canvas3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 150 evas_canvas3d_light_diffuse_set(light, 1.0, 1.0, 1.0, 1.0);
158 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 151 evas_canvas3d_light_specular_set(light, 1.0, 1.0, 1.0, 1.0);
159 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0), 152 evas_canvas3d_light_directional_set(light, EINA_TRUE);
160 evas_canvas3d_light_directional_set(EINA_TRUE)); 153
161 154 light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
162 light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 155 evas_canvas3d_node_light_set(light_node, light);
163 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 156 evas_canvas3d_node_position_set(light_node, 1000.0, 0.0, 1000.0);
164 eo_do(light_node, 157 evas_canvas3d_node_look_at_set(light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
165 evas_canvas3d_node_light_set(light), 158 evas_canvas3d_node_member_add(root_node, light_node);
166 evas_canvas3d_node_position_set(1000.0, 0.0, 1000.0),
167 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
168 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
169 eo_do(root_node,
170 evas_canvas3d_node_member_add(light_node));
171 159
172 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 160 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
173 texture = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); 161 texture = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
174 eo_do(texture, 162 evas_canvas3d_texture_file_set(texture, image_path, NULL);
175 evas_canvas3d_texture_file_set(image_path, NULL), 163 evas_canvas3d_texture_filter_set(texture, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST);
176 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, 164 evas_canvas3d_texture_wrap_set(texture, EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT);
177 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), 165 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture);
178 evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, 166 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
179 EVAS_CANVAS3D_WRAP_MODE_REPEAT)); 167 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
180 eo_do(material, 168 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
181 evas_canvas3d_material_texture_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture), 169 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
182 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 170 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0);
183 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 171 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
184 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 172 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
185 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE), 173 evas_canvas3d_material_shininess_set(material, 50.0);
186 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT,
187 0.01, 0.01, 0.01, 1.0),
188 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE,
189 1.0, 1.0, 1.0, 1.0),
190 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR,
191 1.0, 1.0, 1.0, 1.0),
192 evas_canvas3d_material_shininess_set(50.0));
193 174
194 if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_SAVED_FILES)) 175 if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_SAVED_FILES))
195 fprintf(stderr, "Failed to create folder %s\n\n", 176 fprintf(stderr, "Failed to create folder %s\n\n",
@@ -201,51 +182,44 @@ main(void)
201 mesh[i] = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 182 mesh[i] = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
202 183
203 snprintf(buffer, PATH_MAX, "%s%s", input_template, file_name[i % 8]); 184 snprintf(buffer, PATH_MAX, "%s%s", input_template, file_name[i % 8]);
204 eo_do(mesh[i], 185 efl_file_set(mesh[i], buffer, NULL);
205 efl_file_set(buffer, NULL), 186 evas_canvas3d_mesh_frame_material_set(mesh[i], 0, material);
206 evas_canvas3d_mesh_frame_material_set(0, material), 187 evas_canvas3d_mesh_shade_mode_set(mesh[i], draw_mode[(i % 8)]);
207 evas_canvas3d_mesh_shade_mode_set(draw_mode[(i % 8)]));
208 188
209 snprintf(buffer, PATH_MAX, "%s%s", output_template, file_name[i % 8]); 189 snprintf(buffer, PATH_MAX, "%s%s", output_template, file_name[i % 8]);
210 eo_do(mesh[i], efl_file_save(buffer, NULL, NULL)); 190 efl_file_save(mesh[i], buffer, NULL, NULL);
211 191
212 if (i > 15) 192 if (i > 15)
213 { 193 {
214 eo_do(mesh[i], 194 efl_file_set(mesh[i], buffer, NULL);
215 efl_file_set(buffer, NULL), 195 evas_canvas3d_mesh_frame_material_set(mesh[i], 0, material);
216 evas_canvas3d_mesh_frame_material_set(0, material), 196 evas_canvas3d_mesh_shade_mode_set(mesh[i], draw_mode[(i % 8)]);
217 evas_canvas3d_mesh_shade_mode_set(draw_mode[(i % 8)]));
218 } 197 }
219 198
220 mesh_node[i] = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 199 mesh_node[i] = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
221 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 200 evas_canvas3d_node_member_add(root_node, mesh_node[i]);
222 eo_do(root_node, evas_canvas3d_node_member_add(mesh_node[i])); 201 evas_canvas3d_node_mesh_add(mesh_node[i], mesh[i]);
223 eo_do(mesh_node[i], 202 evas_canvas3d_node_position_set(mesh_node[i], 0, ((i % 4) * 4) + ((i / 16) * 1) - 6.5, (((i % 16) / 4) * 4) - 6);
224 evas_canvas3d_node_mesh_add(mesh[i]),
225 evas_canvas3d_node_position_set(0, ((i % 4) * 4) + ((i / 16) * 1) - 6.5, (((i % 16) / 4) * 4) - 6));
226 } 203 }
227 204
228 /* Set up scene. */ 205 /* Set up scene. */
229 eo_do(scene, 206 evas_canvas3d_scene_root_node_set(scene, root_node);
230 evas_canvas3d_scene_root_node_set(root_node), 207 evas_canvas3d_scene_camera_node_set(scene, camera_node);
231 evas_canvas3d_scene_camera_node_set(camera_node), 208 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
232 evas_canvas3d_scene_size_set(WIDTH, HEIGHT));
233 209
234 /* Add a background rectangle objects. */ 210 /* Add a background rectangle objects. */
235 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 211 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
236 eo_do(background, 212 efl_gfx_color_set(background, 100, 100, 100, 255);
237 efl_gfx_color_set(100, 100, 100, 255), 213 efl_gfx_size_set(background, WIDTH, HEIGHT);
238 efl_gfx_size_set(WIDTH, HEIGHT), 214 efl_gfx_visible_set(background, EINA_TRUE);
239 efl_gfx_visible_set(EINA_TRUE));
240 215
241 /* Add an image object for 3D scene rendering. */ 216 /* Add an image object for 3D scene rendering. */
242 image = evas_object_image_filled_add(evas); 217 image = evas_object_image_filled_add(evas);
243 eo_do(image, 218 efl_gfx_size_set(image, WIDTH, HEIGHT);
244 efl_gfx_size_set(WIDTH, HEIGHT), 219 efl_gfx_visible_set(image, EINA_TRUE);
245 efl_gfx_visible_set(EINA_TRUE));
246 220
247 /* Set the image object as render target for 3D scene. */ 221 /* Set the image object as render target for 3D scene. */
248 eo_do(image, evas_obj_image_scene_set(scene)); 222 evas_obj_image_scene_set(image, scene);
249 223
250 ecore_animator_frametime_set(0.03); 224 ecore_animator_frametime_set(0.03);
251 for (i = 0; i < NUMBER_OF_MESHES; i++) 225 for (i = 0; i < NUMBER_OF_MESHES; i++)