Karma: +2/-0
Posts: 7
Offline
|
 |
« on: June 10, 2008, 07:39:43 PM » |
|
Hello people, first, here the demo: http://www.youtube.com/watch?v=QZFhXjlIiXoI've written a little script for glovepie ( http://carl.kenner.googlepages.com/glovepie) to use our beloved wiimote as a 6 degree of freedom headtracker. This can be used with every game that supports TrackIR (see TrackIR.com for list of games...)! The only thing you need is a IR light source with three dots aligned horizontally, the same as Johnny Lee demonstrates plus one dot in the middle; this one needs to be a little bit behind the outer ones (say 5cm or more, see value var.DotDepth). I installed LEDs/reflectors on a cap. The geometry isn't done exactly, but can be calculated very fast this way. Fortunately, your brain can compensate for the small non-linearities that arise due to this! even without headache :-) I would appreciate leaving my name in the scriptheader below. Enjoy and tell me your opinion! Manuel Unternaehrer MyHeadTracker.pie : // 6 Degrees of Freedom Headtracking with wiimote // 2008 by Manuel Unternaehrer // Inspired by Johnny Lee: http://www.cs.cmu.edu/~johnny/projects/wii/
wiimote.Leds = 1 //Choose whatever you like :-)
var.DotDist = .12 //Distance left+right dot, in meters var.DotDepth = 0.045 //Depth of middle dot
//Adjust Smoothing, Amplifying (Factor) and Calibration FakeTrackIR.x=-smooth(var.pos[1],50) FakeTrackIR.y=smooth(var.pos[2],50) FakeTrackIR.z=smooth(var.pos[3],50) FakeTrackIR.yaw=-smooth(var.yaw,50)*30 FakeTrackIR.roll=smooth(var.roll,50) FakeTrackIR.pitch=-smooth((var.pitch - 30),50)*10
var.scenter = [1024,768,0]/2/1024 //Sensor's center var.p1 = [wiimote.dot1x/1024,wiimote.dot1y/1024,0] var.p2 = [wiimote.dot2x/1024,wiimote.dot2y/1024,0] var.p3 = [wiimote.dot3x/1024,wiimote.dot3y/1024,0]
//Look for Left, Right and Middle dot if wiimote.dot1x < wiimote.dot2x then if wiimote.dot1x < wiimote.dot3x then var.pleft = var.p1 var.pmid = 0 else var.pleft = var.p3 var.pmid = var.p1 endif if wiimote.dot2x < wiimote.dot3x then var.pright = var.p3 var.pmid = var.p2 else var.pright = var.p2 if var.pmid = 0 then var.pmid = var.p3 endif else if wiimote.dot2x < wiimote.dot3x then var.pleft = var.p2 var.pmid = 0 else var.pleft = var.p3 var.pmid = var.p2 endif if wiimote.dot1x < wiimote.dot3x then var.pright = var.p3 var.pmid = var.p1 else var.pright = var.p1 if var.pmid = 0 then var.pmid = var.p3 endif endif
//Do the geometric stuff if wiimote.dot1vis and wiimote.dot2vis and wiimote.dot3vis then
var.posZ = var.DotDist/Tan(Abs(var.pright-var.pleft)*45) var.pos = ((var.pright+var.pleft)/2-var.scenter)*var.posZ + [0,0,var.posZ]
var.roll = aSin((var.pright-var.pleft)[2]/Abs(var.pright-var.pleft))
var.pmidoff = Abs((var.pright-var.pleft) cross (var.pmid-var.pleft))/Abs(var.pright-var.pleft)^2 //0..1,middle dot off-line var.pmidcent = ((var.pright-var.pleft) dot (var.pmid-var.pleft))/Abs(var.pright-var.pleft)^2 //0..1, middle dot off-center
var.turn = aTan((0.5-var.pmidcent)/(var.DotDepth*Cos(var.pitch)/var.DotDist)) var.yaw = var.turn - 45*((var.pright+var.pleft)/2-var.scenter)[1]
var.pitch = aSin(var.pmidoff/(var.DotDepth/var.DotDist)) + 45*((var.pright+var.pleft)/2-var.scenter)[2]
debug = smooth(var.pos,50) + " " + smooth(var.yaw,50) + " " + smooth(var.pitch,50)+ " " + smooth(var.roll,50)
endif
//Test 3D Visualisation, comment out if not needed obj4.colour= 0xFFFF00 obj4.cubesize= 10cm obj4.x=0. obj4.y=0. obj4.z=1.3m obj5.colour= 0xFFFFFF obj5.cubesize= 2cm obj5.x=0. obj5.y=0. obj5.z=1m
cam.x=-smooth(var.pos[1],50) *5 cam.y=smooth(var.pos[2],50) *5 cam.z=-smooth(var.pos[3],50) *3 +1 cam.yaw=-smooth(var.yaw,50) cam.roll=smooth(var.roll,50) cam.pitch=-smooth((var.pitch-30),50)
|
|
|
|
« Last Edit: July 11, 2008, 05:17:25 PM by manuel82 »
|
Logged
|
|
|
|
Karma: +0/-1
Posts: 22
Offline
|
 |
