Page 3 of 3

Re: iPhone support

Posted: Wed Sep 17, 2014 7:58 am
by Player2
it should be something like this:

Code: Select all


if starting:
   centerYaw = 0 
   centerPitch = 0
   centerRoll = 0
   yaw = 0
   pitch = 0
   roll = 0

yaw = iPhone[0].yaw
pitch = -iPhone[0].roll
roll = iPhone[0].pitch

trackIR.yaw = yaw - centerYaw
trackIR.pitch = pitch - centerPitch
trackIR.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll
take care of idents! centerYaw=0 etc. should run just on starting.

gl

Re: iPhone support

Posted: Wed Sep 17, 2014 8:02 am
by Player2
And don't forget to protect your head from exploding batteries!!!

Re: iPhone support

Posted: Wed Sep 17, 2014 10:25 am
by iBookworm
Thanks for the help! I ran your script, but got an error telling me that the iPhone plugin is not sub-scriptable. So I removed the [0]s, and now the script runs. But again, nothing happens in TrackIR when the script is running.

I have no idea what the bracketed zeroes were for. Did I screw up the script by removing them?

Is there something I should be doing in the TrackIR client? It says it can't detect a device, even when the script is running.

Re: iPhone support

Posted: Wed Sep 17, 2014 10:31 am
by iBookworm
Just added diagnostics for watching TrackIR. The numbers for TrackIR's pitch, yaw, and roll directly mirror the iPhone's.

Is this data simply not getting to the TrackIR client?

Or is the data in the wrong form? Should I be running some sort of math conversion?

Re: iPhone support

Posted: Thu Sep 18, 2014 1:46 am
by Player2
TrackIR emulation won't work in every application - they are hiding / encrypting the data. LFS (Live for Speed) was the only game i managed to work with trackIR emulation.
You can read more about the topic here: http://naturalpointofview.blogspot.hu/.

Re: iPhone support

Posted: Thu Sep 18, 2014 2:33 am
by CyberVillain
There is a way of fixing this, but I dont have the time to get it working, if someone with C++ skills would like to look at it i would be thrilled, see issue #30 below.

https://github.com/AndersMalmgren/FreePIE/issues/30

The only skilled C++ guy on the crew are my brother, and he is not very active so I would really like if someone that is skilled in that area would like to join the crew

Re: iPhone support

Posted: Thu Sep 18, 2014 9:37 am
by iBookworm
Good to know. I'll forget the TrackIR and try Freetrack instead.

Unfortunately, I get the same result: nothing. No effect in the Freetrack client program, and no effect in Outerra either.

Any idea what I'm doing wrong?

Here's my script:

if starting:
centerYaw = 0
centerPitch = 0
centerRoll = 0
yaw = 0
pitch = 0
roll = 0

yaw = iPhone.yaw
pitch = -iPhone.roll
roll = iPhone.pitch

freeTrack.yaw = yaw - centerYaw
freeTrack.pitch = pitch - centerPitch
freeTrack.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll

diagnostics.watch(iPhone.pitch)
diagnostics.watch(iPhone.roll)
diagnostics.watch(iPhone.yaw)
diagnostics.watch(freeTrack.yaw)
diagnostics.watch(freeTrack.roll)
diagnostics.watch(freeTrack.pitch)

Re: iPhone support

Posted: Thu Sep 18, 2014 10:54 am
by CyberVillain
"No effect in the Freetrack client program"

Are you running freepie and freetrack client at the same time? That wont work, FreePIE is replacing the Freetrack program

Also you cant both write and read from the Freetrack plgugin, it will get confused

This is a read diagnostics.watch(freeTrack.yaw) and this is a write freeTrack.roll = roll - centerRoll

Re: iPhone support

Posted: Thu Sep 18, 2014 4:03 pm
by iBookworm
Woohooo! Thanks CyberVillain! I got it to work in War Thunder with TrackIR (not Freetrack).

I'm not done with pestering you yet, though. ;) At the moment I get barely any movement. A full 360 degree turn of the iPhone brings only about five degrees in War Thunder. Is there any way to increase the sensitivity? Ideally to match the iPhone's motions and the virtual head's motions as closely as possible (full match won't be possibly, I know, but as close as I can get).

I'd just use an iPhone Air Mouse program but I'm pairing this with a DIY Rift, and I need the roll axis.

Re: iPhone support

Posted: Thu Sep 18, 2014 4:16 pm
by CyberVillain
What units are the ipone in? radians or degrees?

If my memory serves me right trackir is in degrees so if iphone spits out radians you wont do much moving

Re: iPhone support

