Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Psyco92 · Jun 01, 2016 at 10:03 AM · inputwebcam

How do I get FaceTrackNoIR's input in Unity?

I have recently obtained FaceTrackNoIR v200 and have it set up and working for at least one game (Elite Dangerous). I already have full working VR menu that works with the SteamVR asset . The scene can handle both having and not having an HMD.

I am wondering how I can use FTNIR's input data in my Unity project

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Psyco92 · Jun 01, 2016 at 01:47 PM

After much hunting, I found the following source and converted it to work with the 64bit version. The data will need to be smoothed and manipulated to work nicely, it seems very raw at the moment.

Go to : C:\Program Files (x86)\Abbequerque Inc\FaceTrackNoIR_v200 And copy : FreeTrackClient64.dll Into your Unity project under : Assets\Plugins Create a script called FreeTrackClientDll and replace its contents with the following :

 using System;
 using UnityEngine;
 using System.Collections;
 using System.Runtime.InteropServices;
 
 public class FreeTrackClientDll : MonoBehaviour
 {
     [StructLayout(LayoutKind.Sequential)]
     public struct FreeTrackData
     {
         public int dataid;
         public int camwidth, camheight;
         public Single Yaw, Pitch, Roll, X, Y, Z;
         public Single RawYaw, RawPitch, RawRoll;
         public Single RawX, RawY, RawZ;
         public Single x1, y1, x2, y2, x3, y3, x4, y4;
     }
 
     [DllImport("FreeTrackClient64")]
     public static extern bool FTGetData(ref FreeTrackData data);
 
     [DllImport("FreeTrackClient64")]
     public static extern string FTGetDllVersion();
 
     [DllImport("FreeTrackClient64")]
     public static extern void FTReportID(Int32 name);
 
     [DllImport("FreeTrackClient64")]
     public static extern string FTProvider();
 
 
     public float Yaw = 0F;
     public float Pitch = 0F;
     public float Roll = 0F;
     public float X = 0F;
     public float Y = 0F;
     public float Z = 0F;
 
     public float RawYaw = 0F;
     public float RawPitch = 0F;
     public float RawRoll = 0F;
     public float RawX = 0F;
     public float RawY = 0F;
     public float RawZ = 0F;
 
     public float x1 = 0F;
     public float y1 = 0F;
     public float x2 = 0F;
     public float y2 = 0F;
     public float x3 = 0F;
     public float y3 = 0F;
     public float x4 = 0F;
     public float y4 = 0F;
 
     void Update()
     {
         FreeTrackClientDll.FreeTrackData FreeTrackData;
         FreeTrackData = new FreeTrackClientDll.FreeTrackData();
         if (!FreeTrackClientDll.FTGetData(ref FreeTrackData))
         {
             Debug.Log("FTGetData returned false. FreeTrack likely not working.");
             return;
         }
         FreeTrackClientDll.FTGetData(ref FreeTrackData);
 
         Yaw = FreeTrackData.Yaw;
         Pitch = FreeTrackData.Pitch;
         Roll = FreeTrackData.Roll;
         X = FreeTrackData.X;
         Y = FreeTrackData.Y;
         Z = FreeTrackData.Z;
 
         RawYaw = FreeTrackData.RawYaw;
         RawPitch = FreeTrackData.RawPitch;
         RawRoll = FreeTrackData.RawRoll;
 
         RawX = FreeTrackData.RawX;
         RawY = FreeTrackData.RawY;
         RawZ = FreeTrackData.RawZ;
 
         x1 = FreeTrackData.x1;
         y1 = FreeTrackData.y1;
         x2 = FreeTrackData.x2;
         y2 = FreeTrackData.y2;
         x3 = FreeTrackData.x3;
         y3 = FreeTrackData.y3;
         x4 = FreeTrackData.x4;
         y4 = FreeTrackData.y4;
     }
 }


Here is a script that works quite nicely for smooth data, it is adapted from the same source. Use RAW input for unfiltered data.

 using UnityEngine;
 using System.Collections;
 
 public class TranslateToCube : MonoBehaviour
 {
     public FreeTrackClientDll fTInput;
     public bool useRAWData;
     public Transform target;
 
     public float positionScale = 0.001f;
     public float positionLerpRate = 5;
     public float rotationScale = 60.0f;
     public float rotationLerpRate = 5;
 
     private Vector3 startPos = Vector3.zero;
     private Vector3 addedPos = Vector3.zero;
 
     private Vector3 startEul = Vector3.zero;
     private Vector3 addedEul = Vector3.zero;
 
     void Start()
     {
         startPos = target.position;
         startEul = target.eulerAngles;
     }
 
     void Update()
     {
         addedPos = Vector3.Lerp(addedPos, (new Vector3(fTInput.X, fTInput.Y, -fTInput.Z) * positionScale), positionLerpRate * Time.deltaTime);
         addedEul = new Vector3(
            Mathf.LerpAngle(addedEul.x, (useRAWData == true ? fTInput.RawPitch : fTInput.Pitch) * rotationScale, rotationLerpRate * Time.deltaTime),
            Mathf.LerpAngle(addedEul.y, (useRAWData == true ? fTInput.RawYaw : fTInput.Yaw) * rotationScale, rotationLerpRate * Time.deltaTime),
            Mathf.LerpAngle(addedEul.z, (useRAWData == true ? fTInput.RawRoll : fTInput.Roll) * rotationScale, rotationLerpRate * Time.deltaTime)
            );
 
         if (target)
         {
             target.position = startPos + addedPos;
             target.eulerAngles = startEul + addedEul;
         }
     }
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Psyco92 · Jun 01, 2016 at 01:49 PM 1
Share

Any and all improvements welcome

avatar image BahuMan · Aug 05, 2017 at 02:04 PM 1
Share

For those who are wondering where to get the FreeTrackClient64.dll : 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 as mentioned in the solution.

avatar image WavyRancheros · Nov 04, 2020 at 10:39 AM 0
Share

Hi, I might be a little late, but I need help with your code.

I successfully integrated it into my project, but I don't understand the values I am receiving.

I am getting the values circled in red. Why am I not receiving the values listed at "Raw Input"?alt text

inked2020-11-04-11-34-13-facetracknoir-li.jpg (443.6 kB)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

64 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UNITY no longer detecting XBOX360 controller input,XBOX 360 controller no longer working with UNITY 0 Answers

Can't disable Mouse wheel's navigation actions,Can't disable Mouse wheel's navigation 0 Answers

Using Nintendo Switch pro controller 0 Answers

How to control aixs gravity, sensitivity in new Input System 4 Answers

Mouse or Touch events independent of framerate 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges