English

ogre 3d 1.7 beginner’s guide 第三章 第四小节 中文翻译 方向光源

2011/2/23

Directional lights

【 方向光源 】

We have created spotlights and point lights. Now we are going to create the last light type—directional lights. A directional light is a light that is far away and only has a direction and a color, but no light cone or radius like spotlights or point lights. It can be thought of as the sun. For us, the sunlight comes from one direction, the direction of the sun.

【 我们已经创建过了聚光源和点光源。现在我们准备创建最后一种光源类型—— 方向光源。方向光源是一种离你很远的光源而且这种光只有方向和颜色,但是却没有像聚光源和点光源的锥形光束和光照范围。它可以被认为是太阳光。对于我们而言,阳光是从一个方向照射过来的,这个方向也就是阳光的方向。】

Time for action – creating a directional light

【 实践时刻 —— 创建一个方向光源 】

1.  Delete all the old code in createScene(), except for the plane-related code.

【 1. 除了与平面相关的代码,删除所有的createScene() 函数中的旧代码。】

    • Create a light and set the light type to directional light:

【 2. 创建一个光源并且设置光源的类型为方向光源:】

Ogre::Light* light = mSceneMgr->createLight("Light1");

light->setType(Ogre::Light::LT_DIRECTIONAL);

    • Set the light to a white color and the light direction to shine in a down-right direction:

【 设置光源为白色并且设置光源的方向为右下方。】

light->setDiffuseColour(Ogre::ColourValue(1.0f,1.0f,1.0f));

light->setDirection(Ogre::Vector3(1,-1,0));

    • Compile and run the application.

【 编译运行程序。】

What just happened?

【 刚刚发生了什么?】

We created a directional light and set it to shine down and rightwards with

setDirection(1,-1,0). In the previous examples, we always had a rather black plane

and a small part of the plane was illuminated by our pointlight or spotlight. Here, we used

a directional light and hence the complete plane is illuminated. As said before, a directional

light can be thought of as the sun, and the sun doesn't have a falloff radius or anything else. So when it shines, it illuminates everything there is; the same is true for our directional light.

【 我们创建了一个方向光源并且使用setDirection(1,-1,0) 设置它发光的方向是右下。在之前的例子中,我们创建的平面几乎是黑色并且平面只有一小部分被点光源或聚光源所照亮。这里,我们使用了一个方向光源,这以后整个平面被照亮了。正如前面所述,方向光源可以认为是一个太阳,太阳发出的光是没有衰减半径,也没有别的特殊性质。所以当太阳发光的时候,它会照亮所有的物体。这对我们的方向光源同样适用。】

Pop quiz – different light types

【 简单测试 —— 不同的光源类型 】

Recall all three light types that Ogre 3D has and state the differences.

【 回忆Ogre 3D中的三种光源类型并且说明之间的不同 】