Page Menu
Home
Search
Configure Global Search
Log In
Files
F2476
ndof.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Stealth Apprentice (sapprentice)
Nov 13 2013, 1:04 PM
Size
29 KB
Subscribers
None
ndof.patch
View Options
Index: intern/ghost/GHOST_C-api.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_C-api.h,v
retrieving revision 1.6
diff -u -r1.6 GHOST_C-api.h
--- intern/ghost/GHOST_C-api.h 26 Dec 2003 20:12:40 -0000 1.6
+++ intern/ghost/GHOST_C-api.h 5 Feb 2006 22:55:00 -0000
@@ -264,7 +264,19 @@
extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
GHOST_EventConsumerHandle consumerhandle);
+/***************************************************************************************
+ ** N-degree of freedom device management functionality
+ ***************************************************************************************/
+/**
+ * Open N-degree of freedom devices
+ */
+extern void GHOST_OpenNDOF(GHOST_SystemHandle systemhandle,
+ GHOST_WindowHandle windowhandle,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
+ GHOST_NDOFEventHandler_fp setNdofEventHandler);
/***************************************************************************************
** Cursor management functionality
Index: intern/ghost/GHOST_ISystem.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_ISystem.h,v
retrieving revision 1.7
diff -u -r1.7 GHOST_ISystem.h
--- intern/ghost/GHOST_ISystem.h 24 Jan 2003 05:32:14 -0000 1.7
+++ intern/ghost/GHOST_ISystem.h 5 Feb 2006 22:53:16 -0000
@@ -296,6 +296,20 @@
virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer) = 0;
/***************************************************************************************
+ ** N-degree of freedom device management functionality
+ ***************************************************************************************/
+
+ /**
+ * Starts the N-degree of freedom device manager
+ */
+ virtual void openNDOF(GHOST_IWindow*,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
+ GHOST_NDOFEventHandler_fp setNdofEventHandler) = 0;
+
+
+ /***************************************************************************************
** Cursor management functionality
***************************************************************************************/
Index: intern/ghost/GHOST_Types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_Types.h,v
retrieving revision 1.12
diff -u -r1.12 GHOST_Types.h
--- intern/ghost/GHOST_Types.h 29 Mar 2005 14:27:20 -0000 1.12
+++ intern/ghost/GHOST_Types.h 5 Feb 2006 22:51:18 -0000
@@ -131,6 +131,8 @@
GHOST_kEventWindowUpdate,
GHOST_kEventWindowSize,
+ GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
+
GHOST_kNumEventTypes
} GHOST_TEventType;
@@ -321,6 +323,19 @@
/** Displacement of a mouse wheel. */
GHOST_TInt32 z;
} GHOST_TEventWheelData;
+
+
+typedef int (*GHOST_NDOFLibraryInit_fp)();
+typedef void (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
+typedef void* (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
+typedef int (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
+
+typedef struct {
+ /** N-degree of freedom device data */
+ float tx, ty, tz; /** -x left, +y up, +z forward */
+ float rx, ry, rz;
+ float dt;
+} GHOST_TEventNDOFData;
typedef struct {
/** The key code. */
Index: intern/ghost/intern/GHOST_C-api.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_C-api.cpp,v
retrieving revision 1.4
diff -u -r1.4 GHOST_C-api.cpp
--- intern/ghost/intern/GHOST_C-api.cpp 26 Dec 2003 20:12:40 -0000 1.4
+++ intern/ghost/intern/GHOST_C-api.cpp 5 Feb 2006 22:54:50 -0000
@@ -260,6 +260,18 @@
}
+void GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
+ GHOST_NDOFEventHandler_fp setNdofEventHandler)
+{
+ GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
+
+ system->openNDOF((GHOST_IWindow*) windowhandle,
+ setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen, setNdofEventHandler);
+}
+
GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
{
Index: intern/ghost/intern/GHOST_System.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_System.cpp,v
retrieving revision 1.5
diff -u -r1.5 GHOST_System.cpp
--- intern/ghost/intern/GHOST_System.cpp 1 Jan 2003 21:30:39 -0000 1.5
+++ intern/ghost/intern/GHOST_System.cpp 5 Feb 2006 22:52:44 -0000
@@ -47,13 +47,14 @@
#include "GHOST_DisplayManager.h"
#include "GHOST_EventManager.h"
+#include "GHOST_NDOFManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
GHOST_System::GHOST_System()
-: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0)
+: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0), m_ndofManager(0)
{
}
@@ -240,6 +241,20 @@
}
+void GHOST_System::openNDOF(GHOST_IWindow* w,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
+ GHOST_NDOFEventHandler_fp setNdofEventHandler)
+{
+ m_ndofManager->deviceOpen(w,
+ setNdofLibraryInit,
+ setNdofLibraryShutdown,
+ setNdofDeviceOpen,
+ setNdofEventHandler);
+}
+
+
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool& isDown) const
{
GHOST_ModifierKeys keys;
@@ -271,6 +286,7 @@
m_timerManager = new GHOST_TimerManager ();
m_windowManager = new GHOST_WindowManager ();
m_eventManager = new GHOST_EventManager ();
+ m_ndofManager = new GHOST_NDOFManager();
#ifdef GHOST_DEBUG
if (m_eventManager) {
m_eventManager->addConsumer(&m_eventPrinter);
@@ -306,6 +322,10 @@
delete m_eventManager;
m_eventManager = 0;
}
+ if (m_ndofManager) {
+ delete m_ndofManager;
+ m_ndofManager = 0;
+ }
return GHOST_kSuccess;
}
Index: intern/ghost/intern/GHOST_System.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_System.h,v
retrieving revision 1.6
diff -u -r1.6 GHOST_System.h
--- intern/ghost/intern/GHOST_System.h 28 Dec 2002 22:26:45 -0000 1.6
+++ intern/ghost/intern/GHOST_System.h 5 Feb 2006 22:52:26 -0000
@@ -51,6 +51,7 @@
class GHOST_TimerManager;
class GHOST_Window;
class GHOST_WindowManager;
+class GHOST_NDOFManager;
/**
* Implementation of platform independent functionality of the GHOST_ISystem
@@ -184,6 +185,22 @@
*/
virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer);
+
+
+ /***************************************************************************************
+ ** N-degree of freedom devcice management functionality
+ ***************************************************************************************/
+
+ /** Inherited from GHOST_ISystem
+ * Opens the N-degree of freedom device manager
+ */
+ virtual void openNDOF(GHOST_IWindow* w,
+ GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
+ GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
+ GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
+ GHOST_NDOFEventHandler_fp setNdofEventHandler);
+
+
/***************************************************************************************
** Cursor management functionality
***************************************************************************************/
@@ -244,6 +261,12 @@
virtual inline GHOST_WindowManager* getWindowManager() const;
/**
+ * Returns a pointer to our n-degree of freedeom manager.
+ * @return A pointer to our n-degree of freedeom manager.
+ */
+ virtual inline GHOST_NDOFManager* getNDOFManager() const;
+
+ /**
* Returns the state of all modifier keys.
* @param keys The state of all modifier keys (true == pressed).
* @return Indication of success.
@@ -290,6 +313,9 @@
/** The event manager. */
GHOST_EventManager* m_eventManager;
+ /** The N-degree of freedom device manager */
+ GHOST_NDOFManager* m_ndofManager;
+
/** Prints all the events. */
#ifdef GHOST_DEBUG
GHOST_EventPrinter m_eventPrinter;
@@ -312,6 +338,11 @@
inline GHOST_WindowManager* GHOST_System::getWindowManager() const
{
return m_windowManager;
+}
+
+inline GHOST_NDOFManager* GHOST_System::getNDOFManager() const
+{
+ return m_ndofManager;
}
#endif // _GHOST_SYSTEM_H_
Index: intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_SystemWin32.cpp,v
retrieving revision 1.10
diff -u -r1.10 GHOST_SystemWin32.cpp
--- intern/ghost/intern/GHOST_SystemWin32.cpp 7 Nov 2004 16:30:19 -0000 1.10
+++ intern/ghost/intern/GHOST_SystemWin32.cpp 29 Jan 2006 04:43:50 -0000
@@ -64,6 +64,8 @@
#include "GHOST_EventCursor.h"
#include "GHOST_EventKey.h"
#include "GHOST_EventWheel.h"
+#include "GHOST_NDOFManager.h"
+#include "GHOST_EventNDOF.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
@@ -524,7 +526,19 @@
if (hwnd) {
GHOST_WindowWin32* window = (GHOST_WindowWin32*)::GetWindowLong(hwnd, GWL_USERDATA);
if (window) {
- switch (msg) {
+
+ /* Give N-degree of freedom device manager a chance to process its own events before
+ * letting the regular windows event handlers run. This is because the device
+ * driver might be supplying "fake" events such as wheel mouse events
+ * which we don't want since we're handling everything here.
+ * Note that there may be more than one NDOF device being managed.
+ */
+ GHOST_TEventNDOFData* sbevent = system->getNDOFManager()->handle(msg, (unsigned int*)wParam, (unsigned long*)lParam);
+ if (sbevent != 0)
+ {
+ system->pushEvent(new GHOST_EventNDOF(system->getMilliSeconds(), GHOST_kEventNDOFMotion, window, *sbevent));
+ }
+ else switch (msg) {
////////////////////////////////////////////////////////////////////////
// Keyboard events, processed
////////////////////////////////////////////////////////////////////////
@@ -702,7 +716,7 @@
* is sent to the window that has captured the mouse.
*/
break;
-
+
////////////////////////////////////////////////////////////////////////
// Window events, processed
////////////////////////////////////////////////////////////////////////
Index: intern/ghost/intern/GHOST_WindowWin32.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_WindowWin32.h,v
retrieving revision 1.8
diff -u -r1.8 GHOST_WindowWin32.h
--- intern/ghost/intern/GHOST_WindowWin32.h 26 Dec 2003 22:41:51 -0000 1.8
+++ intern/ghost/intern/GHOST_WindowWin32.h 15 Jan 2006 02:39:28 -0000
@@ -216,6 +216,12 @@
*/
void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
+ /**
+ * Returns the HWND of the window. Needed to initialize the
+ * certain device drivers on Windows.
+ * @Returns the HWND of the window
+ */
+ HWND getHWND() const { return m_hWnd; }
protected:
/**
Index: source/blender/include/BSE_view.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BSE_view.h,v
retrieving revision 1.14
diff -u -r1.14 BSE_view.h
--- source/blender/include/BSE_view.h 28 Jan 2006 18:33:13 -0000 1.14
+++ source/blender/include/BSE_view.h 29 Jan 2006 04:39:16 -0000
@@ -68,6 +68,7 @@
void calctrackballvecfirst(struct rcti *area, short *mval, float *vec);
void calctrackballvec(struct rcti *area, short *mval, float *vec);
void viewmove(int mode);
+void viewmoveNDOF(int mode);
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend);
void setwinmatrixview3d(int winx, int winy, struct rctf *rect);
Index: source/blender/include/mydevice.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/mydevice.h,v
retrieving revision 1.21
diff -u -r1.21 mydevice.h
--- source/blender/include/mydevice.h 28 Jan 2006 18:33:13 -0000 1.21
+++ source/blender/include/mydevice.h 29 Jan 2006 04:24:24 -0000
@@ -70,6 +70,9 @@
#define WINQUIT 0x018 /* signal from user that app is to go away */
#define Q_FIRSTTIME 0x019 /* on startup */
+/* N-degre of freedom device : 500 */
+#define NDOFMOTION 500
+
/* standard keyboard */
#define AKEY 'a'
Index: source/blender/makesdna/DNA_userdef_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_userdef_types.h,v
retrieving revision 1.52
diff -u -r1.52 DNA_userdef_types.h
--- source/blender/makesdna/DNA_userdef_types.h 28 Jan 2006 18:33:14 -0000 1.52
+++ source/blender/makesdna/DNA_userdef_types.h 29 Jan 2006 04:24:26 -0000
@@ -161,7 +161,8 @@
struct SolidLight light[3];
short tw_hotspot, tw_flag, tw_handlesize, tw_size;
int textimeout, texcollectrate;
- short obcenter_dia, pad1, pad2, pad3;
+ short obcenter_dia;
+ short ndof_pan, ndof_rotate, pad1;
} UserDef;
extern UserDef U; /* from usiblender.c !!!! */
Index: source/blender/render/intern/source/convertblender.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/render/intern/source/convertblender.c,v
retrieving revision 1.7
diff -u -r1.7 convertblender.c
--- source/blender/render/intern/source/convertblender.c 4 Feb 2006 13:28:50 -0000 1.7
+++ source/blender/render/intern/source/convertblender.c 5 Feb 2006 18:34:30 -0000
@@ -212,7 +212,7 @@
accum= MEM_callocN(2*sizeof(float)*(re->totvert-startvert), "temp accum for stress");
/* de-normalize orco */
- for(a=startvert; a<re->totvert; a++, acc+=2) {
+ for(a=startvert; a<re->totvert; a++) {
VertRen *ver= RE_findOrAddVert(re, a);
if(ver->orco) {
ver->orco[0]= ver->orco[0]*size[0] +loc[0];
Index: source/blender/src/editscreen.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editscreen.c,v
retrieving revision 1.122
diff -u -r1.122 editscreen.c
--- source/blender/src/editscreen.c 2 Feb 2006 12:16:23 -0000 1.122
+++ source/blender/src/editscreen.c 4 Feb 2006 21:57:50 -0000
@@ -2006,6 +2006,8 @@
/* ************ SCREEN MANAGEMENT ************** */
+/* BIF_wait_for_statechange waits for the window handler to invoke add_to_mainqueue */
+
static int statechanged= 0;
void BIF_wait_for_statechange(void)
{
@@ -2036,6 +2038,11 @@
winlay_process_events(0);
return window_get_mbut(mainwin);
}
+short getndof(short *sbval)
+{
+ winlay_process_events(0);
+ return window_get_ndof(mainwin, sbval);
+}
void add_to_mainqueue(Window *win, void *user_data, short evt, short val, char ascii)
{
@@ -2106,6 +2113,7 @@
}
window_set_handler(mainwin, add_to_mainqueue, NULL);
+ window_open_ndof(mainwin); /* needs to occur once the mainwin handler is set */
init_mainwin();
mywinset(1);
Index: source/blender/src/ghostwinlay.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/ghostwinlay.c,v
retrieving revision 1.42
diff -u -r1.42 ghostwinlay.c
--- source/blender/src/ghostwinlay.c 29 Jan 2006 22:25:53 -0000 1.42
+++ source/blender/src/ghostwinlay.c 5 Feb 2006 23:18:42 -0000
@@ -55,11 +55,15 @@
#include "BIF_usiblender.h"
#include "BIF_cursors.h"
+#include "PIL_dynlib.h"
+
#include "mydevice.h"
#include "blendef.h"
#include "winlay.h"
+#include <math.h>
+
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <Carbon/Carbon.h>
@@ -92,6 +96,12 @@
*/
int faked_mbut;
+ /* Last known ndof device state
+ * note that the ghost device manager
+ * can handle any number of devices, but ghostwinlay can't
+ */
+ float ndof[7]; /* tx, ty, tz, rx, ry, rz, dt */
+
GHOST_TimerTaskHandle timer;
int timer_event;
};
@@ -316,6 +326,7 @@
Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int start_maximized)
{
+ int i;
GHOST_WindowHandle ghostwin;
GHOST_TWindowState inital_state;
int scr_w, scr_h;
@@ -359,8 +370,9 @@
win->lmouse[0]= win->size[0]/2;
win->lmouse[1]= win->size[1]/2;
-
-
+
+ for (i = 0; i < 7; ++i)
+ win->ndof[i] = 0;
} else {
GHOST_DisposeWindow(g_system, ghostwin);
}
@@ -512,6 +524,31 @@
}
switch (type) {
+
+ case GHOST_kEventNDOFMotion: {
+ // update ndof device data, and dispatch motion event
+ GHOST_TEventNDOFData *sb= data;
+
+ win->ndof[0] = sb->tx;
+ win->ndof[1] = sb->ty;
+ win->ndof[2] = sb->tz;
+ win->ndof[3] = sb->rx;
+ win->ndof[4] = sb->ry;
+ win->ndof[5] = sb->rz;
+ win->ndof[6] = sb->dt;
+
+ // start interaction for larger than teeny-tiny motions
+ if ((fabsf(sb->tx) > 0.03f) ||
+ (fabsf(sb->ty) > 0.03f) ||
+ (fabsf(sb->tz) > 0.03f) ||
+ (fabsf(sb->rx) > 0.03f) ||
+ (fabsf(sb->ry) > 0.03f) ||
+ (fabsf(sb->rz) > 0.03f)) {
+ window_handle(win, NDOFMOTION, sb->dt * 255);
+ }
+ break;
+ }
+
case GHOST_kEventCursorMove: {
if(win->active == 1) {
GHOST_TEventCursorData *cd= data;
@@ -707,6 +744,13 @@
mval[1]= win->lmouse[1];
}
+void window_get_ndof(Window* win, float* sbval) {
+ int i;
+ for (i = 0; i < 7; ++i) {
+ *sbval++ = win->ndof[i];
+ }
+}
+
void window_get_position(Window *win, int *posx_r, int *posy_r) {
*posx_r= win->position[0];
*posy_r= win->position[1];
@@ -787,4 +831,19 @@
Window *winlay_get_active_window(void) {
return active_gl_window;
+}
+
+void window_open_ndof(Window* win)
+{
+ PILdynlib* ndofLib = PIL_dynlib_open("NDOFPlugin.plug");
+ 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"),
+ PIL_dynlib_find_symbol(ndofLib, "ndofEventHandler"));
+ }
+ else {
+ GHOST_OpenNDOF(g_system, win->ghostwin, 0, 0, 0, 0);
+ }
}
Index: source/blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.330
diff -u -r1.330 space.c
--- source/blender/src/space.c 5 Feb 2006 14:12:45 -0000 1.330
+++ source/blender/src/space.c 5 Feb 2006 18:06:58 -0000
@@ -1057,6 +1057,10 @@
doredraw= 1;
break;
+
+ case NDOFMOTION:
+ viewmoveNDOF(0);
+ break;
case ONEKEY:
if(G.qual==LR_CTRLKEY) {
@@ -2603,7 +2607,17 @@
(xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/2)),y2,(mpref/2),buth,
&(U.uiflag), 0, 0, 0, 0,
"Keep the active object in place when orbiting the views (Object Mode)");
- uiBlockEndAlign(block);
+
+ uiDefButS(block, NUM, USER_AUTOPERSP, "ndPan",
+ (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y1,(mpref/2),buth,
+ &(U.ndof_pan), 0, 200, 0, 0,
+ "The overall panning speed of an NDOF device, as percent of standard");
+ uiDefButS(block, NUM, USER_ORBIT_SELECTION, "ndRot",
+ (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/2)),y1,(mpref/2),buth,
+ &(U.ndof_rotate), 0, 200, 0, 0,
+ "The overall rotation speed of an NDOF device, as percent of standard");
+
+ uiBlockEndAlign(block);
uiDefBut(block, LABEL,0,"Select with:",
(xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y6label,mpref,buth,
Index: source/blender/src/transform.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/transform.c,v
retrieving revision 1.131
diff -u -r1.131 transform.c
--- source/blender/src/transform.c 19 Dec 2005 16:32:18 -0000 1.131
+++ source/blender/src/transform.c 5 Feb 2006 18:56:10 -0000
@@ -670,8 +670,11 @@
else view_editmove(event);
Trans.redraw= 1;
break;
+ case NDOFMOTION:
+ viewmoveNDOF(0);
+ break;
}
- Trans.redraw |= handleNumInput(&(Trans.num), event);
+ Trans.redraw |= handleNumInput(&(Trans.num), event);
arrows_move_cursor(event);
}
else {
@@ -968,7 +971,10 @@
case RETKEY:
Trans.state = TRANS_CONFIRM;
break;
- }
+ case NDOFMOTION:
+ viewmoveNDOF(0);
+ break;
+ }
if(val) {
switch(event) {
case WHEELDOWNMOUSE:
Index: source/blender/src/usiblender.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/usiblender.c,v
retrieving revision 1.99
diff -u -r1.99 usiblender.c
--- source/blender/src/usiblender.c 29 Jan 2006 13:12:42 -0000 1.99
+++ source/blender/src/usiblender.c 29 Jan 2006 19:05:20 -0000
@@ -169,6 +169,13 @@
U.tw_size= 20; // percentage of window size
U.tw_handlesize= 16; // percentage of widget radius
}
+
+ if (U.ndof_pan==0) {
+ U.ndof_pan = 100;
+ }
+ if (U.ndof_rotate==0) {
+ U.ndof_rotate = 100;
+ }
if (G.main->versionfile <= 191) {
strcpy(U.plugtexdir, U.textudir);
Index: source/blender/src/view.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/view.c,v
retrieving revision 1.62
diff -u -r1.62 view.c
--- source/blender/src/view.c 28 Jan 2006 18:33:22 -0000 1.62
+++ source/blender/src/view.c 4 Feb 2006 23:13:42 -0000
@@ -84,6 +84,11 @@
#include "mydevice.h"
#include "blendef.h"
+/* Modules used */
+
+#include "PIL_time.h"
+#include <float.h>
+
#define TRACKBALLSIZE (1.1)
#define BL_NEAR_CLIP 0.001
@@ -776,6 +781,166 @@
BIF_view3d_previewrender_signal(curarea, PR_PROJECTED);
}
+
+
+
+void viewmoveNDOF(int mode)
+{
+ static double prevTime = 0.0;
+
+ int i;
+ float fval[7];
+ float dvec[3];
+ float sbadjust = 1.0f;
+ float len;
+ double now, frametime;
+ short use_sel = 0;
+ Object *ob = OBACT;
+ float m[3][3];
+ float m_inv[3][3];
+ float xvec[3] = {1,0,0};
+ float phi, si;
+ float q1[4];
+ float obofs[3];
+ float reverse;
+ float diff[4];
+ float d, curareaX, curareaY;
+
+ /* Sensitivity will control how fast the view rotates. The value was
+ * obtained experimentally by tweaking until the author didn't get dizzy watching.
+ * Perhaps this should be a configurable user parameter.
+ */
+ float psens = 0.005f * (float) U.ndof_pan; /* pan sensitivity */
+ const float rsens = 0.005f * (float) U.ndof_rotate; /* rotate sensitivity */
+ const float zsens = 0.1f; /* zoom sensitivity */
+
+ const float minZoom = -30.0f;
+ const float maxZoom = 300.0f;
+
+ if (G.obedit==NULL && ob && !(ob->flag & OB_POSEMODE)) {
+ use_sel = 1;
+ }
+
+ /*----------------------------------------------------
+ * sometimes this routine is called from headerbuttons
+ * viewmove needs to refresh the screen
+ */
+ areawinset(curarea->win);
+
+ /*----------------------------------------------------
+ * record how much time has passed. clamp at 10 Hz
+ * pretend the previous frame occured at the clamped time
+ */
+ now = PIL_check_seconds_timer();
+ frametime = (now - prevTime);
+ if (frametime > 0.1f){ /* if more than 1/10s */
+ frametime = 1.0f/60.0; /* clamp at 1/60s so no jumps when starting to move */
+ }
+ prevTime = now;
+ sbadjust *= 60 * frametime; /* normalize ndof device adjustments to 100Hz for framerate independence */
+
+ /* fetch the current state of the ndof device */
+ getndof(fval);
+
+ /* set object offset */
+ if (ob) {
+ obofs[0] = -ob->obmat[3][0];
+ obofs[1] = -ob->obmat[3][1];
+ obofs[2] = -ob->obmat[3][2];
+ }
+ else {
+ VECCOPY(obofs, G.vd->ofs);
+ }
+
+ /* calc an adjustment based on distance from camera */
+ if (ob) {
+ VecSubf(diff, obofs, G.vd->ofs);
+ d = VecLength(diff);
+ }
+ else {
+ d = 1.0f;
+ }
+ reverse = (G.vd->persmat[2][1] < 0.0f) ? -1.0f : 1.0f;
+
+ /*----------------------------------------------------
+ * ndof device pan
+ */
+ psens *= 1.0f + d;
+ curareaX = sbadjust * psens * fval[0];
+ curareaY = sbadjust * psens * fval[1];
+ dvec[0] = curareaX * G.vd->persinv[0][0] + curareaY * G.vd->persinv[1][0];
+ dvec[1] = curareaX * G.vd->persinv[0][1] + curareaY * G.vd->persinv[1][1];
+ dvec[2] = curareaX * G.vd->persinv[0][2] + curareaY * G.vd->persinv[1][2];
+ VecAddf(G.vd->ofs, G.vd->ofs, dvec);
+
+ /*----------------------------------------------------
+ * ndof device dolly
+ */
+ len = zsens * sbadjust * fval[2];
+
+ if (G.vd->persp==2) {
+ if(G.vd->persp==2) {
+ G.vd->camzoom+= 10.0f * -len;
+ }
+ if (G.vd->camzoom < minZoom) G.vd->camzoom = minZoom;
+ else if (G.vd->camzoom > maxZoom) G.vd->camzoom = maxZoom;
+ }
+ else if ((G.vd->dist> 0.001*G.vd->grid) && (G.vd->dist<10.0*G.vd->far)) {
+ G.vd->dist*=(1.0 + len);
+ }
+
+
+ /*----------------------------------------------------
+ * ndof device turntable
+ * derived from the turntable code in viewmove
+ */
+
+ /* Get the 3x3 matrix and its inverse from the quaternion */
+ QuatToMat3(G.vd->viewquat, m);
+ Mat3Inv(m_inv,m);
+
+ /* Determine the direction of the x vector (for rotating up and down) */
+ /* This can likely be compuated directly from the quaternion. */
+ Mat3MulVecfl(m_inv,xvec);
+
+ /* Perform the up/down rotation */
+ phi = sbadjust * rsens * /*0.5f * */ fval[3]; /* spin vertically half as fast as horizontally */
+ si = sin(phi);
+ q1[0] = cos(phi);
+ q1[1] = si * xvec[0];
+ q1[2] = si * xvec[1];
+ q1[3] = si * xvec[2];
+ QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
+
+ if (use_sel) {
+ QuatConj(q1); /* conj == inv for unit quat */
+ VecSubf(G.vd->ofs, G.vd->ofs, obofs);
+ QuatMulVecf(q1, G.vd->ofs);
+ VecAddf(G.vd->ofs, G.vd->ofs, obofs);
+ }
+
+ /* Perform the orbital rotation */
+ phi = sbadjust * rsens * reverse * fval[4]; /* twist the knob, y axis */
+ q1[0] = cos(phi);
+ q1[1] = q1[2] = 0.0;
+ q1[3] = sin(phi);
+ QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
+
+ if (use_sel) {
+ QuatConj(q1);
+ VecSubf(G.vd->ofs, G.vd->ofs, obofs);
+ QuatMulVecf(q1, G.vd->ofs);
+ VecAddf(G.vd->ofs, G.vd->ofs, obofs);
+ }
+
+ /*----------------------------------------------------
+ * refresh the screen
+ */
+ scrarea_do_windraw(curarea);
+ screen_swapbuffers();
+}
+
+
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend)
{
Index: source/blender/src/winlay.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/winlay.h,v
retrieving revision 1.11
diff -u -r1.11 winlay.h
--- source/blender/src/winlay.h 23 Mar 2005 21:10:02 -0000 1.11
+++ source/blender/src/winlay.h 15 Jan 2006 02:45:54 -0000
@@ -82,3 +82,5 @@
void winlay_process_events (int wait_for_event);
void winlay_get_screensize (int *width_r, int *height_r);
+
+void window_open_ndof(Window* win);
Index: source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp,v
retrieving revision 1.7
diff -u -r1.7 BlenderPlayerCtl.cpp
--- source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp 21 May 2004 09:18:42 -0000 1.7
+++ source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp 29 Jan 2006 05:24:02 -0000
@@ -653,7 +653,7 @@
updateEngineInfoDisplay();
// create a scene converter, create and convert the starting scene
- m_sceneconverter = new KX_BlenderSceneConverter(m_gamedata->main, m_ketsjiengine);
+ m_sceneconverter = new KX_BlenderSceneConverter(m_gamedata->main, 0, m_ketsjiengine);
if (m_sceneconverter)
{
m_ketsjiengine->SetSceneConverter(m_sceneconverter);
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
55/02/068a7ce854170f2e38e4d5efacaa
Event Timeline
Log In to Comment