summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-eet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-eet.c')
-rw-r--r--src/examples/evas/evas-3d-eet.c136
1 files changed, 54 insertions, 82 deletions
diff --git a/src/examples/evas/evas-3d-eet.c b/src/examples/evas/evas-3d-eet.c
index 9067825..dc09191 100644
--- a/src/examples/evas/evas-3d-eet.c
+++ b/src/examples/evas/evas-3d-eet.c
@@ -58,8 +58,7 @@ _animate_eet(void *data)
58{ 58{
59 angle += 0.5; 59 angle += 0.5;
60 60
61 eo_do((Evas_Canvas3D_Node *)data, 61 evas_canvas3d_node_orientation_angle_axis_set((Evas_Canvas3D_Node *)data, angle, 1.0, 1.0, 1.0);
62 evas_canvas3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0));
63 62
64 /* Rotate */ 63 /* Rotate */
65 if (angle > 360.0) angle -= 360.0f; 64 if (angle > 360.0) angle -= 360.0f;
@@ -72,7 +71,7 @@ _animate_md2(void *data)
72{ 71{
73 static int frame = 0; 72 static int frame = 0;
74 73
75 eo_do((Evas_Canvas3D_Node *)data, evas_canvas3d_node_mesh_frame_set(mesh, frame)); 74 evas_canvas3d_node_mesh_frame_set((Evas_Canvas3D_Node *)data, mesh, frame);
76 75
77 frame += 32; 76 frame += 32;
78 77
@@ -93,8 +92,8 @@ _on_canvas_resize(Ecore_Evas *ee)
93 int w, h; 92 int w, h;
94 93
95 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 94 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
96 eo_do(background, efl_gfx_size_set(w, h)); 95 efl_gfx_size_set(background, w, h);
97 eo_do(image, efl_gfx_size_set(w, h)); 96 efl_gfx_size_set(image, w, h);
98} 97}
99 98
100int 99int
@@ -119,113 +118,86 @@ main(void)
119 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 118 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
120 119
121 /* Add the root node for the scene. */ 120 /* Add the root node for the scene. */
122 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 121 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
123 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
124 122
125 /* Add the camera. */ 123 /* Add the camera. */
126 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 124 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
127 eo_do(camera, 125 evas_canvas3d_camera_projection_perspective_set(camera, 60.0, 1.0, 1.0, 500.0);
128 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0)); 126
129 127 camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
130 camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 128 evas_canvas3d_node_camera_set(camera_node, camera);
131 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 129 evas_canvas3d_node_member_add(root_node, camera_node);
132 eo_do(camera_node, 130 evas_canvas3d_node_position_set(camera_node, 200.0, 0.0, 40.0);
133 evas_canvas3d_node_camera_set(camera)); 131 evas_canvas3d_node_look_at_set(camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 20.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0);
134 eo_do(root_node,
135 evas_canvas3d_node_member_add(camera_node));
136 eo_do(camera_node,
137 evas_canvas3d_node_position_set(200.0, 0.0, 40.0),
138 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 20.0,
139 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));
140 /* Add the light. */ 132 /* Add the light. */
141 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 133 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
142 eo_do(light, 134 evas_canvas3d_light_ambient_set(light, 1.0, 1.0, 1.0, 1.0);
143 evas_canvas3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 135 evas_canvas3d_light_diffuse_set(light, 1.0, 1.0, 1.0, 1.0);
144 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 136 evas_canvas3d_light_specular_set(light, 1.0, 1.0, 1.0, 1.0);
145 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0), 137 evas_canvas3d_light_directional_set(light, EINA_TRUE);
146 evas_canvas3d_light_directional_set(EINA_TRUE)); 138
147 139 light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
148 light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 140 evas_canvas3d_node_light_set(light_node, light);
149 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 141 evas_canvas3d_node_position_set(light_node, 1000.0, 0.0, 1000.0);
150 eo_do(light_node, 142 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);
151 evas_canvas3d_node_light_set(light), 143 evas_canvas3d_node_member_add(root_node, light_node);
152 evas_canvas3d_node_position_set(1000.0, 0.0, 1000.0),
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,
156 evas_canvas3d_node_member_add(light_node));
157 144
158 /* Add the meshes. */ 145 /* Add the meshes. */
159 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 146 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
160 mesh2 = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 147 mesh2 = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
161 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 148 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
162 149
163 eo_do(mesh, 150 efl_file_set(mesh, input_model_path, NULL);
164 efl_file_set(input_model_path, NULL), 151 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
165 evas_canvas3d_mesh_frame_material_set(0, material), 152 evas_canvas3d_mesh_shade_mode_set(mesh, EVAS_CANVAS3D_SHADE_MODE_PHONG);
166 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG)); 153
167 154 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
168 eo_do(material, 155 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
169 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 156 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
170 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 157 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
171 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 158 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.50, 0.50, 0.00, 0.30);
172 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE), 159 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.00, 0.50, 0.50, 0.30);
173 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 160 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 0.50, 0.00, 0.50, 0.30);
174 0.50, 0.50, 0.00, 0.30), 161 evas_canvas3d_material_shininess_set(material, 50.0);
175 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE,
176 0.00, 0.50, 0.50, 0.30),
177 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR,
178 0.50, 0.00, 0.50, 0.30),
179 evas_canvas3d_material_shininess_set(50.0));
180 162
181 if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_SAVED_FILES)) 163 if (!ecore_file_mkpath(PACKAGE_EXAMPLES_DIR EVAS_SAVED_FILES))
182 fprintf(stderr, "Failed to create folder %s\n\n", 164 fprintf(stderr, "Failed to create folder %s\n\n",
183 PACKAGE_EXAMPLES_DIR EVAS_SAVED_FILES); 165 PACKAGE_EXAMPLES_DIR EVAS_SAVED_FILES);
184 166
185 eo_do(mesh, efl_file_save(output_model_path, NULL, NULL)); 167 efl_file_save(mesh, output_model_path, NULL, NULL);
186 168
187 eo_do(mesh2, 169 efl_file_set(mesh2, output_model_path, NULL);
188 efl_file_set(output_model_path, NULL), 170 evas_canvas3d_mesh_shade_mode_set(mesh2, EVAS_CANVAS3D_SHADE_MODE_PHONG);
189 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG));
190 171
191 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 172 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
192 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
193 173
194 eo_do(root_node, 174 evas_canvas3d_node_member_add(root_node, mesh_node);
195 evas_canvas3d_node_member_add(mesh_node)); 175 evas_canvas3d_node_mesh_add(mesh_node, mesh);
196 eo_do(mesh_node, 176 evas_canvas3d_node_position_set(mesh_node, 0.0, -40.0, 0.0);
197 evas_canvas3d_node_mesh_add(mesh),
198 evas_canvas3d_node_position_set(0.0, -40.0, 0.0));
199 177
200 mesh_node2 = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 178 mesh_node2 = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
201 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH)); 179 evas_canvas3d_node_member_add(root_node, mesh_node2);
202 eo_do(root_node, 180 evas_canvas3d_node_mesh_add(mesh_node2, mesh2);
203 evas_canvas3d_node_member_add(mesh_node2)); 181 evas_canvas3d_node_position_set(mesh_node2, 0.0, 40.0, 0.0);
204 eo_do(mesh_node2,
205 evas_canvas3d_node_mesh_add(mesh2),
206 evas_canvas3d_node_position_set(0.0, 40.0, 0.0));
207 182
208 /* Set up scene. */ 183 /* Set up scene. */
209 eo_do(scene, 184 evas_canvas3d_scene_root_node_set(scene, root_node);
210 evas_canvas3d_scene_root_node_set(root_node), 185 evas_canvas3d_scene_camera_node_set(scene, camera_node);
211 evas_canvas3d_scene_camera_node_set(camera_node), 186 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
212 evas_canvas3d_scene_size_set(WIDTH, HEIGHT));
213 187
214 /* Add a background rectangle objects. */ 188 /* Add a background rectangle objects. */
215 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 189 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
216 eo_do(background, 190 efl_gfx_color_set(background, 0, 0, 0, 255);
217 efl_gfx_color_set(0, 0, 0, 255), 191 efl_gfx_size_set(background, WIDTH, HEIGHT);
218 efl_gfx_size_set(WIDTH, HEIGHT), 192 efl_gfx_visible_set(background, EINA_TRUE);
219 efl_gfx_visible_set(EINA_TRUE));
220 193
221 /* Add an image object for 3D scene rendering. */ 194 /* Add an image object for 3D scene rendering. */
222 image = evas_object_image_filled_add(evas); 195 image = evas_object_image_filled_add(evas);
223 eo_do(image, 196 efl_gfx_size_set(image, WIDTH, HEIGHT);
224 efl_gfx_size_set(WIDTH, HEIGHT), 197 efl_gfx_visible_set(image, EINA_TRUE);
225 efl_gfx_visible_set(EINA_TRUE));
226 198
227 /* Set the image object as render target for 3D scene. */ 199 /* Set the image object as render target for 3D scene. */
228 eo_do(image, evas_obj_image_scene_set(scene)); 200 evas_obj_image_scene_set(image, scene);
229 201
230 ecore_timer_add(0.01, _animate_md2, mesh_node); 202 ecore_timer_add(0.01, _animate_md2, mesh_node);
231 ecore_timer_add(0.01, _animate_eet, mesh_node2); 203 ecore_timer_add(0.01, _animate_eet, mesh_node2);