6 #define FNAME image_map_3d_4_start
7 #define NAME "Image Map 3D 4"
16 Evas_Coord x, y, z, u, v;
34 static Cube *cubes[5];
36 #define POINT(n, p, xx, yy, zz, uu, vv) \
37 c->side[n].pt[p].x = xx; \
38 c->side[n].pt[p].y = yy; \
39 c->side[n].pt[p].z = zz; \
40 c->side[n].pt[p].u = uu; \
41 c->side[n].pt[p].v = vv
44 _cube_new(Evas_Coord w, Evas_Coord h, Evas_Coord d)
52 c = calloc(1, sizeof(Cube));
53 for (i = 0; i < 6; i++)
57 o = evas_object_image_add(evas);
59 snprintf(buf, sizeof(buf), "cube%i.png", i + 1);
60 evas_object_image_file_set(o, build_path(buf), NULL);
61 evas_object_image_fill_set(o, 0, 0, 256, 256);
62 evas_object_resize(o, 256, 256);
65 POINT(0, 0, -w, -h, -d, 0, 0);
66 POINT(0, 1, w, -h, -d, 256, 0);
67 POINT(0, 2, w, h, -d, 256, 256);
68 POINT(0, 3, -w, h, -d, 0, 256);
70 POINT(1, 0, w, -h, -d, 0, 0);
71 POINT(1, 1, w, -h, d, 256, 0);
72 POINT(1, 2, w, h, d, 256, 256);
73 POINT(1, 3, w, h, -d, 0, 256);
75 POINT(2, 0, w, -h, d, 0, 0);
76 POINT(2, 1, -w, -h, d, 256, 0);
77 POINT(2, 2, -w, h, d, 256, 256);
78 POINT(2, 3, w, h, d, 0, 256);
80 POINT(3, 0, -w, -h, d, 0, 0);
81 POINT(3, 1, -w, -h, -d, 256, 0);
82 POINT(3, 2, -w, h, -d, 256, 256);
83 POINT(3, 3, -w, h, d, 0, 256);
85 POINT(4, 0, -w, -h, d, 0, 0);
86 POINT(4, 1, w, -h, d, 256, 0);
87 POINT(4, 2, w, -h, -d, 256, 256);
88 POINT(4, 3, -w, -h, -d, 0, 256);
90 POINT(5, 0, -w, h, -d, 0, 0);
91 POINT(5, 1, w, h, -d, 256, 0);
92 POINT(5, 2, w, h, d, 256, 256);
93 POINT(5, 3, -w, h, d, 0, 256);
100 Evas_Coord x, Evas_Coord y, Evas_Coord z,
101 double dx, double dy, double dz)
104 int i, j, order[6], sorted;
109 for (i = 0; i < 6; i++)
113 for (j = 0; j < 4; j++)
115 evas_map_point_coord_set(m, j,
116 c->side[i].pt[j].x + x,
117 c->side[i].pt[j].y + y,
118 c->side[i].pt[j].z + z);
119 evas_map_point_image_uv_set(m, j,
122 evas_map_point_color_set(m, j, 255, 255, 255, 128);
124 evas_map_util_3d_rotate(m, dx, dy, dz, x, y, z);
125 evas_map_util_3d_lighting(m, -1000, -1000, -1000,
128 evas_map_util_3d_perspective(m, (win_w / 2), (win_h / 2), 0, 512);
129 evas_object_map_enable_set(c->side[i].o, 1);
130 evas_object_map_set(c->side[i].o, m);
133 for (j = 0; j < 4; j++)
134 evas_map_point_coord_get(m, j, NULL, NULL, &(tz[j]));
135 mz[i] = (tz[0] + tz[1] + tz[2] + tz[3]) / 4;
141 for (i = 0; i < 5; i++)
143 if (mz[order[i]] > mz[order[i + 1]])
146 order[i] = order[i + 1];
154 evas_object_raise(c->side[order[0]].o);
155 for (i = 1; i < 6; i++)
156 evas_object_stack_below(c->side[order[i]].o, c->side[order[i - 1]].o);
165 for (i = 0; i < 6; i++) evas_object_del(c->side[i].o);
170 static void _setup(void)
172 cubes[0] = _cube_new(128, 128, 256);
173 cubes[1] = _cube_new(256, 128, 128);
174 cubes[2] = _cube_new(256, 256, 128);
175 cubes[3] = _cube_new(128, 256, 128);
176 cubes[4] = _cube_new(256, 256, 256);
182 static void _cleanup(void)
184 _cube_free(cubes[0]);
185 _cube_free(cubes[1]);
186 _cube_free(cubes[2]);
187 _cube_free(cubes[3]);
188 _cube_free(cubes[4]);
191 /* loop - do things */
192 static void _loop(double t, int f)
195 (win_w / 2) - 640, (win_h / 2) - 256, 512,
196 f / 2.0, f, f / 3.0);
198 (win_w / 2) + 512, (win_h / 2) - 128, 384,
199 f / 3.0, f / 2.0, f / 4.0);
201 (win_w / 2) - 384, (win_h / 2) + 128, 256,
202 f / 2.0, f / 3.0, f);
204 (win_w / 2) + 256, (win_h / 2) + 64, 128,
205 f, f / 5.0, f / 2.0);
207 (win_w / 2), (win_h / 2), 0,
208 f / 4.0, f / 3.0, f / 5.0);
212 /* prepend special key handlers if interactive (before STD) */
213 static void _key(char *key)
229 /* template stuff - ignore */
234 _ui_menu_item_add(ICON, NAME, FNAME);
245 ui_func_set(_key, _loop);