From: Enlightenment S. <no-...@en...> - 2012-10-15 21:54:03
|
Log: ephysics: implement rotation quartenion getter So it's possible to create a custom body update callback using it with evas_map_util_quat_rotate(). Author: bdilly Date: 2012-10-15 14:53:56 -0700 (Mon, 15 Oct 2012) New Revision: 78010 Trac: http://trac.enlightenment.org/e/changeset/78010 Modified: trunk/ephysics/src/lib/EPhysics.h trunk/ephysics/src/lib/ephysics_body.cpp Modified: trunk/ephysics/src/lib/EPhysics.h =================================================================== --- trunk/ephysics/src/lib/EPhysics.h 2012-10-15 21:53:51 UTC (rev 78009) +++ trunk/ephysics/src/lib/EPhysics.h 2012-10-15 21:53:56 UTC (rev 78010) @@ -2924,6 +2924,7 @@ * @param rot_z The amount of degrees @p body is rotated on z axis. * * @see ephysics_body_rotation_set() + * @see ephysics_body_rotation_quaternion_get() * * @ingroup EPhysics_Body */ @@ -2951,6 +2952,24 @@ /** * @brief + * Get body's normalized rotation quaternion (x, y, z and w). + * + * @param body The physics body. + * @param x the x component of the imaginary part of the quaternion. + * @param y the y component of the imaginary part of the quaternion. + * @param z the z component of the imaginary part of the quaternion. + * @param w the w component of the real part of the quaternion. + * + * @see ephysics_body_rotation_set() + * @see ephysics_body_rotation_get() + * + * @ingroup EPhysics_Body + */ +EAPI void +ephysics_body_rotation_quaternion_get(const EPhysics_Body *body, double *x, double *y, double *z, double *w); + +/** + * @brief * Set data to @p body. * * If a previous data was set, it's reference will be lost and body @@ -3169,7 +3188,7 @@ * * If a body of width = 30, height = 20 and depth = 20, and has the center of * mass at x component = 20, y component = 10 and z = 10, it will return - * @p x = 0.666, @p y = 0.5 and @z = 0.5. + * @p x = 0.666, @p y = 0.5 and @p z = 0.5. * * For primitive shapes, like box and circle, the center of mass * is (0.5, 0.5, 0.5). Modified: trunk/ephysics/src/lib/ephysics_body.cpp =================================================================== --- trunk/ephysics/src/lib/ephysics_body.cpp 2012-10-15 21:53:51 UTC (rev 78009) +++ trunk/ephysics/src/lib/ephysics_body.cpp 2012-10-15 21:53:56 UTC (rev 78010) @@ -2612,6 +2612,28 @@ } EAPI void +ephysics_body_rotation_quaternion_get(const EPhysics_Body *body, double *x, double *y, double *z, double *w) +{ + btTransform trans; + btQuaternion quat; + + if (!body) + { + ERR("Can't get rotation, body is null."); + return; + } + + trans = _ephysics_body_transform_get(body); + quat = trans.getRotation(); + quat.normalize(); + + if (x) *x = quat.x(); + if (y) *y = quat.y(); + if (z) *z = quat.z(); + if (w) *w = -quat.w(); +} + +EAPI void ephysics_body_data_set(EPhysics_Body *body, void *data) { if (!body) |