FreeTrackIR + Unity3d = Full success!

Discussion in 'Works In Progress' started by nile1988, Mar 18, 2013.

  1. nile1988

    nile1988

    New Member

    Joined:
    Sep 18, 2012
    Messages:
    5
    Video:



    Screenshots:
    https://www.dropbox.com/sh/3629h8xvy3wgqhw/Jot6hOu1fA#/

    About FreeTrack IR http://www.free-track.net/english/freetrack/qu-est-ce-que-c-est.php

    Download FreeTrack (FREE): http://www.free-track.net/english/freetrack/telechargement.php

    >>>Download my unitypackage v1.0: https://www.dropbox.com/s/ftwmsds4ctnv0p6/FreeTrackClient_1.0.unitypackage
    (2 demo scenes included)


    Source code:
    Code (csharp):
    1. using System;
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Runtime.InteropServices;
    5.  
    6. public class FreeTrackClientDll  : MonoBehaviour {
    7.        
    8.        [StructLayout(LayoutKind.Sequential)]
    9.        public struct FreeTrackData
    10.        {
    11.            public int dataid;
    12.            public int camwidth, camheight;
    13.            public Single Yaw, Pitch, Roll, X, Y, Z;
    14.            public Single RawYaw, RawPitch, RawRoll;
    15.            public Single RawX, RawY, RawZ;
    16.            public Single x1, y1, x2, y2, x3, y3, x4, y4;          
    17.        }
    18.        
    19.        [DllImport("FreeTrackClient")]
    20.        public static extern bool FTGetData(ref FreeTrackData data);
    21.  
    22.        [DllImport("FreeTrackClient")]
    23.        public static extern string FTGetDllVersion();
    24.  
    25.        [DllImport("FreeTrackClient")]
    26.        public static extern void FTReportID(Int32 name);
    27.  
    28.        [DllImport("FreeTrackClient")]
    29.        public static extern string FTProvider();
    30.  
    31.                
    32.         public float Yaw=0F;
    33.         public float Pitch=0F;
    34.         public float Roll=0F;
    35.         public float X=0F;
    36.         public float Y=0F;
    37.         public float Z=0F;
    38.        
    39.         public float RawYaw=0F;
    40.         public float RawPitch=0F;
    41.         public float RawRoll=0F;
    42.         public float RawX=0F;
    43.         public float RawY=0F;
    44.         public float RawZ=0F;
    45.        
    46.         public float x1=0F;
    47.         public float y1=0F;
    48.         public float x2=0F;
    49.         public float y2=0F;
    50.         public float x3=0F;
    51.         public float y3=0F;
    52.         public float x4=0F;
    53.         public float y4=0F;
    54.  
    55.          void Update()
    56. {
    57.                 FreeTrackClientDll.FreeTrackData FreeTrackData;
    58.                 FreeTrackData =  new FreeTrackClientDll.FreeTrackData();
    59.                if (!FreeTrackClientDll.FTGetData(ref FreeTrackData))
    60.                {
    61.                    Debug.Log ("FTGetData returned false. FreeTrack likely not working.");
    62.                    return;
    63.                }
    64.      
    65.         FreeTrackClientDll.FTGetData(ref FreeTrackData);
    66.                
    67.                 Yaw = FreeTrackData.Yaw;
    68.                 Pitch = FreeTrackData.Pitch;
    69.                 Roll = FreeTrackData.Roll;
    70.                 X = FreeTrackData.X;
    71.                 Y = FreeTrackData.Y;
    72.                 Z = FreeTrackData.Z;
    73.                
    74.                 RawYaw=FreeTrackData.RawYaw;
    75.                 RawPitch=FreeTrackData.RawPitch;
    76.                 RawRoll=FreeTrackData.RawRoll;
    77.                
    78.                 RawX=FreeTrackData.RawX;
    79.                 RawY=FreeTrackData.RawY;
    80.                 RawZ=FreeTrackData.RawZ;
    81.        
    82.                 x1=FreeTrackData.x1;
    83.                 y1=FreeTrackData.y1;
    84.                 x2=FreeTrackData.x2;
    85.                 y2=FreeTrackData.y2;
    86.                 x3=FreeTrackData.x3;
    87.                 y3=FreeTrackData.y3;
    88.                 x4=FreeTrackData.x4;
    89.                 y4=FreeTrackData.y4;
    90.    }
    91.  }
    92.  
    93.  
    94.  
    Last edited: Mar 18, 2013
  2. ZJP

    ZJP

    Member

    Joined:
    Jan 22, 2010
    Messages:
    1,496
    Well done. Thx ;)
  3. John G.

    John G.

    Member

    Joined:
    Mar 21, 2013
    Messages:
    309
    Excellent, just was messing with my Home-built Freetrack system today for DCS P51D. Will try it out with UnityFS see how it works.

    EDIT: getting the following error.

    DllNotFoundException: FreeTrackClient
    FreeTrackClientDll.Update () (at Assets/FreeTrackInput/FreeTrackClientDll.cs:60)

    Do I need to replace the FreeTrackClient.dll in the plugins with the FreeTrackClient.dll file in the Freetrack folder C:\Program Files\FreeTrack


    Ok moved the file to the plugins folder of the project - but getting a license issue - guess this only works with unity Pro :(
    Last edited: Nov 13, 2013
  4. nile1988

    nile1988

    New Member

    Joined:
    Sep 18, 2012
    Messages:
    5
    No, this is a copy of DLL from C:\Program Files\FreeTrack

    My fail, sorry, I forgot that Unity Free supports only .NET DLLs, and FreeTrack is not *dotNET.
  5. ZJP

    ZJP

    Member

    Joined:
    Jan 22, 2010
    Messages:
    1,496
    Works with Unity Free. The Dll must be placed in the windows/system32 folder for Windows 32B, in the SysWOW64 folder for Windows 64B

    Look at my signature (here too )for more informations about native DLL with Unity Free.
    Last edited: Nov 21, 2013
  6. nile1988

    nile1988

    New Member

    Joined:
    Sep 18, 2012
    Messages:
    5
    Last edited: Dec 11, 2013
  7. omelchor

    omelchor

    New Member

    Joined:
    Jun 15, 2011
    Messages:
    17
    Well. :) Thanks