diff options
author | David Walter Seikel | 2014-05-03 03:40:09 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-03 03:40:09 +1000 |
commit | 044f64e796ceffff605c5f6cc71317ee096f3a52 (patch) | |
tree | 2042acfca2b98b40339845768823058d9dd3f21e /src/extantz | |
parent | Major extantz clean up part 2. Including new Evas_3d style camera. (diff) | |
download | SledjHamr-044f64e796ceffff605c5f6cc71317ee096f3a52.zip SledjHamr-044f64e796ceffff605c5f6cc71317ee096f3a52.tar.gz SledjHamr-044f64e796ceffff605c5f6cc71317ee096f3a52.tar.bz2 SledjHamr-044f64e796ceffff605c5f6cc71317ee096f3a52.tar.xz |
Rotate camera.
Diffstat (limited to 'src/extantz')
-rw-r--r-- | src/extantz/Evas_3D_demo.c | 24 | ||||
-rw-r--r-- | src/extantz/camera.c | 24 |
2 files changed, 31 insertions, 17 deletions
diff --git a/src/extantz/Evas_3D_demo.c b/src/extantz/Evas_3D_demo.c index df05838..b01dd47 100644 --- a/src/extantz/Evas_3D_demo.c +++ b/src/extantz/Evas_3D_demo.c | |||
@@ -269,13 +269,15 @@ _sphere_init(int precision) | |||
269 | Eina_Bool _animate_scene(void *data) | 269 | Eina_Bool _animate_scene(void *data) |
270 | { | 270 | { |
271 | globals *ourGlobals = data; | 271 | globals *ourGlobals = data; |
272 | |||
273 | static float angle = 0.0f; | 272 | static float angle = 0.0f; |
274 | static float earthAngle = 0.0f; | 273 | static float earthAngle = 0.0f; |
275 | static int frame = 0; | 274 | static int frame = 0; |
276 | static int inc = 1; | 275 | static int inc = 1; |
277 | static int sonicFrame = 0; | 276 | static int sonicFrame = 0; |
278 | Evas_Real x, y, z; | 277 | Evas_Real x, y, z, w; |
278 | EPhysics_Quaternion *quat = ephysics_quaternion_new(); | ||
279 | EPhysics_Quaternion *quat1 = ephysics_quaternion_new(); | ||
280 | EPhysics_Quaternion *result = ephysics_quaternion_new(); | ||
279 | 281 | ||
280 | Scene_Data *scene = ourGlobals->scene; | 282 | Scene_Data *scene = ourGlobals->scene; |
281 | 283 | ||
@@ -307,12 +309,24 @@ Eina_Bool _animate_scene(void *data) | |||
307 | ); | 309 | ); |
308 | 310 | ||
309 | // Camera movement. | 311 | // Camera movement. |
312 | ephysics_quaternion_euler_set(quat1, ourGlobals->gld.move->r, ourGlobals->gld.move->s, ourGlobals->gld.move->t); | ||
313 | eo_do(scene->camera_node, evas_3d_node_orientation_get(EVAS_3D_SPACE_PARENT, &x, &y, &z, &w)); | ||
314 | ephysics_quaternion_set(quat, x, y, z, w); | ||
315 | ephysics_quaternion_multiply(quat, quat1, result); | ||
316 | ephysics_quaternion_normalize(result); | ||
317 | ephysics_quaternion_get(result, &x, &y, &z, &w); | ||
318 | eo_do(scene->camera_node, evas_3d_node_orientation_set(x, y, z, w)); | ||
319 | |||
310 | eo_do(scene->camera_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z)); | 320 | eo_do(scene->camera_node, evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x, &y, &z)); |
311 | x += ourGlobals->gld.move->x; | 321 | x -= ourGlobals->gld.move->x; |
312 | y += ourGlobals->gld.move->y; | 322 | y -= ourGlobals->gld.move->y; |
313 | z += ourGlobals->gld.move->z; | 323 | z -= ourGlobals->gld.move->z; |
314 | eo_do(scene->camera_node, evas_3d_node_position_set(x, y, z)); | 324 | eo_do(scene->camera_node, evas_3d_node_position_set(x, y, z)); |
315 | 325 | ||
326 | free(result); | ||
327 | free(quat1); | ||
328 | free(quat); | ||
329 | |||
316 | return EINA_TRUE; | 330 | return EINA_TRUE; |
317 | } | 331 | } |
318 | 332 | ||
diff --git a/src/extantz/camera.c b/src/extantz/camera.c index 331a85a..41ce25c 100644 --- a/src/extantz/camera.c +++ b/src/extantz/camera.c | |||
@@ -16,9 +16,9 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void | |||
16 | { | 16 | { |
17 | } | 17 | } |
18 | else if (0 == strcmp(ev->key, "Left")) | 18 | else if (0 == strcmp(ev->key, "Left")) |
19 | gld->move->y = 2.0; | 19 | gld->move->r = 2.0; |
20 | else if (0 == strcmp(ev->key, "Right")) | 20 | else if (0 == strcmp(ev->key, "Right")) |
21 | gld->move->y = -2.0; | 21 | gld->move->r = -2.0; |
22 | else if (0 == strcmp(ev->key, "Up")) | 22 | else if (0 == strcmp(ev->key, "Up")) |
23 | gld->move->x = 2.0; | 23 | gld->move->x = 2.0; |
24 | else if (0 == strcmp(ev->key, "Down")) | 24 | else if (0 == strcmp(ev->key, "Down")) |
@@ -27,10 +27,10 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void | |||
27 | gld->move->z = -2.0; | 27 | gld->move->z = -2.0; |
28 | else if (0 == strcmp(ev->key, "Next")) | 28 | else if (0 == strcmp(ev->key, "Next")) |
29 | gld->move->z = 2.0; | 29 | gld->move->z = 2.0; |
30 | // else if (0 == strcmp(ev->key, "Home")) | 30 | else if (0 == strcmp(ev->key, "Home")) |
31 | // ; | 31 | gld->move->y = 2.0; |
32 | // else if (0 == strcmp(ev->key, "End")) | 32 | else if (0 == strcmp(ev->key, "End")) |
33 | // ; | 33 | gld->move->y = -2.0; |
34 | else if (0 == strcmp(ev->key, "space")) | 34 | else if (0 == strcmp(ev->key, "space")) |
35 | gld->move->jump = 1.0; | 35 | gld->move->jump = 1.0; |
36 | else | 36 | else |
@@ -119,9 +119,9 @@ static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void * | |||
119 | { | 119 | { |
120 | } | 120 | } |
121 | else if (0 == strcmp(ev->key, "Left")) | 121 | else if (0 == strcmp(ev->key, "Left")) |
122 | gld->move->y = 0.0; | 122 | gld->move->r = 0.0; |
123 | else if (0 == strcmp(ev->key, "Right")) | 123 | else if (0 == strcmp(ev->key, "Right")) |
124 | gld->move->y = 0.0; | 124 | gld->move->r = 0.0; |
125 | else if (0 == strcmp(ev->key, "Up")) | 125 | else if (0 == strcmp(ev->key, "Up")) |
126 | gld->move->x = 0.0; | 126 | gld->move->x = 0.0; |
127 | else if (0 == strcmp(ev->key, "Down")) | 127 | else if (0 == strcmp(ev->key, "Down")) |
@@ -130,10 +130,10 @@ static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void * | |||
130 | gld->move->z = 0.0; | 130 | gld->move->z = 0.0; |
131 | else if (0 == strcmp(ev->key, "Next")) | 131 | else if (0 == strcmp(ev->key, "Next")) |
132 | gld->move->z = 0.0; | 132 | gld->move->z = 0.0; |
133 | // else if (0 == strcmp(ev->key, "Home")) | 133 | else if (0 == strcmp(ev->key, "Home")) |
134 | // ; | 134 | gld->move->y = 0.0; |
135 | // else if (0 == strcmp(ev->key, "End")) | 135 | else if (0 == strcmp(ev->key, "End")) |
136 | // ; | 136 | gld->move->y = 0.0; |
137 | else if (0 == strcmp(ev->key, "space")) | 137 | else if (0 == strcmp(ev->key, "space")) |
138 | gld->move->jump = 0.0; | 138 | gld->move->jump = 0.0; |
139 | else | 139 | else |