aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-03-13 20:07:06 +1000
committerDavid Walter Seikel2016-03-13 20:07:06 +1000
commitecd63ff10aeef298fe4e939a9667d1ee73cd8c4d (patch)
tree316168f742e09fdb98502ea2981342d920f68c16
parentResizing cleanup. (diff)
downloadSledjHamr-ecd63ff10aeef298fe4e939a9667d1ee73cd8c4d.zip
SledjHamr-ecd63ff10aeef298fe4e939a9667d1ee73cd8c4d.tar.gz
SledjHamr-ecd63ff10aeef298fe4e939a9667d1ee73cd8c4d.tar.bz2
SledjHamr-ecd63ff10aeef298fe4e939a9667d1ee73cd8c4d.tar.xz
Add an avatar, and hook the camera up to it.
-rw-r--r--media/Test%20sim/Rough_Hir.omg2
-rw-r--r--src/extantz/camera.c37
-rw-r--r--src/extantz/scenri.c15
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 =
2{ 2{
3 name = "Rough Hir", 3 name = "Rough Hir",
4 description = 'Initial avatar, from MakeHuman.', 4 description = 'Initial avatar, from MakeHuman.',
5 fake = 4, 5 fake = 5,
6 uuid = '12345678-1234-4321-abcd-0123456rough', 6 uuid = '12345678-1234-4321-abcd-0123456rough',
7 owner = '12345678-1234-4321-abcd-0123456789ab', 7 owner = '12345678-1234-4321-abcd-0123456789ab',
8 details = 8 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)
30 Evas_Real x, y, z; 30 Evas_Real x, y, z;
31 Eo *n = scene->avatar_node; 31 Eo *n = scene->avatar_node;
32 32
33 euler_to_quaternion(&rotate, DEGREE_TO_RADIAN(scene->move->r), DEGREE_TO_RADIAN(scene->move->s), DEGREE_TO_RADIAN(scene->move->p));
34 eina_quaternion_mul(&result, &orient, &rotate);
35 eina_quaternion_normalized(&result, &result);
36 if (n) 33 if (n)
37 { 34 {
38 evas_canvas3d_node_orientation_get(n, EVAS_CANVAS3D_SPACE_PARENT, &orient.x, &orient.y, &orient.z, &orient.w); 35 evas_canvas3d_node_orientation_get(n, EVAS_CANVAS3D_SPACE_PARENT, &orient.x, &orient.y, &orient.z, &orient.w);
36 euler_to_quaternion(&rotate, DEGREE_TO_RADIAN(scene->move->r), DEGREE_TO_RADIAN(scene->move->s), DEGREE_TO_RADIAN(scene->move->p));
37 eina_quaternion_mul(&result, &orient, &rotate);
38 eina_quaternion_normalized(&result, &result);
39 evas_canvas3d_node_orientation_set(n, result.x, result.y, result.z, result.w); 39 evas_canvas3d_node_orientation_set(n, result.x, result.y, result.z, result.w);
40 40
41 eina_quaternion_set(&move, scene->move->x, scene->move->y, scene->move->z, 0); 41 eina_quaternion_set(&move, -scene->move->x, scene->move->y, -scene->move->z, 0);
42 eina_quaternion_mul(&rotate, &result, &move);
43 eina_quaternion_conjugate(&result, &result);
44 eina_quaternion_mul(&move, &rotate, &result);
45 x += move.x;
46 y += move.y;
47 z += move.z;
48 evas_canvas3d_node_position_get(n, EVAS_CANVAS3D_SPACE_PARENT, &x, &y, &z); 42 evas_canvas3d_node_position_get(n, EVAS_CANVAS3D_SPACE_PARENT, &x, &y, &z);
43 eina_quaternion_mul(&rotate, &result, &move);
44 eina_quaternion_conjugate(&result, &result);
45 eina_quaternion_mul(&move, &rotate, &result);
46 x += move.x;
47 y += move.y;
48 z += move.z;
49 evas_canvas3d_node_position_set(n, x, y, z); 49 evas_canvas3d_node_position_set(n, x, y, z);
50 } 50 }
51 51
@@ -66,14 +66,14 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void
66 if (0 == strcmp(ev->key, "Escape")) 66 if (0 == strcmp(ev->key, "Escape"))
67 { 67 {
68 } 68 }
69 else if (0 == strcmp(ev->key, "Left")) move->s = 2.0; 69 else if (0 == strcmp(ev->key, "Left")) move->s = 4.0;
70 else if (0 == strcmp(ev->key, "Right")) move->s = -2.0; 70 else if (0 == strcmp(ev->key, "Right")) move->s = -4.0;
71 else if (0 == strcmp(ev->key, "Up")) move->z = -2.0; 71 else if (0 == strcmp(ev->key, "Up")) move->z = -0.1;
72 else if (0 == strcmp(ev->key, "Down")) move->z = 2.0; 72 else if (0 == strcmp(ev->key, "Down")) move->z = 0.1;
73 else if (0 == strcmp(ev->key, "Prior")) move->y = 2.0; // Pg Up for humans. 73 else if (0 == strcmp(ev->key, "Prior")) move->y = 0.1; // Pg Up for humans.
74 else if (0 == strcmp(ev->key, "Next")) move->y = -2.0; // Pg Dn for humans. 74 else if (0 == strcmp(ev->key, "Next")) move->y = -0.1; // Pg Dn for humans.
75 else if (0 == strcmp(ev->key, "Home")) move->x = -2.0; 75 else if (0 == strcmp(ev->key, "Home")) move->x = -0.1;
76 else if (0 == strcmp(ev->key, "End")) move->x = 2.0; 76 else if (0 == strcmp(ev->key, "End")) move->x = 0.1;
77 else if (0 == strcmp(ev->key, "space")) move->jump = 1.0; 77 else if (0 == strcmp(ev->key, "space")) move->jump = 1.0;
78 else PW("Unexpected down keystroke - %s", ev->key); 78 else PW("Unexpected down keystroke - %s", ev->key);
79 } 79 }
@@ -142,6 +142,7 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void
142 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame. 142 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame.
143 * 143 *
144 * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL. 144 * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL.
145 * And now in Evas_3D, it's different again.
145 */ 146 */
146 147
147static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) 148static 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)
821 stuffs->animateStuffs = (aniStuffs) _animateSonic; 821 stuffs->animateStuffs = (aniStuffs) _animateSonic;
822// else if (4 == fake) 822// else if (4 == fake)
823// stuffs->animateStuffs = (aniStuffs) _animateSphere; 823// stuffs->animateStuffs = (aniStuffs) _animateSphere;
824 else if (5 == fake)
825 {
826 scene->avatar_node = stuffs->mesh_node;
827
828 // Grab the camera for the avatar.
829 evas_canvas3d_node_member_del(evas_canvas3d_node_parent_get(scene->camera_node), scene->camera_node);
830 evas_canvas3d_node_member_add(scene->avatar_node, scene->camera_node);
831
832 evas_canvas3d_node_position_inherit_set(scene->camera_node, TRUE);
833 evas_canvas3d_node_position_set(scene->camera_node, 0.0, 2.5, -1.7);
834
835 evas_canvas3d_node_orientation_inherit_set(scene->camera_node, TRUE);
836 evas_canvas3d_node_orientation_set(scene->camera_node, 0.0, 0.0, 0.0, 1.0);
837 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);
838 }
824} 839}
825 840
826ExtantzStuffs *addStuffs(char *uuid, char *name, char *description, char *owner, 841ExtantzStuffs *addStuffs(char *uuid, char *name, char *description, char *owner,