[Bf-committers] 3D Connexion ndof support in blender 2.5
Rafael Ortis
rsortis at gmail.com
Sun Jan 2 22:18:09 CET 2011
Thanks!
>From the svn logs he made very good progress.
He commented there that his ndof implementation is working in Windows
and Mac but in my Linux it did not worked :(
And based on the part of the code I saw, I think that his work is
going to be much more clean than my patch :D
When his work is going to be merged to the trunk? Only at the end of
the GSoC project?
>From the GSoC project log I think he still has a lot of work to do :(
I'm sending my patch with the corrections proposed by Ton if someone
find it's useful let me know! :D
att.
Rafael Ortis
2011/1/2 M.G. Kishalmi <lmg at kishalmi.net>:
> GSoC log of Mike Erwin (Matts student)
> -> http://www.invisible-cow.com/blender/soc/index.html
>
> soc-2010-merwin branch
> -> https://svn.blender.org/svnroot/bf-blender/branches/soc-2010-merwin/
>
> cheers,
> mario
>
>
> On Sun, Jan 2, 2011 at 8:41 PM, Rafael Ortis <rsortis at gmail.com> wrote:
>> I have read about it in some forum but I didn't find it on Blender GSoC pages.
>> Where can i find Matts work?
>>
>>
>> 2011/1/1 Tom M <letterrip at gmail.com>:
>>> Didn't matts student work on 3dconnexxion as part of GSoC?
>>>
>>> Not sure what stage that part of his project achieved but it might be
>>> worth looking at.
>>>
>>> LetterRip
>>>
>>> On Sat, Jan 1, 2011 at 8:26 AM, Rafael Ortis <rsortis at gmail.com> wrote:
>>>> Yes this is interesting!
>>>>
>>>> I have installed this drivers but in my initial tests the
>>>> rotations/translations was a little bit uncontrollable. But I will
>>>> test with this driver them again.
>>>>
>>>> att
>>>> Rafael Ortis
>>>>
>>>> 2011/1/1 Stephen Swaney <sswaney at centurytel.net>:
>>>>> Also worth noting is the open source SpaceNav project.
>>>>>
>>>>> They have a drop-in replacement for the 3dconnexion driver
>>>>> that also supports a non-proprietary protocol. Looks
>>>>> interesting.
>>>>>
>>>>> http://spacenav.sourceforge.net/
>>>>>
>>>>> --
>>>>> Stephen Swaney
>>>>> sswaney at centurytel.net
>>>>>
>>>>> _______________________________________________
>>>>> Bf-committers mailing list
>>>>> Bf-committers at blender.org
>>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>>
>>>> _______________________________________________
>>>> Bf-committers mailing list
>>>> Bf-committers at blender.org
>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
-------------- next part --------------
Index: source/blender/makesdna/DNA_windowmanager_types.h
===================================================================
--- source/blender/makesdna/DNA_windowmanager_types.h (revisão 34012)
+++ source/blender/makesdna/DNA_windowmanager_types.h (cópia de trabalho)
@@ -44,6 +44,9 @@
struct wmKeyMap;
struct wmKeyConfig;
+/* XXX HACK */
+struct wmNdofState;
+
/* forwards */
struct bContext;
struct wmLocal;
@@ -173,6 +176,11 @@
short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
short pad2[2];
+ /* XXX HACK */
+ struct wmNdofState *ndofState;
+ //float ndof[7];
+ //int pad3;
+
struct wmEvent *eventstate; /* storage for event system */
struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
@@ -298,6 +306,23 @@
} wmOperator;
+
+/* XXX HACK */
+/* Current values of ndof device - used in wmWindow*/
+typedef struct wmNdofState {
+ // translations
+ float tx;
+ float ty;
+ float tz;
+ // rotations
+ float rx;
+ float ry;
+ float rz;
+ // delta
+ float delta;
+} wmNdofState;
+
+
/* operator type exec(), invoke() modal(), return values */
#define OPERATOR_RUNNING_MODAL 1
#define OPERATOR_CANCELLED 2
Index: source/blender/windowmanager/intern/wm_files.c
===================================================================
--- source/blender/windowmanager/intern/wm_files.c (revisão 34012)
+++ source/blender/windowmanager/intern/wm_files.c (cópia de trabalho)
@@ -234,6 +234,10 @@
win->eventstate= oldwin->eventstate;
oldwin->eventstate= NULL;
+ /* XXX HACK */
+ win->ndofState= oldwin->ndofState;
+ oldwin->ndofState= NULL;
+
/* ensure proper screen rescaling */
win->sizex= oldwin->sizex;
win->sizey= oldwin->sizey;
Index: source/blender/windowmanager/intern/wm_window.c
===================================================================
--- source/blender/windowmanager/intern/wm_window.c (revisão 34012)
+++ source/blender/windowmanager/intern/wm_window.c (cópia de trabalho)
@@ -67,6 +67,9 @@
#include "GPU_draw.h"
#include "GPU_extensions.h"
+/* XXX HACK */
+#include "PIL_dynlib.h"
+
/* the global to talk to ghost */
GHOST_SystemHandle g_system= NULL;
@@ -168,7 +171,10 @@
}
if(win->eventstate) MEM_freeN(win->eventstate);
-
+
+ /* XXX HACK */
+ if(win->ndofState) MEM_freeN(win->ndofState);
+
wm_event_free_all(win);
wm_subwindows_free(win);
@@ -297,6 +303,97 @@
}
}
+/* XXX HACK */
+/*************** ndof *************************/
+#ifdef _WIN32
+#define PATH_SEP "\\"
+#else
+#define PATH_SEP "/"
+#endif
+
+void wm_open_ndof(bContext *C, GHOST_WindowHandle ghostwin)
+{
+ char *inst_path, *plug_path;
+ const char *plug_dir = "plugins";
+ const char *plug_name = "3DxNdofBlender.plug";
+ PILdynlib *ndofLib;
+
+ // build the plugin path
+ plug_path = NULL;
+ inst_path = get_install_dir(); // path to main blender exec/bundle
+ if (inst_path) {
+ // assume the ndof plugin is located in the plug-in dir
+ size_t len = strlen(inst_path) + strlen(plug_dir) + strlen(PATH_SEP)*2
+ + strlen(plug_name) + 1;
+ plug_path = MEM_mallocN(len, "ndofpluginpath");
+ if (plug_path) {
+ strncpy(plug_path, inst_path, len);
+ strcat(plug_path, PATH_SEP);
+ strcat(plug_path, plug_dir);
+ strcat(plug_path, PATH_SEP);
+ strcat(plug_path, plug_name);
+ }
+ MEM_freeN(inst_path);
+ }
+
+ ndofLib = PIL_dynlib_open(plug_path);
+
+ /* On systems where blender is installed in /usr/bin/blender, ~/.blender/plugins/ is a better place to look */
+ /* XXX HACK Lookup only on install dir because BLI_gethome() not avaliable */
+ /*if (ndofLib==NULL) {
+
+ if (plug_path) {
+ MEM_freeN(plug_path);
+ }
+
+ inst_path = BLI_gethome();
+ if (inst_path) {
+ size_t len = strlen(inst_path) + strlen(plug_dir) + strlen(PATH_SEP)*2
+ + strlen(plug_name) + 1;
+
+ if (!strstr(inst_path, ".blender")) {
+ len += strlen(".blender") + strlen(PATH_SEP);
+ }
+
+ plug_path = MEM_mallocN(len, "ndofpluginpath");
+ if (plug_path) {
+ strncpy(plug_path, inst_path, len);
+ strcat(plug_path, PATH_SEP);
+ if (!strstr(inst_path, ".blender")) {
+ strcat(plug_path, ".blender");
+ strcat(plug_path, PATH_SEP);
+ }
+ strcat(plug_path, plug_dir);
+ strcat(plug_path, PATH_SEP);
+ strcat(plug_path, plug_name);
+ }
+ }
+
+ ndofLib = PIL_dynlib_open(plug_path);
+ }*/
+
+
+
+#if 1
+ fprintf(stderr, "plugin path=%s; ndofLib=%p\n", plug_path, (void*)ndofLib);
+#endif
+
+ if (plug_path)
+ MEM_freeN(plug_path);
+
+ if (ndofLib) {
+ G.ndofdevice = 0 - GHOST_OpenNDOF(g_system, ghostwin ,
+ PIL_dynlib_find_symbol(ndofLib, "ndofInit"),
+ PIL_dynlib_find_symbol(ndofLib, "ndofShutdown"),
+ PIL_dynlib_find_symbol(ndofLib, "ndofOpen"));
+
+ } else {
+ GHOST_OpenNDOF(g_system, ghostwin, 0, 0, 0);
+ G.ndofdevice = -1;
+ }
+ }
+
+
/* belongs to below */
static void wm_window_add_ghostwindow(bContext *C, const char *title, wmWindow *win)
{
@@ -340,7 +437,14 @@
if(win->eventstate==NULL)
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
-
+
+ /* XXX HACK */
+ if(win->ndofState==NULL)
+ win->ndofState= MEM_callocN(sizeof(wmNdofState), "ndof device state");
+ // Connecto to ndof device
+ wm_open_ndof(C, ghostwin);
+
+
/* until screens get drawn, make it nice grey */
glClearColor(.55, .55, .55, 0.0);
/* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */
@@ -404,6 +508,10 @@
if(win->eventstate==NULL)
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
+ /* XXX HACK */
+ if(win->ndofState==NULL)
+ win->ndofState= MEM_callocN(sizeof(wmNdofState), "ndof device state");
+
/* add keymap handlers (1 handler for all keys in map!) */
keymap= WM_keymap_find(wm->defaultconf, "Window", 0, 0);
WM_event_add_keymap_handler(&win->handlers, keymap);
@@ -759,7 +867,32 @@
}
break;
}
-
+
+ /* XXX HACK */
+ case GHOST_kEventNDOFMotion:
+ {
+ // update ndof device data, dispatch motion event and update window
+ GHOST_TEventNDOFData *sb= data;
+
+ win->ndofState->tx = sb->tx;
+ win->ndofState->ty = sb->ty;
+ win->ndofState->tz = sb->tz;
+ win->ndofState->rx = sb->rx;
+ win->ndofState->ry = sb->ry;
+ win->ndofState->rz = sb->rz;
+ win->ndofState->delta = sb->delta;
+#if 0
+ printf(" motion capted %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f %4.1f \n",
+ win->ndofState->tx, win->ndofState->ty, win->ndofState->tz,
+ win->ndofState->rx, win->ndofState->ry, win->ndofState->rz, win->ndofState->delta);
+#endif
+ wm_event_add_ghostevent(wm, win, type, time, data);
+ wm_window_make_drawable(C, win);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ break;
+ }
+
case GHOST_kEventOpenMainFile:
{
PointerRNA props_ptr;
@@ -1186,3 +1319,12 @@
}
}
+void WM_get_ndof(wmWindow* win, float* sbval) {
+ sbval[0] = win->ndofState->tx;
+ sbval[1] = win->ndofState->ty;
+ sbval[2] = win->ndofState->tz;
+ sbval[3] = win->ndofState->rx;
+ sbval[4] = win->ndofState->ry;
+ sbval[5] = win->ndofState->rz;
+ sbval[6] = win->ndofState->delta;
+}
Index: source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- source/blender/windowmanager/intern/wm_event_system.c (revisão 34012)
+++ source/blender/windowmanager/intern/wm_event_system.c (cópia de trabalho)
@@ -2252,6 +2252,41 @@
event= *evt;
switch (type) {
+
+ /* XXX HACK */
+ /* ndof */
+ case GHOST_kEventNDOFMotion:
+ {
+
+ View3D *v3d = NULL;
+ ScrArea *sa = NULL;
+ ARegion *arTmp = NULL;
+ ARegion *ar = NULL;
+ ScrArea *saFound = NULL;
+ RegionView3D *rv3d = NULL;
+ Scene *scene = win->screen->scene;
+
+ for(sa= win->screen->areabase.first; sa; sa= sa->next) {
+ SpaceLink *sl;
+ for(sl= sa->spacedata.first; sl; sl= sl->next) {
+ if(sl->spacetype==SPACE_VIEW3D) {
+ v3d= (View3D*) sl;
+ saFound = sa;
+ }
+ }
+ }
+
+ for(arTmp=saFound->regionbase.first; arTmp; arTmp= arTmp->next) {
+ if(arTmp->regiontype == RGN_TYPE_WINDOW) {
+ ar = arTmp;
+ }
+ }
+ rv3d = ar->regiondata;
+ viewmoveNDOF(scene, ar, v3d, 0, win);
+
+ break;
+ }
+
/* mouse move */
case GHOST_kEventCursorMove: {
if(win->active) {
Index: source/blender/windowmanager/WM_api.h
===================================================================
--- source/blender/windowmanager/WM_api.h (revisão 34012)
+++ source/blender/windowmanager/WM_api.h (cópia de trabalho)
@@ -343,6 +343,8 @@
/* progress */
void WM_progress_set(struct wmWindow *win, float progress);
void WM_progress_clear(struct wmWindow *win);
+/* XXX HACK */
+void WM_get_ndof(wmWindow* win, float* sbval);
#ifdef WIN32
/* Windows System Console */
Index: source/blender/windowmanager/wm_event_types.h
===================================================================
--- source/blender/windowmanager/wm_event_types.h (revisão 34012)
+++ source/blender/windowmanager/wm_event_types.h (cópia de trabalho)
@@ -84,6 +84,11 @@
#define TIMERJOBS 0x0114 /* timer event, internal use */
#define TIMERAUTOSAVE 0x0115 /* timer event, internal use */
+/* XXX HACK */
+/* N-degre of freedom device : 500 */
+#define NDOFMOTION 500
+#define NDOFBUTTON 501
+
/* standard keyboard */
#define AKEY 'a'
#define BKEY 'b'
Index: source/blender/blenloader/intern/readfile.c
===================================================================
--- source/blender/blenloader/intern/readfile.c (revisão 34012)
+++ source/blender/blenloader/intern/readfile.c (cópia de trabalho)
@@ -4515,7 +4515,8 @@
win->eventstate= NULL;
win->curswin= NULL;
win->tweak= NULL;
-
+ /* XXX HACK */
+ win->ndofState= NULL;
win->queue.first= win->queue.last= NULL;
win->handlers.first= win->handlers.last= NULL;
win->modalhandlers.first= win->modalhandlers.last= NULL;
Index: source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- source/blender/editors/space_view3d/view3d_edit.c (revisão 34012)
+++ source/blender/editors/space_view3d/view3d_edit.c (cópia de trabalho)
@@ -2758,7 +2758,8 @@
int dz_flag = 0;
float m_dist;
-void viewmoveNDOFfly(ARegion *ar, View3D *v3d, int UNUSED(mode))
+/* XXX HACK */
+void viewmoveNDOFfly(ARegion *ar, View3D *v3d, int UNUSED(mode), wmWindow *win)
{
RegionView3D *rv3d= ar->regiondata;
int i;
@@ -2780,7 +2781,8 @@
// fetch the current state of the ndof device
-// XXX getndof(dval);
+ /* XXX HACK */
+ WM_get_ndof(win, dval);
if (v3d->ndoffilter)
filterNDOFvalues(fval);
@@ -2887,7 +2889,8 @@
// XXX BIF_view3d_previewrender_signal(ar, PR_DBASE|PR_DISPRECT);
}
-void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int UNUSED(mode))
+/* XXX HACK */
+void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int UNUSED(mode), wmWindow *win)
{
RegionView3D *rv3d= ar->regiondata;
float fval[7];
@@ -2958,7 +2961,8 @@
// sbadjust *= 60 * frametime; /* normalize ndof device adjustments to 100Hz for framerate independence */
/* fetch the current state of the ndof device & enforce dominant mode if selected */
-// XXX getndof(fval);
+ /* XXX HACK */
+ WM_get_ndof(win, fval);
if (v3d->ndoffilter)
filterNDOFvalues(fval);
Index: source/blender/editors/include/ED_view3d.h
===================================================================
--- source/blender/editors/include/ED_view3d.h (revisão 34012)
+++ source/blender/editors/include/ED_view3d.h (cópia de trabalho)
@@ -47,8 +47,9 @@
struct Scene;
struct View3D;
struct ViewContext;
+/* XXX HACK */
+struct wmWindow;
-
/* for derivedmesh drawing callbacks, for view3d_select, .... */
typedef struct ViewContext {
struct Scene *scene;
@@ -172,5 +173,9 @@
unsigned int ED_viewedit_datamask(struct bScreen *screen);
+/* XXX HACK */
+void viewmoveNDOF(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode, struct wmWindow *win);
+void viewmoveNDOFfly(struct ARegion *ar, struct View3D *v3d, int mode, struct wmWindow *win);
+
#endif /* ED_VIEW3D_H */
More information about the Bf-committers
mailing list