• entries
    743
  • comments
    1924
  • views
    578700

FOV

Sign in to follow this  
Aardvajk

186 views

Further to my recent post about my (awful) field of view calculations for the current project, I'd like to heartily recommend the permissive-fov library by Jonathon Duerig.



I've wrapped it into a static lib to keep it seperate from my game code, but as I understand the BSD license, as long as I put the license and Mr Duerig's copyright notice in my game documentation, it does not restrict anything I want to do with the binaries for my game.

(Someone please tell me if that is not the case [smile]).

It works really, really well. I'm highly impressed. I've been messing about with raycasting, shadowcasting, every thing I could think of and couldn't get any decent results. Bunged Mr D's library in and bingo, perfect results.

I can now just provide a view radius to my wrapper and it all works as required.

So a new DEMO is now up. For the sake of this demo, the fog is set up to only show you what you can currently see, rather than remembering where you have been before. I'm sure you'll agree that Mr D's fov algorithm works extremely well for such a low granularity fog map.

The internet, and people cleverer than me, are both wonderful things.
Sign in to follow this  


4 Comments


Recommended Comments

Quote:
Original post by diablo_tk
Now that is COOL. Line of sight stuff is always a winner with me! job, good.


All the credit goes to Jonathon Duerig. From what I can gather, I think he first developed this permissive field of view algorithm.

Quote:
Original post by diablo_tk
remides mew of a demo I did a while back


Cool demo. You're brave to take on isometrics. I've always found that dead fiddly.

I'm guessing you are doing the line of sight by raycasting there? Works really well on an isometric view, but I found that the non-symetric patterns you get looked wrong on a top down view.

Share this comment


Link to comment
Quote:
Original post by EasilyConfused

I'm guessing you are doing the line of sight by raycasting there? Works really well on an isometric view, but I found that the non-symetric patterns you get looked wrong on a top down view.


It was ages ago that I made it. Heres the code I did for it:

Method UpdateFOW()

Local dofromX%
Local dofromY%

Local thisTile:TISOTile

If explorerList.count() > 0 Then Fog()
For Local FOWHandle:TISOExplorer = EachIn explorerList
Local dofromX% = FOWHandle.GetXISO() - 30
Local dofromY% = FOWHandle.GetYISO() - 30

For Local T:Float = 1 To 90 Step .5
#fogloop
For Local k% = 1 To FOWHandle.radius

Local cAngle% = T * 4

Local tempx# = dofromX + (tileSet.tileWidth / 4) * K * cosTable[T * 4]
Local tempy# = dofromY + (tileSet.tileheight / 4) * k * sinTable[T * 4]
Local ttempx# = tempx - tempx Mod (tileSet.tileWidth / 2)
ttempx = (ttempx / (tileSet.tileWidth / 2)) + 1
Local ttempy# = tempy - tempy Mod (tileSet.tileheight / 2)
ttempy = (ttempy / (tileSet.tileheight / 2)) + 1

If ttempx > -1 And ttempx < width And ttempy > -1 And ttempy < Height Then
For thisTile = EachIn tile[ttempx , ttempy]

thisTile.foged = False
thisTile.explored = True

If Not tileSet.GetTileFlag(thisTile.index, TILEFLAG_WINDOW, True)
thisTile.foged = False
thisTile.explored = True
Exit fogloop
EndIf
Next
End If

Next
Next

For thisTile = EachIn tile[FOWHandle.GetXTISO(), FOWHandle.GetYTISO()]
thisTile.foged = False
Next
Next

End Method


Its in blitzmax and pretty unreadable ^^. But it is basically raycasting.

Share this comment


Link to comment
Wow I'm impressed this was something I always wanted to do after my 2d console project I may start working on something like this but a more isometric one maybe.
Anyway keep it up !

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now