[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11418] branches/ndof: more work on the ndof system.

JLuc Peuriere jlp at nerim.net
Sun Jul 29 20:03:36 CEST 2007


Revision: 11418
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11418
Author:   lukep
Date:     2007-07-29 20:03:36 +0200 (Sun, 29 Jul 2007)

Log Message:
-----------
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

Modified Paths:
--------------
    branches/ndof/intern/ghost/GHOST_Types.h
    branches/ndof/intern/ghost/intern/GHOST_SystemCarbon.cpp
    branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp
    branches/ndof/source/blender/include/BSE_view.h
    branches/ndof/source/blender/include/mydevice.h
    branches/ndof/source/blender/makesdna/DNA_view3d_types.h
    branches/ndof/source/blender/src/ghostwinlay.c
    branches/ndof/source/blender/src/header_view3d.c
    branches/ndof/source/blender/src/space.c
    branches/ndof/source/blender/src/transform.c
    branches/ndof/source/blender/src/view.c

Modified: branches/ndof/intern/ghost/GHOST_Types.h
===================================================================
--- branches/ndof/intern/ghost/GHOST_Types.h	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/intern/ghost/GHOST_Types.h	2007-07-29 18:03:36 UTC (rev 11418)
@@ -137,7 +137,8 @@
 	GHOST_kEventButtonUp,		/// Mouse button event
 	GHOST_kEventWheel,			/// Mouse wheel event
 
-	GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
+	GHOST_kEventNDOFMotion,		/// N degree of freedom device motion event
+	GHOST_kEventNDOFButton,		/// N degree of freedom device button event
 
 	GHOST_kEventKeyDown,
 	GHOST_kEventKeyUp,

Modified: branches/ndof/intern/ghost/intern/GHOST_SystemCarbon.cpp
===================================================================
--- branches/ndof/intern/ghost/intern/GHOST_SystemCarbon.cpp	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/intern/ghost/intern/GHOST_SystemCarbon.cpp	2007-07-29 18:03:36 UTC (rev 11418)
@@ -984,7 +984,7 @@
 			GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
 			if (::TrackGoAway(window, mousePos))
 			{
-				// todo: add option-close, because it\xD8s in the HIG
+				// todo: add option-close, because itÿs in the HIG
 				// if (event.modifiers & optionKey) {
 					// Close the clean documents, others will be confirmed one by one.
 				//}
@@ -1069,6 +1069,7 @@
     OSStatus err = eventNotHandledErr;
 	GHOST_IWindow* window;
 	GHOST_TEventNDOFData data;
+	UInt32 kind;
 	
     switch (::GetEventClass(event))
     {
@@ -1090,7 +1091,19 @@
  		case kEventClassBlender :
 			window = sys->m_windowManager->getActiveWindow();
 			sys->m_ndofManager->GHOST_NDOFGetDatas(data);
-			sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data));
+			kind = ::GetEventKind(event);
+			
+			switch (kind)
+			{
+				case 1:
+					sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data));
+	//				printf("motion\n");
+					break;
+				case 2:
+					sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data));
+//					printf("button\n");
+					break;
+			}
 			err = noErr;
 			break;
 		default : 

