* fixed bug "turntable deviation" #364

In fact, I made it working different, much more cooler!

-------The BallTable Method TM (patent pending)------------

This is a hybrid of the old turntable method (a virtual camara that rotates
around a table) and the trackball method. Mouse moving horizontal, gives
the turntable effect, but with vertical movement it works like a trackball.
So, vertically moving in the middle of the window exactly mimics old
turntable method, moving vertically in the window edge gives a 'twist'
rotation.

Try the turntable for fun! (is in user settings menu)
This commit is contained in:
2003-07-11 16:50:31 +00:00
parent a31693cca4
commit 448079caa2

View File

@@ -31,6 +31,7 @@
*/ */
#include <math.h> #include <math.h>
#include <string.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@@ -397,9 +398,9 @@ void calctrackballvec(rcti *area, short *mval, float *vec)
void viewmove(int mode) void viewmove(int mode)
{ {
float firstvec[3], newvec[3], dvec[3]; float firstvec[3], newvec[3], dvec[3];
float oldquat[4], q1[4], q2[4], si, phi; float oldquat[4], q1[4], si, phi;
int firsttime=1; int firsttime=1;
short mval[2], mvalo[2]; short mvalball[2], mval[2], mvalo[2];
/* sometimes this routine is called from headerbuttons */ /* sometimes this routine is called from headerbuttons */
areawinset(curarea->win); areawinset(curarea->win);
@@ -408,7 +409,11 @@ void viewmove(int mode)
initgrabz(-G.vd->ofs[0], -G.vd->ofs[1], -G.vd->ofs[2]); initgrabz(-G.vd->ofs[0], -G.vd->ofs[1], -G.vd->ofs[2]);
QUATCOPY(oldquat, G.vd->viewquat); QUATCOPY(oldquat, G.vd->viewquat);
getmouseco_sc(mvalo); /* work with screen coordinates because of trackball function */ getmouseco_sc(mvalo); /* work with screen coordinates because of trackball function */
mvalball[0]= mvalo[0]; /* needed for turntable to work */
mvalball[1]= mvalo[1];
calctrackballvec(&curarea->winrct, mvalo, firstvec); calctrackballvec(&curarea->winrct, mvalo, firstvec);
/* cumultime(0); */ /* cumultime(0); */
@@ -436,8 +441,12 @@ void viewmove(int mode)
if(mode==0) { /* view rotate */ if(mode==0) { /* view rotate */
if(U.flag & TRACKBALL) { /* if turntable method, we don't change mvalball[0] */
calctrackballvec(&curarea->winrct, mval, newvec);
if(U.flag & TRACKBALL) mvalball[0]= mval[0];
mvalball[1]= mval[1];
calctrackballvec(&curarea->winrct, mvalball, newvec);
VecSubf(dvec, newvec, firstvec); VecSubf(dvec, newvec, firstvec);
@@ -459,29 +468,18 @@ void viewmove(int mode)
QuatMul(G.vd->viewquat, q1, oldquat); QuatMul(G.vd->viewquat, q1, oldquat);
} }
}
else {
/* roteren around z-axis (x moves) and horizontal axis (y) */
phi= 2*(mval[0]-mvalo[0]); if( (U.flag & TRACKBALL)==0 ) {
/* rotate around z-axis (mouse x moves) */
phi= 2*(mval[0]-mvalball[0]);
phi/= (float)curarea->winx; phi/= (float)curarea->winx;
si= sin(phi); si= sin(phi);
q1[0]= cos(phi); q1[0]= cos(phi);
q1[1]= q1[2]= 0.0; q1[1]= q1[2]= 0.0;
q1[3]= si; q1[3]= si;
/* horizontal axis */
VECCOPY(q2+1, G.vd->viewinv[0]);
Normalise(q2+1);
phi= (mvalo[1]-mval[1]);
phi/= (float)curarea->winy;
si= sin(phi);
q2[0]= cos(phi);
q2[1]*= si;
q2[2]*= si;
q2[3]*= si;
QuatMul(q1, q1, q2);
QuatMul(G.vd->viewquat, G.vd->viewquat, q1); QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
} }
} }
@@ -740,7 +738,7 @@ short selectprojektie(unsigned int *buffer, short x1, short y1, short x2, short
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
glSelectBuffer( MAXPICKBUF, buffer); glSelectBuffer( MAXPICKBUF, (GLuint *)buffer);
glRenderMode(GL_SELECT); glRenderMode(GL_SELECT);
glInitNames(); /* these two calls whatfor? It doesnt work otherwise */ glInitNames(); /* these two calls whatfor? It doesnt work otherwise */
glPushName(-1); glPushName(-1);