summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorperepelits.m <perepelits.m@samsung.com>2015-06-25 16:22:00 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-25 17:21:09 +0200
commitf259ff8d4cf30ce2c23137702af04e123c599f99 (patch)
treea8230ea79bd883e1f74bd9ccdb30782b65a8a623 /src/examples
parent2b29f4dfbf901d40aee552345ae5285b1c2e484c (diff)
evas: fix shooter example
Summary: Disable atlas flag for all objects, fix motion algorithm, add primitives. Reviewers: Hermet, raster, cedric Subscribers: cedric, artem.popov Differential Revision: https://phab.enlightenment.org/D2693 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter-header.h2
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter-macros.h129
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter.c333
3 files changed, 150 insertions, 314 deletions
diff --git a/src/examples/evas/shooter/evas-3d-shooter-header.h b/src/examples/evas/shooter/evas-3d-shooter-header.h
index 235c85b873..de70da7747 100644
--- a/src/examples/evas/shooter/evas-3d-shooter-header.h
+++ b/src/examples/evas/shooter/evas-3d-shooter-header.h
@@ -21,6 +21,8 @@
21 21
22typedef struct _Scene_Data 22typedef struct _Scene_Data
23{ 23{
24 Eo *cube_primitive;
25 Eo *sphere_primitive;
24 Eo *cylinder_primitive; 26 Eo *cylinder_primitive;
25 Eo *texture_diffuse_eagle; 27 Eo *texture_diffuse_eagle;
26 Eo *texture_diffuse_world; 28 Eo *texture_diffuse_world;
diff --git a/src/examples/evas/shooter/evas-3d-shooter-macros.h b/src/examples/evas/shooter/evas-3d-shooter-macros.h
index 2eb3282602..bf3964a561 100644
--- a/src/examples/evas/shooter/evas-3d-shooter-macros.h
+++ b/src/examples/evas/shooter/evas-3d-shooter-macros.h
@@ -62,10 +62,50 @@ typedef struct _vec2
62 float y; 62 float y;
63} vec2; 63} vec2;
64 64
65#define KEY_MOTION(lateral, camera) \ 65#define KEY_MOTION(way) \
66 { \ 66 { \
67 lateral_motion_indicator = lateral; \ 67 for (i = 0; (motion_vec[i] > 0) && (!pressed); i++) \
68 camera_move = camera; \ 68 pressed = (motion_vec[i] == way); \
69 \
70 if (!pressed) \
71 motion_vec[i] = way; \
72 \
73 if ((way == 1) || (way == 3)) \
74 camera_move = CAMERA_MOVE; \
75 else \
76 camera_move = -CAMERA_MOVE; \
77 \
78 if (way < 3) \
79 lateral_motion_indicator = 0; \
80 else \
81 lateral_motion_indicator = 1; \
82 }
83
84#define KEY_MOTION_DOWN(way) \
85 { \
86 while ((motion_vec[i] != way) && (i < 4)) \
87 i++; \
88 for (j = i; j < 3; j++) \
89 motion_vec[j] = motion_vec[j + 1]; \
90 motion_vec[3] = 0; \
91 \
92 i = 0; \
93 while (motion_vec[i] > 0) \
94 i++; \
95 if (i > 0) \
96 { \
97 if ((motion_vec[i - 1] == 1) || (motion_vec[i - 1] == 3)) \
98 camera_move = CAMERA_MOVE; \
99 else \
100 camera_move = -CAMERA_MOVE; \
101 \
102 if (motion_vec[i-1] < 3) \
103 lateral_motion_indicator = 0; \
104 else \
105 lateral_motion_indicator = 1; \
106 } \
107 else \
108 camera_move = 0; \
69 } 109 }
70 110
71 111
@@ -86,7 +126,7 @@ typedef struct _vec2
86 eo_do(mesh, evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG)); 126 eo_do(mesh, evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG));
87 127
88 128
89#define SETUP_MESH(Object, Name, a, d, s) \ 129#define ADD_MESH(Object, Name, a, d, s) \
90 data->material_##Object = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); \ 130 data->material_##Object = eo_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas); \
91 \ 131 \
92 eo_do(data->material_##Object, \ 132 eo_do(data->material_##Object, \
@@ -99,11 +139,11 @@ typedef struct _vec2
99 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_SPECULAR, s, s, s, 1.0), \ 139 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_SPECULAR, s, s, s, 1.0), \
100 evas_canvas3d_material_shininess_set(50.0)); \ 140 evas_canvas3d_material_shininess_set(50.0)); \
101 \ 141 \
102 data->mesh_##Name = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas); \ 142 data->mesh_##Name = eo_add(EVAS_CANVAS3D_MESH_CLASS, evas);
103 \ 143
144#define SETUP_DEFAULT_MESH(Object, Name, Shade_Mode) \
104 eo_do(data->mesh_##Name, \ 145 eo_do(data->mesh_##Name, \
105 evas_canvas3d_mesh_frame_add(0), \ 146 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_##Shade_Mode), \
106 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE), \
107 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), \ 147 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), \
108 evas_canvas3d_mesh_frame_material_set(0, data->material_##Object)); 148 evas_canvas3d_mesh_frame_material_set(0, data->material_##Object));
109 149
@@ -118,13 +158,13 @@ typedef struct _vec2
118 158
119#define MATERIAL_TEXTURE_SET(Object, Name, file, image) \ 159#define MATERIAL_TEXTURE_SET(Object, Name, file, image) \
120 eo_do(data->mesh_##Name, \ 160 eo_do(data->mesh_##Name, \
121 efl_file_set(file, NULL), \ 161 efl_file_set(file, NULL)); \
122 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG), \
123 evas_canvas3d_mesh_frame_material_set(0, data->material_##Object)); \
124 \ 162 \
163 SETUP_DEFAULT_MESH(Object, Name, PHONG) \
125 data->texture_diffuse_##Object = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); \ 164 data->texture_diffuse_##Object = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); \
126 \ 165 \
127 eo_do(data->texture_diffuse_##Object, \ 166 eo_do(data->texture_diffuse_##Object, \
167 evas_canvas3d_texture_atlas_enable_set(EINA_FALSE), \
128 evas_canvas3d_texture_file_set(image, NULL), \ 168 evas_canvas3d_texture_file_set(image, NULL), \
129 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, \ 169 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, \
130 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), \ 170 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), \
@@ -137,31 +177,17 @@ typedef struct _vec2
137 data->texture_diffuse_##Object)); 177 data->texture_diffuse_##Object));
138 178
139 179
140#define CUBE_TEXTURE_SET(Object, Name, v_count, vertex1, vertex2, i_count, index, image) \ 180#define CUBE_TEXTURE_SET(Object, Name, vertex, image) \
141 int textcoords_count = 12; \
142 int pos_count = 12; \
143 if (&vertex1[10] != vertex2) \
144 { \
145 textcoords_count =2; \
146 pos_count = 10; \
147 } \
148 eo_do(data->mesh_##Name, \ 181 eo_do(data->mesh_##Name, \
149 evas_canvas3d_mesh_vertex_count_set(v_count), \ 182 evas_canvas3d_mesh_from_primitive_set(0, data->cube_primitive), \
150 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_POSITION, \
151 pos_count * sizeof(float), &vertex1[ 0]), \
152 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_NORMAL, \
153 pos_count * sizeof(float), &vertex1[ 3]), \
154 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_COLOR, \
155 pos_count * sizeof(float), &vertex1[ 6]), \
156 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_TEXCOORD, \ 183 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_TEXCOORD, \
157 textcoords_count * sizeof(float), vertex2), \ 184 2 * sizeof(float), vertex)); \
158 evas_canvas3d_mesh_index_data_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
159 i_count, &index[0]), \
160 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_NORMAL_MAP)); \
161 \ 185 \
186 SETUP_DEFAULT_MESH(Object, Name, NORMAL_MAP) \
162 data->texture_diffuse_##Object = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); \ 187 data->texture_diffuse_##Object = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); \
163 \ 188 \
164 eo_do(data->texture_diffuse_##Object, \ 189 eo_do(data->texture_diffuse_##Object, \
190 evas_canvas3d_texture_atlas_enable_set(EINA_FALSE), \
165 evas_canvas3d_texture_file_set(image, NULL), \ 191 evas_canvas3d_texture_file_set(image, NULL), \
166 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, \ 192 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, \
167 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), \ 193 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), \
@@ -178,6 +204,7 @@ typedef struct _vec2
178 data->texture_normal_##Object = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); \ 204 data->texture_normal_##Object = eo_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas); \
179 \ 205 \
180 eo_do(data->texture_normal_##Object, \ 206 eo_do(data->texture_normal_##Object, \
207 evas_canvas3d_texture_atlas_enable_set(EINA_FALSE), \
181 evas_canvas3d_texture_file_set(normal, NULL), \ 208 evas_canvas3d_texture_file_set(normal, NULL), \
182 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, \ 209 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, \
183 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), \ 210 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), \
@@ -190,59 +217,43 @@ typedef struct _vec2
190 eo_do(data->mesh_##Name, \ 217 eo_do(data->mesh_##Name, \
191 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_NORMAL_MAP)); 218 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_NORMAL_MAP));
192 219
193#define SPHERE_SET(Name) \
194 eo_do(data->mesh_##Name, \
195 evas_canvas3d_mesh_vertex_count_set(vertex_count), \
196 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_POSITION, \
197 sizeof(vertex), &vertices[0].position), \
198 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_NORMAL, \
199 sizeof(vertex), &vertices[0].normal), \
200 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_TANGENT, \
201 sizeof(vertex), &vertices[0].tangent), \
202 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_COLOR, \
203 sizeof(vertex), &vertices[0].color); \
204 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_TEXCOORD, \
205 sizeof(vertex), &vertices[0].texcoord), \
206 evas_canvas3d_mesh_index_data_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
207 index_count, &indices[0]));
208
209#define TEXTCOORDS_SET(Name, fb1, fb2, lr1, lr2, tb1, tb2) \ 220#define TEXTCOORDS_SET(Name, fb1, fb2, lr1, lr2, tb1, tb2) \
210 static float Name##_textcoords[] = \ 221 static float Name##_textcoords[] = \
211 { \ 222 { \
212 /* Front */ \ 223 /* Front */ \
213 0.0, 0.0, \ 224 0.0, 0.0, \
214 fb1, 0.0, \ 225 fb1, 0.0, \
215 0.0, fb2, \
216 fb1, fb2, \ 226 fb1, fb2, \
217 \
218 /* Back */ \
219 0.0, fb2, \ 227 0.0, fb2, \
220 fb1, fb2, \
221 0.0, 0.0, \
222 fb1, 0.0, \
223 \ 228 \
224 /* Left */ \ 229 /* Left */ \
225 0.0, lr2, \ 230 lr1, 0.0, \
226 lr1, lr2, \ 231 lr1, lr2, \
232 0.0, lr2, \
227 0.0, 0.0, \ 233 0.0, 0.0, \
228 lr1, 0.0, \ 234 \
235 /* Back */ \
236 0.0, 0.0, \
237 fb1, 0.0, \
238 fb1, fb2, \
239 0.0, fb2, \
229 \ 240 \
230 /* Right */ \ 241 /* Right */ \
231 0.0, lr2, \ 242 0.0, lr2, \
232 lr1, lr2, \
233 0.0, 0.0, \ 243 0.0, 0.0, \
234 lr1, 0.0, \ 244 lr1, 0.0, \
245 lr1, lr2, \
235 \ 246 \
236 /* Top */ \ 247 /* Top */ \
248 0.0, 0.0, \
237 0.0, tb2, \ 249 0.0, tb2, \
238 tb1, tb2, \ 250 tb1, tb2, \
239 0.0, 0.0, \
240 tb1, 0.0, \ 251 tb1, 0.0, \
241 \ 252 \
242 /* Bottom */ \ 253 /* Bottom */ \
243 0.0, tb2, \ 254 tb1, 0.0, \
244 tb1, tb2, \ 255 tb1, tb2, \
256 0.0, tb2, \
245 0.0, 0.0, \ 257 0.0, 0.0, \
246 tb1, 0.0, \
247 }; 258 };
248 259
diff --git a/src/examples/evas/shooter/evas-3d-shooter.c b/src/examples/evas/shooter/evas-3d-shooter.c
index 055407a011..c83ab0dc39 100644
--- a/src/examples/evas/shooter/evas-3d-shooter.c
+++ b/src/examples/evas/shooter/evas-3d-shooter.c
@@ -44,6 +44,7 @@ int lateral_motion_indicator = 0;
44int step_indicator = 0; 44int step_indicator = 0;
45int fall_indicator = 0; 45int fall_indicator = 0;
46int aabb_index = 0; 46int aabb_index = 0;
47int motion_vec[4];
47 48
48typedef struct _Ecore_Timers 49typedef struct _Ecore_Timers
49{ 50{
@@ -51,56 +52,6 @@ typedef struct _Ecore_Timers
51 void *data; 52 void *data;
52} Timers; 53} Timers;
53 54
54static float cube_vertices[] =
55{
56 /* Front */
57 -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0,
58 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0,
59 -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0,
60 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0,
61
62 /* Back */
63 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0,
64 -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0,
65 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0,
66 -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0,
67
68 /* Left */
69 -1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0,
70 -1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0,
71 -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0,
72 -1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0,
73
74 /* Right */
75 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
76 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
77 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
78 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
79
80 /* Top */
81 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0,
82 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0,
83 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0,
84 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0,
85
86 /* Bottom */
87 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
88 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
89 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
90 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
91};
92
93static float grass_vertices[] =
94{
95 /* Top */
96 -6.5, 0.0, -4.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 4.0,
97 6.5, 0.0, -4.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 4.0, 4.0,
98 -6.5, 0.0, 4.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
99 6.5, 0.0, 4.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 4.0, 0.0,
100
101};
102
103
104static const unsigned short cube_indices[] = 55static const unsigned short cube_indices[] =
105{ 56{
106 /* Front */ 57 /* Front */
@@ -122,12 +73,6 @@ static const unsigned short cube_indices[] =
122 20, 21, 22, 22, 21, 23 73 20, 21, 22, 22, 21, 23
123}; 74};
124 75
125static const unsigned short grass_indices[] =
126{
127 /* Top */
128 0, 1, 2, 2, 1, 3
129};
130
131static int vertex_count = 0; 76static int vertex_count = 0;
132static vertex *vertices = NULL; 77static vertex *vertices = NULL;
133 78
@@ -143,6 +88,7 @@ _key_down(void *data,
143 Evas_Event_Key_Down *ev = event_info; 88 Evas_Event_Key_Down *ev = event_info;
144 Evas_Real x, y, z; 89 Evas_Real x, y, z;
145 Scene_Data *scene = (Scene_Data *)data; 90 Scene_Data *scene = (Scene_Data *)data;
91 Eina_Bool pressed = EINA_FALSE;
146 int i = 0; 92 int i = 0;
147 if (!strcmp(ev->key, "space")) 93 if (!strcmp(ev->key, "space"))
148 { 94 {
@@ -155,13 +101,13 @@ _key_down(void *data,
155 } 101 }
156 } 102 }
157 else if (!strcmp(ev->key, "s")) 103 else if (!strcmp(ev->key, "s"))
158 KEY_MOTION(0, CAMERA_MOVE) 104 KEY_MOTION(1)
159 else if (!strcmp(ev->key, "w")) 105 else if (!strcmp(ev->key, "w"))
160 KEY_MOTION(0, -CAMERA_MOVE) 106 KEY_MOTION(2)
161 else if (!strcmp(ev->key, "d")) 107 else if (!strcmp(ev->key, "d"))
162 KEY_MOTION(1, CAMERA_MOVE) 108 KEY_MOTION(3)
163 else if (!strcmp(ev->key, "a")) 109 else if (!strcmp(ev->key, "a"))
164 KEY_MOTION(1, -CAMERA_MOVE) 110 KEY_MOTION(4)
165 else if (!strcmp(ev->key, "B")) 111 else if (!strcmp(ev->key, "B"))
166 { 112 {
167 if (!scene->blending) 113 if (!scene->blending)
@@ -308,12 +254,19 @@ _key_up(void *data EINA_UNUSED,
308 void *event_info) 254 void *event_info)
309{ 255{
310 Evas_Event_Key_Down *ev = event_info; 256 Evas_Event_Key_Down *ev = event_info;
257 int i = 0, j;
311 258
312 if (!strcmp(ev->key, "space")) 259 if (!strcmp(ev->key, "space"))
313 space_move = 0; 260 space_move = 0;
314 else if ((!strcmp(ev->key, "s")) || (!strcmp(ev->key, "w")) || 261 else if (!strcmp(ev->key, "s"))
315 (!strcmp(ev->key, "d")) || (!strcmp(ev->key, "a"))) 262 KEY_MOTION_DOWN(1)
316 camera_move = 0; 263 else if (!strcmp(ev->key, "w"))
264 KEY_MOTION_DOWN(2)
265 else if (!strcmp(ev->key, "d"))
266 KEY_MOTION_DOWN(3)
267 else if (!strcmp(ev->key, "a"))
268 KEY_MOTION_DOWN(4)
269
317} 270}
318 271
319/* animate camera, create artificial intelligence of warrior */ 272/* animate camera, create artificial intelligence of warrior */
@@ -561,7 +514,7 @@ _animate_scene_gun(void *data)
561 _scale(scene->mesh_node_rocket[i], 0.004); 514 _scale(scene->mesh_node_rocket[i], 0.004);
562 else if (rocket_indicator[i] == 1) 515 else if (rocket_indicator[i] == 1)
563 { 516 {
564 _scale(scene->mesh_node_rocket[i], 0.2); 517 _scale(scene->mesh_node_rocket[i], 0.4);
565 eo_do(scene->material_rocket[i], 518 eo_do(scene->material_rocket[i],
566 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_AMBIENT, 0.8, 0.8, 0.8, 1.0), 519 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_AMBIENT, 0.8, 0.8, 0.8, 1.0),
567 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_DIFFUSE, 0.2, 0.2, 0.0, 1.0), 520 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_DIFFUSE, 0.2, 0.2, 0.0, 1.0),
@@ -606,7 +559,7 @@ _animate_scene_gun(void *data)
606 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_DIFFUSE, 0.9, 0.1, 0.1, 1.0), 559 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_DIFFUSE, 0.9, 0.1, 0.1, 1.0),
607 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_SPECULAR, 0.5, 0.5, 0.5, 1.0)); 560 evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_SPECULAR, 0.5, 0.5, 0.5, 1.0));
608 561
609 _scale(scene->mesh_node_rocket[i], 2.3); 562 _scale(scene->mesh_node_rocket[i], 4.5);
610 rocket_indicator[i] = 3; 563 rocket_indicator[i] = 3;
611 } 564 }
612 } 565 }
@@ -793,170 +746,23 @@ _play_scene(void *data EINA_UNUSED,
793} 746}
794 747
795void 748void
796_world_init(int precision)
797{
798 int i, j;
799 unsigned short *index;
800 double lati, y , r, longi;
801 vec3 e1, e2;
802 float du1, du2, dv1, dv2, f;
803 vec3 tangent;
804
805 vertex_count = (precision + 1) * (precision + 1);
806 index_count = precision * precision * 6;
807
808 /* Allocate buffer. */
809 vertices = malloc(sizeof(vertex) * vertex_count);
810 indices = malloc(sizeof(unsigned short) * index_count);
811
812 for (i = 0; i <= precision; i++)
813 {
814 lati = (M_PI * (double)i) / (double)precision;
815 y = cos(lati);
816 r = fabs(sin(lati));
817
818 for (j = 0; j <= precision; j++)
819 {
820 longi = (M_PI * 2.0 * j) / precision;
821 vertex *v = &vertices[i * (precision + 1) + j];
822
823 if (j == 0 || j == precision)
824 v->position.x = 0.0;
825 else
826 v->position.x = r * sin(longi);
827
828 v->position.y = y;
829
830 if (j == 0 || j == precision)
831 v->position.z = r;
832 else
833 v->position.z = r * cos(longi);
834
835 v->normal = v->position;
836
837 if (v->position.x > 0.0)
838 {
839 v->tangent.x = -v->normal.y;
840 v->tangent.y = v->normal.x;
841 v->tangent.z = v->normal.z;
842 }
843 else
844 {
845 v->tangent.x = v->normal.y;
846 v->tangent.y = -v->normal.x;
847 v->tangent.z = v->normal.z;
848 }
849
850 v->color.x = v->position.x;
851 v->color.y = v->position.y;
852 v->color.z = v->position.z;
853 v->color.w = 1.0;
854
855 if (j == precision)
856 v->texcoord.x = 1.0;
857 else if (j == 0)
858 v->texcoord.x = 0.0;
859 else
860 v->texcoord.x = (double)j / (double)precision;
861
862 if (i == precision)
863 v->texcoord.y = 1.0;
864 else if (i == 0)
865 v->texcoord.y = 0.0;
866 else
867 v->texcoord.y = 1.0 - (double)i / (double)precision;
868 }
869 }
870
871 index = &indices[0];
872
873 for (i = 0; i < precision; i++)
874 {
875 for (j = 0; j < precision; j++)
876 {
877 *index++ = i * (precision + 1) + j;
878 *index++ = i * (precision + 1) + j + 1;
879 *index++ = (i + 1) * (precision + 1) + j;
880
881 *index++ = (i + 1) * (precision + 1) + j;
882 *index++ = i * (precision + 1) + j + 1;
883 *index++ = (i + 1) * (precision + 1) + j + 1;
884 }
885 }
886
887 for (i = 0; i < index_count; i += 3)
888 {
889 vertex *v0 = &vertices[indices[i + 0]];
890 vertex *v1 = &vertices[indices[i + 1]];
891 vertex *v2 = &vertices[indices[i + 2]];
892
893 e1.x = v1->position.x - v0->position.x;
894 e1.y = v1->position.y - v0->position.y;
895 e1.z = v1->position.z - v0->position.z;
896
897 e2.x = v2->position.x - v0->position.x;
898 e2.y = v2->position.y - v0->position.y;
899 e2.z = v2->position.z - v0->position.z;
900
901 du1 = v1->texcoord.x - v0->texcoord.x;
902 dv1 = v1->texcoord.y - v0->texcoord.y;
903
904 du2 = v2->texcoord.x - v0->texcoord.x;
905 dv2 = v2->texcoord.y - v0->texcoord.y;
906
907 f = 1.0 / (du1 * dv2 - du2 * dv1);
908
909 tangent.x = f * (dv2 * e1.x - dv1 * e2.x);
910 tangent.y = f * (dv2 * e1.y - dv1 * e2.y);
911 tangent.z = f * (dv2 * e1.z - dv1 * e2.z);
912
913 v0->tangent = tangent;
914 }
915
916 for (i = 0; i <= precision; i++)
917 {
918 for (j = 0; j <= precision; j++)
919 {
920 if (j == precision)
921 {
922 vertex *v = &vertices[i * (precision + 1) + j];
923 v->tangent = vertices[i * (precision + 1)].tangent;
924 }
925 }
926 }
927}
928
929void
930_mesh_setup_gun_planet(Scene_Data *data) 749_mesh_setup_gun_planet(Scene_Data *data)
931{ 750{
932 _world_init(20);
933
934 /* Setup material and texture for world. */ 751 /* Setup material and texture for world. */
935 752
936 SETUP_MESH(world, world, 0.5, 0.5, 1.0); 753 ADD_MESH(world, world, 0.5, 0.5, 1.0);
937 SETUP_MESH_NODE(world);
938
939 eo_do(data->mesh_world, 754 eo_do(data->mesh_world,
940 evas_canvas3d_mesh_vertex_count_set(vertex_count), 755 evas_canvas3d_mesh_from_primitive_set(0, data->sphere_primitive));
941 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_POSITION, 756 SETUP_DEFAULT_MESH(world, world, DIFFUSE);
942 sizeof(vertex), &vertices[0].position), 757 SETUP_MESH_NODE(world);
943 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_NORMAL,
944 sizeof(vertex), &vertices[0].normal),
945 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_TANGENT,
946 sizeof(vertex), &vertices[0].tangent),
947 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_COLOR,
948 sizeof(vertex), &vertices[0].color);
949 evas_canvas3d_mesh_frame_vertex_data_set(0, EVAS_CANVAS3D_VERTEX_TEXCOORD,
950 sizeof(vertex), &vertices[0].texcoord),
951 evas_canvas3d_mesh_index_data_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, index_count, &indices[0]));
952 758
953 eo_do(data->mesh_node_world, 759 eo_do(data->mesh_node_world,
954 evas_canvas3d_node_scale_set(150, 150, 150), 760 evas_canvas3d_node_scale_set(350, 350, 350),
955 evas_canvas3d_node_position_set(0.0, 0.0, 0.0)); 761 evas_canvas3d_node_position_set(0.0, 0.0, 0.0));
956 762
957 /* Setup material and texture for player */ 763 /* Setup material and texture for player */
958 764
959 SETUP_MESH(soldier, soldier, 0.2, 0.6, 1.0) 765 ADD_MESH(soldier, soldier, 0.2, 0.6, 1.0)
960 MATERIAL_TEXTURE_SET(soldier, soldier, soldier_path, soldier_tex_path) 766 MATERIAL_TEXTURE_SET(soldier, soldier, soldier_path, soldier_tex_path)
961 767
962 SETUP_MESH_NODE(soldier) 768 SETUP_MESH_NODE(soldier)
@@ -970,12 +776,12 @@ _mesh_setup_gun_planet(Scene_Data *data)
970 0, 1, 0), 776 0, 1, 0),
971 evas_canvas3d_node_mesh_frame_set(data->mesh_soldier, 0)); 777 evas_canvas3d_node_mesh_frame_set(data->mesh_soldier, 0));
972 778
973 SETUP_MESH(soldier, soldier_jump, 1.0, 1.0, 1.0) 779 ADD_MESH(soldier, soldier_jump, 1.0, 1.0, 1.0)
974 MATERIAL_TEXTURE_SET(soldier, soldier_jump, soldier_jump_path, soldier_tex_path) 780 MATERIAL_TEXTURE_SET(soldier, soldier_jump, soldier_jump_path, soldier_tex_path)
975 781
976 /* Setup material and texture for tommy gun */ 782 /* Setup material and texture for tommy gun */
977 783
978 SETUP_MESH(tommy, tommy, 0.0, 0.3, 1.0) 784 ADD_MESH(tommy, tommy, 0.0, 0.3, 1.0)
979 SETUP_MESH_NODE(tommy) 785 SETUP_MESH_NODE(tommy)
980 eo_do(data->mesh_tommy, 786 eo_do(data->mesh_tommy,
981 efl_file_set(gun_path, NULL), 787 efl_file_set(gun_path, NULL),
@@ -991,7 +797,7 @@ _mesh_setup_gun_planet(Scene_Data *data)
991 797
992 /* Setup material and texture for gazebo */ 798 /* Setup material and texture for gazebo */
993 799
994 SETUP_MESH(gazebo, gazebo, 0.01, 1.0, 1.0) 800 ADD_MESH(gazebo, gazebo, 0.01, 1.0, 1.0)
995 SETUP_MESH_NODE(gazebo) 801 SETUP_MESH_NODE(gazebo)
996 MATERIAL_TEXTURE_SET(gazebo, gazebo, gazebo_bot_path, gazebo_b_path) 802 MATERIAL_TEXTURE_SET(gazebo, gazebo, gazebo_bot_path, gazebo_b_path)
997 NORMAL_SET(gazebo, gazebo, gazebo_b_n_path) 803 NORMAL_SET(gazebo, gazebo, gazebo_b_n_path)
@@ -1003,7 +809,7 @@ _mesh_setup_gun_planet(Scene_Data *data)
1003 809
1004 /* Setup material and texture for carpet */ 810 /* Setup material and texture for carpet */
1005 811
1006 SETUP_MESH(carpet, carpet, 0.01, 1.0, 1.0) 812 ADD_MESH(carpet, carpet, 0.01, 1.0, 1.0)
1007 SETUP_MESH_NODE(carpet) 813 SETUP_MESH_NODE(carpet)
1008 MATERIAL_TEXTURE_SET(carpet, carpet, gazebo_top_path, gazebo_t_path) 814 MATERIAL_TEXTURE_SET(carpet, carpet, gazebo_top_path, gazebo_t_path)
1009 NORMAL_SET(carpet, carpet, gazebo_t_n_path) 815 NORMAL_SET(carpet, carpet, gazebo_t_n_path)
@@ -1011,6 +817,7 @@ _mesh_setup_gun_planet(Scene_Data *data)
1011 if (data->blending) 817 if (data->blending)
1012 { 818 {
1013 eo_do(data->texture_diffuse_carpet, 819 eo_do(data->texture_diffuse_carpet,
820 evas_canvas3d_texture_atlas_enable_set(EINA_FALSE),
1014 evas_canvas3d_texture_file_set(gazebo_t_trans_path, NULL)); 821 evas_canvas3d_texture_file_set(gazebo_t_trans_path, NULL));
1015 eo_do(data->mesh_carpet, 822 eo_do(data->mesh_carpet,
1016 evas_canvas3d_mesh_blending_enable_set(EINA_TRUE), 823 evas_canvas3d_mesh_blending_enable_set(EINA_TRUE),
@@ -1022,7 +829,7 @@ _mesh_setup_gun_planet(Scene_Data *data)
1022 evas_canvas3d_node_position_set(-20, -10, -35)); 829 evas_canvas3d_node_position_set(-20, -10, -35));
1023 /* Setup material and texture for eagle. */ 830 /* Setup material and texture for eagle. */
1024 831
1025 SETUP_MESH(eagle, eagle, 0.01, 1.0, 1.0) 832 ADD_MESH(eagle, eagle, 0.01, 1.0, 1.0)
1026 SETUP_MESH_NODE(eagle) 833 SETUP_MESH_NODE(eagle)
1027 MATERIAL_TEXTURE_SET(eagle, eagle, eagle_path, eagle_tex_path) 834 MATERIAL_TEXTURE_SET(eagle, eagle, eagle_path, eagle_tex_path)
1028 835
@@ -1031,7 +838,9 @@ _mesh_setup_gun_planet(Scene_Data *data)
1031 evas_canvas3d_node_position_set(-20, 20, 0)); 838 evas_canvas3d_node_position_set(-20, 20, 0));
1032 /* Set material for bounding box */ 839 /* Set material for bounding box */
1033 840
1034 SETUP_MESH(cube, cube, 0.01, 1.0, 1.0) 841 ADD_MESH(cube, cube, 0.01, 1.0, 1.0)
842 eo_do(data->mesh_cube, evas_canvas3d_mesh_frame_add(0));
843 SETUP_DEFAULT_MESH(cube, cube, DIFFUSE);
1035 SETUP_MESH_NODE(cube) 844 SETUP_MESH_NODE(cube)
1036 845
1037 eo_do(data->mesh_cube, 846 eo_do(data->mesh_cube,
@@ -1042,15 +851,15 @@ _mesh_setup_gun_planet(Scene_Data *data)
1042 851
1043 /* Setup mesh for column carpet */ 852 /* Setup mesh for column carpet */
1044 853
1045 SETUP_MESH(column_c, column_c, 0.2, 0.8, 1.0) 854 ADD_MESH(column_c, column_c, 0.2, 0.8, 1.0)
1046 SETUP_MESH_NODE(column_c) 855 SETUP_MESH_NODE(column_c)
1047 TEXTCOORDS_SET(cube, 5.0, 0.1, 5.0, 0.1, 5.0, 0.4) 856 TEXTCOORDS_SET(cube, 5.0, 0.4, 5.0, 0.1, 5.0, 0.1)
1048 CUBE_TEXTURE_SET(column_c, column_c, 24, cube_vertices, cube_textcoords, 36, cube_indices, red_brick_path) 857 CUBE_TEXTURE_SET(column_c, column_c, cube_textcoords, red_brick_path)
1049 NORMAL_SET(column_c, column_c, red_brick_n_path) 858 NORMAL_SET(column_c, column_c, red_brick_n_path)
1050 859
1051 eo_do(data->mesh_node_column_c, 860 eo_do(data->mesh_node_column_c,
1052 evas_canvas3d_node_orientation_angle_axis_set(90, 0, 1.0, 0.0), 861 evas_canvas3d_node_orientation_angle_axis_set(90, 0, 1.0, 0.0),
1053 evas_canvas3d_node_scale_set(48.0, 0.8 , 2.4 ), 862 evas_canvas3d_node_scale_set(96.0, 1.6 , 4.8 ),
1054 evas_canvas3d_node_position_set(10 , 9.0, -12)); 863 evas_canvas3d_node_position_set(10 , 9.0, -12));
1055 864
1056 /* Setup mesh for bounding sphere */ 865 /* Setup mesh for bounding sphere */
@@ -1083,32 +892,32 @@ _mesh_setup_wall(Scene_Data *data, int index)
1083{ 892{
1084 /* Setup material and texture for wall. */ 893 /* Setup material and texture for wall. */
1085 894
1086 SETUP_MESH(wall, wall[index], 0.2, 0.8, 1.0) 895 ADD_MESH(wall, wall[index], 0.2, 0.8, 1.0)
1087 SETUP_MESH_NODE(wall[index]) 896 SETUP_MESH_NODE(wall[index])
1088 TEXTCOORDS_SET(wall, 12.0, 1.0, 0.2, 1.0, 12.0, 0.2) 897 TEXTCOORDS_SET(wall, 12.0, 0.2, 0.2, 1.0, 12.0, 1.0)
1089 CUBE_TEXTURE_SET(wall, wall[index], 24, cube_vertices, wall_textcoords, 36, cube_indices, red_brick_path) 898 CUBE_TEXTURE_SET(wall, wall[index], wall_textcoords, red_brick_path)
1090 NORMAL_SET(wall, wall[index], red_brick_n_path) 899 NORMAL_SET(wall, wall[index], red_brick_n_path)
1091 900
1092 /* placing of wall carpet on the floor grid */ 901 /* placing of wall carpet on the floor grid */
1093 if (index == 0) 902 if (index == 0)
1094 eo_do(data->mesh_node_wall[index], 903 eo_do(data->mesh_node_wall[index],
1095 evas_canvas3d_node_scale_set(6.7 * 9.75, 10.0 , 1.0 ), 904 evas_canvas3d_node_scale_set(6.7 * 19.5, 20.0, 2.0),
1096 evas_canvas3d_node_position_set(-39.7 + 18.6 * 3, 0.0, -60.3)); 905 evas_canvas3d_node_position_set(-39.7 + 18.6 * 3, 0.0, -60.3));
1097 else if (index == 1) 906 else if (index == 1)
1098 { 907 {
1099 eo_do(data->mesh_node_wall[index], 908 eo_do(data->mesh_node_wall[index],
1100 evas_canvas3d_node_scale_set(5 * 9.75, 10.0 , 1.0 ), 909 evas_canvas3d_node_scale_set(5 * 19.5, 20.0, 2.0),
1101 evas_canvas3d_node_position_set(81.2, 0.0, -51.5 + 19.5 * 2), 910 evas_canvas3d_node_position_set(81.2, 0.0, -51.5 + 19.5 * 2),
1102 evas_canvas3d_node_orientation_angle_axis_set(90, 0, 1.0, 0.0)); 911 evas_canvas3d_node_orientation_angle_axis_set(90, 0, 1.0, 0.0));
1103 } 912 }
1104 else if (index == 2) 913 else if (index == 2)
1105 eo_do(data->mesh_node_wall[index], 914 eo_do(data->mesh_node_wall[index],
1106 evas_canvas3d_node_scale_set(6.7 * 9.75, 10.0 , 1.0 ), 915 evas_canvas3d_node_scale_set(6.7 * 19.5, 20.0, 2.0),
1107 evas_canvas3d_node_position_set(-39.7 + 18.6*3, 0.0, 35.3)); 916 evas_canvas3d_node_position_set(-39.7 + 18.6*3, 0.0, 35.3));
1108 else if (index == 3) 917 else if (index == 3)
1109 { 918 {
1110 eo_do(data->mesh_node_wall[index], 919 eo_do(data->mesh_node_wall[index],
1111 evas_canvas3d_node_scale_set(5* 9.75, 10.0 , 1.0 ), 920 evas_canvas3d_node_scale_set(5* 19.5, 20.0, 2.0),
1112 evas_canvas3d_node_position_set(-48.4, 0.0, -51.5 + 19.5 * 2), 921 evas_canvas3d_node_position_set(-48.4, 0.0, -51.5 + 19.5 * 2),
1113 evas_canvas3d_node_orientation_angle_axis_set(90, 0, 1.0, 0.0)); 922 evas_canvas3d_node_orientation_angle_axis_set(90, 0, 1.0, 0.0));
1114 } 923 }
@@ -1139,7 +948,6 @@ _mesh_setup_column(Scene_Data *data, int index)
1139 evas_canvas3d_mesh_from_primitive_set(0, data->cylinder_primitive), 948 evas_canvas3d_mesh_from_primitive_set(0, data->cylinder_primitive),
1140 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE), 949 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE),
1141 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES), 950 evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES),
1142 evas_canvas3d_mesh_frame_material_set(0, data->material_column),
1143 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG), 951 evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_PHONG),
1144 evas_canvas3d_mesh_frame_material_set(0, data->material_column)); 952 evas_canvas3d_mesh_frame_material_set(0, data->material_column));
1145 953
@@ -1147,6 +955,7 @@ _mesh_setup_column(Scene_Data *data, int index)
1147 955
1148 eo_do(data->texture_diffuse_column, 956 eo_do(data->texture_diffuse_column,
1149 evas_canvas3d_texture_file_set(red_brick_path, NULL), 957 evas_canvas3d_texture_file_set(red_brick_path, NULL),
958 evas_canvas3d_texture_atlas_enable_set(EINA_FALSE),
1150 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, 959 evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST,
1151 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST), 960 EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST),
1152 evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT)); 961 evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT));
@@ -1170,16 +979,16 @@ _mesh_setup_grass(Scene_Data *data)
1170{ 979{
1171 /* Setup material and texture for grass. */ 980 /* Setup material and texture for grass. */
1172 981
1173 SETUP_MESH(grass, grass, 0.4, 0.8, 1.0) 982 ADD_MESH(grass, grass, 0.4, 0.8, 1.0)
1174 SETUP_MESH_NODE(grass) 983 SETUP_MESH_NODE(grass)
1175 CUBE_TEXTURE_SET(grass, grass, 4, grass_vertices, &grass_vertices[10], 984 TEXTCOORDS_SET(grass, 6.0, 3.0, 1.0, 1.0, 1.0, 1.0)
1176 6, grass_indices, gray_brick_path) 985 CUBE_TEXTURE_SET(grass, grass, grass_textcoords, gray_brick_path)
1177 NORMAL_SET(grass, grass, gray_brick_n_path) 986 NORMAL_SET(grass, grass, gray_brick_n_path)
1178 987
1179 /* placing of grass carpet on the floor grid */ 988 /* placing of grass carpet on the floor grid */
1180 eo_do(data->mesh_node_grass, 989 eo_do(data->mesh_node_grass,
1181 evas_canvas3d_node_scale_set(10.0, 1.0, 12.0), 990 evas_canvas3d_node_scale_set(130.0, 1.0, 96.0),
1182 evas_canvas3d_node_position_set(16, -10.0, -12)); 991 evas_canvas3d_node_position_set(16.5, -10.0, -12));
1183} 992}
1184 993
1185void 994void
@@ -1189,25 +998,24 @@ _mesh_setup(Scene_Data *data, float h EINA_UNUSED, float w EINA_UNUSED, float d
1189 998
1190 if (!index) 999 if (!index)
1191 { 1000 {
1192 SETUP_MESH(level[0], level[index], 0.4, 0.8, 1.0) 1001 ADD_MESH(level[0], level[index], 0.4, 0.8, 1.0)
1193 SETUP_MESH_NODE(level[index]) 1002 SETUP_MESH_NODE(level[index])
1194 CUBE_TEXTURE_SET(level[0], level[index], 24, cube_vertices, isource, 36, cube_indices, red_brick_path) 1003 CUBE_TEXTURE_SET(level[0], level[index], isource, red_brick_path)
1195 NORMAL_SET(level[0], level[index], red_brick_n_path) 1004 NORMAL_SET(level[0], level[index], red_brick_n_path)
1196 1005
1197 eo_do(data->mesh_node_level[index], 1006 eo_do(data->mesh_node_level[index],
1198 evas_canvas3d_node_scale_set(9.75, 10.0, 1.0), 1007 evas_canvas3d_node_scale_set(19.5, 20.0, 2.0),
1199 evas_canvas3d_node_position_set(50, 0, -15)); 1008 evas_canvas3d_node_position_set(50, 0, -15));
1200 } 1009 }
1201 else 1010 else
1202 { 1011 {
1203 SETUP_MESH(level[1], level[index], 0.4, 0.8, 1.0) 1012 ADD_MESH(level[1], level[index], 0.4, 0.8, 1.0)
1204 SETUP_MESH_NODE(level[index]) 1013 SETUP_MESH_NODE(level[index])
1205 CUBE_TEXTURE_SET(level[1], level[index], 24, cube_vertices, 1014 CUBE_TEXTURE_SET(level[1], level[index], isource, gray_brick_path)
1206 isource, 36, cube_indices, gray_brick_path)
1207 NORMAL_SET(level[1], level[index], gray_brick_n_path) 1015 NORMAL_SET(level[1], level[index], gray_brick_n_path)
1208 1016
1209 eo_do(data->mesh_node_level[index], 1017 eo_do(data->mesh_node_level[index],
1210 evas_canvas3d_node_scale_set(1.0, 1.0, 4.0), 1018 evas_canvas3d_node_scale_set(2.0, 2.0, 8.0),
1211 evas_canvas3d_node_position_set(40 + (2 * index), -10 + (2 * index), -10)); 1019 evas_canvas3d_node_position_set(40 + (2 * index), -10 + (2 * index), -10));
1212 } 1020 }
1213} 1021}
@@ -1217,7 +1025,7 @@ _mesh_setup_warrior(Scene_Data *data)
1217{ 1025{
1218 /* Setup mesh for warrior */ 1026 /* Setup mesh for warrior */
1219 1027
1220 SETUP_MESH(warrior, warrior, 0.4, 0.6, 1.0) 1028 ADD_MESH(warrior, warrior, 0.4, 0.6, 1.0)
1221 SETUP_MESH_NODE(warrior) 1029 SETUP_MESH_NODE(warrior)
1222 MATERIAL_TEXTURE_SET(warrior, warrior, warrior_path, warrior_tex_path) 1030 MATERIAL_TEXTURE_SET(warrior, warrior, warrior_path, warrior_tex_path)
1223 1031
@@ -1229,7 +1037,7 @@ _mesh_setup_warrior(Scene_Data *data)
1229void 1037void
1230_mesh_setup_snake(Scene_Data *data) 1038_mesh_setup_snake(Scene_Data *data)
1231{ 1039{
1232 SETUP_MESH(snake, snake, 0.01, 1.0, 1.0) 1040 ADD_MESH(snake, snake, 0.01, 1.0, 1.0)
1233 SETUP_MESH_NODE(snake) 1041 SETUP_MESH_NODE(snake)
1234 MATERIAL_TEXTURE_SET(snake, snake, snake_path, snake_tex_path) 1042 MATERIAL_TEXTURE_SET(snake, snake, snake_path, snake_tex_path)
1235 NORMAL_SET(snake, snake, snake_tex_n_path) 1043 NORMAL_SET(snake, snake, snake_tex_n_path)
@@ -1242,11 +1050,12 @@ _mesh_setup_snake(Scene_Data *data)
1242void 1050void
1243_mesh_setup_rocket(Scene_Data *data, int index) 1051_mesh_setup_rocket(Scene_Data *data, int index)
1244{ 1052{
1245 SETUP_MESH(rocket[index], rocket[index], 0.8, 0.2, 0.5); 1053 ADD_MESH(rocket[index], rocket[index], 0.8, 0.2, 0.5);
1054 eo_do(data->mesh_rocket[index],
1055 evas_canvas3d_mesh_from_primitive_set(0, data->sphere_primitive));
1056 SETUP_DEFAULT_MESH(rocket[index], rocket[index], DIFFUSE);
1246 SETUP_MESH_NODE(rocket[index]); 1057 SETUP_MESH_NODE(rocket[index]);
1247 1058
1248 SPHERE_SET(rocket[index])
1249
1250 eo_do(data->mesh_node_rocket[index], 1059 eo_do(data->mesh_node_rocket[index],
1251 evas_canvas3d_node_scale_set(1, 1, 1), 1060 evas_canvas3d_node_scale_set(1, 1, 1),
1252 evas_canvas3d_node_position_set(ROCKET_POS_X, ROCKET_POS_Y, ROCKET_POS_Z)); 1061 evas_canvas3d_node_position_set(ROCKET_POS_X, ROCKET_POS_Y, ROCKET_POS_Z));
@@ -1256,6 +1065,20 @@ void
1256_scene_setup(Scene_Data *data) 1065_scene_setup(Scene_Data *data)
1257{ 1066{
1258 int i = 0; 1067 int i = 0;
1068
1069 for (i = 0; i < 4; i++)
1070 motion_vec[i] = 0;
1071
1072 data->cube_primitive = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
1073 eo_do(data->cube_primitive,
1074 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE),
1075 evas_canvas3d_primitive_precision_set(10));
1076
1077 data->sphere_primitive = eo_add(EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
1078 eo_do(data->sphere_primitive,
1079 evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE),
1080 evas_canvas3d_primitive_precision_set(50));
1081
1259 global_scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas); 1082 global_scene = eo_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
1260 1083
1261 eo_do(global_scene, 1084 eo_do(global_scene,
@@ -1288,10 +1111,10 @@ _scene_setup(Scene_Data *data)
1288 for ( i = 0; i < 4; i++) 1111 for ( i = 0; i < 4; i++)
1289 _mesh_setup_wall(data, i); 1112 _mesh_setup_wall(data, i);
1290 1113
1291 TEXTCOORDS_SET(bricks1, 1.0, 1.0, 0.2, 1.0, 1.0, 0.2) 1114 TEXTCOORDS_SET(bricks1, 1.0, 0.2, 0.2, 1.0, 1.0, 1.0)
1292 _mesh_setup(data, 9.75, 10, 1, bricks1_textcoords, 0); 1115 _mesh_setup(data, 9.75, 10, 1, bricks1_textcoords, 0);
1293 1116
1294 TEXTCOORDS_SET(bricks2, 1.0, 0.5, 3.0, 0.5, 2.0, 1.5) 1117 TEXTCOORDS_SET(bricks2, 1.0, 1.5, 3.0, 0.5, 2.0, 0.5)
1295 for (i = 1; i < 10; i++) 1118 for (i = 1; i < 10; i++)
1296 _mesh_setup(data, 1, 1, 4, bricks2_textcoords, i); 1119 _mesh_setup(data, 1, 1, 4, bricks2_textcoords, i);
1297 1120