Unity Community


Results 1 to 7 of 7

  1. Location
    Russia
    Posts
    5

    Lightbulb FreeTrackIR + Unity3d = Success!

    Video:



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

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

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

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


    Source code:
    Code:  
    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.  }
    Last edited by nile1988; 03-18-2013 at 01:58 PM.

  2. ZJP ZJP is online now

    Location
    GMT -4/-5
    Posts
    1,301


  3. Posts
    225
    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 by John G.; 11-12-2013 at 04:09 PM.


  4. Location
    Russia
    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 is online now

    Location
    GMT -4/-5
    Posts
    1,301
    Quote Originally Posted by nile1988 View Post
    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.
    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 by ZJP; 11-21-2013 at 07:05 AM.


  6. Location
    Russia
    Posts
    5
    FreeTrack Delphi sources https://github.com/PeterN/freetrack
    May be somebody wants to make .Net port of FTclient specially for UnityFree users.

    PS: ZJP, tnx for reply!
    Last edited by nile1988; 12-11-2013 at 06:00 AM.


  7. Posts
    17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •