 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
rambozo79
Joined: 15 Mar 2007 Posts: 7
Digg It |
Posted: Sat Mar 17, 2007 3:31 pm Post subject: Help with an IR script. |
|
|
I am trying to use dot1 and dot2 for tracking. In my script, if both dots are visible then it will add the value of each then divide by two in order to get the average, which I use to define directinputx. And that bit works fine.
Aside from using both dots, I also want to be able to use just one dot, in the cases where both are not visible. So basically, I want one dot to be able to pick up where the both left off.
I have been been trying to accomplish this by offsetting the only visible dot by the distance between the dots when they were visible. That should give me the rough distance of where the invisible dot should be, if it was visible. I imagine this to be true because the physical distance between the dots is static, the physical distance between the LEDs in the sensor bar. But It seems that when redefining mouse.directinputx with these values, the cursor still jumps on the screen, as if my virtual dot is nowhere near where the physical dot was.
What am I overlooking? Where am I going wrong?
I don't know if this is reinventing the wheel, but I imagine it to be a better way of IR tracking. It should expand the tracking range beyond tracking off of one dot, and by tracking off of the value between the two dots, it should put the cursor closer to the center of the screen without having to offset your sensor bar from one side of the screen to the other.
Anyway, here is my code.
| Quote: |
var.deadzone = 30
If wiimote.dot1vis = false and wiimote.dot2vis = false then
var.k = mouse.DirectInputX
var.l = mouse.DirectInputY
var.x = mouse.directinputX
endif
If wiimote.dot1vis = true and wiimote.dot2vis = true then
var.k = ((wiimote.dot2x)+(wiimote.dot1x)/2)
var.l = ((wiimote.dot2y)+(wiimote.dot1y)/2)
if wiimote.dot2x > wiimote.dot1x then
var.m = (wiimote.dot2x - wiimote.dot1x)
endif
if wiimote.dot1x > wiimote.dot2x then
var.m = (wiimote.dot1x - wiimote.dot2x)
endif
Mouse.directinputx = (screen.desktopwidth - round(var.k))*screen.Width/screen.desktopwidth
mouse.directinputy = round(wiimote.dot2y)*screen.height/screen.desktopheight
var.x = mouse.directinputx
endif
If wiimote.dot1vis = false and wiimote.dot2vis = true then
//var.j = (wiimote.dot2vis + var.k) + (wiimote.dot2x - (screen.desktopwidth/2))
var.j = wiimote.dot2x + var.m
var.v = (wiimote.dot2x + var.j) / 2
Mouse.directinputx = (screen.desktopwidth - round(var.v))*screen.Width/screen.desktopwidth
//var.x = mouse.directinputx
mouse.directinputy = round(wiimote.dot2y)*screen.height/screen.desktopheight
endif
If wiimote.dot1vis = true and wiimote.dot2vis = false then
var.j = wiimote.dot1x + var.m
var.v = (wiimote.dot1x + var.j) / 2
Mouse.directinputx = (screen.desktopwidth + round(var.v))*screen.Width/screen.desktopwidth
//var.x = mouse.directinputx
mouse.directinputy = round(wiimote.dot1y)*screen.height/screen.desktopheight
endif |
|
|
| Back to top |
|
 |
Dr_Zoidberg
Joined: 29 Dec 2006 Posts: 60
Digg It |
Posted: Sat Mar 17, 2007 4:15 pm Post subject: |
|
|
I have been doing this with my IR FPS script. http://www.wiili.org/forum/new-fps-ir-script-using-directinput-t1639.html
Have a look at the first half of the Script where it says Phantom dot.
It is not as easy as I thought it would be.
You haven't included any angle calculation in your script, so you will get a jumpy cursor if you tilt your wiimote.
The distance (reported by the wiimote) between the two dots changes more than it should. Just show the distance variable in the debug line and you will see it changing depending on how far the dots are from the edge of the wiimote sensor.
If only one dot is visible you don't know if the distance between the wiimote and the sensorbar has changed and therefore can't correct the distance between the two dots.
With some fixes it works quite well and I use the extended range for turning in fps games. If glitches happen, they shouldn't matter. |
|
| Back to top |
|
 |
