Layout Checker Algorythm [r-speeds]
Ollj
our themepark-stalking nightmare Fade Join Date: 2002-12-12 Member: 10696Members
<div class="IPBDescription">Lots of text</div> What about the idea of making a "layout r-speeds checker".
All this tool does is reading a 2-color gif/bmp of a map overview (white = wall, black = path) to see if there would be places with bad r_speeds (if the map would be plain).
After reading a B&W map Layout that tool draws out 2 pictures:
1) This picture shows "r_speed performance" of every point shown by the color of this point (red = bad r_speed performance, green = average , blue = close to 0.
2) This picture shows the 10 "longest straigt lines of sight" (througth long corridors and "L shapes" that should be "U shapes").
1:
lets define "r_speed performance":
Its not the ingame r_speeds because I dont want to (and cant) transfer the way VIS works onto a 2D layout.
Its just the max amount of room that you can see from a point in a 180° field of view (VIS checks a 180° field of view).
The algorythm:
go through the whole bitmap and check each point if its black (room) or white (wall):
If its black send 8 "mayor scanning rays" from this point and continue trought black space till they hit a white wall (or the picture border wich gives an "leak error" <!--emo&:)--><img src='http://www.natural-selection.org/forums/html/emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif'><!--endemo--> )
(see pic 1, I mean the blue lines only)
Store their length (trigonometry)
if length of diagonal ray > 0 ->> make 1 more ray in between of the blue ones (red lines)
if length = 0 ->> notice a "wall" (you dont expect a higher r_speed when you look to a wall, we just care for wider open fields of view)
Now lets group the rays between the walls because our field of view is 180°, not 360° and not a thin ray.
a group of 9 rays = 180° field of view.
A "wall" splits "groups of rays" into smaller groups.
if the group is <=9 sum up the length of the rays to a "group length" the "group length" is relative to the room that you see from this point (!!!) (in this case you will see 2 walls (90° left and 90° right side) when you stand there)
if the group is > 9 split the group in each possible group of 9 Rays . We just want to know the highest possible r-Speed performance.)
Example:
if there is no "wall" you have 16 Rays and 16 possible 180° fields of view. if the group is 15 rays big you have 7 possible full 180° views without seeing a wall. 14 -> 6 , 13 -> 5 ...
- Now compare all the "group length`s" of this point. we just care for the longest, and store it by the coordinate of this point.
(now we have the longest "group length" of each black point of the map)
- Now search the longest "group length" of all points and set that as 100%.
- Now set 100% = red , 50% =blue , 0% = green ...
A rainbow that shows the "max group lenghts" of all points relative to the longest "max group length"
Draw each "max group length" color on each black point.
Done.
-> red places show you places were you can exect high r_speeds.
2:
lets define "longest straigt lines of sight".
Its the longest straight line that can go from one wall to another.
This is simular to "1" but now we scan the whole map in "world rays" instread of scanning from one point.
A world ray is just one ray that goes straight thought the world without getting stopped.
Groups of "world rays" cover the whole map with the same angle (parallel)
Pic 2 shows 12 groups of world rays (a world way is red, green or blue) scanning in 12 different angles.
you can try more smooth angle-steps of course...
Now make 10 variables for a top 10 to remember length and the 2 wall points of the 10 "longest straigt lines of sight".
For each angle of world rays check each single world ray when it hits 2 wall points (white) with a room point (black) between it.
calculate the length of a world ray (trigonometric with its angle) and put it in the top 10 if its long enough.
When each single ray of all angles is checked your top 10 is finished.
Now draw the 10 lines reading start and end point and do rainbowcolor(relative length like in "1") from the top 10.
-> you directly see the 10 longest lines of sight and their lenght (red = longest)
The advantage of "2" is that its more absolute than "1".
Making more smoother angles makes it take longer, but gives way better results.
All this tool does is reading a 2-color gif/bmp of a map overview (white = wall, black = path) to see if there would be places with bad r_speeds (if the map would be plain).
After reading a B&W map Layout that tool draws out 2 pictures:
1) This picture shows "r_speed performance" of every point shown by the color of this point (red = bad r_speed performance, green = average , blue = close to 0.
2) This picture shows the 10 "longest straigt lines of sight" (througth long corridors and "L shapes" that should be "U shapes").
1:
lets define "r_speed performance":
Its not the ingame r_speeds because I dont want to (and cant) transfer the way VIS works onto a 2D layout.
Its just the max amount of room that you can see from a point in a 180° field of view (VIS checks a 180° field of view).
The algorythm:
go through the whole bitmap and check each point if its black (room) or white (wall):
If its black send 8 "mayor scanning rays" from this point and continue trought black space till they hit a white wall (or the picture border wich gives an "leak error" <!--emo&:)--><img src='http://www.natural-selection.org/forums/html/emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif'><!--endemo--> )
(see pic 1, I mean the blue lines only)
Store their length (trigonometry)
if length of diagonal ray > 0 ->> make 1 more ray in between of the blue ones (red lines)
if length = 0 ->> notice a "wall" (you dont expect a higher r_speed when you look to a wall, we just care for wider open fields of view)
Now lets group the rays between the walls because our field of view is 180°, not 360° and not a thin ray.
a group of 9 rays = 180° field of view.
A "wall" splits "groups of rays" into smaller groups.
if the group is <=9 sum up the length of the rays to a "group length" the "group length" is relative to the room that you see from this point (!!!) (in this case you will see 2 walls (90° left and 90° right side) when you stand there)
if the group is > 9 split the group in each possible group of 9 Rays . We just want to know the highest possible r-Speed performance.)
Example:
if there is no "wall" you have 16 Rays and 16 possible 180° fields of view. if the group is 15 rays big you have 7 possible full 180° views without seeing a wall. 14 -> 6 , 13 -> 5 ...
- Now compare all the "group length`s" of this point. we just care for the longest, and store it by the coordinate of this point.
(now we have the longest "group length" of each black point of the map)
- Now search the longest "group length" of all points and set that as 100%.
- Now set 100% = red , 50% =blue , 0% = green ...
A rainbow that shows the "max group lenghts" of all points relative to the longest "max group length"
Draw each "max group length" color on each black point.
Done.
-> red places show you places were you can exect high r_speeds.
2:
lets define "longest straigt lines of sight".
Its the longest straight line that can go from one wall to another.
This is simular to "1" but now we scan the whole map in "world rays" instread of scanning from one point.
A world ray is just one ray that goes straight thought the world without getting stopped.
Groups of "world rays" cover the whole map with the same angle (parallel)
Pic 2 shows 12 groups of world rays (a world way is red, green or blue) scanning in 12 different angles.
you can try more smooth angle-steps of course...
Now make 10 variables for a top 10 to remember length and the 2 wall points of the 10 "longest straigt lines of sight".
For each angle of world rays check each single world ray when it hits 2 wall points (white) with a room point (black) between it.
calculate the length of a world ray (trigonometric with its angle) and put it in the top 10 if its long enough.
When each single ray of all angles is checked your top 10 is finished.
Now draw the 10 lines reading start and end point and do rainbowcolor(relative length like in "1") from the top 10.
-> you directly see the 10 longest lines of sight and their lenght (red = longest)
The advantage of "2" is that its more absolute than "1".
Making more smoother angles makes it take longer, but gives way better results.
Comments
However, a lot of R_Speeds are vertical detail anyway, but it'd still be better then nothing.
and why would you check the r_speeds for a 3d map with a 2d bitmap?
i ahve no idea what r_speeds are or what the loops youre talking about mean, but bitmap file structure is no problem.
i ahve no idea what r_speeds are or what the loops youre talking about mean, but bitmap file structure is no problem. <!--QuoteEnd--> </td></tr></table><span class='postcolor'> <!--QuoteEEnd-->
Sweet, can you PM me with reference links on how to do it? That'd be great, thanks. I'll work on it during class tomorrow, I've finished everything I need for the week anyway.
For me its the other way around.
<!--QuoteBegin--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> </td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->
R_speed:
Redraw or refresh speed.
Commonly used for the wpoly count only, as in: "What are your r_speeds?"
Although really it also includes many other factors such as: transparencies, epolys & sprites.
R_speeds affects lag and fps.
<!--QuoteEnd--></td></tr></table><span class='postcolor'><!--QuoteEEnd-->
r_speeds are high when you see much of the map in HL -> This causes less fps and lag.
This should be in the mapping forum, my fault.
<a href='http://rookscape.com/vbgaming/tutR.php' target='_blank'>http://rookscape.com/vbgaming/tutR.php</a>
heres the same thing written from the java point of view:
<a href='http://www.javaworld.com/javaworld/javatips/jw-javatip60.html' target='_blank'>http://www.javaworld.com/javaworld/javatip...-javatip60.html</a>
heres microsoft's version, reading HEX:
<a href='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_4v1h.asp' target='_blank'>http://msdn.microsoft.com/library/default....itmaps_4v1h.asp</a>
they look quite similar, so any information that one is missing you should be able to glean from the other two links.
(sorry if i am insufficiently helpful, i havent done any programming in about two years, at which point i was writing VGA games on my 386)
Feel free to use any more accurate Algorythm to approximate the max-visible-space in 180°.
But dont take this way of "r_speed"-pre-testing (with just a small 2D bitmap) too serious.