Chinaunix首页 | 论坛 | 博客
  • 博客访问: 174369
  • 博文数量: 43
  • 博客积分: 827
  • 博客等级: 准尉
  • 技术积分: 487
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-26 19:19
文章分类

全部博文(43)

文章存档

2015年(1)

2014年(1)

2013年(5)

2012年(36)

我的朋友

分类: WINDOWS

2012-05-06 17:15:55

对于Light的数据,在Irrlicht中用SLight结构记录,这个结构中的数据和在DX中的Light结构差不多。这主要也是用于FFP中。

而一个Light在Irrlicht中用CLightSceneNode表示,因此来说一个Light也是一个Scene Node。

对于一个Dynamic Light的过程

OnAnimate:
CLightSceneNode没有重写该函数,直接使用ISceneNode的,标准的使用Animator来运动Light。

OnRegisterSceneNode:
这里面会修正Light的数据(通过doLightRecalc()来修正),因为OnAnimate过后,Dynamic Light的一些数据会发生变化,并将该Light Scene Node加到Scene Manager中的Light List中。

render:
这个过程相关于这个light在整个系统中的设定。主要这两个过程:
        // Add the light to the dynamic light list.
        DriverLightIndex = driver->addDynamicLight(LightData);
        // Set the light to Device.
        setVisible(LightIsOn);

在CD3D9Driver中
s32 CD3D9Driver::addDynamicLight(const SLight& dl)
{
        CNullDriver::addDynamicLight(dl);        // Here will add the light to the light list of the driver.
        ...
        ++LastSetLight;                          // This is the light index of this light

        if(D3D_OK == pID3DDevice->SetLight(LastSetLight, &light))                // Set it to device
        {
                // I don't care if this succeeds
                (void)pID3DDevice->LightEnable(LastSetLight, true);
                return LastSetLight;
        }
}

在setVisible 中:
LightIsOn = isVisible;
driver->turnLightOn((u32)DriverLightIndex, LightIsOn);
        (void)pID3DDevice->LightEnable(lightIndex, turnOn);


OnAnimate和OnRegisterSceneNode都主要负责Light的数据更新
render主要负责将该Light设定到Driver List中,并设定到Device中。

注:
1:Light Scene Node的 render 在 Light Pass中。
2:在Irrlicht中提供了ILightManager接口,但是自身没有实现这个Manager系统。
3:Irrlicht中的光照主要使用的FFP。


对于Irrlicht中每一帧对于Light的流程处理

1:对于Light的时间驱动处理,在OnAnimate中进行
2:将Light设定到Light Render Pass的List中去,只有设定到Render Pass的Light才会有渲染的机会。这一步在OnRegisterNode中进行
3:重新设定在Device中的Light,这一步在Light Render Pass中进行,这一步对于每一个在Light Render Pass的List中的Light,都会调用render,而LightSceneNode::render主要是将该Light设定到Irrlicht Driver中的List中,并对每一个LightSceneNode指定一个Index,这个Index是在Device中SetLightEnable的Index。所以Light Render Pass的主要功能就是对后面的各个Pass,设定好所有的Light。注意:在每一帧的Light Render Pass开始的时候,都会将Device中原来的Light List清空,然后重新构造。
4:后续的对于Node的渲染没有差别。


对于两个Light List的说明

1: SceneManager::LightList      这个List是对于Light Render Pass的List,在registerSceneNode中构造
2:CNullDriver::Lights           这个List是在Device中设定的Lights,在SceneNode::render中进行构造,对于LightSceneNode中的Index也是对于该List的索引

在每一帧的开始,这两个List都会被清理,再重新构造。

阅读(840) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~