kopia lustrzana https://github.com/FreeSpacenav/libspnav
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-baaf7b16a646pull/2/head
rodzic
9d76c6d615
commit
566fd3485a
|
@ -258,9 +258,11 @@ int handle_event(XEvent *xev)
|
||||||
/* if so deal with motion and button events */
|
/* if so deal with motion and button events */
|
||||||
if(spev.type == SPNAV_EVENT_MOTION) {
|
if(spev.type == SPNAV_EVENT_MOTION) {
|
||||||
/* apply axis/angle rotation to the quaternion */
|
/* apply axis/angle rotation to the quaternion */
|
||||||
float axis_len = sqrt(SQ(spev.motion.rx) + SQ(spev.motion.ry) + SQ(spev.motion.rz));
|
if(spev.motion.rx || spev.motion.ry || spev.motion.rz) {
|
||||||
rot = quat_rotate(rot, axis_len * 0.001, -spev.motion.rx / axis_len,
|
float axis_len = sqrt(SQ(spev.motion.rx) + SQ(spev.motion.ry) + SQ(spev.motion.rz));
|
||||||
-spev.motion.ry / axis_len, spev.motion.rz / axis_len);
|
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 */
|
/* add translation */
|
||||||
pos.x += spev.motion.x * 0.001;
|
pos.x += spev.motion.x * 0.001;
|
||||||
|
|
2
spnav.c
2
spnav.c
|
@ -36,7 +36,7 @@ OF SUCH DAMAGE.
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include "spnav.h"
|
#include "spnav.h"
|
||||||
|
|
||||||
#define SPNAV_SOCK_PATH "/var/run/spnav.sock"
|
#define SPNAV_SOCK_PATH "/var/run/spnav.sock"
|
||||||
|
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
Ładowanie…
Reference in New Issue