aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-06 00:37:13 +1000
committerDavid Walter Seikel2014-05-06 00:37:13 +1000
commit95d791b9dbdcb6bb27a9ee2ce5aa17cdf9a933bf (patch)
tree60c82569897b5d39234169fd8fd81c88d8459afa /src/extantz
parentShuffle stuff around into the new scenri.c and camera stuff. (diff)
downloadSledjHamr-95d791b9dbdcb6bb27a9ee2ce5aa17cdf9a933bf.zip
SledjHamr-95d791b9dbdcb6bb27a9ee2ce5aa17cdf9a933bf.tar.gz
SledjHamr-95d791b9dbdcb6bb27a9ee2ce5aa17cdf9a933bf.tar.bz2
SledjHamr-95d791b9dbdcb6bb27a9ee2ce5aa17cdf9a933bf.tar.xz
Camera no longer needs ourGlobals.
Diffstat (limited to 'src/extantz')
-rw-r--r--src/extantz/camera.c77
-rw-r--r--src/extantz/extantz.c4
-rw-r--r--src/extantz/extantz.h6
-rw-r--r--src/extantz/scenri.c2
4 files changed, 43 insertions, 46 deletions
diff --git a/src/extantz/camera.c b/src/extantz/camera.c
index c4b4757..ad628b5 100644
--- a/src/extantz/camera.c
+++ b/src/extantz/camera.c
@@ -1,17 +1,15 @@
1#include "extantz.h" 1#include "extantz.h"
2 2
3 3
4Eina_Bool animateCamera(globals *ourGlobals) 4Eina_Bool animateCamera(Scene_Data *scene)
5{ 5{
6 Evas_Real x, y, z, w; 6 Evas_Real x, y, z, w;
7 EPhysics_Quaternion *quat = ephysics_quaternion_new(); 7 EPhysics_Quaternion *quat = ephysics_quaternion_new();
8 EPhysics_Quaternion *quat1 = ephysics_quaternion_new(); 8 EPhysics_Quaternion *quat1 = ephysics_quaternion_new();
9 EPhysics_Quaternion *result = ephysics_quaternion_new(); 9 EPhysics_Quaternion *result = ephysics_quaternion_new();
10 10
11 Scene_Data *scene = ourGlobals->scene;
12
13 // Camera movement. 11 // Camera movement.
14 ephysics_quaternion_euler_set(quat1, ourGlobals->gld.move->r, ourGlobals->gld.move->s, ourGlobals->gld.move->t); 12 ephysics_quaternion_euler_set(quat1, scene->move->r, scene->move->s, scene->move->t);
15 eo_do(scene->camera_node, evas_3d_node_orientation_get(EVAS_3D_SPACE_PARENT, &x, &y, &z, &w)); 13 eo_do(scene->camera_node, evas_3d_node_orientation_get(EVAS_3D_SPACE_PARENT, &x, &y, &z, &w));
16 ephysics_quaternion_set(quat, x, y, z, w); 14 ephysics_quaternion_set(quat, x, y, z, w);
17 ephysics_quaternion_multiply(quat, quat1, result); 15 ephysics_quaternion_multiply(quat, quat1, result);
@@ -20,9 +18,9 @@ Eina_Bool animateCamera(globals *ourGlobals)
20 eo_do(scene->camera_node, evas_3d_node_orientation_set(x, y, z, w)); 18 eo_do(scene->camera_node, evas_3d_node_orientation_set(x, y, z, w));
21 19
22 eo_do(scene->camera_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z)); 20 eo_do(scene->camera_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z));
23 x -= ourGlobals->gld.move->x; 21 x -= scene->move->x;
24 y -= ourGlobals->gld.move->y; 22 y -= scene->move->y;
25 z -= ourGlobals->gld.move->z; 23 z -= scene->move->z;
26 eo_do(scene->camera_node, evas_3d_node_position_set(x, y, z)); 24 eo_do(scene->camera_node, evas_3d_node_position_set(x, y, z));
27 25
28 free(result); 26 free(result);
@@ -34,11 +32,10 @@ Eina_Bool animateCamera(globals *ourGlobals)
34 32
35static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) 33static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
36{ 34{
37 globals *ourGlobals = data; 35 cameraMove *move = data;
38 GLData *gld = &ourGlobals->gld; 36 Evas_Event_Key_Down *ev = event_info;
39 Evas_Event_Key_Down *ev = event_info;
40 37
41 if (gld->move) 38 if (move)
42 { 39 {
43 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called. 40 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
44 41
@@ -47,15 +44,15 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void
47 if (0 == strcmp(ev->key, "Escape")) 44 if (0 == strcmp(ev->key, "Escape"))
48 { 45 {
49 } 46 }
50 else if (0 == strcmp(ev->key, "Left")) gld->move->r = 2.0; 47 else if (0 == strcmp(ev->key, "Left")) move->r = 2.0;
51 else if (0 == strcmp(ev->key, "Right")) gld->move->r = -2.0; 48 else if (0 == strcmp(ev->key, "Right")) move->r = -2.0;
52 else if (0 == strcmp(ev->key, "Up")) gld->move->x = 2.0; 49 else if (0 == strcmp(ev->key, "Up")) move->x = 2.0;
53 else if (0 == strcmp(ev->key, "Down")) gld->move->x = -2.0; 50 else if (0 == strcmp(ev->key, "Down")) move->x = -2.0;
54 else if (0 == strcmp(ev->key, "Prior")) gld->move->z = -2.0; 51 else if (0 == strcmp(ev->key, "Prior")) move->z = -2.0;
55 else if (0 == strcmp(ev->key, "Next")) gld->move->z = 2.0; 52 else if (0 == strcmp(ev->key, "Next")) move->z = 2.0;
56 else if (0 == strcmp(ev->key, "Home")) gld->move->y = 2.0; 53 else if (0 == strcmp(ev->key, "Home")) move->y = 2.0;
57 else if (0 == strcmp(ev->key, "End")) gld->move->y = -2.0; 54 else if (0 == strcmp(ev->key, "End")) move->y = -2.0;
58 else if (0 == strcmp(ev->key, "space")) gld->move->jump = 1.0; 55 else if (0 == strcmp(ev->key, "space")) move->jump = 1.0;
59 else printf("Unexpected down keystroke - %s\n", ev->key); 56 else printf("Unexpected down keystroke - %s\n", ev->key);
60 } 57 }
61 else printf("Camera input not ready\n"); 58 else printf("Camera input not ready\n");
@@ -127,11 +124,10 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void
127 124
128static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) 125static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
129{ 126{
130 globals *ourGlobals = data; 127 cameraMove *move = data;
131 GLData *gld = &ourGlobals->gld; 128 Evas_Event_Key_Up *ev = event_info;
132 Evas_Event_Key_Up *ev = event_info;
133 129
134 if (gld->move) 130 if (move)
135 { 131 {
136 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called. 132 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
137 133
@@ -140,15 +136,15 @@ static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *
140 if (0 == strcmp(ev->key, "Escape")) 136 if (0 == strcmp(ev->key, "Escape"))
141 { 137 {
142 } 138 }
143 else if (0 == strcmp(ev->key, "Left")) gld->move->r = 0.0; 139 else if (0 == strcmp(ev->key, "Left")) move->r = 0.0;
144 else if (0 == strcmp(ev->key, "Right")) gld->move->r = 0.0; 140 else if (0 == strcmp(ev->key, "Right")) move->r = 0.0;
145 else if (0 == strcmp(ev->key, "Up")) gld->move->x = 0.0; 141 else if (0 == strcmp(ev->key, "Up")) move->x = 0.0;
146 else if (0 == strcmp(ev->key, "Down")) gld->move->x = 0.0; 142 else if (0 == strcmp(ev->key, "Down")) move->x = 0.0;
147 else if (0 == strcmp(ev->key, "Prior")) gld->move->z = 0.0; 143 else if (0 == strcmp(ev->key, "Prior")) move->z = 0.0;
148 else if (0 == strcmp(ev->key, "Next")) gld->move->z = 0.0; 144 else if (0 == strcmp(ev->key, "Next")) move->z = 0.0;
149 else if (0 == strcmp(ev->key, "Home")) gld->move->y = 0.0; 145 else if (0 == strcmp(ev->key, "Home")) move->y = 0.0;
150 else if (0 == strcmp(ev->key, "End")) gld->move->y = 0.0; 146 else if (0 == strcmp(ev->key, "End")) move->y = 0.0;
151 else if (0 == strcmp(ev->key, "space")) gld->move->jump = 0.0; 147 else if (0 == strcmp(ev->key, "space")) move->jump = 0.0;
152 else printf("Unexpected up keystroke - %s\n", ev->key); 148 else printf("Unexpected up keystroke - %s\n", ev->key);
153 } 149 }
154 else printf("Camera input not ready\n"); 150 else printf("Camera input not ready\n");
@@ -182,16 +178,16 @@ static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Ev
182 return processed; 178 return processed;
183} 179}
184 180
185Evas_3D_Node *cameraAdd(globals *ourGlobals, Scene_Data *scene, Evas_Object *image) 181Evas_3D_Node *cameraAdd(Evas *evas, Scene_Data *scene, Evas_Object *image)
186{ 182{
187 Evas_3D_Node *result = NULL; 183 Evas_3D_Node *result = NULL;
188 Evas_3D_Camera *camera; 184 Evas_3D_Camera *camera;
189 185
190 camera = eo_add(EVAS_3D_CAMERA_CLASS, ourGlobals->evas, 186 camera = eo_add(EVAS_3D_CAMERA_CLASS, evas,
191 evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0) 187 evas_3d_camera_projection_perspective_set(60.0, 1.0, 1.0, 500.0)
192 ); 188 );
193 189
194 result = evas_3d_node_add(ourGlobals->evas, EVAS_3D_NODE_TYPE_CAMERA); 190 result = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_CAMERA);
195 eo_do(result, 191 eo_do(result,
196 evas_3d_node_camera_set(camera), 192 evas_3d_node_camera_set(camera),
197 evas_3d_node_position_set(50.0, 0.0, 20.0), 193 evas_3d_node_position_set(50.0, 0.0, 20.0),
@@ -201,12 +197,11 @@ Evas_3D_Node *cameraAdd(globals *ourGlobals, Scene_Data *scene, Evas_Object *ima
201 eo_do(scene->root_node, evas_3d_node_member_add(result)); 197 eo_do(scene->root_node, evas_3d_node_member_add(result));
202 eo_do(scene->scene, evas_3d_scene_camera_node_set(result)); 198 eo_do(scene->scene, evas_3d_scene_camera_node_set(result));
203 199
200 scene->move = calloc(1, sizeof(cameraMove));
204 // In this code, we are making our own camera, so grab it's input when we are focused. 201 // In this code, we are making our own camera, so grab it's input when we are focused.
205 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, ourGlobals); 202 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, scene->move);
206 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, ourGlobals); 203 evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, scene->move);
207 elm_object_event_callback_add(image, _cb_event_GL, ourGlobals); 204 elm_object_event_callback_add(image, _cb_event_GL, NULL);
208
209 ourGlobals->gld.move = calloc(1, sizeof(cameraMove));
210 205
211 return result; 206 return result;
212} 207}
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 11f1d4e..b7de3a7 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -170,7 +170,7 @@ static void _draw_gl(Evas_Object *obj)
170#endif 170#endif
171 171
172 _animate_scene(ourGlobals); 172 _animate_scene(ourGlobals);
173 animateCamera(ourGlobals); 173 animateCamera(ourGlobals->scene);
174 174
175#if USE_IRR 175#if USE_IRR
176 drawIrr_end(ourGlobals); 176 drawIrr_end(ourGlobals);
@@ -487,6 +487,8 @@ EAPI_MAIN int elm_main(int argc, char **argv)
487 init_evas_gl(&ourGlobals); 487 init_evas_gl(&ourGlobals);
488 488
489 Evas_3D_Demo_add(&ourGlobals); 489 Evas_3D_Demo_add(&ourGlobals);
490 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move.
491 ourGlobals.gld.move = ourGlobals.scene->move;
490 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals); 492 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals);
491 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals); 493 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals);
492 494
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h
index c22a61d..1c12843 100644
--- a/src/extantz/extantz.h
+++ b/src/extantz/extantz.h
@@ -158,6 +158,7 @@ typedef struct _Scene_Data
158 Evas_3D_Material *material3; 158 Evas_3D_Material *material3;
159 Evas_3D_Texture *texture_diffuse; 159 Evas_3D_Texture *texture_diffuse;
160 160
161 cameraMove *move;
161} Scene_Data; 162} Scene_Data;
162 163
163// Elm GL view related data here. 164// Elm GL view related data here.
@@ -178,7 +179,6 @@ typedef struct _GLData
178 IVideoDriver *driver; 179 IVideoDriver *driver;
179 ISceneManager *smgr; 180 ISceneManager *smgr;
180 ICameraSceneNode *camera; 181 ICameraSceneNode *camera;
181
182 cameraMove *move; 182 cameraMove *move;
183 183
184#if DO_GEARS 184#if DO_GEARS
@@ -255,8 +255,8 @@ Eina_Bool _animate_scene(globals *ourGlobals);
255void Evas_3D_Demo_fini(globals *ourGlobals); 255void Evas_3D_Demo_fini(globals *ourGlobals);
256 256
257Scene_Data *scenriAdd(globals *ourGlobals); 257Scene_Data *scenriAdd(globals *ourGlobals);
258Evas_3D_Node *cameraAdd(globals *ourGlobals, Scene_Data *scene, Evas_Object *win); 258Evas_3D_Node *cameraAdd(Evas *evas, Scene_Data *scene, Evas_Object *win);
259Eina_Bool animateCamera(globals *ourGlobals); 259Eina_Bool animateCamera(Scene_Data *scene);
260 260
261winFang *chat_add(globals *ourGlobals); 261winFang *chat_add(globals *ourGlobals);
262winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save); 262winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save);
diff --git a/src/extantz/scenri.c b/src/extantz/scenri.c
index 0805108..0c71ba2 100644
--- a/src/extantz/scenri.c
+++ b/src/extantz/scenri.c
@@ -113,7 +113,7 @@ Scene_Data *scenriAdd(globals *ourGlobals)
113 elm_object_tooltip_text_set(obj, ""); 113 elm_object_tooltip_text_set(obj, "");
114 elm_object_tooltip_hide(obj); 114 elm_object_tooltip_hide(obj);
115 scene->image = obj; 115 scene->image = obj;
116 scene->camera_node = cameraAdd(ourGlobals, scene, obj); 116 scene->camera_node = cameraAdd(ourGlobals->evas, scene, obj);
117 117
118 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas, 118 scene->light = eo_add(EVAS_3D_LIGHT_CLASS, ourGlobals->evas,
119 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0), 119 evas_3d_light_ambient_set(1.0, 1.0, 1.0, 1.0),