Hello,

I've done with head tracking support for FlightGear. It is consists of general head tracking code for FlightGear and closed source TrackIR server. I can't publish TrackIR related code because of NaturalPoint policy, but program itself is free to use and redistribute with FlightGear Flight Simulator.

Patch for current CVS version and TrackIR server binary attached to this letter. In order to use it apply patch, rebuild FlightGear and place fgtrack.exe in directory contains fgfs.exe.

When FlightGear starting in Windows environment it tries to launch TrackIR server automatically in local mode. It is possible to start TrackIR server manually, for example in order to run TrackIR hardware on one computer and FlightGear on another. In remote mode TrackIR server sits in the system tray and can be configured by right mouse button click.

Head tracking protocol is very easy. Head tracking data is packed in UDP packets. Each packet consists of version number byte (currently equals to 1) and 6 values: head orientation (HEADING, ROLL, PITCH) and head position (X, Y, Z).

All value are in fixed point format 16.16. Angles are in degrees, position in the range [-100.0, 100.0]. Unused valus must be filled with zeroes.

If somebody is going to implement its own head tracking server, he could use following functions to make packet:

void serializeFloat(char *data, float value)
{
    int fixed = (int)(value * 65536.0f);
    data[0] = (fixed >> 24) & 0xFF;
    data[1] = (fixed >> 16) & 0xFF;
    data[2] = (fixed >> 8) & 0xFF;
    data[3] = fixed & 0xFF;
}


void makePacket(char *data, float heading, float roll, float pitch,
                                           float x, float y, float z)
{
    data[0] = 1;
    serializeFloat(data + 1, heading);
    serializeFloat(data + 5, roll);
    serializeFloat(data + 9, pitch);
    serializeFloat(data + 13, x);
    serializeFloat(data + 17, y);
    serializeFloat(data + 21, z);
}


Please note that TrackIR server attached to this letter wouldn't work before next TrackIR drivers release.

--
Best regards,
Alexander Babichev                      http://www.babichev.info

Attachment: trackir.tar.gz
Description: application/gzip

_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to