Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

FreeTrackIR + Unity3d = Full success!

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

  1. nile1988

    nile1988

    Joined:
    Sep 18, 2012
    Posts:
    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
    Posts:
    2,626
    Well done. Thx ;)
     
  3. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,062
    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
    Posts:
    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
    Posts:
    2,626
    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
    Posts:
    5
    Last edited: Dec 11, 2013
  7. omelchor

    omelchor

    Joined:
    Jun 15, 2011
    Posts:
    19
    Well. :) Thanks
     
  8. nayanseth

    nayanseth

    Joined:
    Feb 7, 2015
    Posts:
    4
    @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:
      196
  9. nayanseth

    nayanseth

    Joined:
    Feb 7, 2015
    Posts:
    4
    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
    Posts:
    17
    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
    Posts:
    4
    SAOTA and gterveen like this.
  12. gterveen

    gterveen

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

    fabio1955

    Joined:
    Nov 11, 2009
    Posts:
    71
    I also would like to have a 64 bit compiled version of the plugin, pease!
     
  14. Psyco92

    Psyco92

    Joined:
    Nov 15, 2013
    Posts:
    14
    Last edited: Jun 1, 2016
  15. drpd

    drpd

    Joined:
    Jan 21, 2013
    Posts:
    3
    Been getting a problem with this script. Seems to be flickering from the Freetrack input?
     
  16. barino-jm

    barino-jm

    Joined:
    Aug 5, 2015
    Posts:
    1
    Been getting a problem with this script. Seems to be flickering from the Freetrack input?


    Me too..
     
  17. BahuMan

    BahuMan

    Joined:
    Jan 26, 2014
    Posts:
    2
    A few comments have been asking how to get it to work in a 64-bit Unity project.
    There is a 64-bit version of the dll supplied as part of FaceTrackNoIR.
    Go to http://www.facetracknoir.nl/ and download the free plugin-pack for FaceTrackNoIR.
    It will install the C:\Program Files (x86)\Abbequerque Inc\FaceTrackNoIR_v200\FreeTrackClient64.dll

    copy that dll in the same "plugins" folder of your Unity project where you found the FreeTrackClient.dll 32-bit version.
    Now, change every mention of FreeTrackClient.dll into FreeTrackClient64.dll

    in C#:
    Code (CSharp):
    1. [DllImport("FreeTrackClient")]
    becomes
    Code (CSharp):
    1. [DllImport("FreeTrackClient64")]