游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2009|回复: 3

关于“BSP Trees and Polygon”一文里"RENDER-PORTAL-ENGINE&am

[复制链接]

8

主题

24

帖子

24

积分

注册会员

Rank: 2

积分
24
发表于 2004-8-5 17:32:00 | 显示全部楼层 |阅读模式
“Portal Rendering”主题,27页

文章里关于“基于入口渲染引擎”的定义如下:

RENDER-PORTAL-ENGINE (Sector, ViewFrustum)
1 for each polygon P1 in Sector
2     if (P1 is a portal and INSIDE-FRUSTUM (ViewFrustum, P1))
3        NewFrustum = CLIP-FRUSTUM (ViewFrustum, P1)
4        NewSector = get the sector that is connected with the current sector through portal P1
5        RENDER-PORTAL-ENGINE (NewSector, NewFrustum)
6     else if (P1 has not been drawn yet)
7        draw P1
8 return

我觉得,就算是Viewer所在Sector里的多边形不是也要经过截头体(ViewFrustum)的筛选吗?为什么原定义里的 if 语句会这样写?

if (P1 is a portal and INSIDE-FRUSTUM (ViewFrustum, P1)) {...}
else if (P1 has not been drawn yet) {...}

这样一来,本地Sector里的多边形不是要全部都渲染一遍?岂不造成巨大的计算资源浪费?

我觉得应该改成下面的定义:

RENDER-PORTAL-ENGINE (Sector, ViewFrustum)
1 for each polygon P1 in Sector
2     if (INSIDE-FRUSTUM (ViewFrustum, P1))
3        if (P1 is a portal)
4             NewFrustum = CLIP-FRUSTUM (ViewFrustum, P1)
5             NewSector = get the sector that is connected with the current sector through portal P1
6        RENDER-PORTAL-ENGINE (NewSector, NewFrustum)
7          else if (P1 has not been drawn yet)
8                 draw P1
9 return

不知道是否正确,希望高手指教。

(推荐"Binary Space Partioning Trees and Polygon"是篇很好的文章,值得仔细看看!地址在另外的帖子里有,但一时想不起是哪帖了)

20

主题

473

帖子

502

积分

高级会员

Rank: 4

积分
502
发表于 2004-8-6 10:33:00 | 显示全部楼层

Re:关于“BSP Trees and Polygon”一文里"RENDER-PORTAL-ENGINE&quo

a.  if (P1 is a portal and INSIDE-FRUSTUM (ViewFrustum, P1))

b.    if (INSIDE-FRUSTUM (ViewFrustum, P1))
        if (P1 is a portal)

a 和 b 在这里是等价的,都是判断一个polygon是portal且在视锥内

8

主题

24

帖子

24

积分

注册会员

Rank: 2

积分
24
 楼主| 发表于 2004-8-6 12:56:00 | 显示全部楼层

Re:关于“BSP Trees and Polygon”一文里“RENDER-PORTAL-ENGINE”函

恩,我觉得无论polygon是不是portal,首先都必须先判断在不在视维内。
按照原定义,一旦polygon不是portal,渲染的条件就只剩 (P1 has not been drawn yet) ,就是说非portal的polygon,只要是要没画过的,即使不在视维内也要渲染出来,这样不是有问题吗?

更大的问题是,若一个polygon是portal,但不在视维内。你看,按照原定义,3、4、5行是没可能执行的了,而是执行 7 draw p1 !!!! 一个portal怎么能简单执行 draw ?

我理解的加括号原定义:

1 for each polygon P1 in Sector
     {
2     if (P1 is a portal and INSIDE-FRUSTUM (ViewFrustum, P1))
          {
3         NewFrustum = CLIP-FRUSTUM (ViewFrustum, P1)
4         NewSector = get the sector that is connected with the current sector through portal P1
5          RENDER-PORTAL-ENGINE (NewSector, NewFrustum)
          }
6     else if (P1 has not been drawn yet)
7              { draw P1 }
      }
8 return

20

主题

473

帖子

502

积分

高级会员

Rank: 4

积分
502
发表于 2004-8-6 16:29:00 | 显示全部楼层

Re:关于“BSP Trees and Polygon”一文里"RENDER-PORTAL-ENGINE&quo

这里是写的伪代码,“and ”并不是c语言里的&&意思,只是说同时满足
也就是说,并不是一个肢不满足就else的

你对portol的理解是对的

对于绘制portal的问题,完全可以在portal->draw这个方法里来解决,因为有时候portal也是需要绘制出来用于debug
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-14 17:25

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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