FOV

Published July 23, 2007
Advertisement
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.
Previous Entry Demo ready
0 likes 4 comments

Comments

diablo_tk
Now that is COOL. Line of sight stuff is always a winner with me! job, good.

remides mew of a demo I did a while back
July 23, 2007 04:55 PM
Aardvajk
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.
July 23, 2007 05:33 PM
diablo_tk
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.

July 23, 2007 06:01 PM
Black Knight
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 !
July 25, 2007 12:59 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement