Streaming live into Unity - how?

NatNet, VRPN, TrackD, and Plugins
Post Reply
thekapptin
Posts: 3
Joined: Wed Jan 26, 2011 7:16 pm

Streaming live into Unity - how?

Post by thekapptin »

I'm trying to use the motion capture rig as a controller for a game using Unity 2.6.1 (I need skeleton data). I don't really know what I'm doing though. I've messed around with it for several hours but have made no progress.

Is it possible to stream directly into Unity using the NatNet DLLs? If not, what do I have to do to get real time mocap data into Unity? What steps do I have to go through to make this work?

Any help is greatly appreciated.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Streaming live into Unity - how?

Post by morgan »

Yes NatNet supports streaming identified markers, rigid bodies, and skeleton data.

For Unity you would likely stream skeleton data directly. The NatNet sample SampleClient3D shows how to connect to Arena, query Arena for the skeleton hierarchy, and receive the joint angles for each bone every frame.

Also - check this post:

http://forum.naturalpoint.com/forum/ubb ... #Post44771
thekapptin
Posts: 3
Joined: Wed Jan 26, 2011 7:16 pm

Re: Streaming live into Unity - how?

Post by thekapptin »

I've looked over that topic a few times and I unfortunately wasn't able to figure anything out from it.

What I'm really stuck on is actually running the NatNet code in Unity. I just can't figure out how to do it. Unity uses C# (or Javascript) so I can't run the C++ code directly. I have an inkling that a DLL with all the NatNet functions could work, as Unity can make use of C++ DLL plug-ins, but it seems the prepackaged NatNet DLL (NatNetLib.dll) only works with native C++ applications. I need a way to 'bridge the gap' between the C++ sample clients and Unity's C#-based scripting.
Will I need to write a complete DLL that encapsulates the sample code and include NatNetLib.dll?

Thanks for reading,
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Streaming live into Unity - how?

Post by morgan »

Hey Simon,

you have a couple of options:

1. Parse packets directly in Unity/C#. This does not use NatNet, but simply decodes the streaming packets directly. There is an example of how to do this in the NatNet samples (PacketClient Sample) - you would need to port this code to C#. Another forum user I believe has done this.

http://forum.naturalpoint.com/forum/ubb ... #Post44771


2. Use the NatNet .Net wrapper - NatNet SDK ships with a .NET managed assembly that allows for consumption of NatNet data directly by .NET apps. I believe the Unity C# dev environment supports adding .NET assemblies, so just add the NatNetML.dll to your project - all the NatNet types and data will then be available to you. See the NatNet WinForms example for an example of how to do this in C# using VisualStudio and a Winddows Forms application.

3. Write a Unity plugin. This would be your own custom native plugin that sits between Unity and the NatNet SDK.

might be some other approaches as well.

Morgan
thekapptin
Posts: 3
Joined: Wed Jan 26, 2011 7:16 pm

Re: Streaming live into Unity - how?

Post by thekapptin »

That should help a lot. I'll look into those options.

The link you posted is broken. Could you repost it?

Thanks,
NaturalPoint - Mike
Posts: 1896
Joined: Tue Feb 01, 2011 8:41 am
Location: Corvallis, OR

Re: Streaming live into Unity - how?

Post by NaturalPoint - Mike »

Post Reply