summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-3d-md2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/evas/evas-3d-md2.c')
-rw-r--r--src/examples/evas/evas-3d-md2.c120
1 files changed, 47 insertions, 73 deletions
diff --git a/src/examples/evas/evas-3d-md2.c b/src/examples/evas/evas-3d-md2.c
index 9409efc..e19dfd6 100644
--- a/src/examples/evas/evas-3d-md2.c
+++ b/src/examples/evas/evas-3d-md2.c
@@ -47,7 +47,7 @@ _animate_scene(void *data)
47{ 47{
48 static int frame = 0; 48 static int frame = 0;
49 49
50 eo_do((Evas_Canvas3D_Node *)data, evas_canvas3d_node_mesh_frame_set(mesh, frame)); 50 evas_canvas3d_node_mesh_frame_set((Evas_Canvas3D_Node *)data, mesh, frame);
51 51
52 frame += 32; 52 frame += 32;
53 53
@@ -68,8 +68,8 @@ _on_canvas_resize(Ecore_Evas *ee)
68 int w, h; 68 int w, h;
69 69
70 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); 70 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
71 eo_do(background, efl_gfx_size_set(w, h)); 71 efl_gfx_size_set(background, w, h);
72 eo_do(image, efl_gfx_size_set(w, h)); 72 efl_gfx_size_set(image, w, h);
73} 73}
74 74
75int 75int
@@ -94,102 +94,76 @@ main(void)
94 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 94 scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
95 95
96 /* Add the root node for the scene. */ 96 /* Add the root node for the scene. */
97 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 97 root_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_NODE));
98 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
99 98
100 /* Add the camera. */ 99 /* Add the camera. */
101 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas); 100 camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
102 eo_do(camera, 101 evas_canvas3d_camera_projection_perspective_set(camera, 60.0, 1.0, 1.0, 500.0);
103 evas_canvas3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0));
104 102
105 camera_node = 103 camera_node =
106 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 104 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
107 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA)); 105 evas_canvas3d_node_camera_set(camera_node, camera);
108 eo_do(camera_node, 106 evas_canvas3d_node_member_add(root_node, camera_node);
109 evas_canvas3d_node_camera_set(camera)); 107 evas_canvas3d_node_position_set(camera_node, 100.0, 0.0, 20.0);
110 eo_do(root_node, 108 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);
111 evas_canvas3d_node_member_add(camera_node));
112 eo_do(camera_node,
113 evas_canvas3d_node_position_set(100.0, 0.0, 20.0),
114 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 20.0,
115 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));
116 /* Add the light. */ 109 /* Add the light. */
117 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas); 110 light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
118 eo_do(light, 111 evas_canvas3d_light_ambient_set(light, 1.0, 1.0, 1.0, 1.0);
119 evas_canvas3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 112 evas_canvas3d_light_diffuse_set(light, 1.0, 1.0, 1.0, 1.0);
120 evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0), 113 evas_canvas3d_light_specular_set(light, 1.0, 1.0, 1.0, 1.0);
121 evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0), 114 evas_canvas3d_light_directional_set(light, EINA_TRUE);
122 evas_canvas3d_light_directional_set(EINA_TRUE));
123 115
124 light_node = 116 light_node =
125 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, 117 eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
126 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT)); 118 evas_canvas3d_node_light_set(light_node, light);
127 eo_do(light_node, 119 evas_canvas3d_node_position_set(light_node, 1000.0, 0.0, 1000.0);
128 evas_canvas3d_node_light_set(light), 120 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);
129 evas_canvas3d_node_position_set(1000.0, 0.0, 1000.0), 121 evas_canvas3d_node_member_add(root_node, light_node);
130 evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0,
131 EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
132 eo_do(root_node,
133 evas_canvas3d_node_member_add(light_node));
134 122
135 /* Add the mesh. */ 123 /* Add the mesh. */
136 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); 124 mesh = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
137 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); 125 material = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
138 126
139 eo_do(mesh, 127 efl_file_set(mesh, model_path, NULL);
140 efl_file_set(model_path, NULL), 128 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
141 evas_canvas3d_mesh_frame_material_set(0, material), 129 evas_canvas3d_mesh_shade_mode_set(mesh, EVAS_CANVAS3D_SHADE_MODE_PHONG);
142 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG));
143 130
144 texture = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); 131 texture = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
145 eo_do(texture, 132 evas_canvas3d_texture_file_set(texture, image_path, NULL);
146 evas_canvas3d_texture_file_set(image_path, NULL), 133 evas_canvas3d_texture_filter_set(texture, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST);
147 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, 134 evas_canvas3d_texture_wrap_set(texture, EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT);
148 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), 135 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture);
149 evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, 136 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
150 EVAS_CANVAS3D_WRAP_MODE_REPEAT)); 137 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
151 eo_do(material, 138 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
152 evas_canvas3d_material_texture_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture), 139 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
153 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE), 140 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0);
154 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE), 141 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
155 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE), 142 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
156 evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE), 143 evas_canvas3d_material_shininess_set(material, 50.0);
157 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 144
158 0.01, 0.01, 0.01, 1.0), 145 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_MESH));
159 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 146 evas_canvas3d_node_member_add(root_node, mesh_node);
160 1.0, 1.0, 1.0, 1.0), 147 evas_canvas3d_node_mesh_add(mesh_node, mesh);
161 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR,
162 1.0, 1.0, 1.0, 1.0),
163 evas_canvas3d_material_shininess_set(50.0));
164
165 mesh_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
166 evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
167 eo_do(root_node,
168 evas_canvas3d_node_member_add(mesh_node));
169 eo_do(mesh_node,
170 evas_canvas3d_node_mesh_add(mesh));
171 148
172 /* Set up scene. */ 149 /* Set up scene. */
173 eo_do(scene, 150 evas_canvas3d_scene_root_node_set(scene, root_node);
174 evas_canvas3d_scene_root_node_set(root_node), 151 evas_canvas3d_scene_camera_node_set(scene, camera_node);
175 evas_canvas3d_scene_camera_node_set(camera_node), 152 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
176 evas_canvas3d_scene_size_set(WIDTH, HEIGHT));
177 153
178 /* Add a background rectangle objects. */ 154 /* Add a background rectangle objects. */
179 background = eo_add(EVAS_RECTANGLE_CLASS, evas); 155 background = eo_add(EVAS_RECTANGLE_CLASS, evas);
180 eo_do(background, 156 efl_gfx_color_set(background, 0, 0, 0, 255);
181 efl_gfx_color_set(0, 0, 0, 255), 157 efl_gfx_size_set(background, WIDTH, HEIGHT);
182 efl_gfx_size_set(WIDTH, HEIGHT), 158 efl_gfx_visible_set(background, EINA_TRUE);
183 efl_gfx_visible_set(EINA_TRUE));
184 159
185 /* Add an image object for 3D scene rendering. */ 160 /* Add an image object for 3D scene rendering. */
186 image = evas_object_image_filled_add(evas); 161 image = evas_object_image_filled_add(evas);
187 eo_do(image, 162 efl_gfx_size_set(image, WIDTH, HEIGHT);
188 efl_gfx_size_set(WIDTH, HEIGHT), 163 efl_gfx_visible_set(image, EINA_TRUE);
189 efl_gfx_visible_set(EINA_TRUE));
190 164
191 /* Set the image object as render target for 3D scene. */ 165 /* Set the image object as render target for 3D scene. */
192 eo_do(image, evas_obj_image_scene_set(scene)); 166 evas_obj_image_scene_set(image, scene);
193 167
194 ecore_timer_add(0.01, _animate_scene, mesh_node); 168 ecore_timer_add(0.01, _animate_scene, mesh_node);
195 169