summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-fog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-fog.c')
-rw-r--r--src/examples/evas/evas-3d-fog.c127
1 files changed, 54 insertions, 73 deletions
diff --git a/src/examples/evas/evas-3d-fog.c b/src/examples/evas/evas-3d-fog.c
index 5d191e8..33bd05c 100644
--- a/src/examples/evas/evas-3d-fog.c
+++ b/src/examples/evas/evas-3d-fog.c
@@ -59,8 +59,8 @@ _on_canvas_resize(Ecore_Evas *ee)
59 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 59 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
60 60
61 evas_object_resize(background, w, h); 61 evas_object_resize(background, w, h);
62 eo_do(background, efl_gfx_size_set(w, h)); 62 efl_gfx_size_set(background, w, h);
63 eo_do(image, efl_gfx_size_set(w, h)); 63 efl_gfx_size_set(image, w, h);
64} 64}
65 65
66static Eina_Bool 66static Eina_Bool
@@ -71,8 +71,7 @@ _animate_scene(void *data)
71 71
72 angle += 0.5; 72 angle += 0.5;
73 73
74 eo_do(scene->animation_node, 74 evas_canvas3d_node_orientation_angle_axis_set(scene->animation_node, angle, 0.0, 1.0, 0.0);
75 evas_canvas3d_node_orientation_angle_axis_set(angle, 0.0, 1.0, 0.0));
76 75
77 if (angle > 360.0) angle -= 360.0f; 76 if (angle > 360.0) angle -= 360.0f;
78 77
@@ -84,49 +83,40 @@ _camera_setup(Scene_Data *data)
84{ 83{
85 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 84 data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
86 85
87 eo_do(data->camera, 86 evas_canvas3d_camera_projection_perspective_set(data->camera, 60.0, 1.0, 2.0, 50.0);
88 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 2.0, 50.0));
89 87
90 data->camera_node = 88 data->camera_node =
91 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 89 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
92 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA));
93 90
94 eo_do(data->camera_node, 91 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
95 evas_canvas3d_node_camera_set(data->camera), 92 evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 7.0);
96 evas_canvas3d_node_position_set(0.0, 0.0, 7.0), 93 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);
97 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
98 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
99 94
100 eo_do(data->root_node, evas_canvas3d_node_member_add(data->camera_node)); 95 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
101} 96}
102 97
103static void 98static void
104_light_setup(Scene_Data *data) 99_light_setup(Scene_Data *data)
105{ 100{
106 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 101 data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
107 eo_do(data->light, 102 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
108 evas_canvas3d_light_ambient_set(0.2, 0.2, 0.2, 1.0), 103 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
109 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 104 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
110 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0));
111 105
112 data->light_node = 106 data->light_node =
113 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 107 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
114 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 108 evas_canvas3d_node_light_set(data->light_node, data->light);
115 eo_do(data->light_node, 109 evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
116 evas_canvas3d_node_light_set(data->light), 110 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);
117 evas_canvas3d_node_position_set(0.0, 0.0, 10.0), 111 evas_canvas3d_node_member_add(data->root_node, data->light_node);
118 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
119 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
120 eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node));
121} 112}
122 113
123static void 114static void
124_set_ball(Eo *mesh, Eo *sphere, Evas_Canvas3D_Material *material) 115_set_ball(Eo *mesh, Eo *sphere, Evas_Canvas3D_Material *material)
125{ 116{
126 eo_do(mesh, 117 evas_canvas3d_mesh_from_primitive_set(mesh, 0, sphere);
127 evas_canvas3d_mesh_from_primitive_set(0, sphere), 118 evas_canvas3d_mesh_shade_mode_set(mesh, EVAS_CANVAS3D_SHADE_MODE_PHONG);
128 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG), 119 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
129 evas_canvas3d_mesh_frame_material_set(0, material));
130} 120}
131 121
132 122
@@ -135,20 +125,17 @@ _mesh_setup(Scene_Data *data)
135{ 125{
136 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 126 data->material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
137 127
138 eo_do(data->material, 128 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
139 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 129 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
140 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 130 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
141 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 131 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0);
142 132 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
143 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0), 133 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
144 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0), 134 evas_canvas3d_material_shininess_set(data->material, 100.0);
145 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0),
146 evas_canvas3d_material_shininess_set(100.0));
147 135
148 data->sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas); 136 data->sphere = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
149 eo_do(data->sphere, 137 evas_canvas3d_primitive_form_set(data->sphere, EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE);
150 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE), 138 evas_canvas3d_primitive_precision_set(data->sphere, 50);
151 evas_canvas3d_primitive_precision_set(50));
152 139
153 data->mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 140 data->mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
154 data->mesh1 = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 141 data->mesh1 = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
@@ -157,28 +144,27 @@ _mesh_setup(Scene_Data *data)
157 _set_ball(data->mesh1, data->sphere, data->material); 144 _set_ball(data->mesh1, data->sphere, data->material);
158 145
159 data->animation_node = 146 data->animation_node =
160 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 147 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
161 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
162 148
163 data->mesh_node = 149 data->mesh_node =
164 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 150 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
165 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
166 151
167 eo_do(data->animation_node, evas_canvas3d_node_member_add(data->mesh_node)); 152 evas_canvas3d_node_member_add(data->animation_node, data->mesh_node);
168 eo_do(data->root_node, evas_canvas3d_node_member_add(data->animation_node)); 153 evas_canvas3d_node_member_add(data->root_node, data->animation_node);
169 eo_do(data->mesh_node, evas_canvas3d_node_mesh_add(data->mesh), 154 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh);
170 evas_canvas3d_node_position_set(0.0, 0.0, 3.0)); 155 evas_canvas3d_node_position_set(data->mesh_node, 0.0, 0.0, 3.0);
171 156
172 data->mesh_node1 = 157 data->mesh_node1 =
173 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 158 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
174 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
175 159
176 eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node1)); 160 evas_canvas3d_node_member_add(data->root_node, data->mesh_node1);
177 eo_do(data->mesh_node1, evas_canvas3d_node_mesh_add(data->mesh1), 161 evas_canvas3d_node_mesh_add(data->mesh_node1, data->mesh1);
178 evas_canvas3d_node_scale_set(3, 3, 3)); 162 evas_canvas3d_node_scale_set(data->mesh_node1, 3, 3, 3);
179 163
180 eo_do(data->mesh, evas_canvas3d_mesh_fog_enable_set(EINA_TRUE), evas_canvas3d_mesh_fog_color_set(FOG_COLOR, FOG_FACTOR)); 164 evas_canvas3d_mesh_fog_enable_set(data->mesh, EINA_TRUE);
181 eo_do(data->mesh1, evas_canvas3d_mesh_fog_enable_set(EINA_TRUE), evas_canvas3d_mesh_fog_color_set(FOG_COLOR, FOG_FACTOR)); 165 evas_canvas3d_mesh_fog_color_set(data->mesh, FOG_COLOR, FOG_FACTOR);
166 evas_canvas3d_mesh_fog_enable_set(data->mesh1, EINA_TRUE);
167 evas_canvas3d_mesh_fog_color_set(data->mesh1, FOG_COLOR, FOG_FACTOR);
182} 168}
183 169
184static void 170static void
@@ -186,21 +172,18 @@ _scene_setup(Scene_Data *data)
186{ 172{
187 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 173 data->scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
188 174
189 eo_do(data->scene, 175 evas_canvas3d_scene_size_set(data->scene, WIDTH, HEIGHT);
190 evas_canvas3d_scene_size_set(WIDTH, HEIGHT); 176 evas_canvas3d_scene_background_color_set(data->scene, FOG_COLOR, 1);
191 evas_canvas3d_scene_background_color_set(FOG_COLOR, 1));
192 177
193 data->root_node = 178 data->root_node =
194 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 179 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
195 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
196 180
197 _camera_setup(data); 181 _camera_setup(data);
198 _light_setup(data); 182 _light_setup(data);
199 _mesh_setup(data); 183 _mesh_setup(data);
200 184
201 eo_do(data->scene, 185 evas_canvas3d_scene_root_node_set(data->scene, data->root_node);
202 evas_canvas3d_scene_root_node_set(data->root_node), 186 evas_canvas3d_scene_camera_node_set(data->scene, data->camera_node);
203 evas_canvas3d_scene_camera_node_set(data->camera_node));
204} 187}
205 188
206int 189int
@@ -227,20 +210,18 @@ main(void)
227 210
228 /* Add a background rectangle objects. */ 211 /* Add a background rectangle objects. */
229 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 212 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
230 eo_do(background, 213 efl_gfx_color_set(background, 0, 0, 0, 255);
231 efl_gfx_color_set(0, 0, 0, 255), 214 efl_gfx_size_set(background, WIDTH, HEIGHT);
232 efl_gfx_size_set(WIDTH, HEIGHT), 215 efl_gfx_visible_set(background, EINA_TRUE);
233 efl_gfx_visible_set(EINA_TRUE));
234 216
235 /* Add an image object for 3D scene rendering. */ 217 /* Add an image object for 3D scene rendering. */
236 image = evas_object_image_filled_add(evas); 218 image = evas_object_image_filled_add(evas);
237 219
238 eo_do(image, 220 efl_gfx_size_set(image, WIDTH, HEIGHT);
239 efl_gfx_size_set(WIDTH, HEIGHT), 221 efl_gfx_visible_set(image, EINA_TRUE);
240 efl_gfx_visible_set(EINA_TRUE));
241 222
242 /* Set the image object as render target for 3D scene. */ 223 /* Set the image object as render target for 3D scene. */
243 eo_do(image, evas_obj_image_scene_set(data.scene)); 224 evas_obj_image_scene_set(image, data.scene);
244 225
245 /* Add animation timer callback. */ 226 /* Add animation timer callback. */
246 ecore_animator_frametime_set(0.008); 227 ecore_animator_frametime_set(0.008);