« Reply #1 on: June 10, 2008, 11:45:28 PM » |
|
I think that you are my hero. Could I use this with HL2 or Doom3 (Quake etc...) instead of the other first person shooters thats mentioned in the list?
|
|
|
|
|
Logged
|
|
|
|
Karma: +2/-0
Posts: 7
Offline
|
 |
« Reply #2 on: June 11, 2008, 09:42:50 PM » |
|
Hi,
I'm not quite sure whether this works with other games. Probably not over the TrackIR Interface. Depending on how the camera in this games are controlled, the script could be adapted do control it according to your head moving...
Here another little piece of code. this time it's a sort of fishtank made with glovePie, like the one Johnny Lee presents. You need a 2-dot glasses. there's even an object "in front of the monitor". Closing one eye gets a much stronger effect, try it out!
greets, Manuel
PS: insert "cam.Stereoscopic=true" and watch it with colored glasses... amazing ! :-)
fishtank.pie use the one below
|
|
|
|
« Last Edit: June 13, 2008, 10:23:07 AM by manuel82 »
|
Logged
|
|
|
|
Karma: +0/-1
Posts: 22
Offline
|
 |
« Reply #3 on: June 11, 2008, 10:37:58 PM » |
|
Like i said before.. H.E.R.O.!!!
Thank you will play with this glovepie script later!
|
|
|
|
|
Logged
|
|
|
|
Karma: +2/-0
Posts: 7
Offline
|
 |
