diff options
| author | Wim Vriend <facetracknoir@gmail.com> | 2010-07-17 12:20:26 +0000 | 
|---|---|---|
| committer | Wim Vriend <facetracknoir@gmail.com> | 2010-07-17 12:20:26 +0000 | 
| commit | eaacd47152e280baf330f88591dda6a04953a628 (patch) | |
| tree | 94f4a0ca42047b367b07838585f228d139ae257b | |
| parent | 1de2c6cab939b0d887b8d2acc59fe24939df2cfc (diff) | |
Added TrackIR support
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@15 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
27 files changed, 925 insertions, 168 deletions
diff --git a/FaceTrackNoIR.ncb b/FaceTrackNoIR.ncb Binary files differindex f3ad3e60..8cf3818c 100644 --- a/FaceTrackNoIR.ncb +++ b/FaceTrackNoIR.ncb diff --git a/FaceTrackNoIR.sln b/FaceTrackNoIR.sln index 1f25f7c2..d1c96190 100644 --- a/FaceTrackNoIR.sln +++ b/FaceTrackNoIR.sln @@ -5,6 +5,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FaceTrackNoIR", "FaceTrackN  EndProject
  Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "SetupFaceTrackNoIR", "SetupFaceTrackNoIR\SetupFaceTrackNoIR.vdproj", "{95D54F4D-F5E2-4DEC-B517-E32F34312C07}"
  EndProject
 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_ProtocolTester", "FTNoIR_ProtocolTester\FTNoIR_ProtocolTester.vcproj", "{52D2A4B6-7D76-437B-AD7F-7CDB13F2D27C}"
 +EndProject
  Global
  	GlobalSection(SolutionConfigurationPlatforms) = preSolution
  		Debug|Win32 = Debug|Win32
 @@ -17,6 +19,10 @@ Global  		{9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.Build.0 = Release|Win32
  		{95D54F4D-F5E2-4DEC-B517-E32F34312C07}.Debug|Win32.ActiveCfg = Debug
  		{95D54F4D-F5E2-4DEC-B517-E32F34312C07}.Release|Win32.ActiveCfg = Release
 +		{52D2A4B6-7D76-437B-AD7F-7CDB13F2D27C}.Debug|Win32.ActiveCfg = Debug|Win32
 +		{52D2A4B6-7D76-437B-AD7F-7CDB13F2D27C}.Debug|Win32.Build.0 = Debug|Win32
 +		{52D2A4B6-7D76-437B-AD7F-7CDB13F2D27C}.Release|Win32.ActiveCfg = Release|Win32
 +		{52D2A4B6-7D76-437B-AD7F-7CDB13F2D27C}.Release|Win32.Build.0 = Release|Win32
  	EndGlobalSection
  	GlobalSection(SolutionProperties) = preSolution
  		HideSolutionNode = FALSE
 diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo Binary files differindex 926106cd..bf792cac 100644 --- a/FaceTrackNoIR.suo +++ b/FaceTrackNoIR.suo diff --git a/FaceTrackNoIR/FTIRServer.cpp b/FaceTrackNoIR/FTIRServer.cpp new file mode 100644 index 00000000..bee31ca0 --- /dev/null +++ b/FaceTrackNoIR/FTIRServer.cpp @@ -0,0 +1,255 @@ +/********************************************************************************
 +* FTIRServer		FTIRServer is the Class, that communicates headpose-data	*
 +*					to games, using the NPClient.dll.		         			*
 +*																				*
 +* Copyright (C) 2010	Wim Vriend (Developing)									*
 +*						Ron Hendriks (Testing and Research)						*
 +*																				*
 +* 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 3 of the License, or (at your		*
 +* option) any later version.													*
 +*																				*
 +* 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, see <http://www.gnu.org/licenses/>.				*
 +*																				*
 +********************************************************************************/
 +/*
 +	Modifications (last one on top):
 +*/
 +#include "FTIRServer.h"
 +
 +
 +float FTIRServer::virtPosX = 0.0f;
 +float FTIRServer::virtPosY = 0.0f;
 +float FTIRServer::virtPosZ = 0.0f;
 +
 +float FTIRServer::virtRotX = 0.0f;
 +float FTIRServer::virtRotY = 0.0f;
 +float FTIRServer::virtRotZ = 0.0f;
 +
 +/** constructor **/
 +FTIRServer::FTIRServer() {
 +
 +	// Create events
 +	m_StopThread = CreateEvent(0, TRUE, FALSE, 0);
 +	m_WaitThread = CreateEvent(0, TRUE, FALSE, 0);
 +
 +	ProgramName = "";
 +}
 +
 +/** destructor **/
 +FTIRServer::~FTIRServer() {
 +
 +	// Trigger thread to stop
 +	::SetEvent(m_StopThread);
 +
 +	// Wait until thread finished
 +	::WaitForSingleObject(m_WaitThread, INFINITE);
 +
 +	// Close handles
 +	::CloseHandle(m_StopThread);
 +	::CloseHandle(m_WaitThread);
 +
 +	//
 +	// Free the DLL
 +	//
 +	FTIRClientLib.unload();
 +
 +	//terminates the QThread and waits for finishing the QThread
 +	terminate();
 +	wait();
 +}
 +
 +/** QThread run @override **/
 +void FTIRServer::run() {
 +	importSetPosition setposition;
 +
 +	//
 +	// Get the setposition function from the DLL and use it!
 +	//
 +	setposition = (importSetPosition) FTIRClientLib.resolve("SetPosition");
 +	if (setposition == NULL) {
 +		qDebug() << "FTIRServer::run() says: SetPosition function not found in DLL!";
 +		return;
 +	}
 +	else {
 +		setposition (7.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f);
 +	}
 +
 +	forever
 +	{
 +	    // Check event for stop thread
 +		if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0)
 +		{
 +			// Set event
 +			::SetEvent(m_WaitThread);
 +			return;
 +		}
 +
 +		if ( (pMemData != NULL) && (WaitForSingleObject(hFTIRMutex, 100) == WAIT_OBJECT_0) ) {
 +
 +//			qDebug() << "FTIRServer says: virtRotX =" << virtRotX << " virtRotY =" << virtRotY;
 +			setposition (virtPosX, virtPosY, virtPosZ, virtRotZ, virtRotX, virtRotY );
 +
 +			//qDebug() << "FTIRServer says: pMemData.xRot =" << pMemData->data.xRot << " yRot =" << pMemData->data.yRot;
 +			ReleaseMutex(hFTIRMutex);
 +		}
 +
 +		// just for lower cpu load
 +		msleep(15);	
 +		yieldCurrentThread();
 +	}
 +}
 +
 +//
 +// Create a memory-mapping to the Freetrack data.
 +// It contains the tracking data, a handle to the main-window and the program-name of the Game!
 +//
 +//
 +bool FTIRServer::FTIRCreateMapping(HANDLE handle)
 +{
 +	bool result;
 +
 +	qDebug() << "FTIRCreateMapping says: Starting Function";
 +
 +	//
 +	// A FileMapping is used to create 'shared memory' between the FTIRServer and the FTClient.
 +	//
 +	// Try to create a FileMapping to the Shared Memory.
 +	// If one already exists: close it.
 +	//
 +	hFTIRMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , 
 +		                           sizeof( TRACKIRDATA ) + sizeof( HANDLE ) + 100, 
 +								   (LPCSTR) FTIR_MM_DATA );
 +
 +	if ( hFTIRMemMap != 0 ) {
 +		qDebug() << "FTIRCreateMapping says: FileMapping Created!" << hFTIRMemMap;
 +	}
 +
 +	if ( ( hFTIRMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) {
 +		CloseHandle( hFTIRMemMap );
 +		hFTIRMemMap = 0;
 +	}
 +
 +	//
 +	// Create a new FileMapping, Read/Write access
 +	//
 +	hFTIRMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FTIR_MM_DATA );
 +	if ( ( hFTIRMemMap != 0 ) ) {
 +		qDebug() << "FTIRCreateMapping says: FileMapping Created again:" << hFTIRMemMap;
 +		pMemData = (FTIRMemMap *) MapViewOfFile(hFTIRMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TRACKIRDATA) + sizeof(hFTIRMemMap) + 100);
 +		if (pMemData != NULL) {
 +			pMemData->RegisteredHandle = handle;	// The game uses the handle, to send a message that the Program-Name was set!
 +		}
 +	    hFTIRMutex = CreateMutexA(NULL, false, FTIR_MUTEX);
 +	}
 +	else {
 +		QMessageBox::information(0, "FaceTrackNoIR error", QString("FTIRServer Error! \n"));
 +		return false;
 +	}
 +
 +  result = false;
 +return result;
 +}
 +
 +//
 +// Destory the FileMapping to the shared memory
 +//
 +void FTIRServer::FTIRDestroyMapping()
 +{
 +	if ( pMemData != NULL ) {
 +		UnmapViewOfFile ( pMemData );
 +	}
 +	
 +	CloseHandle( hFTIRMutex );
 +	CloseHandle( hFTIRMemMap );
 +	hFTIRMemMap = 0;
 +}
 +
 +//
 +// Check if the Client DLL exists and load it (to test it), if so.
 +// Returns 'true' if all seems OK.
 +//
 +bool FTIRServer::FTIRCheckClientDLL()
 +{   
 +	QSettings settings("NaturalPoint", "NATURALPOINT\\NPClient Location");	// Registry settings (in HK_USER)
 +	QString aLocation;														// Location of Client DLL
 +	QString aFileName;														// File Path and Name
 +
 +	//importProvider provider;
 +	//char *pProvider;
 +
 +	qDebug() << "FTCheckClientDLL says: Starting Function";
 +
 +	try {
 +
 +		//
 +		// Load the NPClient.dll from the current path of FaceTrackNoIR, because there is no
 +		// guarantee TrackIR or GlovePIE is also installed.
 +		//
 +		// Write this path in the registry (under NaturalPoint/NATURALPOINT, for the game(s).
 +		//
 +		aLocation =  QCoreApplication::applicationDirPath() + "/";
 +		qDebug() << "FTCheckClientDLL says: Location of DLL =" << aLocation;
 +
 +		//
 +		// Append a '/' to the Path and then the name of the dll.
 +		//
 +		aFileName = aLocation;
 +		aFileName.append(FTIR_CLIENT_FILENAME);
 +		qDebug() << "FTCheckClientDLL says: Full path of DLL =" << aFileName;
 +						
 +		if ( QFile::exists( aFileName ) ) {
 +			qDebug() << "FTCheckClientDLL says: DLL exists!";
 +			//
 +			// Write the path to the key in the Registry, so the game(s) can find it too...
 +			//
 +			settings.setValue( "Path" , aLocation );
 +
 +			//
 +			// Load the DLL and map to the functions in it.
 +			//
 +			FTIRClientLib.setFileName(aFileName);
 +			FTIRClientLib.load();
 +			//provider = (importProvider) FTIRClientLib.resolve("FTProvider");
 +			//if (provider) {
 +			//	pProvider = provider();
 +			//	qDebug() << "FTCheckClientDLL says: Provider =" << pProvider;
 +			//}
 +		}
 +		else {
 +			QMessageBox::information(0, "FaceTrackNoIR error", QString("Necessary file (NPClient.dll) was NOT found!\n"));
 +			return false;
 +		}
 +	} catch(...) {
 +		settings.~QSettings();
 +	}
 +	return true;
 +}
 +
 +//
 +// Scale the measured value to the Joystick values
 +//
 +float FTIRServer::scale2AnalogLimits( float x, float min_x, float max_x ) {
 +double y;
 +double local_x;
 +	
 +	local_x = x;
 +	if (local_x > max_x) {
 +		local_x = max_x;
 +	}
 +	if (local_x < min_x) {
 +		local_x = min_x;
 +	}
 +	y = ( NP_AXIS_MAX * local_x ) / max_x;
 +
 +	return (float) y;
 +}
 +
 +//END
 diff --git a/FaceTrackNoIR/FTIRServer.h b/FaceTrackNoIR/FTIRServer.h new file mode 100644 index 00000000..868beaaf --- /dev/null +++ b/FaceTrackNoIR/FTIRServer.h @@ -0,0 +1,118 @@ +/********************************************************************************
 +* FTIRServer		FTIRServer is the Class, that communicates headpose-data	*
 +*					to games, using the NPClient.dll.		         			*
 +*																				*
 +* Copyright (C) 2010	Wim Vriend (Developing)									*
 +*						Ron Hendriks (Testing and Research)						*
 +*																				*
 +* 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 3 of the License, or (at your		*
 +* option) any later version.													*
 +*																				*
 +* 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, see <http://www.gnu.org/licenses/>.				*
 +*																				*
 +********************************************************************************/
 +#pragma once
 +#ifndef INCLUDED_FTIRSERVER_H
 +#define INCLUDED_FTIRSERVER_H
 + 
 +//#include "Windows.h" 
 +#include "FTIRTypes.h"
 +#include <QString>
 +#include <QMessageBox>
 +#include <QSettings>
 +#include <QFile>
 +#include <QApplication>
 +#include <QDebug>
 +#include <QThread>
 +#include <QMutex>
 +#include <QLibrary>
 +#include <QUdpSocket>
 +
 +typedef void (WINAPI *importSetPosition)(float x, float y, float z, float xRot, float yRot, float zRot);
 +//typedef bool (WINAPI *importGetData)(TFreeTrackData * data);
 +//typedef HANDLE (WINAPI *importGetMapHandle)(void);
 +
 +using namespace std;
 +
 +class FTIRServer : public QThread {
 +	Q_OBJECT
 +
 +public: 
 +
 +	// public member methods
 +	FTIRServer();
 +	~FTIRServer();
 +
 +	bool FTIRCreateMapping(HANDLE handle);
 +	void FTIRDestroyMapping();
 +	bool FTIRCheckClientDLL();
 +
 +	// protected member methods
 +protected:
 +	void run();
 +
 +private:
 +	// Handles to neatly terminate thread...
 +	HANDLE m_StopThread;
 +	HANDLE m_WaitThread;
 +
 +	HANDLE hFTIRMemMap;
 +	FTIRMemMap *pMemData;
 +	HANDLE hFTIRMutex;
 +
 +	///** member varables for saving the head pose **/
 +	//float headPosX;
 +	//float headPosY;
 +	//float headPosZ;
 +	//
 +	//float headRotX;
 +	//float headRotY;
 +	//float headRotZ;
 +	//bool confid;
 +
 +
 +	// Private properties
 +	QString ProgramName;
 +	QLibrary FTIRClientLib;
 +	float scale2AnalogLimits( float x, float min_x, float max_x );
 +
 +public:
 +
 +	// Settings for calculating the Virtual Pose
 +	static float virtPosX;
 +	static float virtPosY;
 +	static float virtPosZ;
 +	
 +	static float virtRotX;
 +	static float virtRotY;
 +	static float virtRotZ;
 +
 +	//void setHeadPosX(float x) { headPosX = x; }
 +	//void setHeadPosY(float y) { headPosY = y; }
 +	//void setHeadPosZ(float z) { headPosZ = z; }
 +
 +	//void setHeadRotX(float x) { headRotX = x; }
 +	//void setHeadRotY(float y) { headRotY = y; }
 +	//void setHeadRotZ(float z) { headRotZ = z; }
 +
 +	void setVirtRotX(float rot) { virtRotX = scale2AnalogLimits (rot, -180.0f, 180.0f); }
 +	void setVirtRotY(float rot) { virtRotY = scale2AnalogLimits (rot, -180.0f, 180.0f); }
 +	void setVirtRotZ(float rot) { virtRotZ = scale2AnalogLimits (rot, -180.0f, 180.0f); }
 +
 +	void setVirtPosX(float pos) { virtPosX = scale2AnalogLimits (pos, -50.0f, 50.0f); }
 +	void setVirtPosY(float pos) { virtPosY = scale2AnalogLimits (pos, -50.0f, 50.0f); }
 +	void setVirtPosZ(float pos) { virtPosZ = scale2AnalogLimits (pos, -50.0f, 50.0f); }
 +
 +};
 +
 +
 +#endif//INCLUDED_FTIRSERVER_H
 +//END
 diff --git a/FaceTrackNoIR/FTIRTypes.h b/FaceTrackNoIR/FTIRTypes.h new file mode 100644 index 00000000..6402245e --- /dev/null +++ b/FaceTrackNoIR/FTIRTypes.h @@ -0,0 +1,196 @@ +/********************************************************************************
 +* FTIRTypes			FTIRTypes contains the specific type definitions for the	*
 +*					Fake TrackIR protocol.					         			*
 +*					It was modelled after FTTypes.cpp.							*
 +*																				*
 +* Copyright (C) 2010	Wim Vriend (Developing)									*
 +*						Ron Hendriks (Testing and Research)						*
 +*																				*
 +* 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 3 of the License, or (at your		*
 +* option) any later version.													*
 +*																				*
 +* 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, see <http://www.gnu.org/licenses/>.				*
 +*																				*
 +********************************************************************************/
 +#pragma once
 +#ifndef INCLUDED_FTIRTYPES_H
 +#define INCLUDED_FTIRTYPES_H
 +  
 +#include "Windows.h" 
 +#include <tchar.h>
 +#include <stdio.h>
 +
 +//#include "Registry.h"
 +
 +//
 +// Versioning hasn't been worked out yet...
 +//
 +// The following is the previous spec definition of versioning info -- I can probably do
 +// something very similar to this -- will keep you posted.
 +//
 +// request version information using 2 messages, they cannot be expected to arrive in a specific order - so always parse using the High byte
 +// the messages have a NPCONTROL byte in the first parameter, and the second parameter has packed bytes.
 +//   Message 1) (first parameter)NPCONTROL : (second parameter) (High Byte)NPVERSIONMAJOR (Low Byte) major version number data
 +//   Message 2) (first parameter)NPCONTROL : (second parameter) (High Byte)NPVERSIONMINOR (Low Byte) minor version number data
 +
 +#define	NPQUERYVERSION	1040
 +
 +// CONTROL DATA SUBFIELDS
 +#define	NPVERSIONMAJOR	1
 +#define	NPVERSIONMINOR	2
 +
 +// DATA FIELDS
 +#define	NPControl		8	// indicates a control data field
 +						// the second parameter of a message bearing control data information contains a packed data format. 
 +						// The High byte indicates what the data is, and the Low byte contains the actual data
 +// roll, pitch, yaw
 +#define	NPRoll		1	// +/- 16383 (representing +/- 180) [data = input - 16383]
 +#define	NPPitch		2	// +/- 16383 (representing +/- 180) [data = input - 16383]
 +#define	NPYaw		4	// +/- 16383 (representing +/- 180) [data = input - 16383]
 +
 +// x, y, z - remaining 6dof coordinates
 +#define	NPX			16	// +/- 16383 [data = input - 16383]
 +#define	NPY			32	// +/- 16383 [data = input - 16383]
 +#define	NPZ			64	// +/- 16383 [data = input - 16383]
 +
 +#define	NP_AXIS_MIN				-16383
 +#define	NP_AXIS_MAX				16383
 +
 +// raw object position from imager
 +#define	NPRawX		128	// 0..25600 (actual value is multiplied x 100 to pass two decimal places of precision)  [data = input / 100]
 +#define	NPRawY		256  // 0..25600 (actual value is multiplied x 100 to pass two decimal places of precision)  [data = input / 100]
 +#define	NPRawZ		512  // 0..25600 (actual value is multiplied x 100 to pass two decimal places of precision)  [data = input / 100]
 +
 +// x, y, z deltas from raw imager position 
 +#define	NPDeltaX		1024 // +/- 2560 (actual value is multiplied x 10 to pass two decimal places of precision)  [data = (input / 10) - 256]
 +#define	NPDeltaY		2048 // +/- 2560 (actual value is multiplied x 10 to pass two decimal places of precision)  [data = (input / 10) - 256]
 +#define	NPDeltaZ		4096 // +/- 2560 (actual value is multiplied x 10 to pass two decimal places of precision)  [data = (input / 10) - 256]
 +
 +// raw object position from imager
 +#define	NPSmoothX		8192	  // 0..32766 (actual value is multiplied x 10 to pass one decimal place of precision) [data = input / 10]
 +#define	NPSmoothY		16384  // 0..32766 (actual value is multiplied x 10 to pass one decimal place of precision) [data = input / 10]
 +#define	NPSmoothZ		32768  // 0..32766 (actual value is multiplied x 10 to pass one decimal place of precision) [data = input / 10]
 +
 +// NPESULT values are returned from the Game Client API functions.
 +//
 +typedef enum tagNPResult
 +{
 +	NP_OK = 0,
 +    NP_ERR_DEVICE_NOT_PRESENT,
 +	NP_ERR_UNSUPPORTED_OS,
 +	NP_ERR_INVALID_ARG,
 +	NP_ERR_DLL_NOT_FOUND,
 +	NP_ERR_NO_DATA,
 +	NP_ERR_INTERNAL_DATA
 +} NPRESULT;
 +
 +//  static const char* FTIR_CLIENT_LOCATION = "Software\\NaturalPoint\\NATURALPOINT\\NPClient Location";
 +  static const char* FTIR_CLIENT_FILENAME = "NPClient.dll";
 +  static const char* FTIR_MM_DATA = "{0F98177E-0E5C-4F86-8837-229D19B1701D}";
 +//  static const char* FTIR_MM_DATA = "FT_TIR_SharedMem";
 +//  static const char* FREETRACK = "Freetrack";
 +  static const char* FTIR_MUTEX = "FT_TIR_Mutex";
 +//  static const char* FT_PROGRAMID = "FT_ProgramID";
 +  static const char* FTIR_REGISTER_PROGRAMHANDLE = "FT_Register_Program_Handle";
 +  static const char* FTIR_UNREGISTER_PROGRAMHANDLE = "FT_UnRegister_Program_Handle";
 +
 +typedef struct tagTrackIRData
 +{
 +	unsigned short wNPStatus;
 +	unsigned short wPFrameSignature;
 +	unsigned long  dwNPIOData;
 +
 +	float fNPRoll;
 +	float fNPPitch;
 +	float fNPYaw;
 +	float fNPX;
 +	float fNPY;
 +	float fNPZ;
 +	float fNPRawX;
 +	float fNPRawY;
 +	float fNPRawZ;
 +	float fNPDeltaX;
 +	float fNPDeltaY;
 +	float fNPDeltaZ;
 +	float fNPSmoothX;
 +	float fNPSmoothY;
 +	float fNPSmoothZ;
 +
 + ////   unsigned short wError;
 + ////   short iFrame;
 + ////   unsigned short wUnknown3;
 +	////float xRot, yRot, zRot;
 + ////   float x,y,z;
 +	////int iPadding[9];
 +
 +} TRACKIRDATA, *LPTRACKIRDATA;
 +
 +struct FTIRMemMap {
 +    // Emulators can check this
 +    int iRecordSize;
 +	TRACKIRDATA data;
 +    int Version;
 +    // Emulators should read these
 +    HANDLE RegisteredHandle;
 +    bool Transmission, Cursor;
 +    long int RequestFormat;
 +    long int ProgramProfileID;
 +    // Read/Write
 +    int LastError;
 +    int Param[16];
 +    unsigned short ClientNotify1, ClientNotify2;
 +    char Signature[400];
 +};
 +typedef FTIRMemMap * PFTIRMemMap;
 +
 +//
 +// Typedef for pointer to the notify callback function that is implemented within
 +// the client -- this function receives head tester reports from the game client API
 +//
 +typedef NPRESULT (__stdcall *PF_NOTIFYCALLBACK)( unsigned short, unsigned short );
 +
 +// Typedefs for game client API functions (useful for declaring pointers to these
 +// functions within the client for use during GetProcAddress() ops)
 +//
 +typedef NPRESULT (__stdcall *PF_NP_REGISTERWINDOWHANDLE)( HWND );
 +typedef NPRESULT (__stdcall *PF_NP_UNREGISTERWINDOWHANDLE)( void );
 +typedef NPRESULT (__stdcall *PF_NP_REGISTERPROGRAMPROFILEID)( unsigned short );
 +typedef NPRESULT (__stdcall *PF_NP_QUERYVERSION)( unsigned short* );
 +typedef NPRESULT (__stdcall *PF_NP_REQUESTDATA)( unsigned short );
 +typedef NPRESULT (__stdcall *PF_NP_GETDATA)( LPTRACKIRDATA );
 +typedef NPRESULT (__stdcall *PF_NP_REGISTERNOTIFY)( PF_NOTIFYCALLBACK );
 +typedef NPRESULT (__stdcall *PF_NP_UNREGISTERNOTIFY)( void );
 +typedef NPRESULT (__stdcall *PF_NP_STARTCURSOR)( void );
 +typedef NPRESULT (__stdcall *PF_NP_STOPCURSOR)( void );
 +typedef NPRESULT (__stdcall *PF_NP_STARTDATATRANSMISSION)( void );
 +typedef NPRESULT (__stdcall *PF_NP_STOPDATATRANSMISSION)( void );
 +
 +//// Function Prototypes ///////////////////////////////////////////////
 +//
 +// Functions exported from game client API DLL ( note __stdcall calling convention
 +// is used for ease of interface to clients of differing implementations including
 +// C, C++, Pascal (Delphi) and VB. )
 +//
 +//NPRESULT __stdcall NP_RegisterWindowHandle( HWND hWnd );
 +//NPRESULT __stdcall NP_RegisterWindowHandle( HWND );
 +//NPRESULT __stdcall NP_UnregisterWindowHandle( void );
 +//NPRESULT __stdcall NP_RegisterProgramProfileID( unsigned short wPPID );
 +//NPRESULT __stdcall NP_QueryVersion( unsigned short* pwVersion );
 +//NPRESULT __stdcall NP_RequestData( unsigned short wDataReq );
 +//NPRESULT __stdcall NP_GetData( LPTRACKIRDATA pTID );
 +//NPRESULT __stdcall NP_RegisterNotify( PF_NOTIFYCALLBACK pfNotify );
 +//NPRESULT __stdcall NP_UnregisterNotify( void );
 +//NPRESULT __stdcall NP_StartCursor( void );
 +//NPRESULT __stdcall NP_StopCursor( void );
 +//NPRESULT __stdcall NP_StartDataTransmission( void );
 +//NPRESULT __stdcall NP_StopDataTransmission( void );
 +
 +#endif//INCLUDED_FTIRTYPES_H
 diff --git a/FaceTrackNoIR/FaceApp.cpp b/FaceTrackNoIR/FaceApp.cpp index 433e9b2d..231a07c9 100644 --- a/FaceTrackNoIR/FaceApp.cpp +++ b/FaceTrackNoIR/FaceApp.cpp @@ -1,6 +1,7 @@  #include "FaceApp.h"
  #include "windows.h"
  #include "FTTypes.h"
 +#include "FTIRTypes.h"
  #include <QDebug>
  //
 @@ -41,6 +42,8 @@ void FaceApp::SetupEventFilter( FaceTrackNoIR *window ) {  	mainWindow = window;
  	msgID_FTClient = RegisterWindowMessageA ( FT_PROGRAMID );
  	qDebug() << "FaceApp::SetupEventFilter says: Message ID =" << msgID_FTClient;
 +	msgID_FTIR_Register = RegisterWindowMessageA ( FTIR_REGISTER_PROGRAMHANDLE );
 +	msgID_FTIR_UnRegister = RegisterWindowMessageA ( FTIR_UNREGISTER_PROGRAMHANDLE );
  	////if ( RegisterHotKey( window->winId(), 777, MOD_WIN, VK_HOME ) ) {
  	////	qDebug() << "FaceApp::SetupEventFilter says: RegisterHotKey HOME =" << VK_HOME;
 diff --git a/FaceTrackNoIR/FaceApp.h b/FaceTrackNoIR/FaceApp.h index 4edd3227..75eb6df2 100644 --- a/FaceTrackNoIR/FaceApp.h +++ b/FaceTrackNoIR/FaceApp.h @@ -19,6 +19,8 @@ protected:  private:
  	FaceTrackNoIR *mainWindow;	
  	int msgID_FTClient;
 +	int msgID_FTIR_Register;
 +	int msgID_FTIR_UnRegister;
  };
  #endif					//  FACEAPP_H
 diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index c8b717cf..8556eb5b 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -682,6 +682,7 @@ void FaceTrackNoIR::createIconGroupBox()  	ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FlightGear.ico"), tr("FlightGear"));
  	ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico"), tr("FTNoir client"));
  	ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/PPJoy.ico"), tr("Virtual Joystick"));
 +	ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/TrackIR.ico"), tr("Fake TrackIR"));
  	ui.iconcomboTrackerSource->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/SeeingMachines.ico"), tr("Face API"));
  	ui.iconcomboTrackerSource->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico"), tr("FTNoir server"));
 @@ -750,6 +751,9 @@ void FaceTrackNoIR::setIcon(int index)  		ui.btnShowServerControls->show();
  		ui.btnShowServerControls->setEnabled ( true );
  		break;
 +	case TRACKIR:
 +		ui.btnShowServerControls->hide();
 +		break;
  	default:
  		break;
  	}
 diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index cbd4c769..01213b37 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -914,7 +914,7 @@ color:#000;</string>                 <number>-1</number>
                </property>
                <property name="maxVisibleItems">
 -               <number>3</number>
 +               <number>5</number>
                </property>
               </widget>
               <widget class="QPushButton" name="btnShowServerControls">
 diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj index 9995eec2..32418646 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj @@ -198,11 +198,11 @@  				>
  			</File>
  			<File
 -				RelativePath=".\FTServer.cpp"
 +				RelativePath=".\FTIRServer.cpp"
  				>
  			</File>
  			<File
 -				RelativePath=".\FTTypes.cpp"
 +				RelativePath=".\FTServer.cpp"
  				>
  			</File>
  			<File
 @@ -306,6 +306,36 @@  				>
  			</File>
  			<File
 +				RelativePath=".\FTIRServer.h"
 +				>
 +				<FileConfiguration
 +					Name="Release|Win32"
 +					>
 +					<Tool
 +						Name="VCCustomBuildTool"
 +						Description="Moc'ing $(InputFileName)..."
 +						CommandLine=""$(QTDIR)\bin\moc.exe"  "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_LARGEFILE_SUPPORT -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 -I"$(QTDIR)\include\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtGui\." -I"$(QTDIR)\include\QtNetwork\." -I"$(QTDIR)\include\QtOpenGL\." -I"$(QTDIR)\include\QtTest\." -I"$(QTDIR)\include\QtWebKit\." -I"$(SM_API_CPP_WRAPPERS)\include\." -I"$(SM_API_PATH)\include\." -I"$(SM_API_QTDIR)\include\." -I"$(SM_API_WIDGETS)\include\." -I".\GeneratedFiles\$(ConfigurationName)\." -I".\GeneratedFiles\."
