英语水平有限,欢迎大家批评指正
本文并没有将原文全部翻译,只是将其中的一些知识点翻译总结了一下,想要查看详细讲解的话,可以到原文处看一下,附上英文原文地址:http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Intermediate+Tutorial+6&structure=Tutorials
Introduction
本教程中我们将学习如何给场景中的对象添加射影贴花(projective decals 映射贴图?)。当你想要做一些诸如一个选择指示器、一个投影出你所瞄准的东西的瞄准景象或一些投影到某些东西上的其他类型的贴花,投影纹理是很有用的。
Projective Decals
Frustums
A frustum represents a pyramid capped at a the near and far end, which represents a visible area or a projection. OGRE用它来表示摄像机(Camera类直接继承自Frustum类)。本教程中我们要使用一个frustum来投射贴花到场景中的网格。
创建投影仪(projector)的第一件事是创建代表投影仪的frustum,并把它绑定到一个场景节点上。添加如下代码到creatProjector中:
mDecalFrustum = new Ogre::Frustum();
mProjectorNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("DecalProjectorNode");
mProjectorNode->attachObject(mDecalFrustum);
mProjectorNode->setPosition(0,5,0);
这段代码创建了一个投影仪(projector),当你离它越来越远它就会种植(grow)贴花,很像一台电影投影仪一样。如果你想要创建一个投影仪(projector)来维持一个与距离无关的大小和形状不变的贴花,添加如下代码(本教程中不使用):
// Do not add this to the project
mDecalFrustum->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
mDecalFrustum->setOrthoWindowHeight(100);
setOrthoWindowHeight()使用方向比率(aspect ratio)设置一个orthographic frustum的大小。
Before continuing, please take note of where our frustum is projecting the decal. In this application there is a ring of Ogre heads and the frustum sits in the dead center of them (though shifted up slightly, by 5 units), pointed in the -Z direction (which is the default since we did not change the orientation). This means that, eventually, when we run the application decals will be projected onto the back Ogre heads.
Modifying the Material
为了使贴花(decal)真正的出现在对象上,他使用的材质需要接收贴花。(未完待续。。。)