summaryrefslogtreecommitdiffhomepage
path: root/FaceTrackNoIR
diff options
context:
space:
mode:
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r--FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml16
-rw-r--r--FaceTrackNoIR/FGServer.cpp68
-rw-r--r--FaceTrackNoIR/tracker.cpp2
3 files changed, 38 insertions, 48 deletions
diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml
index 0d6e8005..d8bd1d0a 100644
--- a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml
+++ b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml
@@ -1,19 +1,6 @@
<?xml version="1.0"?>
<PropertyList>
- <input>
- <keyboard>
- <key n="61">
- <name>= (equal sign)</name>
- <desc>Reset Head Tracker</desc>
- <binding>
- <command>nasal</command>
- <script>headtracker.reset()</script>
- </binding>
- </key>
- </keyboard>
- </input>
-
<nasal>
<headtracker>
<script>
@@ -21,12 +8,10 @@
new: func(prop) {
var m = { parents: [Value] };
m.prop = props.globals.getNode(prop, 1);
- m.lowpass = aircraft.lowpass.new(0.7);
m.value = 0;
return m;
},
apply: func(value) {
- value = me.lowpass.filter(value);
me.prop.setDoubleValue(me.prop.getValue() - me.value + value);
me.value = value;
},
@@ -79,7 +64,6 @@
loop();
- gui.popupTip("press '=' (equal sign) to reset head tracker", 20);
</script>
</headtracker>
</nasal>
diff --git a/FaceTrackNoIR/FGServer.cpp b/FaceTrackNoIR/FGServer.cpp
index 53cd68ff..292c194b 100644
--- a/FaceTrackNoIR/FGServer.cpp
+++ b/FaceTrackNoIR/FGServer.cpp
@@ -62,22 +62,6 @@ QHostAddress sender;
quint16 senderPort;
//
- // Create UDP-sockets if they don't exist already.
- // They must be created here, because they must be in the Tracker thread (Tracker::run())
- //
- if (inSocket == 0) {
- qDebug() << "FGServer::sendHeadposeToGame creating sockets";
- inSocket = new QUdpSocket();
- // Connect the inSocket to the port, to receive messages
-// inSocket->bind(QHostAddress::LocalHost, 5551);
- inSocket->bind(QHostAddress::Any, destPort+1);
- }
-
- if (outSocket == 0) {
- outSocket = new QUdpSocket();
- }
-
- //
// Copy the Raw measurements directly to the client.
//
TestData.x = virtPosX;
@@ -94,28 +78,32 @@ quint16 senderPort;
//! [1]
// no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), QHostAddress::LocalHost, 5550);
- no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort);
- if ( no_bytes > 0) {
-// qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double );
- }
- else {
- qDebug() << "FGServer::writePendingDatagrams says: nothing sent!";
+ if (outSocket != 0) {
+ no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort);
+ if ( no_bytes > 0) {
+ // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double );
+ }
+ else {
+ qDebug() << "FGServer::writePendingDatagrams says: nothing sent!";
+ }
}
//
// FlightGear keeps sending data, so we must read that here.
//
- while (inSocket->hasPendingDatagrams()) {
+ if (inSocket != 0) {
+ while (inSocket->hasPendingDatagrams()) {
- QByteArray datagram;
- datagram.resize(inSocket->pendingDatagramSize());
+ QByteArray datagram;
+ datagram.resize(inSocket->pendingDatagramSize());
- inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort);
+ inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort);
- fg_cmd = cmd; // Let's just accept that command for now...
- if ( cmd > 0 ) {
- qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd;
- headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle
+ fg_cmd = cmd; // Let's just accept that command for now...
+ if ( cmd > 0 ) {
+ qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd;
+ headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle
+ }
}
}
}
@@ -139,6 +127,26 @@ bool FGServer::checkServerInstallationOK( HANDLE handle )
inSocket = 0;
outSocket = 0;
+ //
+ // Create UDP-sockets.
+ //
+ if (inSocket == 0) {
+ qDebug() << "FGServer::sendHeadposeToGame creating insocket";
+ inSocket = new QUdpSocket();
+
+ // Connect the inSocket to the port, to receive messages
+ if (!inSocket->bind(QHostAddress::Any, destPort+1)) {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton);
+ delete inSocket;
+ inSocket = 0;
+ return false;
+ }
+ }
+
+ if (outSocket == 0) {
+ outSocket = new QUdpSocket();
+ }
+
return true;
}
diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp
index 91c386c0..5a2d07a2 100644
--- a/FaceTrackNoIR/tracker.cpp
+++ b/FaceTrackNoIR/tracker.cpp
@@ -321,8 +321,6 @@ void Tracker::run() {
float rawrotX, rawrotY, rawrotZ; // Locals...
float rawposX, rawposY, rawposZ;
- //float new_camera_position.pitch, new_camera_position.yaw, new_camera_position.roll; // Locals...
- //float new_camera_position.x, new_camera_position.y, new_camera_position.z;
SYSTEMTIME now;
long newHeadPoseTime;