Index: source/blender/src/ghostwinlay.c =================================================================== --- source/blender/src/ghostwinlay.c (revision 11248) +++ source/blender/src/ghostwinlay.c (working copy) @@ -889,15 +889,50 @@ return active_gl_window; } +#ifdef _WIN32 +#define PATH_SEP "\\" +#else +#define PATH_SEP "/" +#endif + void window_open_ndof(Window* win) { - PILdynlib* ndofLib = PIL_dynlib_open("XXXXXXX-PUT-HERE-YOUR-PATH-TO-THE-PLUG--/spaceplug.plug"); - if (ndofLib) { + char *inst_path, *plug_path; + const char *plug_dir = "plugins"; + const char *plug_name = "3DxNdofBlender.plug"; + PILdynlib *ndofLib; - GHOST_OpenNDOF(g_system, win->ghostwin, - PIL_dynlib_find_symbol(ndofLib, "ndofInit"), - PIL_dynlib_find_symbol(ndofLib, "ndofShutdown"), - PIL_dynlib_find_symbol(ndofLib, "ndofOpen")); + // 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); +#if 0 + fprintf(stderr, "plugin path=%s; ndofLib=%p\n", plug_path, (void*)ndofLib); +#endif + + if (plug_path) + MEM_freeN(plug_path); + + if (ndofLib) { + GHOST_OpenNDOF(g_system, win->ghostwin, + PIL_dynlib_find_symbol(ndofLib, "ndofInit"), + PIL_dynlib_find_symbol(ndofLib, "ndofShutdown"), + PIL_dynlib_find_symbol(ndofLib, "ndofOpen")); // original patch only // PIL_dynlib_find_symbol(ndofLib, "ndofEventHandler")); Index: source/blender/blenlib/BLI_blenlib.h =================================================================== --- source/blender/blenlib/BLI_blenlib.h (revision 11248) +++ source/blender/blenlib/BLI_blenlib.h (working copy) @@ -247,6 +247,8 @@ */ void BLI_where_am_i(char *fullname, char *name); +char *get_install_dir(void); + /** * determines the full path to the application bundle on OS X * Index: source/blender/blenloader/intern/writefile.c =================================================================== --- source/blender/blenloader/intern/writefile.c (revision 11248) +++ source/blender/blenloader/intern/writefile.c (working copy) @@ -1981,7 +1981,7 @@ #define PATHSEPERATOR "/" #endif -static char *get_install_dir(void) { +char *get_install_dir(void) { extern char bprogname[]; char *tmpname = BLI_strdup(bprogname); char *cut;