« Reply #4 on: June 13, 2008, 10:22:19 AM » |
|
Me again, with a much better fishtank  fishtank2.pie // Fishtank with glovepie and wiimote, 2 dots needed // Watching the fishtank, Close one eye, the effect is much greater! // 2008 by Manuel Unternaehrer // Inspired by Johnny Lee: http://www.cs.cmu.edu/~johnny/projects/wii/
pie.framerate=50Hz
wiimote.Leds = 1 //Choose whatever you like :-)
var.DotDist = .12 m //Distance left+right dot, in meters var.ScreenHeight = .18 m //Visualisation Window's Height, measured with ruler
//interesting part cam.x=-smooth(var.pos[1],5) cam.y=smooth(var.pos[2],5) cam.z=-smooth(var.pos[3],5) cam.yaw=smooth(var.yaw,5) cam.roll=0 cam.pitch=-smooth((var.pitch),5) cam.vFov=aTan(var.ScreenHeight/(smooth(var.posZ,5))/2)*2 cam.nearclip=10cm // cam.Stereoscopic=true
// the rest is my degenerated 6DOF Headtracker (with much shorter code)
var.scenter = [1024,768,0]/2/1024 //Sensor's center var.p1 = [wiimote.dot1x/1024,wiimote.dot1y/1024,0] var.p2 = [wiimote.dot2x/1024,wiimote.dot2y/1024,0]
//Look for Left, Right and Middle dot if wiimote.dot1x < wiimote.dot2x then var.pleft = var.p1 var.pright = var.p2 else var.pleft =var.p2 var.pright = var.p1 endif
//Do the geometric stuff if wiimote.dot1vis and wiimote.dot2vis then
var.posZ = var.DotDist/Tan(Abs(var.pright-var.pleft)*45) var.pos = ((var.pright+var.pleft)/2-var.scenter)*var.posZ*3.14/4 + [0,0,var.posZ]
var.yaw = 45*((var.pright+var.pleft)/2-var.scenter)[1] //Changed for Fishtank demo
var.pitch = 45*((var.pright+var.pleft)/2-var.scenter)[2] //Changed for Fishtank demo
endif
debug = smooth(var.pos,0) + " " + smooth(var.yaw,0) + " " + smooth(var.pitch,0)+ " " + smooth(var.roll,0)
//Test 3D Visualisation, comment out if not needed obj4.colour= 0xFFFF00 obj4.cubesize= var.ScreenHeight obj4.x=0. obj4.y=0. obj4.z=.5m
obj5.colour= 0xFFFFFF obj5.cubesize= 2cm obj5.x=0. obj5.y=0. obj5.z=0.2m
//Object "in front of the monitor": obj12.colour= 0x0000FF obj12.cubesize= 2cm obj12.x=0. obj12.y=0. obj12.z=-0.1m
obj1.colour= 0xFFFF00 obj1.cubesize= 2cm obj1.pos = [-var.ScreenHeight/2,-var.ScreenHeight/2,.2]
obj2.colour= 0xFFFF00 obj2.cubesize= 2cm obj2.pos = [var.ScreenHeight/2,-var.ScreenHeight/2,.2]
obj6.colour= 0xFFFF00 obj6.cubesize= 2cm obj6.pos = [-var.ScreenHeight/2,var.ScreenHeight/2,.2]
obj7.colour= 0xFFFF00 obj7.cubesize= 2cm obj7.pos = [var.ScreenHeight/2,var.ScreenHeight/2,.2]
obj8.colour= 0xFFFF00 obj8.cubesize= 2cm obj8.pos = [var.ScreenHeight/2,-var.ScreenHeight/2,.0]
obj9.colour= 0xFFFF00 obj9.cubesize= 2cm obj9.pos = [-var.ScreenHeight/2,-var.ScreenHeight/2,.0]
obj10.colour= 0xFFFF00 obj10.cubesize= 2cm obj10.pos = [var.ScreenHeight/2,var.ScreenHeight/2,0.0]
obj11.colour= 0xFFFF00 obj11.cubesize= 2cm obj11.pos = [-var.ScreenHeight/2,var.ScreenHeight/2,.0]
|
|
|
|
|
Logged
|
|
|
|
Karma: +2/-0
Posts: 7
Offline
|
 |
« Reply #5 on: June 19, 2008, 06:30:15 PM » |
|
300 views an no feedbacks?  But I hope some of you try it out and see how well it works... Greets
|
|
|
|
|
Logged
|
|
|
|
Karma: +0/-1
Posts: 22
Offline
|
 |
« Reply #6 on: June 19, 2008, 09:29:44 PM » |
|
I have tried it. I LOVE it!!!!!
I didn't know you could place objects (cubes) on screen using glovepie. Is it possible to place complex models in a simalar way?
|
|
|
|
|
Logged
|
|
|
|
Karma: +0/-0
Posts: 3
Offline
|
 |
« Reply #7 on: June 23, 2008, 09:54:28 AM » |
|
wow, excellent work!
Can you please explain the maths and how you calculated the 6DOF? if its not too much to ask could you also upload an diagram showing the how its calcaulated?
I've been trying to figure out how to do 6DOF (and I couldn't work out how the POSIT algorithm works) thanks in advanced,
I've been struggling with 6DOF for such a long time, if you could help me out your a star man!
Anhar
|
|
|
|
|
Logged
|
|
|
|
Karma: +2/-0
Posts: 7
Offline
|
 |
