diff options
Diffstat (limited to '')
-rw-r--r-- | src/extantz/camera.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/extantz/camera.c b/src/extantz/camera.c index ba960d4..bbf8b01 100644 --- a/src/extantz/camera.c +++ b/src/extantz/camera.c | |||
@@ -28,22 +28,26 @@ Eina_Bool animateCamera(Scene_Data *scene) | |||
28 | { | 28 | { |
29 | Eina_Quaternion rotate, orient, result, move; | 29 | Eina_Quaternion rotate, orient, result, move; |
30 | Evas_Real x, y, z; | 30 | Evas_Real x, y, z; |
31 | Eo *n = scene->avatar_node; | ||
31 | 32 | ||
32 | eo_do(scene->camera_node, evas_canvas3d_node_orientation_get(EVAS_CANVAS3D_SPACE_PARENT, &orient.x, &orient.y, &orient.z, &orient.w)); | ||
33 | euler_to_quaternion(&rotate, DEGREE_TO_RADIAN(scene->move->r), DEGREE_TO_RADIAN(scene->move->s), DEGREE_TO_RADIAN(scene->move->p)); | 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); | 34 | eina_quaternion_mul(&result, &orient, &rotate); |
35 | eina_quaternion_normalized(&result, &result); | 35 | eina_quaternion_normalized(&result, &result); |
36 | eo_do(scene->camera_node, evas_canvas3d_node_orientation_set(result.x, result.y, result.z, result.w)); | 36 | if (n) |
37 | { | ||
38 | evas_canvas3d_node_orientation_get(n, EVAS_CANVAS3D_SPACE_PARENT, &orient.x, &orient.y, &orient.z, &orient.w); | ||
39 | evas_canvas3d_node_orientation_set(n, result.x, result.y, result.z, result.w); | ||
37 | 40 | ||
38 | 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); |
39 | eo_do(scene->camera_node, evas_canvas3d_node_position_get(EVAS_CANVAS3D_SPACE_PARENT, &x, &y, &z)); | ||
40 | eina_quaternion_mul(&rotate, &result, &move); | 42 | eina_quaternion_mul(&rotate, &result, &move); |
41 | eina_quaternion_conjugate(&result, &result); | 43 | eina_quaternion_conjugate(&result, &result); |
42 | eina_quaternion_mul(&move, &rotate, &result); | 44 | eina_quaternion_mul(&move, &rotate, &result); |
43 | x += move.x; | 45 | x += move.x; |
44 | y += move.y; | 46 | y += move.y; |
45 | z += move.z; | 47 | z += move.z; |
46 | eo_do(scene->camera_node, evas_canvas3d_node_position_set(x, y, z)); | 48 | evas_canvas3d_node_position_get(n, EVAS_CANVAS3D_SPACE_PARENT, &x, &y, &z); |
49 | evas_canvas3d_node_position_set(n, x, y, z); | ||
50 | } | ||
47 | 51 | ||
48 | return EINA_TRUE; | 52 | return EINA_TRUE; |
49 | } | 53 | } |
@@ -204,19 +208,20 @@ Eo *cameraAdd(Evas *evas, Scene_Data *scene, Evas_Object *image) | |||
204 | Eo *camera; | 208 | Eo *camera; |
205 | 209 | ||
206 | camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas, | 210 | camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas, |
207 | evas_canvas3d_camera_projection_perspective_set(90.0, 1.0, 1.0, 1024.0) | 211 | evas_canvas3d_camera_projection_perspective_set(eoid, 90.0, 1.0, 1.0, 1024.0) |
208 | ); | 212 | ); |
209 | 213 | ||
210 | result = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA), | 214 | result = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas, |
211 | evas_canvas3d_node_camera_set(camera), | 215 | evas_canvas3d_node_constructor(eoid, EVAS_CANVAS3D_NODE_TYPE_CAMERA), |
212 | evas_canvas3d_node_position_set(0.0, 4.0, 8.0), | 216 | evas_canvas3d_node_camera_set(eoid, camera), |
213 | // evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 20.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0), | 217 | evas_canvas3d_node_position_set(eoid, 0.0, 4.0, 8.0), |
214 | evas_canvas3d_node_orientation_set(0.0, 0.0, 0.0, 1.0) | 218 | // evas_canvas3d_node_look_at_set(eoid, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 20.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0), |
215 | ); | 219 | evas_canvas3d_node_orientation_set(eoid, 0.0, 0.0, 0.0, 1.0) |
220 | ); | ||
216 | // eo_unref(camera); | 221 | // eo_unref(camera); |
217 | 222 | ||
218 | eo_do(scene->root_node, evas_canvas3d_node_member_add(result)); | 223 | evas_canvas3d_node_member_add(scene->root_node, result); |
219 | eo_do(scene->scene, evas_canvas3d_scene_camera_node_set(result)); | 224 | evas_canvas3d_scene_camera_node_set(scene->scene, result); |
220 | 225 | ||
221 | scene->move = calloc(1, sizeof(cameraMove)); | 226 | scene->move = calloc(1, sizeof(cameraMove)); |
222 | // In this code, we are making our own camera, so grab it's input when we are focused. | 227 | // In this code, we are making our own camera, so grab it's input when we are focused. |