rambozo79
Joined: 15 Mar 2007 Posts: 7
Digg It |
Posted: Sat Mar 17, 2007 7:01 pm Post subject: |
|
|
Oh man, it appears that I was trying to reinvent the wheel. Everything I have been trying to accomplish with this script, you have already worked out. Even the bit about continuing cursor movement when the dots are no longer visible.
I guess this means that further work on my script is useless.
And no, I haven't yet calculated angles in my script, obviously. I only realized the issue last night, and haven't even begun to try and figure it out. I was just discussing it with my father last night. But it seems you have already figured it out.
Anyway, no problem. I am happy to see this script of yours. I will just adopt it and start playing some armed assault.
But before I start into another pointless endeavor, do you happen to know how to map the nunchuck rawforce to the "E" and "Q" keys. tilting the chuck would be great for leaning. I haven't looked all through your script yet, so forgive me if that is in there too.
Anway, I'm about to try it out.
Thanks again dude.
And know, it isn't easy. I have been wracking my brain over it. |
|
| Back to top |
|
 |
rambozo79
Joined: 15 Mar 2007 Posts: 7
Digg It |
Posted: Sun Mar 18, 2007 2:33 am Post subject: |
|
|
| Well, I played with your script a bit today. It is very nice. I made some modifications to better suit my needs. I removed the nunchuck functions for flicking it left and right, and replaced it with tilting which works really well for leaning in Armed assault and Rainbow six 3. I am still going to tweak it out a little more for rainbow six 3 yet. There are some more functions I want to map to the buttons, but in all, it is a great script. Thanks man. It accomplishes everything I was trying to do. |
|
| Back to top |
|
 |
Dr_Zoidberg
Joined: 29 Dec 2006 Posts: 60
Digg It |
Posted: Sun Mar 18, 2007 3:38 am Post subject: |
|
|
I didn't include rotation for the nunchuk, because i like to hold the nunchuk without worring about rotations and therefore used flicking. (I haven't updated my script to distinguish between left and right that will be included in the next version.) I have concentrated mainly on the IR part, thats why the rest of the script is rather simple.
I you haven't allready tried it, I recommend changing the values of the speed factors (or even the areas) to adjust the turning rate and range. |
|
| Back to top |
|
 |
rambozo79
Joined: 15 Mar 2007 Posts: 7
Digg It |
Posted: Sun Mar 18, 2007 4:39 am Post subject: |
|
|
| Dr_Zoidberg wrote: | I didn't include rotation for the nunchuk, because i like to hold the nunchuk without worring about rotations and therefore used flicking. (I haven't updated my script to distinguish between left and right that will be included in the next version.) I have concentrated mainly on the IR part, thats why the rest of the script is rather simple.
I you haven't allready tried it, I recommend changing the values of the speed factors (or even the areas) to adjust the turning rate and range. |
Well, I really like the nunchuk flicking gesture, except it seems to interfere with the tilting. I adjusted the tilting to have a large degree of dead space. So accidentally triggering it isn't much of a problem. It actually works really well. But I am still using the forward flicking gesture as the primary action function. It works great for that. I remapped most all of the buttons though.
It seems you had some adjustability mapped to some of the buttons. like a toggle to switch between different mouse functions, among other things I really didn't look too deep into. I am pleased enough with the default values for now, and remapped those buttons to different functions. I mapped the up and down on the dpad for mouse wheel and the minus key I remapped to toggle between the 1 and 2 number keys. Remapped button one and button two for escape and enter.
Basically, I am just trying to fit it into the tactical shooter role. But at the same time, I like RTS games and a few RPGs, So I might come up with a button combination that would remap it entirely just for those games, something I can use as a simple toggle.
But right now, I'm not going to change much. It works, and I wanna play a little bit of games with it for a while. I can tweak it here and there as I go.
Anyway, it is a good script to build off of. It would have taken me too much time to come up with it by myself. It seems you already did the hard work. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|