Motive to Unity

NatNet, VRPN, TrackD, and Plugins
beckdo
NaturalPoint Employee
NaturalPoint Employee
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Motive to Unity

Post by beckdo » Fri Mar 13, 2015 3:55 pm

Hey Brad,

We include a DLL based Unity plug-in project with the Camera SDK. It's unfortunately a bit dated. We found that there were a number of down-sides to the DLL approach to Unity. It's platform-specific, requires a pro license, and struggled with some issues related to connecting directly to the hardware from within the Unity DLL plug-in.

Our customers have had great traction with the simplicity of the sockets based approach and it doesn't suffer from any of the down-sides listed above.

That said, we might in the future and also there's nothing stopping a customer from putting together the DLL.

Thanks,
Doug

hulnglei
Posts: 2
Joined: Sat Aug 11, 2012 9:26 pm

Re: Motive to Unity

Post by hulnglei » Tue Mar 24, 2015 8:18 pm

Hello, the google share is dated. Can you share it again?

BradleyNewman
Posts: 10
Joined: Mon Sep 01, 2014 2:35 pm
Location: Los Angeles, CA
Contact:

Re: Motive to Unity

Post by BradleyNewman » Tue Mar 24, 2015 8:47 pm

hulnglei wrote:Hello, the google share is dated. Can you share it again?
The link should still work..can you explain in more detail the problem you are experiencing?
Bradley Newman
Senior Research Associate
USC School of Cinematic Arts
Worldbuilding Media Lab (WbML) - worldbuilding.usc.edu

DmitriG
Posts: 4
Joined: Wed Jun 17, 2015 3:39 pm

Re: Motive to Unity

Post by DmitriG » Wed Jun 17, 2015 4:42 pm

BradleyNewman wrote:The link should still work..can you explain in more detail the problem you are experiencing?
Hey Bradley,
your UnityProject works perfectly fine for me with rigidBodies!

I'm currently developing a couple of avatar based Unity 5 scenes for my thesis and wondering myself if you had may be already written some parts of code to acquire skeleton data with NatNet SDK (UnityToMotive v2) from Motive (C#) during your project?
In the NatNetSDK\include\NatNetTypes.h file I've found sSkeletonDescription and sSkeletonData structures, but I'm not sure how their actual xml representation in a stream does look like.

Would the following lines be enough to get the skeleton data out of the stream properly?

Code: Select all

public XmlNodeList skeletonList;
// (...) and inside of the 'void OnPacketReceived(...)' method:
xmlDoc.LoadXml(Packet);
skeletonList = xmlDoc.GetElementsByTagName("Skeleton");
Inside this list there is also a child object called 'Bones', but I haven't figured out yet how to traverse through it properly, since I'm not quite familiar with XmlDocument Class:
https://msdn.microsoft.com/en-us/librar ... .110).aspx

Or is there another way to distinguish between DataDescriptors in C# in Unity (e.g. whether it's Descriptor_RigidBody or Descriptor_Skeleton)?

I would appreciate any help or hints on this issue from anyone!

BradleyNewman
Posts: 10
Joined: Mon Sep 01, 2014 2:35 pm
Location: Los Angeles, CA
Contact:

Re: Motive to Unity

Post by BradleyNewman » Thu Jun 18, 2015 11:49 am

I haven't looked into skeletons and don't have plans to do so anytime soon unfortunately. Best of luck though!

Brad
Bradley Newman
Senior Research Associate
USC School of Cinematic Arts
Worldbuilding Media Lab (WbML) - worldbuilding.usc.edu

danwarom
Posts: 7
Joined: Wed Feb 13, 2013 7:08 pm
Location: Los Angeles

Re: Motive to Unity

Post by danwarom » Sun Jun 21, 2015 9:52 am

Hey Bradley,

I just wanted to thank you for offering this up, it was a great framework to start building on top of. I was wondering if you had any problems (or Natural Motion for that matter) with this getting uploaded to Github so we can all contribute? It looks like there's a fair number of us developing on top of something similar and who doesn't love a bit of open source collaboration eh?!