"
 +						AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
 +						Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
 +					/>
 +				</FileConfiguration>
 +				<FileConfiguration
 +					Name="Debug|Win32"
 +					>
 +					<Tool
 +						Name="VCCustomBuildTool"
 +						Description="Moc'ing $(InputFileName)..."
 +						CommandLine=""$(QTDIR)\bin\moc.exe"  "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_LARGEFILE_SUPPORT -DQT_OPENGL_LIB -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 -I"$(QTDIR)\include\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtGui\." -I"$(QTDIR)\include\QtOpenGL\." -I"$(QTDIR)\include\QtTest\." -I"$(QTDIR)\include\QtWebKit\." -I".\." -I".\GeneratedFiles\$(ConfigurationName)\." -I".\GeneratedFiles\."
"
 +						AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
 +						Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
 +					/>
 +				</FileConfiguration>
 +			</File>
 +			<File
 +				RelativePath=".\FTIRTypes.h"
 +				>
 +			</File>
 +			<File
  				RelativePath=".\FTServer.h"
  				>
  				<FileConfiguration
 @@ -469,97 +499,9 @@  					>
  				</File>
  				<File
 -					RelativePath=".\UIElements\button_forward.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_forward_pressed.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_play.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_play_pressed.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_rewind.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_rewind_pressed.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_Start_SweetSpotter_disabled.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_Start_SweetSpotter_enabled.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_Start_SweetSpotter_enabled_pressed.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_Stop_SweetSpotter.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\button_Stop_SweetSpotter_pressed.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\buttons_pause.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\buttons_pause_pressed.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\listener_klein_final_V3.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\listener_klein_final_V3_not detected.png"
 -					>
 -				</File>
 -				<File
  					RelativePath=".\UIElements\Logo_FaceTrackNoIR_32px.png"
  					>
  				</File>
 -				<File
 -					RelativePath=".\UIElements\logoLehrstuhl.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\logoTU.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\Loudspeaker_active.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\Loudspeaker_inactive.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\spot.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\SweetSpotterLOGO_16px.png"
 -					>
 -				</File>
 -				<File
 -					RelativePath=".\UIElements\SweetSpotterLOGO_32px.png"
 -					>
 -				</File>
  			</Filter>
  		</Filter>
  		<Filter
 @@ -638,6 +580,18 @@  					</FileConfiguration>
  				</File>
  				<File
 +					RelativePath=".\GeneratedFiles\Release\moc_FTIRServer.cpp"
 +					>
 +					<FileConfiguration
 +						Name="Debug|Win32"
 +						ExcludedFromBuild="true"
 +						>
 +						<Tool
 +							Name="VCCLCompilerTool"
 +						/>
 +					</FileConfiguration>
 +				</File>
 +				<File
  					RelativePath=".\GeneratedFiles\Release\moc_FTServer.cpp"
  					>
  					<FileConfiguration
 @@ -716,6 +670,18 @@  					</FileConfiguration>
  				</File>
  				<File
 +					RelativePath=".\GeneratedFiles\Debug\moc_FTIRServer.cpp"
 +					>
 +					<FileConfiguration
 +						Name="Release|Win32"
 +						ExcludedFromBuild="true"
 +						>
 +						<Tool
 +							Name="VCCLCompilerTool"
 +						/>
 +					</FileConfiguration>
 +				</File>
 +				<File
  					RelativePath=".\GeneratedFiles\Debug\moc_FTServer.cpp"
  					>
  					<FileConfiguration
 diff --git a/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp b/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp index f14c187b..85287b60 100644 --- a/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp @@ -1,7 +1,7 @@  /****************************************************************************
  ** Resource object code
  **
 -** Created: Sun 13. Jun 15:55:11 2010
 +** Created: Tue 29. Jun 20:59:33 2010
  **      by: The Resource Compiler for Qt version 4.6.2
  **
  ** WARNING! All changes made in this file will be lost!
 diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h b/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h index c712202d..b361c21e 100644 --- a/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h +++ b/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h @@ -1,7 +1,7 @@  /********************************************************************************
  ** Form generated from reading UI file 'FTNoIR_ppjoycontrols.ui'
  **
 -** Created: Mon 14. Jun 20:32:49 2010
 +** Created: Tue 29. Jun 20:59:28 2010
  **      by: Qt User Interface Compiler version 4.6.2
  **
  ** WARNING! All changes made in this file will be lost when recompiling UI file!
 diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h index 03e07ccb..b4200594 100644 --- a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h +++ b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h @@ -1,7 +1,7 @@  /********************************************************************************
  ** Form generated from reading UI file 'FaceTrackNoIR.ui'
  **
 -** Created: Sun 13. Jun 16:10:04 2010
 +** Created: Tue 29. Jun 20:59:30 2010
  **      by: Qt User Interface Compiler version 4.6.2
  **
  ** WARNING! All changes made in this file will be lost when recompiling UI file!
 @@ -522,7 +522,7 @@ public:          iconcomboBox->setObjectName(QString::fromUtf8("iconcomboBox"));
          iconcomboBox->setGeometry(QRect(10, 20, 151, 22));
          iconcomboBox->setStyleSheet(QString::fromUtf8(""));
 -        iconcomboBox->setMaxVisibleItems(3);
 +        iconcomboBox->setMaxVisibleItems(5);
          btnShowServerControls = new QPushButton(groupGameProtocol);
          btnShowServerControls->setObjectName(QString::fromUtf8("btnShowServerControls"));
          btnShowServerControls->setEnabled(true);
 diff --git a/FaceTrackNoIR/Release/BuildLog.htm b/FaceTrackNoIR/Release/BuildLog.htm Binary files differindex 35239261..09e7b3af 100644 --- a/FaceTrackNoIR/Release/BuildLog.htm +++ b/FaceTrackNoIR/Release/BuildLog.htm diff --git a/FaceTrackNoIR/Release/mt.dep b/FaceTrackNoIR/Release/mt.dep index da1401d7..7f6bad00 100644 --- a/FaceTrackNoIR/Release/mt.dep +++ b/FaceTrackNoIR/Release/mt.dep @@ -1 +1 @@ -Manifest resource last updated at 21:14:55.58 on di 15-06-2010 
 +Manifest resource last updated at  9:54:44.39 on za 17-07-2010 
 diff --git a/FaceTrackNoIR/images/TrackIR.ico b/FaceTrackNoIR/images/TrackIR.ico Binary files differnew file mode 100644 index 00000000..99e02e7b --- /dev/null +++ b/FaceTrackNoIR/images/TrackIR.ico diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 666f9c34..4cbd4453 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -95,6 +95,7 @@ Tracker::Tracker( int clientID ) {  	server_FT = 0;
  	server_FG = 0;
  	server_PPJoy = 0;
 +	server_FTIR = 0;
  	switch (selectedClient) {
  		case FREE_TRACK:
  			server_FT = new FTServer;					// Create Free-track protocol-server
 @@ -111,6 +112,10 @@ Tracker::Tracker( int clientID ) {  			server_PPJoy = new PPJoyServer ( this );	// Create PPJoy protocol-server
  			break;
 +		case TRACKIR:
 +			server_FTIR = new FTIRServer;				// Create Fake-TIR protocol-server
 +			break;
 +
  		default:
  			// should never be reached
  		break;
 @@ -131,6 +136,9 @@ Tracker::~Tracker() {  	if (server_PPJoy) {
  		server_PPJoy->deleteLater();
  	}
 +	if (server_FTIR) {
 +		server_FTIR->deleteLater();
 +	}
  	// Trigger thread to stop
  	::SetEvent(m_StopThread);
 @@ -194,6 +202,19 @@ void Tracker::setup(QWidget *head, FaceTrackNoIR *parent) {  	if (server_PPJoy) {
  		server_PPJoy->start();							// Start the thread
  	}
 +
 +	//
 +	// Check if the NP Client DLL is available
 +	// and create the necessary mapping to shared memory.
 +	// The handle of the MainWindow is sent to 'The Game', so it can send a message back.
 +	//
 +	if (server_FTIR) {
 +		DLL_Ok = server_FTIR->FTIRCheckClientDLL();
 +		DLL_Ok = server_FTIR->FTIRCreateMapping( mainApp->winId() );
 +
 +		server_FTIR->start();								// Start the thread
 +	}
 +
  }
  /** QThread run method @override **/
 @@ -356,6 +377,19 @@ void Tracker::run() {  				server_FT->setHeadPosY( Tracker::Y.headPos * 1000.0f);
  				server_FT->setHeadPosZ( ( Tracker::Z.headPos - Tracker::Z.initial_headPos ) * 1000.0f);
  			}
 +
 +			//
 +			// Copy the Raw values directly to Fake-trackIR server
 +			//
 +			//if (server_FTIR) {
 +			//	server_FTIR->setHeadRotX( Tracker::Pitch.headPos );			// rads
 +			//	server_FTIR->setHeadRotY( Tracker::Yaw.headPos );
 +			//	server_FTIR->setHeadRotZ( Tracker::Roll.headPos);
 +
 +			//	server_FTIR->setHeadPosX( Tracker::X.headPos * 1000.0f);		// From m to mm
 +			//	server_FTIR->setHeadPosY( Tracker::Y.headPos * 1000.0f);
 +			//	server_FTIR->setHeadPosZ( ( Tracker::Z.headPos - Tracker::Z.initial_headPos ) * 1000.0f);
 +			//}
  		}
  		//
 @@ -437,6 +471,24 @@ void Tracker::run() {  				server_PPJoy->setVirtPosY ( ( Tracker::Y.invert   * Tracker::Y.sens     * (getSmoothFromList( &Y.rawList ) - Y.offset_headPos) ) * 100.0f );
  				server_PPJoy->setVirtPosZ ( ( Tracker::Z.invert   * Tracker::Z.sens     * (getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Tracker::Z.initial_headPos) ) * 100.0f );
  			}
 +
 +			// Fake-trackIR
 +			if (server_FTIR) {
 +
 +				float rotX = getDegreesFromRads ( Tracker::Pitch.invert * Tracker::Pitch.sens * Pitch.newPos );
 +				float rotY = getDegreesFromRads ( Tracker::Yaw.invert   * Tracker::Yaw.sens   *  Yaw.newPos );
 +				float rotZ = getDegreesFromRads ( Tracker::Roll.invert  * Tracker::Roll.sens  * Roll.newPos );
 +				qDebug() << "Tracker::run() says: virtRotX =" << rotX << " virtRotY =" << rotY;
 +
 +				server_FTIR->setVirtRotX ( rotX );
 +				server_FTIR->setVirtRotY ( rotY );
 +				server_FTIR->setVirtRotZ ( rotZ );
 +
 +				server_FTIR->setVirtPosX ( ( Tracker::X.invert * Tracker::X.sens * (getSmoothFromList( &X.rawList ) - X.offset_headPos) ) * 1000.0f);
 +				server_FTIR->setVirtPosY ( ( Tracker::Y.invert * Tracker::Y.sens * (getSmoothFromList( &Y.rawList ) - Y.offset_headPos) ) * 1000.0f );
 +				server_FTIR->setVirtPosZ ( ( Tracker::Z.invert * Tracker::Z.sens * (getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Tracker::Z.initial_headPos) ) * 1000.0f );
 +			}
 +
  		}
  		else {
  			//
 @@ -468,6 +520,15 @@ void Tracker::run() {  				server_PPJoy->setVirtPosY ( 0.0f );
  				server_PPJoy->setVirtPosZ ( 0.0f );
  			}
 +
 +			if (server_FTIR) {
 +				server_FTIR->setVirtRotX ( 0.0f );
 +				server_FTIR->setVirtRotY ( 0.0f );
 +				server_FTIR->setVirtRotZ ( 0.0f );
 +				server_FTIR->setVirtPosX ( 0.0f );
 +				server_FTIR->setVirtPosY ( 0.0f );
 +				server_FTIR->setVirtPosZ ( 0.0f );
 +			}
  		}
  		//for lower cpu load 
 @@ -486,11 +547,6 @@ void Tracker::registerHeadPoseCallback() {  /** Callback function for head-pose - only static methods could be called **/
  void Tracker::receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVideoFrame video_frame)
  {
 -	//SYSTEMTIME now;
 -	//long newHeadPoseTime;
 -	//float dT;
 -//	float rate;
 -
  	//
  	// Perform actions, when valid data is received from faceAPI.
  	//
 @@ -504,33 +560,18 @@ void Tracker::receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVid  		Tracker::setHeadRotY(head_pose.head_rot.y_rads);
  		Tracker::setHeadRotZ(head_pose.head_rot.z_rads);	
 -		////
 -		//// Get the System-time and substract the time from the previous call.
 -		//// dT will be used for the EWMA-filter.
 -		////
 -		//GetSystemTime ( &now );
 -		//newHeadPoseTime = (((now.wHour * 3600) + (now.wMinute * 60) + now.wSecond) * 1000) + now.wMilliseconds;
 -		//dT = (newHeadPoseTime - Tracker::prevHeadPoseTime) / 1000.0f;
 -
 -		//// Remember time for next call
 -		//Tracker::prevHeadPoseTime = newHeadPoseTime;
 -
 -
 -
 -		//
 -		// Calculate the new values, applying a low-pass filter.
 -		// Add the values to their respective QList, for further smoothing
 -		//
  		// Pitch
 -		//if (Tracker::useFilter) {
 -		//	Pitch.newPos = lowPassFilter ( getCorrectedNewRaw ( rateLimiter ( Tracker::Pitch.headPos, &Tracker::Pitch.prevRawPos, dT, 1.0f ), rotNeutralZone ), 
 -		//		                           &Pitch.prevPos, dT, Tracker::Pitch.red );
 -		//}
 -		//else {
 -			Pitch.newPos = getCorrectedNewRaw ( Tracker::Pitch.headPos, rotNeutralZone );
 -		//}
 +		Pitch.newPos = getCorrectedNewRaw ( Tracker::Pitch.headPos, rotNeutralZone );
  		addRaw2List ( &Pitch.rawList, Pitch.maxItems, Pitch.newPos );
 +		// Yaw
 +		Yaw.newPos = getCorrectedNewRaw ( Tracker::Yaw.headPos, rotNeutralZone );
 +		addRaw2List ( &Yaw.rawList, Yaw.maxItems, Yaw.newPos );
 +
 +		// Roll
 +		Roll.newPos = getCorrectedNewRaw ( Tracker::Roll.headPos, rotNeutralZone );
 +		addRaw2List ( &Roll.rawList, Roll.maxItems, Roll.newPos );
 +
  		//
  		// Log something
  		//
 @@ -540,54 +581,19 @@ void Tracker::receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVid  		//	QTextStream out(&data);
  		//	out << "Limited Raw= " << rate << " dT= " << dT << " Raw= " << Tracker::Pitch.headPos << " Filtered= " << Pitch.newPos << '\n';
  		//}
 -//		Tracker::Pitch.prevRawPos = Tracker::Pitch.headPos;
 -
 -		// Yaw
 -		//if (Tracker::useFilter) {
 -		//	Yaw.newPos = lowPassFilter ( getCorrectedNewRaw ( rateLimiter ( Tracker::Yaw.headPos, &Tracker::Yaw.prevRawPos, dT, 1.0f ), rotNeutralZone ), 
 -		//								 &Yaw.prevPos, dT, Tracker::Yaw.red );
 -		//}
 -		//else {
 -			Yaw.newPos = getCorrectedNewRaw ( Tracker::Yaw.headPos, rotNeutralZone );
 -		//}
 -		addRaw2List ( &Yaw.rawList, Yaw.maxItems, Yaw.newPos );
 -		// Roll
 -		//if (Tracker::useFilter) {
 -		//	Roll.newPos = lowPassFilter ( getCorrectedNewRaw (rateLimiter ( Tracker::Roll.headPos, &Tracker::Roll.prevRawPos, dT, 1.0f ), rotNeutralZone ),
 -		//								  &Roll.prevPos, dT, Tracker::Roll.red );
 -		//}
 -		//else {
 -			Roll.newPos = getCorrectedNewRaw ( Tracker::Roll.headPos, rotNeutralZone );
 -		//}
 -		addRaw2List ( &Roll.rawList, Roll.maxItems, Roll.newPos );
  		// X-position
 -		//if (Tracker::useFilter) {
 -		//	X.newPos = lowPassFilter ( Tracker::X.headPos, &X.prevPos, dT, Tracker::X.red );
 -		//}
 -		//else {
 -			X.newPos = Tracker::X.headPos;
 -		//}
 +		X.newPos = Tracker::X.headPos;
  		addRaw2List ( &X.rawList, X.maxItems, X.newPos );
  		// Y-position
 -		//if (Tracker::useFilter) {
 -		//	Y.newPos = lowPassFilter ( Tracker::Y.headPos, &Y.prevPos, dT, Tracker::Y.red );
 -		//}
 -		//else {
 -			Y.newPos = Tracker::Y.headPos;
 -		//}
 +		Y.newPos = Tracker::Y.headPos;
  		addRaw2List ( &Y.rawList, Y.maxItems, Y.newPos );
  		// Z-position (distance to camera, absolute!)
 -		//if (Tracker::useFilter) {
 -		//	Z.newPos = lowPassFilter ( Tracker::Z.headPos, &Z.prevPos, dT, Tracker::Z.red );
 -		//}
 -		//else {
 -			Z.newPos = Tracker::Z.headPos;
 -		//}
 +		Z.newPos = Tracker::Z.headPos;
  		addRaw2List ( &Z.rawList, Z.maxItems, Z.newPos );
  	} else {
 diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 10021ffb..b535324f 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -38,6 +38,7 @@  #include "FTServer.h"				// Freetrack-server
  #include "FGServer.h"				// FlightGear-server
  #include "PPJoyServer.h"			// Virtual Joystick
 +#include "FTIRServer.h"				// FakeTIR-server
  // include the DirectX Library files
  #pragma comment (lib, "dinput8.lib")
 @@ -59,7 +60,8 @@ enum FTNoIR_Client {  	FREE_TRACK = 0,
  	FLIGHTGEAR = 1,
  	FTNOIR = 2,
 -	PPJOY = 3
 +	PPJOY = 3,
 +	TRACKIR = 4
  };
  class FaceTrackNoIR;				// pre-define parent-class to avoid circular includes
 @@ -137,6 +139,7 @@ private:  	FTServer *server_FT;							// Freetrack Server
  	FGServer *server_FG;							// FlightGear Server
  	PPJoyServer *server_PPJoy;						// PPJoy Server
 +	FTIRServer *server_FTIR;						// Fake TIR Server
  protected:
  	// qthread override run method 
 diff --git a/SetupFaceTrackNoIR/SetupFaceTrackNoIR.vdproj b/SetupFaceTrackNoIR/SetupFaceTrackNoIR.vdproj index 8f11debc..92197456 100644 --- a/SetupFaceTrackNoIR/SetupFaceTrackNoIR.vdproj +++ b/SetupFaceTrackNoIR/SetupFaceTrackNoIR.vdproj @@ -93,6 +93,12 @@          }
          "Entry"
          {
 +        "MsmKey" = "8:_15EE3885CF76410290465B8DD4E41A59"
 +        "OwnerKey" = "8:_UNDEFINED"
 +        "MsmSig" = "8:_UNDEFINED"
 +        }
 +        "Entry"
 +        {
          "MsmKey" = "8:_16C58D11698F44F8AD4EE9372AA6DEAA"
          "OwnerKey" = "8:_UNDEFINED"
          "MsmSig" = "8:_UNDEFINED"
 @@ -339,6 +345,12 @@          }
          "Entry"
          {
 +        "MsmKey" = "8:_7749DE7101A34E9CAD0B2F68CBA01378"
 +        "OwnerKey" = "8:_UNDEFINED"
 +        "MsmSig" = "8:_UNDEFINED"
 +        }
 +        "Entry"
 +        {
          "MsmKey" = "8:_7CA04E8400FC4421B2E6E28ABD2F913D"
          "OwnerKey" = "8:_UNDEFINED"
          "MsmSig" = "8:_UNDEFINED"
 @@ -375,6 +387,12 @@          }
          "Entry"
          {
 +        "MsmKey" = "8:_8FD1D69FC4CD4CA38CF929A1DA238205"
 +        "OwnerKey" = "8:_UNDEFINED"
 +        "MsmSig" = "8:_UNDEFINED"
 +        }
 +        "Entry"
 +        {
          "MsmKey" = "8:_91E1A8AE7AFF40ECAD3359F21F0765E1"
          "OwnerKey" = "8:_UNDEFINED"
          "MsmSig" = "8:_UNDEFINED"
 @@ -699,6 +717,12 @@          }
          "Entry"
          {
 +        "MsmKey" = "8:_F18199244F3E4454BF3BE86ADE222E88"
 +        "OwnerKey" = "8:_UNDEFINED"
 +        "MsmSig" = "8:_UNDEFINED"
 +        }
 +        "Entry"
 +        {
          "MsmKey" = "8:_FB3E1677A893494CAA8D6F809D17E66C"
          "OwnerKey" = "8:_UNDEFINED"
          "MsmSig" = "8:_UNDEFINED"
 @@ -1078,6 +1102,26 @@              "IsDependency" = "11:FALSE"
              "IsolateTo" = "8:"
              }
 +            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_15EE3885CF76410290465B8DD4E41A59"
 +            {
 +            "SourcePath" = "8:..\\bin\\NPClient.dll"
 +            "TargetName" = "8:NPClient.dll"
 +            "Tag" = "8:"
 +            "Folder" = "8:_BDB04948DE364E43BE4090C5F9E45677"
 +            "Condition" = "8:"
 +            "Transitive" = "11:FALSE"
 +            "Vital" = "11:TRUE"
 +            "ReadOnly" = "11:FALSE"
 +            "Hidden" = "11:FALSE"
 +            "System" = "11:FALSE"
 +            "Permanent" = "11:FALSE"
 +            "SharedLegacy" = "11:FALSE"
 +            "PackageAs" = "3:1"
 +            "Register" = "3:4"
 +            "Exclude" = "11:FALSE"
 +            "IsDependency" = "11:FALSE"
 +            "IsolateTo" = "8:"
 +            }
              "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_16C58D11698F44F8AD4EE9372AA6DEAA"
              {
              "SourcePath" = "8:..\\bin\\resources\\shapemodel2d_left_eyebrow_scale100.bin"
 @@ -1878,6 +1922,26 @@              "IsDependency" = "11:FALSE"
              "IsolateTo" = "8:"
              }
 +            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7749DE7101A34E9CAD0B2F68CBA01378"
 +            {
 +            "SourcePath" = "8:..\\bin\\FTNoIR_ProtocolTester.exe"
 +            "TargetName" = "8:FTNoIR_ProtocolTester.exe"
 +            "Tag" = "8:"
 +            "Folder" = "8:_BDB04948DE364E43BE4090C5F9E45677"
 +            "Condition" = "8:"
 +            "Transitive" = "11:FALSE"
 +            "Vital" = "11:TRUE"
 +            "ReadOnly" = "11:FALSE"
 +            "Hidden" = "11:FALSE"
 +            "System" = "11:FALSE"
 +            "Permanent" = "11:FALSE"
 +            "SharedLegacy" = "11:FALSE"
 +            "PackageAs" = "3:1"
 +            "Register" = "3:1"
 +            "Exclude" = "11:FALSE"
 +            "IsDependency" = "11:FALSE"
 +            "IsolateTo" = "8:"
 +            }
              "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7CA04E8400FC4421B2E6E28ABD2F913D"
              {
              "SourcePath" = "8:..\\bin\\resources\\svm_model_regression.bin"
 @@ -1998,6 +2062,26 @@              "IsDependency" = "11:FALSE"
              "IsolateTo" = "8:"
              }
 +            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8FD1D69FC4CD4CA38CF929A1DA238205"
 +            {
 +            "SourcePath" = "8:..\\bin\\Settings\\FreeFalcon.ini"
 +            "TargetName" = "8:FreeFalcon.ini"
 +            "Tag" = "8:"
 +            "Folder" = "8:_44ADBF8693B049F99A2A38D3702C77BE"
 +            "Condition" = "8:"
 +            "Transitive" = "11:FALSE"
 +            "Vital" = "11:TRUE"
 +            "ReadOnly" = "11:FALSE"
 +            "Hidden" = "11:FALSE"
 +            "System" = "11:FALSE"
 +            "Permanent" = "11:FALSE"
 +            "SharedLegacy" = "11:FALSE"
 +            "PackageAs" = "3:1"
 +            "Register" = "3:1"
 +            "Exclude" = "11:FALSE"
 +            "IsDependency" = "11:FALSE"
 +            "IsolateTo" = "8:"
 +            }
              "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_91E1A8AE7AFF40ECAD3359F21F0765E1"
              {
              "SourcePath" = "8:..\\bin\\smft31.dll"
 @@ -2978,6 +3062,26 @@              "IsDependency" = "11:FALSE"
              "IsolateTo" = "8:"
              }
 +            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F18199244F3E4454BF3BE86ADE222E88"
 +            {
 +            "SourcePath" = "8:..\\bin\\images\\TrackIR.ico"
 +            "TargetName" = "8:TrackIR.ico"
 +            "Tag" = "8:"
 +            "Folder" = "8:_40DAD99DC6924B3B84F32C94378E760A"
 +            "Condition" = "8:"
 +            "Transitive" = "11:FALSE"
 +            "Vital" = "11:TRUE"
 +            "ReadOnly" = "11:FALSE"
 +            "Hidden" = "11:FALSE"
 +            "System" = "11:FALSE"
 +            "Permanent" = "11:FALSE"
 +            "SharedLegacy" = "11:FALSE"
 +            "PackageAs" = "3:1"
 +            "Register" = "3:1"
 +            "Exclude" = "11:FALSE"
 +            "IsDependency" = "11:FALSE"
 +            "IsolateTo" = "8:"
 +            }
              "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FB3E1677A893494CAA8D6F809D17E66C"
              {
              "SourcePath" = "8:..\\bin\\images\\Freetrack.ico"
 @@ -3378,6 +3482,56 @@                      "Transitive" = "11:FALSE"
                          "Keys"
                          {
 +                            "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_4E38DFCB2A994660834812A748060009"
 +                            {
 +                            "Name" = "8:NaturalPoint"
 +                            "Condition" = "8:"
 +                            "AlwaysCreate" = "11:FALSE"
 +                            "DeleteAtUninstall" = "11:FALSE"
 +                            "Transitive" = "11:FALSE"
 +                                "Keys"
 +                                {
 +                                    "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_1AD8DA0A3CF841479B70684258E5701E"
 +                                    {
 +                                    "Name" = "8:NaturalPoint"
 +                                    "Condition" = "8:"
 +                                    "AlwaysCreate" = "11:FALSE"
 +                                    "DeleteAtUninstall" = "11:FALSE"
 +                                    "Transitive" = "11:FALSE"
 +                                        "Keys"
 +                                        {
 +                                            "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_0C788A6FCDED451C81B0EB6AD2D68B39"
 +                                            {
 +                                            "Name" = "8:NPClient Location"
 +                                            "Condition" = "8:"
 +                                            "AlwaysCreate" = "11:FALSE"
 +                                            "DeleteAtUninstall" = "11:FALSE"
 +                                            "Transitive" = "11:FALSE"
 +                                                "Keys"
 +                                                {
 +                                                }
 +                                                "Values"
 +                                                {
 +                                                    "{ADCFDA98-8FDD-45E4-90BC-E3D20B029870}:_E8223EF2CBD940649C02C98D71D45F4A"
 +                                                    {
 +                                                    "Name" = "8:Path"
 +                                                    "Condition" = "8:"
 +                                                    "Transitive" = "11:FALSE"
 +                                                    "ValueTypes" = "3:1"
 +                                                    "Value" = "8:[TARGETDIR]"
 +                                                    }
 +                                                }
 +                                            }
 +                                        }
 +                                        "Values"
 +                                        {
 +                                        }
 +                                    }
 +                                }
 +                                "Values"
 +                                {
 +                                }
 +                            }
                              "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_5C8F2BBC0F0D469F91BB538A55CE88A0"
                              {
                              "Name" = "8:Freetrack"
 diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe Binary files differindex 7c9b28d1..0de91d3d 100644 --- a/bin/FaceTrackNoIR.exe +++ b/bin/FaceTrackNoIR.exe diff --git a/bin/FreeTrackClient.dll b/bin/FreeTrackClient.dll Binary files differindex 58d3e31e..bf85aa8f 100644 --- a/bin/FreeTrackClient.dll +++ b/bin/FreeTrackClient.dll diff --git a/bin/NPClient.dll b/bin/NPClient.dll Binary files differnew file mode 100644 index 00000000..b979550f --- /dev/null +++ b/bin/NPClient.dll diff --git a/bin/Settings/FreeFalcon.ini b/bin/Settings/FreeFalcon.ini new file mode 100644 index 00000000..3747e73a --- /dev/null +++ b/bin/Settings/FreeFalcon.ini @@ -0,0 +1,25 @@ +[Tracking]
 +Smooth=10
 +NeutralZone=5
 +sensYaw=300
 +sensPitch=300
 +sensRoll=300
 +sensX=20
 +sensY=20
 +sensZ=50
 +invertYaw=false
 +invertPitch=true
 +invertRoll=false
 +invertX=true
 +invertY=false
 +invertZ=false
 +useEWMA=true
 +redYaw=50
 +redPitch=50
 +redRoll=50
 +redX=75
 +redY=75
 +redZ=75
 +
 +[GameProtocol]
 +Selection=4
 diff --git a/bin/Settings/default.ini b/bin/Settings/default.ini index 3d3c6e94..0b2fe7fe 100644 --- a/bin/Settings/default.ini +++ b/bin/Settings/default.ini @@ -7,3 +7,6 @@ sensX=110  sensY=177
  sensZ=242
  NeutralZone=3
 +
 +[GameProtocol]
 +Selection=4
 diff --git a/bin/Settings/test.ini b/bin/Settings/test.ini index aeba2fcb..d863f216 100644 --- a/bin/Settings/test.ini +++ b/bin/Settings/test.ini @@ -1,9 +1,25 @@  [Tracking]
 -Smooth=10
 +Smooth=15
  NeutralZone=5
 -sensYaw=164
 -sensPitch=100
 -sensRoll=100
 +sensYaw=300
 +sensPitch=300
 +sensRoll=300
  sensX=100
  sensY=100
  sensZ=100
 +invertYaw=false
 +invertPitch=true
 +invertRoll=false
 +invertX=true
 +invertY=false
 +invertZ=false
 +useEWMA=true
 +redYaw=50
 +redPitch=50
 +redRoll=50
 +redX=75
 +redY=75
 +redZ=75
 +
 +[GameProtocol]
 +Selection=4
 diff --git a/bin/images/TrackIR.ico b/bin/images/TrackIR.ico Binary files differnew file mode 100644 index 00000000..99e02e7b --- /dev/null +++ b/bin/images/TrackIR.ico  | 