« Reply #8 on: July 07, 2008, 05:38:13 PM » |
|
here the demo: http://www.youtube.com/watch?v=QZFhXjlIiXoI'll make a documentation as soon as I have time and I'm in the mood to do it :-) Greets BTW: in this demo I used a negativ "DotDepth" value, because the middle dot is *in front of* the others
|
|
|
|
« Last Edit: July 08, 2008, 01:14:15 PM by manuel82 »
|
Logged
|
|
|
|
Karma: +0/-1
Posts: 22
Offline
|
 |
« Reply #9 on: July 07, 2008, 09:33:14 PM » |
|
OH MAN!!!! Thats sooooo what i'm after!!
I take it its easy to use the glovepie script, then start a game and then start playing?
|
|
|
|
|
Logged
|
|
|
|
Karma: +0/-0
Posts: 24
Offline
|
 |
« Reply #10 on: July 09, 2008, 10:41:31 PM » |
|
here the demo: http://www.youtube.com/watch?v=QZFhXjlIiXoI'll make a documentation as soon as I have time and I'm in the mood to do it :-) Greets BTW: in this demo I used a negativ "DotDepth" value, because the middle dot is *in front of* the others Wow, I love what you have done with this! Thank you! I have a question though. I used the fishtank one that uses the 2 dot glasses. I can run the script and watch what happens to the cubes within glovepie, but how can I get it to work with TrackIR games like you did in the video. I have downloaded the demo of "Live for Speed" from the TrackIR website you included. Am I doing something wrong?
|
|
|
|
|
Logged
|
|
|
|
Karma: +2/-0
Posts: 7
Offline
|
 |
« Reply #11 on: July 10, 2008, 03:33:40 PM » |
|
Hi,
in order to use it in games you need the first script, the "headtracker" and not the "fishtank". This one needs 3 dots, as you can see in the youtube movie, so as to calculate not only the position of your head (X,Y,Z) but also its turning-axes (Pitch, Yaw and Roll). Using a 3dot headset, simply run the script in glovepie, minimize the glovepie window, start the game, et voilą, that's it. (Glovepie simulates a virtual TrackIR-device)
I hope this helps you
greets
|
|
|
|
|
Logged
|
|
|
|
Karma: +0/-0
Posts: 24
Offline
|
 |
« Reply #12 on: July 10, 2008, 05:33:56 PM » |
|
Hi,
in order to use it in games you need the first script, the "headtracker" and not the "fishtank". This one needs 3 dots, as you can see in the youtube movie, so as to calculate not only the position of your head (X,Y,Z) but also its turning-axes (Pitch, Yaw and Roll). Using a 3dot headset, simply run the script in glovepie, minimize the glovepie window, start the game, et voilą, that's it. (Glovepie simulates a virtual TrackIR-device)
I hope this helps you
greets
Perfect! Thanks for your help! Do you have any ideas of how to make my 2 dot glasses into 3 dots?
|
|
|
|
|
Logged
|
|
|
|
Karma: +0/-0
Posts: 4
Offline
|
 |
« Reply #13 on: July 13, 2008, 08:20:12 PM » |
|
I always thought a 3-horizontal-LEDs system would work. Looks like someone beat me to the punch.  Now that you can use your head as a pointer, if you combine that with the "look margin" technique seen in Metroid Prime 3, the Wiimote in your hand becomes free to point wherever you want. Now that you don't have to use a Wiimote you hold for looking and turning, Two-mote Style (holding a Wiimote in each hand) is now an option. (Use the D-Pad for moving and strafing) Granted, a head pointer isn't precise enough to select objects like you would with a normal pointer, but that's no big deal. You could just use a Wiimote the normal way for that.
|
|
|
|
« Last Edit: July 13, 2008, 08:39:19 PM by Maginomicon »
|
Logged
|
|
|
|
Karma: +0/-0
Posts: 1
Offline
|
 |
« Reply #14 on: August 06, 2008, 04:36:30 PM » |
|
This is awesome. I purchased a Wiimote (~$30) a bluetooth adapter ($30 from target) and some IR led's, resistor, AC adapter, some solder and misc stuff ($30 from radio shack)...
I have GlovePIE and your script, but when I run your script and go into FSX nothing happens. Im sure there's more to it than just that?
This would make me infinitely happy if I could get this to work with FSX.
|
|
|
|
|
Logged
|
|
|
|
|