summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-aabb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-aabb.c')
-rw-r--r--src/examples/evas/evas-3d-aabb.c157
1 files changed, 63 insertions, 94 deletions
diff --git a/src/examples/evas/evas-3d-aabb.c b/src/examples/evas/evas-3d-aabb.c
index c8d906c..d02668b 100644
--- a/src/examples/evas/evas-3d-aabb.c
+++ b/src/examples/evas/evas-3d-aabb.c
@@ -57,7 +57,7 @@ _animate_scene(void *data)
57{ 57{
58 static int frame = 0; 58 static int frame = 0;
59 59
60 eo_do((Evas_Canvas3D_Node *)data, evas_canvas3d_node_mesh_frame_set(mesh, frame)); 60 evas_canvas3d_node_mesh_frame_set((Evas_Canvas3D_Node *)data, mesh, frame);
61 61
62 _redraw_aabb(); 62 _redraw_aabb();
63 63
@@ -84,22 +84,22 @@ _on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void
84 { 84 {
85 case 1: 85 case 1:
86 { 86 {
87 eo_do(node, evas_canvas3d_node_orientation_angle_axis_set(90, 1.0, 0.0, 0.0)); 87 evas_canvas3d_node_orientation_angle_axis_set(node, 90, 1.0, 0.0, 0.0);
88 break; 88 break;
89 } 89 }
90 case 2: 90 case 2:
91 { 91 {
92 eo_do(node, evas_canvas3d_node_orientation_angle_axis_set(90, 0.0, 1.0, 0.0)); 92 evas_canvas3d_node_orientation_angle_axis_set(node, 90, 0.0, 1.0, 0.0);
93 break; 93 break;
94 } 94 }
95 case 3: 95 case 3:
96 { 96 {
97 eo_do(node, evas_canvas3d_node_orientation_angle_axis_set(90, 0.0, 0.0, 1.0)); 97 evas_canvas3d_node_orientation_angle_axis_set(node, 90, 0.0, 0.0, 1.0);
98 break; 98 break;
99 } 99 }
100 case 4: 100 case 4:
101 { 101 {
102 eo_do(node, evas_canvas3d_node_orientation_angle_axis_set(90, 1.0, 1.0, 0.0)); 102 evas_canvas3d_node_orientation_angle_axis_set(node, 90, 1.0, 1.0, 0.0);
103 break; 103 break;
104 } 104 }
105 } 105 }
@@ -111,8 +111,8 @@ _on_canvas_resize(Ecore_Evas *ee)
111 int w, h; 111 int w, h;
112 112
113 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 113 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
114 eo_do(background, efl_gfx_size_set(w, h)); 114 efl_gfx_size_set(background, w, h);
115 eo_do(image, efl_gfx_size_set(w, h)); 115 efl_gfx_size_set(image, w, h);
116} 116}
117 117
118static Eina_Bool 118static Eina_Bool
@@ -120,9 +120,9 @@ _redraw_aabb()
120{ 120{
121 Evas_Real x0, y0, z0, x1, y1, z1; 121 Evas_Real x0, y0, z0, x1, y1, z1;
122 122
123 eo_do(mesh_node, evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1)); 123 evas_canvas3d_node_bounding_box_get(mesh_node, &x0, &y0, &z0, &x1, &y1, &z1);
124 eo_do(mesh_box_node, evas_canvas3d_node_position_set((x0 + x1)/2, (y0 + y1)/2, (z0 + z1)/2), 124 evas_canvas3d_node_position_set(mesh_box_node, (x0 + x1)/2, (y0 + y1)/2, (z0 + z1)/2);
125 evas_canvas3d_node_scale_set(x1 - x0, y1 - y0, z1 - z0)); 125 evas_canvas3d_node_scale_set(mesh_box_node, x1 - x0, y1 - y0, z1 - z0);
126 126
127 return EINA_TRUE; 127 return EINA_TRUE;
128} 128}
@@ -144,118 +144,87 @@ main(void)
144 144
145 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 145 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
146 146
147 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 147 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
148 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
149 148
150 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 149 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
151 eo_do(camera, 150 evas_canvas3d_camera_projection_perspective_set(camera, 60.0, 1.0, 1.0, 500.0);
152 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0));
153 151
154 camera_node = 152 camera_node =
155 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 153 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
156 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 154 evas_canvas3d_node_camera_set(camera_node, camera);
157 eo_do(camera_node, 155 evas_canvas3d_node_member_add(root_node, camera_node);
158 evas_canvas3d_node_camera_set(camera)); 156 evas_canvas3d_node_position_set(camera_node, 100.0, 50.0, 20.0);
159 eo_do(root_node, 157 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);
160 evas_canvas3d_node_member_add(camera_node));
161 eo_do(camera_node,
162 evas_canvas3d_node_position_set(100.0, 50.0, 20.0),
163 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 20.0,
164 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));
165 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 158 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
166 eo_do(light, 159 evas_canvas3d_light_ambient_set(light, 1.0, 1.0, 1.0, 1.0);
167 evas_canvas3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 160 evas_canvas3d_light_diffuse_set(light, 1.0, 1.0, 1.0, 1.0);
168 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 161 evas_canvas3d_light_specular_set(light, 1.0, 1.0, 1.0, 1.0);
169 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0), 162 evas_canvas3d_light_directional_set(light, EINA_TRUE);
170 evas_canvas3d_light_directional_set(EINA_TRUE));
171 163
172 light_node = 164 light_node =
173 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 165 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
174 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 166 evas_canvas3d_node_light_set(light_node, light);
175 eo_do(light_node, 167 evas_canvas3d_node_position_set(light_node, 1000.0, 0.0, 1000.0);
176 evas_canvas3d_node_light_set(light), 168 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);
177 evas_canvas3d_node_position_set(1000.0, 0.0, 1000.0), 169 evas_canvas3d_node_member_add(root_node, light_node);
178 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
179 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
180 eo_do(root_node,
181 evas_canvas3d_node_member_add(light_node));
182 170
183 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 171 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
184 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 172 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
185 173
186 eo_do(mesh, 174 efl_file_set(mesh, model_path, NULL);
187 efl_file_set(model_path, NULL), 175 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
188 evas_canvas3d_mesh_frame_material_set(0, material), 176 evas_canvas3d_mesh_shade_mode_set(mesh, EVAS_CANVAS3D_SHADE_MODE_PHONG);
189 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG));
190 177
191 texture = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); 178 texture = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
192 eo_do(texture, 179 evas_canvas3d_texture_file_set(texture, image_path, NULL);
193 evas_canvas3d_texture_file_set(image_path, NULL), 180 evas_canvas3d_texture_filter_set(texture, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST);
194 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, 181 evas_canvas3d_texture_wrap_set(texture, EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT);
195 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), 182 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture);
196 evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, 183 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
197 EVAS_CANVAS3D_WRAP_MODE_REPEAT)); 184 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
198 eo_do(material, 185 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
199 evas_canvas3d_material_texture_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture), 186 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
200 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 187 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0);
201 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 188 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
202 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 189 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
203 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE), 190 evas_canvas3d_material_shininess_set(material, 50.0);
204 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 191
205 0.01, 0.01, 0.01, 1.0), 192 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
206 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 193 mesh_box_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
207 1.0, 1.0, 1.0, 1.0),
208 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR,
209 1.0, 1.0, 1.0, 1.0),
210 evas_canvas3d_material_shininess_set(50.0));
211
212 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
213 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
214 mesh_box_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
215 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
216 194
217 material_box = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 195 material_box = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
218 eo_do(material_box, evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE)); 196 evas_canvas3d_material_enable_set(material_box, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
219 197
220 cube = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 198 cube = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
221 eo_do(cube, 199 evas_canvas3d_primitive_form_set(cube, EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE);
222 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE));
223 200
224 mesh_box = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 201 mesh_box = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
225 eo_do(mesh_box, 202 evas_canvas3d_mesh_from_primitive_set(mesh_box, 0, cube);
226 evas_canvas3d_mesh_from_primitive_set(0, cube), 203 evas_canvas3d_mesh_vertex_assembly_set(mesh_box, EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES);
227 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES), 204 evas_canvas3d_mesh_shade_mode_set(mesh_box, EVAS_CANVAS3D_SHADE_MODE_VERTEX_COLOR);
228 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_VERTEX_COLOR), 205 evas_canvas3d_mesh_frame_material_set(mesh_box, 0, material_box);
229 evas_canvas3d_mesh_frame_material_set(0, material_box));
230 _redraw_aabb(); 206 _redraw_aabb();
231 207
232 eo_do(root_node, 208 evas_canvas3d_node_member_add(root_node, mesh_box_node);
233 evas_canvas3d_node_member_add(mesh_box_node)); 209 evas_canvas3d_node_mesh_add(mesh_box_node, mesh_box);
234 eo_do(mesh_box_node,
235 evas_canvas3d_node_mesh_add(mesh_box));
236 210
237 eo_do(root_node, 211 evas_canvas3d_node_member_add(root_node, mesh_node);
238 evas_canvas3d_node_member_add(mesh_node)); 212 evas_canvas3d_node_mesh_add(mesh_node, mesh);
239 eo_do(mesh_node,
240 evas_canvas3d_node_mesh_add(mesh));
241 213
242 eo_do(scene, 214 evas_canvas3d_scene_root_node_set(scene, root_node);
243 evas_canvas3d_scene_root_node_set(root_node), 215 evas_canvas3d_scene_camera_node_set(scene, camera_node);
244 evas_canvas3d_scene_camera_node_set(camera_node), 216 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
245 evas_canvas3d_scene_size_set(WIDTH, HEIGHT));
246 217
247 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 218 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
248 eo_do(background, 219 efl_gfx_color_set(background, 0, 0, 0, 255);
249 efl_gfx_color_set(0, 0, 0, 255), 220 efl_gfx_size_set(background, WIDTH, HEIGHT);
250 efl_gfx_size_set(WIDTH, HEIGHT), 221 efl_gfx_visible_set(background, EINA_TRUE);
251 efl_gfx_visible_set(EINA_TRUE));
252 222
253 image = evas_object_image_filled_add(evas); 223 image = evas_object_image_filled_add(evas);
254 eo_do(image, 224 efl_gfx_size_set(image, WIDTH, HEIGHT);
255 efl_gfx_size_set(WIDTH, HEIGHT), 225 efl_gfx_visible_set(image, EINA_TRUE);
256 efl_gfx_visible_set(EINA_TRUE));
257 evas_object_focus_set(image, EINA_TRUE); 226 evas_object_focus_set(image, EINA_TRUE);
258 eo_do(image, evas_obj_image_scene_set(scene)); 227 evas_obj_image_scene_set(image, scene);
259 228
260 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_key_down, mesh_node); 229 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_key_down, mesh_node);
261 230