fixed a bug in the cube example where zero rotational values would destroy the rotation quaternion making the cube disappear

git-svn-id: svn+ssh://svn.code.sf.net/p/spacenav/code/trunk/libspnav@113 ef983eb1-d774-4af8-acfd-baaf7b16a646
pull/2/head
John Tsiombikas 2010-12-06 08:34:13 +00:00
rodzic 9d76c6d615
commit 566fd3485a
2 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -258,9 +258,11 @@ int handle_event(XEvent *xev)
/* if so deal with motion and button events */
if(spev.type == SPNAV_EVENT_MOTION) {
/* apply axis/angle rotation to the quaternion */
float axis_len = sqrt(SQ(spev.motion.rx) + SQ(spev.motion.ry) + SQ(spev.motion.rz));
rot = quat_rotate(rot, axis_len * 0.001, -spev.motion.rx / axis_len,
-spev.motion.ry / axis_len, spev.motion.rz / axis_len);
if(spev.motion.rx || spev.motion.ry || spev.motion.rz) {
float axis_len = sqrt(SQ(spev.motion.rx) + SQ(spev.motion.ry) + SQ(spev.motion.rz));
rot = quat_rotate(rot, axis_len * 0.001, -spev.motion.rx / axis_len,
-spev.motion.ry / axis_len, spev.motion.rz / axis_len);
}
/* add translation */
pos.x += spev.motion.x * 0.001;

Wyświetl plik

@ -36,7 +36,7 @@ OF SUCH DAMAGE.
#include <sys/select.h>
#include "spnav.h"
#define SPNAV_SOCK_PATH "/var/run/spnav.sock"
#define SPNAV_SOCK_PATH "/var/run/spnav.sock"
#ifdef USE_X11
#include <X11/Xlib.h>