Ogre中级教程7翻译版
- 格式:docx
- 大小:44.57 KB
- 文档页数:14
Ogre 中级教程 7
Table of contents 目录
Introduction 先决条件 Setting Up the Scene 创建场景 Creating a Texture 创建纹理 Writing Our Texture to a File 写出我们的纹理到文件 Implementing the Miniscreen 实现迷你场景 Creating a Material From Scratch
翻译 by
CatD
从头创建一个材质
Using a RenderTargetListener
使用一个渲染目标监听器
Render to Texture and Shaders
渲染到纹理和阴影
Exercises
练习
o o o o o o o o Easy
简单
Intermediate
中级
Difficult
困难
Advanced
地狱(括弧笑)
Conclusion
总结
Full Source
全部代码
Next
下一节
Introduction 先决条件
This tutorial covers the basics of rendering a scene to a texture. This technique is used for a variety of effects. It is particularly useful in combination with shaders. Motion blur effects can be created in this way. 本教程涵盖了渲染纹理到一个场景,这个技术用于制作出各种效果,它在结合着色器时格外的 有用,可以用这种方法创建动态模糊效果。 The basic idea is rather simple. Instead of just sending render information strictly to our render window, we will also send the information to be rendered directly to a texture in our scene. This texture will then be used like a texture loaded from the hard drive. 基本的想法非常简单,咱在咱的场景里发送直接渲染的信息到纹理来代替咱发送严格的渲染信 息,这种结构将用起来像是使用一个已经被硬盘加载的纹理。 The full source for this tutorial is here. 本教程的完整代码链接。 Note: There is also source available for the BaseApplication framework and Ogre 1.7 here. 注意:我们同时也准备了 Baseapplication 框架和 Ogre1.7 的资源链接。
Setting Up the Scene 建立场景
First, as usual, we are going to set up a basic scene. Add the following variables to your project. 首先,和往常一样,咱准备建立一个基本的场景,为你的工程添加下面的代码:
BasicApp.h
Ogre::MovablePlane* mPlane; Ogre::Entity* mPlaneEntity; Ogre::SceneNode* mPlaneNode; Ogre::Rectangle2D* mMiniscreen;
Remember to initalize them all in the constructor. 记得在构造器里面注册这些:
BasicApp.cpp
mPlane(0), mPlaneEntity(0),
mPlaneNode(0), mMiniscreen(0)
Finally, we'll set up the basic scene elements we need. Add the following to createScene: 终于,咱准备好了咱创建基本场景所需要的所有元素辣,将下面的代码扔进咱的 createScene ()创建场景函数里:
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2)); //设置环境灯光颜色为 0.2,0.2,0.2 最大值为 1 Ogre::Light* light = mSceneMgr->createLight("MainLight"); light->setPosition(20, 80, 50); //创建 MainLight 这里没有设置灯光的类型,采取了默认的设置 mCamera->setPosition(60, 200, 70); mCamera->lookAt(0,0,0); //设定了摄像机的位置和 LookAt(指向)的点 Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( "PlaneMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); //使用材质管理器创建了材质 Ogre::TextureUnitState* tuisTexture = mat->getTechnique(0)->getPass(0)>createTextureUnitState("grass_1024.jpg"); //不知道在干啥(括弧笑 mPlane = new Ogre::MovablePlane("Plane"); mPlane->d = 0; mPlane->normal = Ogre::Vector3::UNIT_Y; //创建一个平面 Ogre::MeshManager::getSingleton().createPlane( "PlaneMesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *mPlane, 120, 120, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z); mPlaneEntity = mSceneMgr->createEntity("PlaneMesh");