Posted: Thu Sep 18, 2014 4:33 pm
by iBookworm
Ha! Yep. After my last post I started thinking about that. Looked at the "Watch" window and saw that the data maxed out at pi. Figured War Thunder was translating that into degrees. So I divided 360 by pi and plugged the result in as a "* multiply" in FreePie. I now have 360 degree head tracking. This works way, way better than any of my homemade TrackIR kit (no translation, of course, but for almost 1-to-1 movement and great responsiveness I'm willing to live with that).

Thanks so much for your help, CyberVillain, and you too, PlayerTwo.

For anyone who's interesting in doing the same thing, here's the completed script. I removed the "- centerYaw" etc. function since I couldn't figure out how to make it work with "* multiply." So far I just center myself with the mouse before starting. We'll see if I run into any problems when I start using this thing for real.

if starting:
centerYaw = 0
centerPitch = 0
centerRoll = 0
yaw = 0
pitch = 0
roll = 0
multiply = 114.591559026

yaw = -iPhone.yaw
pitch = iPhone.roll
roll = iPhone.pitch

trackIR.yaw = yaw * multiply
trackIR.pitch = pitch * multiply
trackIR.roll = roll * multiply

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll

diagnostics.watch(iPhone.pitch)
diagnostics.watch(iPhone.roll)
diagnostics.watch(iPhone.yaw)

Re: iPhone support

Posted: Fri Sep 19, 2014 12:54 am
by CyberVillain
Nice that you got it to work, there are built in suppot for this in Python and thus in FreePIE

https://docs.python.org/2/library/math. ... conversion

Re: iPhone support

Posted: Fri Sep 19, 2014 6:33 am
by iBookworm
Oh cool. So I could probably use something like

trackIR.yaw = math.degrees(iPhone.yaw)

to automatically convert the iPhone's radians to degrees.

Tried out the whole package last night: DIY Rift HMD, War Thunder, and my iPod Touch 4G for tracking. :woot It worked really, really well. With the tracking, I felt like the HMD was a window into another world. I had a blast buzzing an aircraft carrier with tight, controlled turns, turns that you just can't do without the spacial orientation that head tracking brings.

Palmer praised the iPhone's sensors somewhere on MTBS back when he was working on the FOV2GO. He said they are very accurate with little drift. That's been my experience so far. I've never tried the Rift, but the fluidity and the responsiveness of the iPod was what I'd imagined when I read about people's experiences with the Rift. (I should note that I'm using an iPod for this, and I haven't noticed any of the stuttering or latency issues that some people have reported with the iPhone.) It seems one-to-one. I've noticed a little drift, but it always seemed to come after my poor little MacBook Air dropped frames in War Thunder (it ain't a gaming machine, though it does better than I figured it would), so it's probably not the iPod's fault. I think FreePIE uses less CPU than TrackIR, too — or at least, less than FreeTrack. What a great program.

Now what I'd love to do is to figure out how to use FreePIE and the iPod to mimic the Rift's tracker in all those Unity Rift demos . . . but I gather that no one has been able to trick the computer into thinking there's a Rift plugged in yet. Does that mean FreePIE's Rift plugin only works with the Rift as read, not write?

Re: iPhone support

Posted: Fri Sep 19, 2014 7:54 am
by CyberVillain
Always fun to read above real world usages of FreePIE (I havent used it myself alot in that way :D)

Both TrackIr (Maybe TrackIR uses hardware) and freetrack uses the CPU to decode the video feed into cordinates so that will offcourse take alot of resources

About rift, yeah the only way to get it to work with ALL Rift content is to simulate the tracker HID of the Rift.
Unity demos uses a SDK dll so those could be possible to fake using a fake dll.

There is not just the tracker data though, you also need to solve the barrel distortion stuff etc, frankly I dont have the time :/

I need more people ;)

Re: iPhone support

Posted: Fri Sep 19, 2014 10:06 am
by iBookworm
Well, the warping is usually done in the Unity demos. Some demos won't start without the Rift. Some will start but will switch to a regular screen when they don't detect the Rift. But some do start up with the warping going. The best experience I've had in terms of 3D and depth has been with RiftSino. It works really well with the optics of my DIY Rift, though my field of view isn't as good as the real Rift. But alas, no head tracking. Conversely, I get great head tracking in War Thunder but the TriDef 3D in that is just a mess. The 3D scale isn't quite right and the textures are missing half the time.

If there were a way to use the iPhone for tracking even just in a few Unity demos, that would be amazing. Making a fake dll is far beyond me, though. But no worries. FreePIE is amazing as it is. I can't be greedy. :)

Re: iPhone support

Posted: Fri Sep 19, 2014 10:26 am
by CyberVillain
The unity demos uses the SDK for the distortion, so that needs to be faked too, or if you relay that part of the SDK to the original SDK. But I think that wont work with the never 4.x SDK

Re: iPhone support

Posted: Mon Sep 22, 2014 1:26 pm
by iBookworm
Hmm. You're right. But some Unity demos, like RiftSino, run with warping without the SDK even installed. I wonder what determines that.

Re: iPhone support

Posted: Thu Dec 25, 2014 10:29 pm
by Corsair911
Hey, sorry to be late to the party, but I've been scouring the net for only 2 days! I'm going to try and attempt to use a iPhone 6 (not 6+) as a HMD by using it with google cardboard as a starting point. Right now all I care about getting to work is Minecrift since it doesn't need a true oculus to work. So far I've gotten it to work more or less by using the iPhone tracking to mouse emulation. I've also seen that FreePIE can emulate the Hydra. Is there any script to use a iPhone's tracking to emulate the Hydra? I have no idea how to code. :D

Thanks