From ecd63ff10aeef298fe4e939a9667d1ee73cd8c4d Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Mar 2016 20:07:06 +1000 Subject: Add an avatar, and hook the camera up to it. --- media/Test%20sim/Rough_Hir.omg | 2 +- src/extantz/camera.c | 37 +++++++++++++++++++------------------ src/extantz/scenri.c | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/media/Test%20sim/Rough_Hir.omg b/media/Test%20sim/Rough_Hir.omg index b6fa61e..2f7a130 100644 --- a/media/Test%20sim/Rough_Hir.omg +++ b/media/Test%20sim/Rough_Hir.omg @@ -2,7 +2,7 @@ Stuffs = { name = "Rough Hir", description = 'Initial avatar, from MakeHuman.', - fake = 4, + fake = 5, uuid = '12345678-1234-4321-abcd-0123456rough', owner = '12345678-1234-4321-abcd-0123456789ab', details = diff --git a/src/extantz/camera.c b/src/extantz/camera.c index bbf8b01..937d965 100644 --- a/src/extantz/camera.c +++ b/src/extantz/camera.c @@ -30,22 +30,22 @@ Eina_Bool animateCamera(Scene_Data *scene) Evas_Real x, y, z; Eo *n = scene->avatar_node; - euler_to_quaternion(&rotate, DEGREE_TO_RADIAN(scene->move->r), DEGREE_TO_RADIAN(scene->move->s), DEGREE_TO_RADIAN(scene->move->p)); - eina_quaternion_mul(&result, &orient, &rotate); - eina_quaternion_normalized(&result, &result); if (n) { evas_canvas3d_node_orientation_get(n, EVAS_CANVAS3D_SPACE_PARENT, &orient.x, &orient.y, &orient.z, &orient.w); + euler_to_quaternion(&rotate, DEGREE_TO_RADIAN(scene->move->r), DEGREE_TO_RADIAN(scene->move->s), DEGREE_TO_RADIAN(scene->move->p)); + eina_quaternion_mul(&result, &orient, &rotate); + eina_quaternion_normalized(&result, &result); evas_canvas3d_node_orientation_set(n, result.x, result.y, result.z, result.w); - eina_quaternion_set(&move, scene->move->x, scene->move->y, scene->move->z, 0); - eina_quaternion_mul(&rotate, &result, &move); - eina_quaternion_conjugate(&result, &result); - eina_quaternion_mul(&move, &rotate, &result); - x += move.x; - y += move.y; - z += move.z; + eina_quaternion_set(&move, -scene->move->x, scene->move->y, -scene->move->z, 0); evas_canvas3d_node_position_get(n, EVAS_CANVAS3D_SPACE_PARENT, &x, &y, &z); + eina_quaternion_mul(&rotate, &result, &move); + eina_quaternion_conjugate(&result, &result); + eina_quaternion_mul(&move, &rotate, &result); + x += move.x; + y += move.y; + z += move.z; evas_canvas3d_node_position_set(n, x, y, z); } @@ -66,14 +66,14 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void if (0 == strcmp(ev->key, "Escape")) { } - else if (0 == strcmp(ev->key, "Left")) move->s = 2.0; - else if (0 == strcmp(ev->key, "Right")) move->s = -2.0; - else if (0 == strcmp(ev->key, "Up")) move->z = -2.0; - else if (0 == strcmp(ev->key, "Down")) move->z = 2.0; - else if (0 == strcmp(ev->key, "Prior")) move->y = 2.0; // Pg Up for humans. - else if (0 == strcmp(ev->key, "Next")) move->y = -2.0; // Pg Dn for humans. - else if (0 == strcmp(ev->key, "Home")) move->x = -2.0; - else if (0 == strcmp(ev->key, "End")) move->x = 2.0; + else if (0 == strcmp(ev->key, "Left")) move->s = 4.0; + else if (0 == strcmp(ev->key, "Right")) move->s = -4.0; + else if (0 == strcmp(ev->key, "Up")) move->z = -0.1; + else if (0 == strcmp(ev->key, "Down")) move->z = 0.1; + else if (0 == strcmp(ev->key, "Prior")) move->y = 0.1; // Pg Up for humans. + else if (0 == strcmp(ev->key, "Next")) move->y = -0.1; // Pg Dn for humans. + else if (0 == strcmp(ev->key, "Home")) move->x = -0.1; + else if (0 == strcmp(ev->key, "End")) move->x = 0.1; else if (0 == strcmp(ev->key, "space")) move->jump = 1.0; else PW("Unexpected down keystroke - %s", ev->key); } @@ -142,6 +142,7 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame. * * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL. + * And now in Evas_3D, it's different again. */ static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) diff --git a/src/extantz/scenri.c b/src/extantz/scenri.c index 7662a96..4074b61 100644 --- a/src/extantz/scenri.c +++ b/src/extantz/scenri.c @@ -821,6 +821,21 @@ void stuffsSetup(ExtantzStuffs *stuffs, Scene_Data *scene, int fake) stuffs->animateStuffs = (aniStuffs) _animateSonic; // else if (4 == fake) // stuffs->animateStuffs = (aniStuffs) _animateSphere; + else if (5 == fake) + { + scene->avatar_node = stuffs->mesh_node; + + // Grab the camera for the avatar. + evas_canvas3d_node_member_del(evas_canvas3d_node_parent_get(scene->camera_node), scene->camera_node); + evas_canvas3d_node_member_add(scene->avatar_node, scene->camera_node); + + evas_canvas3d_node_position_inherit_set(scene->camera_node, TRUE); + evas_canvas3d_node_position_set(scene->camera_node, 0.0, 2.5, -1.7); + + evas_canvas3d_node_orientation_inherit_set(scene->camera_node, TRUE); + evas_canvas3d_node_orientation_set(scene->camera_node, 0.0, 0.0, 0.0, 1.0); + evas_canvas3d_node_look_at_set(scene->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 10.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0); + } } ExtantzStuffs *addStuffs(char *uuid, char *name, char *description, char *owner, -- cgit v1.1