adding the initial patch updated to 2.44 in ndof branch
notes : it compiles but is non functional lacks the platform specific changes in ghost ( i cant test windows) lacks the code for plug-in. the platform specific code will be added when we sync with Ettore work the plug-in itself cannot be added here
This commit is contained in:
parent
9fec189e7a
commit
16340dfe12
@ -1,4 +1,4 @@
|
||||
LCGDIR = '#../lib/darwin-6.1-powerpc'
|
||||
LCGDIR = '#../../trunk/lib/darwin-6.1-powerpc'
|
||||
LIBDIR = '${LCGDIR}'
|
||||
|
||||
# enable ffmpeg support
|
||||
@ -15,16 +15,17 @@ BF_VERSE_INCLUDE = BF_VERSE
|
||||
BF_VERSE_LIBS = "libverse"
|
||||
|
||||
# python.org libs install in /library
|
||||
BF_PYTHON_VERSION = '2.3'
|
||||
BF_PYTHON_VERSION = '2.5'
|
||||
if BF_PYTHON_VERSION=='2.3':
|
||||
BF_PYTHON = '/System/Library/Frameworks/Python.framework/Versions/'
|
||||
else:
|
||||
BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/'
|
||||
BF_PYTHON = '/Library/Frameworks/Python.framework'
|
||||
|
||||
BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}'
|
||||
BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}'
|
||||
BF_PYTHON_INC = '${BF_PYTHON}/Headers'
|
||||
BF_PYTHON_BINARY = '${BF_PYTHON}/python'
|
||||
BF_PYTHON_LIB = ''
|
||||
BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config'
|
||||
BF_PYTHON_LIBPATH = '${BF_PYTHON}/Versions/${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config'
|
||||
#BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config'
|
||||
BF_PYTHON_LINKFLAGS = '-u __dummy -u _PyMac_Error -framework System -framework Python'
|
||||
|
||||
WITH_BF_OPENAL = 'true'
|
||||
@ -32,7 +33,7 @@ WITH_BF_OPENAL = 'true'
|
||||
# for gcc 3.3
|
||||
#BF_OPENAL = LIBDIR + '/openal'
|
||||
# for gcc 3.4
|
||||
BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal'
|
||||
BF_OPENAL = '#../../trunk/lib/darwin-8.0.0-powerpc/openal'
|
||||
|
||||
BF_OPENAL_INC = '${BF_OPENAL}/include'
|
||||
BF_OPENAL_LIB = 'openal'
|
||||
@ -86,7 +87,7 @@ BF_FTGL_INC = '${BF_FTGL}/include'
|
||||
BF_FTGL_LIB = 'extern_ftgl'
|
||||
|
||||
WITH_BF_GAMEENGINE='true'
|
||||
WITH_BF_PLAYER='true'
|
||||
WITH_BF_PLAYER='false'
|
||||
|
||||
WITH_BF_ODE = 'false'
|
||||
BF_ODE = LIBDIR + '/ode'
|
||||
|
@ -265,6 +265,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
|
||||
|
@ -295,6 +295,20 @@ public:
|
||||
*/
|
||||
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
|
||||
***************************************************************************************/
|
||||
|
@ -133,6 +133,8 @@ typedef enum {
|
||||
GHOST_kEventButtonUp, /// Mouse button event
|
||||
GHOST_kEventWheel, /// Mouse wheel event
|
||||
|
||||
GHOST_kEventNDOFMotion, /// N degree of freedom device motion event
|
||||
|
||||
GHOST_kEventKeyDown,
|
||||
GHOST_kEventKeyUp,
|
||||
// GHOST_kEventKeyAuto,
|
||||
@ -336,6 +338,18 @@ typedef struct {
|
||||
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. */
|
||||
GHOST_TKey key;
|
||||
|
@ -259,6 +259,18 @@ GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_Eve
|
||||
return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
|
||||
}
|
||||
|
||||
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)
|
||||
|
69
intern/ghost/intern/GHOST_EventNDOF.h
Normal file
69
intern/ghost/intern/GHOST_EventNDOF.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* $Id: GHOST_EventNdof.h,v 1.6 2002/12/28 22:26:45 maarten Exp $
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
/**
|
||||
* @file GHOST_EventNdof.h
|
||||
* Declaration of GHOST_EventNdof class.
|
||||
*/
|
||||
|
||||
#ifndef _GHOST_EVENT_NDOF_H_
|
||||
#define _GHOST_EVENT_NDOF_H_
|
||||
|
||||
#include "GHOST_Event.h"
|
||||
|
||||
/**
|
||||
* N-degree of freedom device event.
|
||||
*/
|
||||
class GHOST_EventNDOF : public GHOST_Event
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msec The time this event was generated.
|
||||
* @param type The type of this event.
|
||||
* @param x The x-coordinate of the location the cursor was at at the time of the event.
|
||||
* @param y The y-coordinate of the location the cursor was at at the time of the event.
|
||||
*/
|
||||
GHOST_EventNDOF(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window,
|
||||
GHOST_TEventNDOFData data)
|
||||
: GHOST_Event(msec, type, window)
|
||||
{
|
||||
m_ndofEventData = data;
|
||||
m_data = &m_ndofEventData;
|
||||
}
|
||||
|
||||
protected:
|
||||
/** translation & rotation from the device. */
|
||||
GHOST_TEventNDOFData m_ndofEventData;
|
||||
};
|
||||
|
||||
|
||||
#endif // _GHOST_EVENT_NDOF_H_
|
||||
|
107
intern/ghost/intern/GHOST_NDOFManager.cpp
Normal file
107
intern/ghost/intern/GHOST_NDOFManager.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
|
||||
// Insert Blender compatible license here :-)
|
||||
|
||||
// note: an implementation is currently only provided for Windows, but designed to be easy to move to Linux, etc.
|
||||
|
||||
/**
|
||||
|
||||
To use this implemenation, you must specify the #define WITH_SPACEBALL for the ghost library.
|
||||
Only this cpp file is affected by the macro, the header file and everything else are independent
|
||||
of the spaceball libraries.
|
||||
|
||||
The 3dXWare SDK is available from the tab on the left side of -
|
||||
http://www.3dconnexion.com/support/4a.php
|
||||
|
||||
The SDK is necessary to build this file with WITH_SPACEBALL defined.
|
||||
|
||||
For this stuff to work, siappdll.dll and spwini.dll must be in the executable path of blender
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "GHOST_NDOFManager.h"
|
||||
//#include "GHOST_WindowWin32.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
GHOST_NDOFLibraryInit_fp ndofLibraryInit = 0;
|
||||
GHOST_NDOFLibraryShutdown_fp ndofLibraryShutdown = 0;
|
||||
GHOST_NDOFDeviceOpen_fp ndofDeviceOpen = 0;
|
||||
GHOST_NDOFEventHandler_fp ndofEventHandler = 0;
|
||||
}
|
||||
|
||||
|
||||
//typedef enum SpwRetVal (WINAPI *PFNSI_INIT) (void);
|
||||
|
||||
GHOST_NDOFManager::GHOST_NDOFManager()
|
||||
{
|
||||
m_DeviceHandle = 0;
|
||||
|
||||
// discover the API from the plugin
|
||||
ndofLibraryInit = 0;
|
||||
ndofLibraryShutdown = 0;
|
||||
ndofDeviceOpen = 0;
|
||||
ndofEventHandler = 0;
|
||||
}
|
||||
|
||||
GHOST_NDOFManager::~GHOST_NDOFManager()
|
||||
{
|
||||
if (ndofLibraryShutdown)
|
||||
ndofLibraryShutdown(m_DeviceHandle);
|
||||
|
||||
m_DeviceHandle = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window,
|
||||
GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
|
||||
GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
|
||||
GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
|
||||
GHOST_NDOFEventHandler_fp setNdofEventHandler)
|
||||
{
|
||||
ndofLibraryInit = setNdofLibraryInit;
|
||||
ndofLibraryShutdown = setNdofLibraryShutdown;
|
||||
ndofDeviceOpen = setNdofDeviceOpen;
|
||||
ndofEventHandler = setNdofEventHandler;
|
||||
|
||||
if (ndofLibraryInit)
|
||||
{
|
||||
ndofLibraryInit();
|
||||
}
|
||||
/*
|
||||
if (ndofDeviceOpen)
|
||||
{
|
||||
GHOST_WindowWin32* win32 = (GHOST_WindowWin32*) window; // GHOST_IWindow doesn't have RTTI...
|
||||
if (win32 != 0)
|
||||
{
|
||||
m_DeviceHandle = ndofDeviceOpen(win32->getHWND());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
GHOST_TEventNDOFData*
|
||||
GHOST_NDOFManager::handle(unsigned int message, unsigned int* wParam, unsigned long* lParam)
|
||||
{
|
||||
static GHOST_TEventNDOFData sbdata;
|
||||
int handled = 0;
|
||||
if (ndofEventHandler && m_DeviceHandle != 0)
|
||||
{
|
||||
handled = ndofEventHandler(&sbdata.tx, m_DeviceHandle, message, wParam, lParam);
|
||||
}
|
||||
return handled ? &sbdata : 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GHOST_NDOFManager::available()
|
||||
{
|
||||
return m_DeviceHandle != 0;
|
||||
}
|
39
intern/ghost/intern/GHOST_NDOFManager.h
Normal file
39
intern/ghost/intern/GHOST_NDOFManager.h
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef _GHOST_NDOFMANAGER_H_
|
||||
#define _GHOST_NDOFMANAGER_H_
|
||||
|
||||
#include "GHOST_System.h"
|
||||
#include "GHOST_IWindow.h"
|
||||
|
||||
|
||||
|
||||
class GHOST_NDOFManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
GHOST_NDOFManager();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~GHOST_NDOFManager();
|
||||
|
||||
void deviceOpen(GHOST_IWindow* window,
|
||||
GHOST_NDOFLibraryInit_fp setNdofLibraryInit,
|
||||
GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
|
||||
GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen,
|
||||
GHOST_NDOFEventHandler_fp setNdofEventHandler);
|
||||
|
||||
bool available();
|
||||
|
||||
/* to do: abstract for Linux, MacOS, etc. */
|
||||
GHOST_TEventNDOFData* handle(unsigned int message, unsigned int* wparam, unsigned long* lparam);
|
||||
|
||||
protected:
|
||||
void* m_DeviceHandle;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@ -239,6 +240,19 @@ GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent* event)
|
||||
return success;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
@ -271,6 +285,11 @@ GHOST_TSuccess GHOST_System::init()
|
||||
m_timerManager = new GHOST_TimerManager ();
|
||||
m_windowManager = new GHOST_WindowManager ();
|
||||
m_eventManager = new GHOST_EventManager ();
|
||||
m_ndofManager = new GHOST_NDOFManager();
|
||||
|
||||
if(m_ndofManager)
|
||||
printf("ndof manager \n");
|
||||
|
||||
#ifdef GHOST_DEBUG
|
||||
if (m_eventManager) {
|
||||
m_eventManager->addConsumer(&m_eventPrinter);
|
||||
@ -306,6 +325,10 @@ GHOST_TSuccess GHOST_System::exit()
|
||||
delete m_eventManager;
|
||||
m_eventManager = 0;
|
||||
}
|
||||
if (m_ndofManager) {
|
||||
delete m_ndofManager;
|
||||
m_ndofManager = 0;
|
||||
}
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ class GHOST_Event;
|
||||
class GHOST_TimerManager;
|
||||
class GHOST_Window;
|
||||
class GHOST_WindowManager;
|
||||
class GHOST_NDOFManager;
|
||||
|
||||
/**
|
||||
* Implementation of platform independent functionality of the GHOST_ISystem
|
||||
@ -184,6 +185,24 @@ public:
|
||||
*/
|
||||
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
|
||||
***************************************************************************************/
|
||||
@ -243,6 +262,12 @@ public:
|
||||
*/
|
||||
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).
|
||||
@ -290,6 +315,9 @@ protected:
|
||||
/** 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;
|
||||
@ -314,5 +342,10 @@ inline GHOST_WindowManager* GHOST_System::getWindowManager() const
|
||||
return m_windowManager;
|
||||
}
|
||||
|
||||
inline GHOST_NDOFManager* GHOST_System::getNDOFManager() const
|
||||
{
|
||||
return m_ndofManager;
|
||||
}
|
||||
|
||||
#endif // _GHOST_SYSTEM_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 viewmoveNDOF(int mode);
|
||||
|
||||
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
|
||||
void setwinmatrixview3d(int winx, int winy, struct rctf *rect);
|
||||
|
@ -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'
|
||||
|
@ -181,7 +181,9 @@ typedef struct UserDef {
|
||||
short recent_files; /* maximum number of recently used files to remember */
|
||||
short smooth_viewtx; /* miliseconds to spend spinning the view */
|
||||
short glreslimit;
|
||||
char pad[4];
|
||||
short ndof_pan, ndof_rotate;
|
||||
// short pads[4];
|
||||
// char pad[8];
|
||||
} UserDef;
|
||||
|
||||
extern UserDef U; /* from usiblender.c !!!! */
|
||||
|
@ -2163,6 +2163,12 @@ short get_activedevice(void)
|
||||
return window_get_activedevice(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)
|
||||
{
|
||||
|
||||
@ -2227,6 +2233,7 @@ static bScreen *addscreen(char *name) /* use setprefsize() if you want somethin
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -55,11 +55,16 @@
|
||||
#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>
|
||||
#define __CARBONSOUND__
|
||||
@ -107,6 +112,12 @@ struct _Window {
|
||||
*/
|
||||
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;
|
||||
};
|
||||
@ -334,6 +345,7 @@ Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int s
|
||||
GHOST_WindowHandle ghostwin;
|
||||
GHOST_TWindowState inital_state;
|
||||
int scr_w, scr_h;
|
||||
int i;
|
||||
|
||||
winlay_get_screensize(&scr_w, &scr_h);
|
||||
posy= (scr_h-posy-sizey);
|
||||
@ -366,7 +378,10 @@ Window *window_open(char *title, int posx, int posy, int sizex, int sizey, int s
|
||||
|
||||
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);
|
||||
@ -538,6 +553,31 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
}
|
||||
|
||||
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;
|
||||
@ -705,6 +745,13 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void window_get_ndof(Window* win, float* sbval) {
|
||||
int i;
|
||||
for (i = 0; i < 7; ++i) {
|
||||
*sbval++ = win->ndof[i];
|
||||
}
|
||||
}
|
||||
|
||||
char *window_get_title(Window *win) {
|
||||
char *title= GHOST_GetTitle(win->ghostwin);
|
||||
char *mem_title= BLI_strdup(title);
|
||||
@ -831,3 +878,21 @@ void winlay_get_screensize(int *width_r, int *height_r) {
|
||||
Window *winlay_get_active_window(void) {
|
||||
return active_gl_window;
|
||||
}
|
||||
|
||||
void window_open_ndof(Window* win)
|
||||
{
|
||||
PILdynlib* ndofLib = PIL_dynlib_open("NDOFPlugin.plug");
|
||||
printf("passing here \n");
|
||||
if (ndofLib) {
|
||||
printf("and here \n");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1566,6 +1566,10 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
doredraw= 1;
|
||||
break;
|
||||
|
||||
case NDOFMOTION:
|
||||
viewmoveNDOF(0);
|
||||
break;
|
||||
|
||||
case ONEKEY:
|
||||
if(G.qual==LR_CTRLKEY) {
|
||||
flip_subdivison(1);
|
||||
@ -3330,7 +3334,9 @@ void drawinfospace(ScrArea *sa, void *spacedata)
|
||||
(xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/2)),y2,(mpref/2),buth,
|
||||
&(U.uiflag), 0, 0, 0, 0,
|
||||
"Use selection as the orbiting center");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
@ -3442,6 +3448,18 @@ void drawinfospace(ScrArea *sa, void *spacedata)
|
||||
&(U.obcenter_dia), 4, 10, 0, 0,
|
||||
"Diameter in Pixels for Object/Lamp center display");
|
||||
|
||||
uiDefBut(block, LABEL,0,"6DOF devices speeds :",
|
||||
(xpos+edgsp+(5*mpref)+(6*midsp)),y2label,mpref,buth,
|
||||
0, 0, 0, 0, 0, "");
|
||||
//FIXME NDOF BAD ETIQUETTES
|
||||
uiDefButS(block, NUM, USER_AUTOPERSP, "ndPan",
|
||||
(xpos+edgsp+(5*mpref)+(6*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+(5*mpref)+(6*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");
|
||||
|
||||
} else if (U.userpref == 1) { /* edit methods */
|
||||
|
||||
|
@ -726,6 +726,9 @@ static void transformEvent(unsigned short event, short val) {
|
||||
else view_editmove(event);
|
||||
Trans.redraw= 1;
|
||||
break;
|
||||
case NDOFMOTION:
|
||||
viewmoveNDOF(0);
|
||||
break;
|
||||
}
|
||||
Trans.redraw |= handleNumInput(&(Trans.num), event);
|
||||
Trans.redraw |= handleSnapping(&Trans, event);
|
||||
@ -1072,6 +1075,9 @@ void ManipulatorTransform()
|
||||
case RETKEY:
|
||||
Trans.state = TRANS_CONFIRM;
|
||||
break;
|
||||
case NDOFMOTION:
|
||||
viewmoveNDOF(0);
|
||||
break;
|
||||
}
|
||||
if(val) {
|
||||
switch(event) {
|
||||
|
@ -190,6 +190,13 @@ static void init_userdef_file(void)
|
||||
if(U.pad_rot_angle==0)
|
||||
U.pad_rot_angle= 15;
|
||||
|
||||
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);
|
||||
strcpy(U.sounddir, "/");
|
||||
|
@ -88,6 +88,7 @@
|
||||
#include "blendef.h"
|
||||
|
||||
#include "PIL_time.h" /* smoothview */
|
||||
#include <float.h>
|
||||
|
||||
#define TRACKBALLSIZE (1.1)
|
||||
#define BL_NEAR_CLIP 0.001
|
||||
@ -800,6 +801,169 @@ void viewmove(int mode)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Gets the lens and clipping values from a camera of lamp type object */
|
||||
void object_view_settings(Object *ob, float *lens, float *clipsta, float *clipend)
|
||||
{
|
||||
|
@ -79,6 +79,8 @@ void window_warp_pointer (Window *win, int x, int y);
|
||||
|
||||
void window_queue_redraw (Window *win);
|
||||
|
||||
void window_open_ndof(Window* win);
|
||||
|
||||
/* Global windowing operations */
|
||||
|
||||
Window* winlay_get_active_window(void);
|
||||
|
Loading…
Reference in New Issue
Block a user