1. Submit bugs to enter our 5.4 Beta Sweepstakes. Read more about it here.
  2. Unity 5.4 public beta is now available for all users. Grab the build and visit the 5.4 beta forum.
  3. Missing a module? More about the new installer in 5.3 here.
  4. 4.7.1 released for Xcode 7.3 support. Thread here.

FreeTrackIR + Unity3d = Full success!

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

  1. nile1988

    nile1988

    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
    DxStd_IgnatPribylov likes this.
  2. ZJP

    ZJP

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

    John G.

    Joined:
    Mar 21, 2013
    Messages:
    917
    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

    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

    Joined:
    Jan 22, 2010
    Messages:
    2,380
    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

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

    omelchor

    Joined:
    Jun 15, 2011
    Messages:
    18
    Well. :) Thanks
     
  8. nayanseth

    nayanseth

    Joined:
    Feb 7, 2015
    Messages:
    3
    @nile1988 Even in the pro version it says could not locate the dll file. How to proceed?
     

    Attached Files:

    • 1.png
      1.png
      File size:
      116.2 KB
      Views:
      135
  9. nayanseth

    nayanseth

    Joined:
    Feb 7, 2015
    Messages:
    3
    If anyone is facing dll not found exception, then do the following things:
    1. Switch to trial version of pro
    2. Put all the scripts in the home directory of Assets. The dll not found issue is coming because dll file is in sub-folders.
     
  10. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Messages:
    10
    I would love to try this out, but I get "Failed to load 'Assets/FreeTrackClient.dll', expected 64 bit architecture (IMAGE_FILE_MACHINE_AMD64), but was IMAGE_FILE_MACHINE_I386. You must recompile your plugin for 64 bit architecture." ... is there a 64 bit version of the dll available?
     
  11. nayanseth

    nayanseth

    Joined:
    Feb 7, 2015
    Messages:
    3
    SAOTA and gterveen like this.
  12. gterveen

    gterveen

    Joined:
    Dec 17, 2012
    Messages:
    10
    awesome, thank you mate :)
     
  13. fabio1955

    fabio1955

    Joined:
    Nov 11, 2009
    Messages:
    68
    I also would like to have a 64 bit compiled version of the plugin, pease!