FreeTrack Forum

Welcome, you're not connected. ( Log in - Register )

RSS >  Faking freetrack server
CyberVillain #1 02/01/2012 - 12h41

Class : Apprenti
Posts : 14
Registered on : 07/11/2011

Off line

I'm making a little headtracking software for the Sparkfun 9DOF IMU. I want to send data to the freetrackclient.dll so all programs that implement that dll works with my program. How does the freetrack server send its data to the client? Windows messages, ethernet, MSMQ?
CyberVillain #2 03/01/2012 - 00h00

Class : Apprenti
Posts : 14
Registered on : 07/11/2011

Off line

I reversed engineered the code

A simple test program


using System;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
using System.Threading;

namespace FakeFreeTrack
{
   [StructLayout(LayoutKind.Sequential)]
   public struct TFreeTrackData
   {
       public int DataID;
       public int CamWidth;
       public int CamHeight;
       // virtual pose
       public float Yaw;   // positive yaw to the left
       public float Pitch; // positive pitch up
       public float Roll;  // positive roll to the left
       public float X;
       public float Y;
       public float Z;
       // raw pose with no smoothing, sensitivity, response curve etc.
       public float RawYaw;
       public float RawPitch;
       public float RawRoll;
       public float RawX;
       public float RawY;
       public float RawZ;
       // raw points, sorted by Y, origin top left corner
       public float X1;
       public float Y1;
       public float X2;
       public float Y2;
       public float X3;
       public float Y3;
       public float X4;
       public float Y4;
   };

   class Program
   {
       static void Main(string[] args)
       {
           var random = new Random();
           var count = 0;
               using (var memoryMappedFile = MemoryMappedFile.CreateOrOpen("FT_SharedMem", Marshal.SizeOf(typeof(TFreeTrackData))))
               {
                   using (var accessor = memoryMappedFile.CreateViewAccessor())
                   {
                       while (true)
                       {
                           count++;
                           TFreeTrackData model =  new TFreeTrackData();
                           model.DataID = count;
                           model.CamWidth = 320;
                           model.CamHeight = 240;
                           model.Yaw = random.Next(0, 120) / (float)(180.0 / Math.PI);

                           accessor.Write(0, ref model);
                           Thread.Sleep(5);
                       }
                   }
               }
       }
   }
}
Edited by CyberVillain on 03/01/2012 at 00h15.

 >  Fast reply

Message

 >  Stats

1 user(s) connected during the last 10 minutes (0 member(s) and 1 guest(s)).