Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJean-Luc Peurière <jlp@nerim.net>2007-07-29 22:03:36 +0400
committerJean-Luc Peurière <jlp@nerim.net>2007-07-29 22:03:36 +0400
commitbfa77f611f750510e1ee0eda15d987990281ef7c (patch)
tree262cdea55afd894679d8f0356b2e7252b12953bf /source
parent288e07b649ac700f04d2a54d83301235a0b3c04e (diff)
more work on the ndof system.
turntable code should work reasonabilly well now. fly code need works but is no more insane on Os X. transform object is not present here. if you find the movements a bit slow, you can speed it in the preferences up to 2x in the view & controls panel. button1 (left) of the device let you switch between the 3 modes. button2 let you switch between unconstrained and dominant mode. the plugin must be named 3DxNdofBlender.plug and be placed in a folder named plugins in same folder as executable check no scaling is done in the plugin please check it works ok on 3 platforms
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/BSE_view.h1
-rw-r--r--source/blender/include/mydevice.h1
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h3
-rw-r--r--source/blender/src/ghostwinlay.c8
-rw-r--r--source/blender/src/header_view3d.c23
-rw-r--r--source/blender/src/space.c24
-rwxr-xr-xsource/blender/src/transform.c12
-rw-r--r--source/blender/src/view.c83
8 files changed, 116 insertions, 39 deletions
diff --git a/source/blender/include/BSE_view.h b/source/blender/include/BSE_view.h
index d625cbab595..94834d2c771 100644
--- a/source/blender/include/BSE_view.h
+++ b/source/blender/include/BSE_view.h
@@ -76,6 +76,7 @@ void sdrawbox(short x1, short y1, short x2, short y2);
void calctrackballvecfirst(struct rcti *area, short *mval, float *vec);
void calctrackballvec(struct rcti *area, short *mval, float *vec);
void viewmove(int mode);
+void viewmoveNDOFfly(int mode);
void viewmoveNDOF(int mode);
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
diff --git a/source/blender/include/mydevice.h b/source/blender/include/mydevice.h
index af20c093a16..9a8d154e030 100644
--- a/source/blender/include/mydevice.h
+++ b/source/blender/include/mydevice.h
@@ -72,6 +72,7 @@
/* N-degre of freedom device : 500 */
#define NDOFMOTION 500
+#define NDOFBUTTON 501
/* standard keyboard */
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 27cd20c3210..8734e504cf4 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -139,7 +139,8 @@ typedef struct View3D {
short snap_target;
- short pad2;
+ char ndofmode; /* mode of transform for 6DOF devices 0 normal, 1 fly, 2 ob transform */
+ char ndoffilter; /*filter for 6DOF devices 0 normal, 1 dominant */
void *properties_storage; /* Nkey panel stores stuff here, not in file */
diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c
index f960356d7b5..907d0320b57 100644
--- a/source/blender/src/ghostwinlay.c
+++ b/source/blender/src/ghostwinlay.c
@@ -586,7 +586,13 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
;
break;
}
-
+ case GHOST_kEventNDOFButton: {
+ GHOST_TEventNDOFData *sb= data;
+
+// printf("this is a button %i\n", sb->buttons);
+ window_handle(win, NDOFBUTTON, sb->buttons);
+ break;
+ }
case GHOST_kEventCursorMove: {
if(win->active == 1) {
GHOST_TEventCursorData *cd= data;
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c
index 0178ae25e89..5688b514a95 100644
--- a/source/blender/src/header_view3d.c
+++ b/source/blender/src/header_view3d.c
@@ -5258,7 +5258,28 @@ void view3d_buttons(void)
}
uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE_DEHLT, xco,0,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (hold CTRL for anim)");
-
+
+ {
+ char tempstring[256];
+ switch (G.vd->ndofmode) {
+ case 0:
+ sprintf(tempstring,"6dof : %s %s", "turntable",((G.vd->ndoffilter==1) ? "dominant" : ""));
+ break;
+ case 1:
+ sprintf(tempstring,"6dof : %s %s", "fly",((G.vd->ndoffilter==1) ? "dominant" : ""));
+ break;
+ case 2:
+ sprintf(tempstring,"6dof : %s %s", "transform",((G.vd->ndoffilter==1) ? "dominant" : ""));
+ break;
+ default:
+ tempstring[0]=0;
+ break;
+ }
+ uiDefBut(block, LABEL,0,tempstring,
+ xco+=XIC*2,0,150,YIC, 0, 1.0, 0, 0, 0,
+ "");
+
+ }
if (ob && (ob->flag & OB_POSEMODE)) {
xco+= XIC/2;
uiBlockBeginAlign(block);
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index c09f2e79243..cc3109cb57a 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -1567,10 +1567,29 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
doredraw= 1;
break;
- case NDOFMOTION:
- viewmoveNDOF(1);
+ case NDOFMOTION:
+ if (G.vd->ndofmode == 0) {
+ viewmoveNDOF(1);
+ } else if (G.vd->ndofmode == 1) {
+ viewmoveNDOFfly(1);
+ } else {
+ ;
+ }
+
break;
+ case NDOFBUTTON:
+ if (val == 1) {
+ G.vd->ndofmode +=1;
+ if (G.vd->ndofmode > 2) /* we have currently 3 modes : 0 original, 1 fly, 2 transform */
+ G.vd->ndofmode = 0;
+ }
+ if (val == 2) {
+ G.vd->ndoffilter =(G.vd->ndoffilter == 1 ? 0 : 1);
+ }
+ allqueue(REDRAWHEADERS, 0);
+ break;
+
case ONEKEY:
if(G.qual==LR_CTRLKEY) {
flip_subdivison(1);
@@ -2584,6 +2603,7 @@ static void initview3d(ScrArea *sa)
vd->gridflag &= ~V3D_SHOW_Z;
vd->depths= NULL;
+ vd->ndofmode=0;
}
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c
index e2819cc3693..9e6c1b68937 100755
--- a/source/blender/src/transform.c
+++ b/source/blender/src/transform.c
@@ -726,9 +726,9 @@ static void transformEvent(unsigned short event, short val) {
else view_editmove(event);
Trans.redraw= 1;
break;
- case NDOFMOTION:
- viewmoveNDOF(0);
- break;
+// case NDOFMOTION:
+// viewmoveNDOF(1);
+ // break;
}
Trans.redraw |= handleNumInput(&(Trans.num), event);
Trans.redraw |= handleSnapping(&Trans, event);
@@ -1075,9 +1075,9 @@ void ManipulatorTransform()
case RETKEY:
Trans.state = TRANS_CONFIRM;
break;
- case NDOFMOTION:
- viewmoveNDOF(0);
- break;
+ // case NDOFMOTION:
+ // viewmoveNDOF(1);
+ // break;
}
if(val) {
switch(event) {
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index c84addcf0ff..06782b1a873 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -545,13 +545,24 @@ void calctrackballvec(rcti *area, short *mval, float *vec)
// can be increased for improved response from
// small deflections of the device input.
+
+// lukep notes : i disagree on the range.
+// the normal 3Dconnection driver give +/-400
+// on defaut range in other applications
+// and up to +/- 1000 if set to maximum
+// because i remove the scaling by delta,
+// which was a bad idea as it depend of the system
+// speed and os, i changed the scaling values, but
+// those are still not ok
+
+
float ndof_axis_scale[6] = {
- +2.0, // Tx
- +2.0, // Tz
- +2.0, // Ty
- +0.25, // Rx
- +0.25, // Rz
- +0.25 // Ry
+ +0.01, // Tx
+ +0.01, // Tz
+ +0.01, // Ty
+ +0.0015, // Rx
+ +0.0015, // Rz
+ +0.0015 // Ry
};
// statics for controlling G.vd->dist corrections.
@@ -563,10 +574,20 @@ float m_dist;
void getndof(float *sbval);
-#define USE_NEW_NDOFMOVE
+static filterNDOFvalues(float *sbval)
+{
+ int i=0;
+ float max = 0.0;
+
+ for (i =0; i<5;i++)
+ if (fabs(sbval[i]) > max)
+ max = fabs(sbval[i]);
+ for (i =0; i<5;i++)
+ if (fabs(sbval[i]) != max )
+ sbval[i]=0.0;
+}
-#ifdef USE_NEW_NDOFMOVE
-void viewmoveNDOF(int mode)
+void viewmoveNDOFfly(int mode)
{
int i;
float phi;
@@ -589,16 +610,18 @@ void viewmoveNDOF(int mode)
// fetch the current state of the ndof device
getndof(dval);
- for(i=0;i<7;i++) printf("%f ",dval[i]);
- printf("\n");
+ if (G.vd->ndoffilter)
+ filterNDOFvalues(fval);
+
+// for(i=0;i<7;i++) printf("%f ",dval[i]);
+// printf("\n");
// Scale input values
- if(dval[6] == 0) return; // guard against divide by zero
+// if(dval[6] == 0) return; // guard against divide by zero
for(i=0;i<6;i++) {
- dval[i] = dval[i] / dval[6]; // this should be moved to device specific
// user scaling
dval[i] = dval[i] * ndof_axis_scale[i];
@@ -695,7 +718,6 @@ void viewmoveNDOF(int mode)
/*----------------------------------------------------
* refresh the screen
*/
-
scrarea_do_windraw(curarea);
screen_swapbuffers();
@@ -704,8 +726,6 @@ void viewmoveNDOF(int mode)
BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
}
-#endif
-
void viewmove(int mode)
{
Object *ob = OBACT;
@@ -994,10 +1014,6 @@ void viewmove(int mode)
}
-
-#ifndef USE_NEW_NDOFMOVE
-
-
void viewmoveNDOF(int mode)
{
static double prevTime = 0.0;
@@ -1057,19 +1073,31 @@ void viewmoveNDOF(int mode)
/* fetch the current state of the ndof device */
getndof(fval);
- // printf(" motion command %f %f %f %f %f %f %f \n", fval[0], fval[1], fval[2],
- // fval[3], fval[4], fval[5], fval[6]);
-
+ // printf(" motion command %f %f %f %f %f %f %f \n", fval[0], fval[1], fval[2],
+ // fval[3], fval[4], fval[5], fval[6]);
+ if (G.vd->ndoffilter)
+ filterNDOFvalues(fval);
+
// put scaling back here, was previously in ghostwinlay
fval[0] = fval[0] * (1.0f/1024.0f);
fval[1] = fval[1] * (1.0f/1024.0f);
fval[2] = fval[2] * (1.0f/1024.0f);
- fval[3] = fval[3] * 0.00003f;
- fval[4] = fval[4] * 0.00003f;
- fval[5] = fval[5] * 0.00003f;
+ fval[3] = fval[3] * 0.00005f;
+ fval[4] = fval[4] * 0.00005f;
+ fval[5] = fval[5] * 0.00005f;
fval[6] = fval[6] / 1000000.0f;
-
+
+ // scale more if not in perspective mode
+ if (G.vd->persp == 0) {
+ fval[0] = fval[0] * 0.05f;
+ fval[1] = fval[1] * 0.05f;
+ fval[2] = fval[2] * 0.05f;
+ fval[3] = fval[3] * 0.9f;
+ fval[4] = fval[4] * 0.9f;
+ fval[5] = fval[5] * 0.9f;
+ }
+
/* set object offset */
if (ob) {
@@ -1169,7 +1197,6 @@ void viewmoveNDOF(int mode)
screen_swapbuffers();
}
-#endif
/* Gets the lens and clipping values from a camera of lamp type object */