Real time motion capture in Unity3D with OptiTrack

warren
Posts: 3
Joined: Thu Sep 09, 2010 6:50 pm

Re: Real time motion capture in Unity3D with OptiTrack

Post by warren »

Well, I have a third Unity3D use/question. (note: I am a programming amateur).

I'd like to send each visible blob's size and X,Y coordinates into my Unity3D project (I'm using a single OptiTrack camera for a DIY multitouch table).

As far as I can tell, Unity3D only allows I/O through a dll "plugin" (and only with it's Pro software version). Based off this page in the manual:
http://unity3d.com/support/documentatio ... ugins.html

So, I'll need to use the new OptiTrack Camera SDK to create a DLL with exported functions (in Visual Studio), yeah?
Or would it be easier to just slip in some calls to the old Baseline OptiTrack SDK's cameradll.dll?

Would appreciate any advice from the smart folk. Will post my progress in this thread, if I make any.


p.s. This blog was recommended for it's advice on creating a dll in Visual Studio:
http://geeklit.blogspot.com/2006/08/cal ... rom-c.html
...but I'm really nervous that I'm making this all too complicated. (And, I sure would love to avoid learning how to use VisualStudio. Already pretty busy with tutorials for Maya, MotionBuilder, Unity3D, and OptiTrack Expression.)
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Real time motion capture in Unity3D with OptiTrack

Post by beckdo »

Hey Warren,

I'm sure you're cooking up something interesting. What you're describing is pretty straight-forward to accomplish with the new Camera SDK and would be a worthy addition to the included samples. I think that with a Unity/Camera SDK plug-in users could make some really cool stuff in Unity.

I just implemented a native DLL plug-in to Unity in the last week, so it's fresh in my mind. I'll see if I can put something together.

D
ypapelis
Posts: 9
Joined: Mon Nov 08, 2010 8:44 am

Re: Real time motion capture in Unity3D with OptiTrack

Post by ypapelis »

Warren,

I wrote a Unity C# script to receive udp messages from a C/C++ program and use them to move objects in the Unity environment. I also wrote a simple C/C++ program to receive the Arena messages and repackage them for sending to Unity. It works pretty well, especially because the coordinate systems in Arena and Unity can be made to match, and angles use Quaternion.

The only "catch" on the Unity side is that in order to use blocking messages, I had to use a thread, and threads in Unity cannot modify the game objects; so I had to use a shared array and a lock to ensure mutual exclusion between the Unity thread receiving the messages and the 'Update' function that moves the actual objects.

Hope that helps; I would be willing to share the scripts but they are pretty messy right now.
zakro
Posts: 1
Joined: Tue Mar 29, 2011 4:32 am

Re: Real time motion capture in Unity3D with OptiTrack

Post by zakro »

Hi, I�m trying to do the same but I have a problem: the dll that is provided with NatNet (NatNetLib.dll) has decorated function names. Is it posible that someone from NaturalPoint change this? The only thing to do is to export the functions with an "export 'C' " block. This would help a lot.
Post Reply