找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1859|回复: 4

【高级教程】vis的工作原理--by Egir Helgrimson>

[复制链接]

该用户从未签到

发表于 2007-11-18 13:14:46 | 显示全部楼层 |阅读模式
vis是地图编译的一个必不可少的程序!
他的作用是优化地图结构~
他会把你的地图割来割去的,割不好就割出了wallbug来~

--------------------------------------------------------------------------------

Disclaimer
This document is more like a how it might work, than how itactually works. I have yet to learn what is actually going on. For nowI'm just guessing, and the idea is that I'll update this document as Iget more enlightened. In order to get it right, you might have to startby getting it wrong, in that way you are at least getting it B). I amgoing to write as if what I am writing is facts, but I have neithersources, nor any experiments to prove myself, so if you need a sourcefor some school assignment, this document does not qualify.
Introduction
VISingis the part of the compile process where visibility is calculated. Thishowever is a quite delicate process, divided into two faces. Whichaccording to the compile log are:
  • BasePortalVIS
  • LeafThread
Nodes
Before the VIS compiler is invoked, the BSPcompiler has done a VIS preparing task that is essential to mapperformance, when it is run in game. It devides the map into nodes.Nodes are basically little rooms filling up the map, so that no materwhere the player is, he will be inside some node, as long as he isinside the map. To explain further, I'll use an example.
Example 1 - filling the map with nodes
This is our map, seen from above.
BSP now figures out how to fill the map with nodes. It may look something like this, where each colour represents a node.
Where nodes intersect we have a portal. Now that we know everythingabout how an when nodes are created we can move along to the nextexciting topic.
BasePortalVIS
The name suggests that these calculations are all about which portalsare visible from the active node. What we can see and what we can't seecan be hard to predict, though we can be pretty sure that we can seewhat's inside the node we're in, and what's inside the node next to thenode that we are in. (The ajacant node).
Since we have five nodes in our example, we would initialise 5node trees. Building the BasePortalVIS will make us end up with fivetrees looking something like this.
Thedarker colours represent the root nodes, and the lighter coloursrepresent the adjacent nodes. These calculations aren't especially hardto do (de_slap took about 1 minute).
Now we know what in any case should be able to see, and that iswhats in the node in which we are, and what is in the node next to us.But what about the nodes that lie next to the nodes that lies next tothe node that we are currently in. And what about the nodes lying nextto them etc...
LeafThread
The nodes that lie next to the nodesthat lie next to the root node are metaphorical leafs on the tree sincethey are in the opposite end of the tree trunk as the tree root. SinceI take it that very few of my readers knows what a tree looks like I'vedrawn an overview so you won't get lost in my technical language.
Nowit is clear what LeafThreads needs to do, it needs to find the leavesthat correspond to each leaf node. I'll again surrender to the power ofan example.
Example 2 - Finding the leaves corresponding to the orange node.
Wefind leaves be checking which portals we can see from a portal in theroot node, through a portal in a node next to the root node. This isillustrated below.
Obviouslywe can see the portal between the red and yellow nodes, but we cant seeany of the portals either between the yellow and blue node, nor betweenthe blue and the green node. This will result in that, when you are inthe orange node, only polygons in the orange, red and yellow rooms arerendered. This is illustrated below.
Nodes hatched with orange are the only nodes visible from orange. (which makes them leaves on the orange tree, so to say).
How is this done?
If a portal has a coordinate thatlies within any span of vectors each made by two points in an alreadyvisible portal and a portal from the root node respectively, its nodesare visible if and only if this portal belongs to an already visiblenode from the corresponding portal in the root node. HLVIS recursivelyrepeats this from the newly sighted portal, and the correspondingportal from the root node to see if we can spot additional portals.Only portals next to an already visible node needs to be tested to seeif they are within the prior mentioned span.
I trust what I just wrote in the previous paragraph didn't makesense to anyone. So I guess I once again have to spawn another example.
Example 3
We have only the portals to worry about.The orange portal belongs to the root node. The blue portal belongs toa neighbour node. And the green portal is the one that we will try tosee if we can actually see. In other words, the question is, can we seethe green portal, from the orange portal through the blue portal.
Tosolve this problem out, all we have do do is find all the vectors thatwe can make using one point from the orange portal, and one point fromthe blue portal respectively. That leaves us with no less than 16vectors, as illustrated below.
It looks like a mess to be honest, and this is also what explains thelong compile time HLVIS uses for the LeafThread calculations. Whetherall vectors are used, or some bright head figured out which one couldbe spared away, I have no idea. By scaling these 16 vectors withdifferent scalars, and then adding them together, we may be able toreach a coordinate somewhere in the green portal, and if so, we canconclude that the green portal is indeed visible from the orangeportal. Just like this.
Whetherthis has anything to do with the quite useful point file created if aLEAK is found I will leave to your imagination to figure out, since Ihave no idea.
Conclusion
I conclude that because of thecomplexity of calculating the LeafThread the very same calculations arequite time consuming. I have a good idea on how to theoretically halfthis time, if this article contains a bit of truth in it. I hope youenjoyed reading this, and that has helped you to understand myunderstanding on how HLVIS works.

[ 本帖最后由 Simen.sllove 于 2007-11-20 09:28 编辑 ]

该用户从未签到

发表于 2007-11-18 13:16:11 | 显示全部楼层
都是英文,谁来弄啊。所长,你要负责翻译!

该用户从未签到

 楼主| 发表于 2007-11-18 13:20:45 | 显示全部楼层
翻译太耗时间了~~

我还要做图呢~

该用户从未签到

发表于 2007-11-18 13:27:42 | 显示全部楼层
怎么又是E文啊,中文概括下啊

该用户从未签到

 楼主| 发表于 2007-11-18 13:35:00 | 显示全部楼层
原帖由 Simen.BlooM 于 2007-11-18 13:27 发表
怎么又是E文啊,中文概括下啊


有些概念性词汇根本找不到合适的中文来翻译~


这是写给有一定做图经验的老手的,让他们了解一下vis的原理,

不适合新手的教程啊~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表