Also, regarding skeleton streaming, the code actually exists in the demo scene provided by Natural Motion. Its a fairly simple tasks to add this to the UDP Streaming code provided by Bradley and look for both. Although I will warn you that in my test case, streaming the skeleton in any capacity took a huge performance hit on the scene in Unity, I went from 60fps to 12fps. While several rigid bodies can stream in realtime with practically no overhead. This was tried both with my integrated UDP streamer and the UDP streamer provided by NM (that streams only skeletons).

Thanks again and like I said, with Bradleys blessing, i'll get these onto Github for all to contribute too.

Cheers
Dan Warom

DmitriG
Posts: 4
Joined: Wed Jun 17, 2015 3:39 pm

Re: Motive to Unity

Post by DmitriG » Mon Jun 22, 2015 10:10 am

Hey Dan,
Also, regarding skeleton streaming, the code actually exists in the demo scene provided by Natural Motion. Its a fairly simple tasks to add this to the UDP Streaming code provided by Bradley and look for both.
Somehow I haven't found this skeleton streaming code in Natural Motion samples or demo scenes. At least not for Unity3D (c# version of it). Could you please point out in what file is it located?
Or do you mean there are some lines related to skeleton streaming in the UnitySample.cpp file?

I'm now on the way to steam skeletons as rigid bodies (there is an option in Motive and I coded according to its xml stream represantation, such as Skeleton>Bones>Bone[], but haven't tested it yet), so that shouldn't actually affect overall performance more than the default rigid bodies' stream.

Cheers,
Dmitri

BradleyNewman
Posts: 10
Joined: Mon Sep 01, 2014 2:35 pm
Location: Los Angeles, CA
Contact:

Re: Motive to Unity

Post by BradleyNewman » Mon Jun 22, 2015 10:22 am

Sure thing, go for it! Here is the latest version which included a fix for a linker error: https://drive.google.com/open?id=0B_5Y8 ... authuser=0

Something that would be cool is if somebody built a Unity plugin for Windows that connected directly with the NatNet stream instead of using UnitySample.exe to connect NatNet and Unity. I'm using this plugin for VR and want to minimize as much latency as possible, so a plugin would be the most direct connection to NatNet to shave off some milliseconds of latency. Although, this would mean somebody would have to maintain the plugin for new Unity versions.

Best,
Brad
Bradley Newman
Senior Research Associate
USC School of Cinematic Arts
Worldbuilding Media Lab (WbML) - worldbuilding.usc.edu

danwarom
Posts: 7
Joined: Wed Feb 13, 2013 7:08 pm
Location: Los Angeles

Re: Motive to Unity

Post by danwarom » Sun Jul 12, 2015 11:05 am

Thanks for that Brad, for those interested, its now live at;

https://github.com/DanWuh/Motive2Unity

Saves you having to maintain a Google Drive entry for it! I'll also add my tweaks to it next week when I'm back in the office.

Cheers
Dan

DmitriG
Posts: 4
Joined: Wed Jun 17, 2015 3:39 pm

Re: Motive to Unity

Post by DmitriG » Thu Jul 16, 2015 6:06 pm

Hey all

finally I've figured it out and extended Bradley's version with the support of multiple skeletons and correct names' representations of their attributes in xml. I also altered xml node names a bit.

Moreover, I added some new stuff to OptitrackRigidBodyManager.cs and to SlipStream.cs.
Also take a look at RigidBody_Local.cs file in attached Unity Project, where I use some getters from OptitrackRigidBodyManager.

It was a bit tricky to get the xml structure for two or more skeletons right, but I haven't experienced any performance drops described by Dan in my Unity scene. Within what size of skeleton's crowd have you tested it? :-)

MotiveToUnity v2.3:
https://drive.google.com/file/d/0B0OTJ5 ... sp=sharing

Make sure you use the correct local interface and Motive streaming settings look as follows in Data Streaming panel:
Stream Markers: False;
Stream Rigid Bodies: True;
Stream Skeletons: True;
Local Rigid Bodies: True;
Skeleton as Rigid Body: False

Cheers,
Dmitri
Last edited by DmitriG on Tue Aug 04, 2015 11:08 am, edited 2 times in total.

Post Reply