My first raycaster found here. When you play it, it looks like you're in a curved room, but the map is a perfectly straight square. Can someone explain to me why? I tried to make the scripts as simple as possible (I don't know how else to do it since I didn't look at a tutorial), so it shouldn't be all that hard to read. Just know that I made 4 scanners and 2 drawers.
Offline
so that you don't need to download, here is the script for sensing the walls
and here is the script for drawing the wallswhen I receivesense ▼deleteall ▼ofdistances ▼setdrawing ▼to1setdistance ▼to0setscanning remembering thingamajig ▼to48repeat24because I have 4 sensorssetdistance ▼to60go tomovement ▼the movement spritepoint in direction+direction ▼ofmovement ▼scanning remembering thingamajigrepeat untiltouchingorwall ▼?distance=0move1stepschangedistance ▼by-1adddistancetodistances ▼changescanning remembering thingamajig ▼by-1
Each drawer does that script twice to match up with the 4 lists of distances. I'm trying to figure out how to fix that when it senses, it draws it in a curved room when it's supposed to be straight. Can someone please help me?when I receivedraw ▼go to x:1y:180since each drawer takes half the screenset pen size to5set pen color toclearpen upsethelp counting ▼to24since each distances list is 24 items longrepeat24set pen shade toitem*help countingofdistances ▼1+2/3set y toitem*help countingofdistances ▼4pen downset y to*item*help countingofdistances ▼4-1pen upchangehelp counting ▼by-1set pen shade to0change x by5because the pen size is 5
Last edited by TorbyFork234 (2012-04-13 16:49:17)
Offline
The reason is because you're using purely distance. If you use purely distance, even if points are on the same line that's perpendicular to your view, they're different distances. This creates the Fisheye effect. In order to correct this, take the distance you get when scanning and multiply by the cosine of the offset of the angle (i.e. if you're drawing the part of the wall right in the middle, the offset is 0 degrees and so the distance will simply be multiplied by 1).
Offline
AtomicBawm3 wrote:
The reason is because you're using purely distance. If you use purely distance, even if points are on the same line that's perpendicular to your view, they're different distances. This creates the Fisheye effect. In order to correct this, take the distance you get when scanning and multiply by the cosine of the offset of the angle (i.e. if you're drawing the part of the wall right in the middle, the offset is 0 degrees and so the distance will simply be multiplied by 1).
How do I find the offset of the angle? I tried turning 1 degree, moving 1 step, and seeing if it's still touching the wall, and if not, take that direction and continue going. but that didn't work.
Offline
Your offset would by your variable "scanning remembering thingamajig." Also, you might be able to reduce your FOV.
Offline
so the new script should be
?addtodistance*cos ▼ofscanning remembering thingamajigdistances ▼
Last edited by TorbyFork234 (2012-04-13 17:21:08)
Offline
Yep, looks like it from the way you've got your scripts set up. I hope this helps...what you could do is change you FOV from 96 to something more like 60 as well...that will reduce the effect as well. That would mean at the beginning:
Sensor 1 variable: 30
Sensor 2 variable: 15
Sensor 3 variable: 0
Sensor 4 variable: -15
Offline
AtomicBawm3 wrote:
Yep, looks like it from the way you've got your scripts set up.
I hope this helps...what you could do is change you FOV from 96 to something more like 60 as well...that will reduce the effect as well. That would mean at the beginning:
Sensor 1 variable: 30
Sensor 2 variable: 15
Sensor 3 variable: 0
Sensor 4 variable: -15
But that would also reduce the resolution so I won't do it.
Offline
It didn't work, it only made it worse.
Offline
Oh, I know why it's not working...You have your distance counting down as it gets farther away...so your formula for distance would be:
Tell me how that works out.addto60-*cos ▼ofvariable60-distancedistances ▼
Last edited by AtomicBawm3 (2012-04-14 12:05:46)
Offline
no, I tried that and everything up close was fine, but everything far away was all wacky. and then I tried
and that didn't work either.*60-cos ▼ofvariable60-distance
Offline
Next thing I'll try
Would it work?60-*cos ▼of-direction ▼ofmovement ▼variable60-distance
Offline
Didn't work. Help anyone?
Offline