Modified: branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/intern/ghost/intern/GHOST_SystemX11.cpp	2007-07-29 18:03:36 UTC (rev 11418)
@@ -462,25 +462,21 @@
 			} else 
 #endif
 			if (sNdofInfo.currValues) {
-				sNdofInfo.currValues->changed = 1;
-				sNdofInfo.currValues->delta = xcme.data.s[8] - sNdofInfo.currValues->time;
-				sNdofInfo.currValues->time = xcme.data.s[8];
-				sNdofInfo.currValues->tx = xcme.data.s[2] >> 4;
-				sNdofInfo.currValues->ty = xcme.data.s[3] >> 4;
-				sNdofInfo.currValues->tz = xcme.data.s[4] >> 4;
-				sNdofInfo.currValues->rx = xcme.data.s[5];
-				sNdofInfo.currValues->ry = xcme.data.s[6];
-				sNdofInfo.currValues->rz = xcme.data.s[7];
+  				GHOST_TEventNDOFData data;
+				data.changed = 1;
+				data.delta = xcme.data.s[8] - data.time;
+				data.time = xcme.data.s[8];
+				data.tx = xcme.data.s[2] >> 4;
+				data.ty = xcme.data.s[3] >> 4;
+				data.tz = xcme.data.s[4] >> 4;
+				data.rx = xcme.data.s[5];
+				data.ry = xcme.data.s[6];
+				data.rz = xcme.data.s[7];
 
-				/*fprintf(stderr, "ClientMessage: [%d %d %d][%d %d %d] t=%llu\n",
-				        sNdofInfo.currValues->tx, sNdofInfo.currValues->ty, 
-				        sNdofInfo.currValues->tz, sNdofInfo.currValues->rx, 
-				        sNdofInfo.currValues->ry, sNdofInfo.currValues->rz, 
-						sNdofInfo.currValues->time); */
+				g_event = new GHOST_EventNDOF(getMilliSeconds(),
+                                GHOST_kEventNDOFMotion,
+                                window, data);
 				
-				g_event = new GHOST_EventNDOF(getMilliSeconds(), 
-				                              GHOST_kEventNDOFMotion, 
-				                              window, *sNdofInfo.currValues);
 			} else {
 				/* Unknown client message, ignore */
 			}

Modified: branches/ndof/source/blender/include/BSE_view.h
===================================================================
--- branches/ndof/source/blender/include/BSE_view.h	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/include/BSE_view.h	2007-07-29 18:03:36 UTC (rev 11418)
@@ -76,6 +76,7 @@
 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);

Modified: branches/ndof/source/blender/include/mydevice.h
===================================================================
--- branches/ndof/source/blender/include/mydevice.h	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/include/mydevice.h	2007-07-29 18:03:36 UTC (rev 11418)
@@ -72,6 +72,7 @@
 
 /* N-degre of freedom device : 500 */
 #define NDOFMOTION 500
+#define NDOFBUTTON 501
 
 /* standard keyboard */
 

Modified: branches/ndof/source/blender/makesdna/DNA_view3d_types.h
===================================================================
--- branches/ndof/source/blender/makesdna/DNA_view3d_types.h	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/makesdna/DNA_view3d_types.h	2007-07-29 18:03:36 UTC (rev 11418)
@@ -139,7 +139,8 @@
 	
 	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 */
 

Modified: branches/ndof/source/blender/src/ghostwinlay.c
===================================================================
--- branches/ndof/source/blender/src/ghostwinlay.c	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/src/ghostwinlay.c	2007-07-29 18:03:36 UTC (rev 11418)
@@ -586,7 +586,13 @@
 ;
           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;

Modified: branches/ndof/source/blender/src/header_view3d.c
===================================================================
--- branches/ndof/source/blender/src/header_view3d.c	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/src/header_view3d.c	2007-07-29 18:03:36 UTC (rev 11418)
@@ -5258,7 +5258,28 @@
 		}
 
 		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);

Modified: branches/ndof/source/blender/src/space.c
===================================================================
--- branches/ndof/source/blender/src/space.c	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/src/space.c	2007-07-29 18:03:36 UTC (rev 11418)
@@ -1567,10 +1567,29 @@
 				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 @@
 	vd->gridflag &= ~V3D_SHOW_Z;
 
 	vd->depths= NULL;
+	vd->ndofmode=0;
 }
 
 

Modified: branches/ndof/source/blender/src/transform.c
===================================================================
--- branches/ndof/source/blender/src/transform.c	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/src/transform.c	2007-07-29 18:03:36 UTC (rev 11418)
@@ -726,9 +726,9 @@
 			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 @@
 			case RETKEY:
 				Trans.state = TRANS_CONFIRM;
 				break;
-            case NDOFMOTION:
-                viewmoveNDOF(0);
-                break;
+   //         case NDOFMOTION:
+     //           viewmoveNDOF(1);
+     //           break;
 			}
 			if(val) {
 				switch(event) {

Modified: branches/ndof/source/blender/src/view.c
===================================================================
--- branches/ndof/source/blender/src/view.c	2007-07-29 16:46:21 UTC (rev 11417)
+++ branches/ndof/source/blender/src/view.c	2007-07-29 18:03:36 UTC (rev 11418)
@@ -545,13 +545,24 @@
 // 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

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list