由于第二章写出的时候还没有把wizzard搞出来,所以这个项目是手动生成,估计后面我都会用WIZZARD来生成

#include "BaseTutorial2.h"
BasicTutorial2::BasicTutorial2(void)
{}
BasicTutorial2::~BasicTutorial2(void)
{}
void BasicTutorial2::createCamera(void)
{mCamera=mSceneMgr->createCamera("PlayerCam");//you can use getCamera retrieves a pointer to the named camera.mCamera->setPosition(Ogre::Vector3(0,10,500));mCamera->lookAt(Ogre::Vector3(0,0,0));mCamera->setNearClipDistance(5);//though you should not use a far clip distance with Stencil ShadowsmCameraMan=new OgreBites::SdkCameraMan(mCamera);//The Ogre Wiki Tutorial Framework uses OgreBites for GUI widgets and camera handling. //It uses it because OgreBites - the Ogre sample framework - is included in every Ogre SDK, and because it simplifies things a lot.}
void BasicTutorial2::createViewports(void)
{Ogre::Viewport* vp=mWindow->addViewport(mCamera);vp->setBackgroundColour(Ogre::ColourValue(0,0,0));mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth())/Ogre::Real(vp->getActualHeight()));}
void BasicTutorial2::createScene(void)
{mSceneMgr->setAmbientLight(Ogre::ColourValue(0,0,0));mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);//Ogre currently supports three types of Shadows://1.Modulative Texture Shadows (Ogre::SHADOWTYPE_TEXTURE_MODULATIVE) - The least computationally expensive of //the three. This creates a black and white render-to-texture of shadow casters, which is then applied to the scene.//2.Modulative Stencil Shadows (Ogre::SHADOWTYPE_STENCIL_MODULATIVE) - This technique renders all shadow volumes as//a modulation after all non-transparent objects have been rendered to the scene. This is not as intensive as //Additive Stencil Shadows, but it is also not as accurate.//3.Additive Stencil Shadows (Ogre::SHADOWTYPE_STENCIL_ADDITIVE) - This technique renders each light as a separate //additive pass on the scene. This is very hard on the graphics card because each additional light requires an //additional pass at rendering the scene.//Ogre does not support soft shadows as part of the engine. If you want soft shadows you will need to write your own vertex and fragment programs. Ogre::Entity* entNinja=mSceneMgr->createEntity("Ninja","ninja.mesh");entNinja->setCastShadows(true);mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);Ogre::Plane plane(Ogre::Vector3::UNIT_Y,0);Ogre::MeshManager::getSingleton().createPlane("ground",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,plane,\1500,1500,20,20,true,1,5,5,Ogre::Vector3::UNIT_Z);Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity","ground");mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);entGround->setMaterialName("Examples/Rockwall");entGround->setCastShadows(false);//Now that we have a Ninja and ground in the scene, let's compile and run the program. //We see... nothing! What's going on? In the previous tutorial we added entities and they displayed fine. //The reason the Ninja doesn't show up is that the scene's ambient light has been set to total darkness. //So let's add a light to see what is going on.Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");pointLight->setType(Ogre::Light::LT_POINT);pointLight->setPosition(Ogre::Vector3(0,150,250));pointLight->setDiffuseColour(1.0f,0.0f,0.0f);pointLight->setSpecularColour(1.0f,0.0f,0.0f);Ogre::Light* directionalLight=mSceneMgr->createLight("directionalLight");directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);directionalLight->setDiffuseColour(Ogre::ColourValue(.25f,.25f,0));directionalLight->setSpecularColour(Ogre::ColourValue(.25f,.25f,0));directionalLight->setDirection(Ogre::Vector3( 0,-1,1));Ogre::Light* spotLight=mSceneMgr->createLight("spotLight");spotLight->setType(Ogre::Light::LT_SPOTLIGHT);spotLight->setDiffuseColour(0,0,1.0f);spotLight->setSpecularColour(0,0,1.0f);spotLight->setDirection(-1,-1,0);spotLight->setPosition(Ogre::Vector3(300,300,0));spotLight->setSpotlightRange(Ogre::Degree(35),Ogre::Degree(35));
}//2 end#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif#ifdef __cplusplus
extern "C" {
#endif#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#elseint main(int argc, char *argv[])
#endif{// Create application objectBasicTutorial2 app;try {app.go();} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#elsestd::cerr << "An exception has occured: " <<e.getFullDescription().c_str() << std::endl;
#endif}return 0;}#ifdef __cplusplus
}
#endif

三种不同的阴影效果:

第二章 Cameras, Lights, and Shadows相关推荐

  1. 第二章 创建webGL设备和绘制缓冲区呈现 Context Creation and Drawing Buffer Presentation

    第二章 创建webGL设备和绘制缓冲区呈现 Context Creation and Drawing Buffer Presentation     在开始使用webGL API之前您先要从现有的HT ...

  2. 【《Real-Time Rendering 3rd》 提炼总结】(二) 第二章 · 图形渲染管线 The Graphics Rendering Pipeline

    本文由@浅墨_毛星云 出品,转载请注明出处.   文章链接: http://blog.csdn.net/poem_qianmo/article/details/70544201 这篇文章是解析计算机图 ...

  3. 【转载】《Real-Time Rendering 3rd》 提炼总结】(二) 第二章 · 图形渲染管线 The Graphics Rendering Pipeline

    本文由@浅墨_毛星云 出品.   文章链接: http://blog.csdn.net/poem_qianmo/article/details/70544201 这篇文章是解析计算机图形学界" ...

  4. 王道考研 计算机网络笔记 第二章:物理层

    本文基于2019 王道考研 计算机网络: 2019 王道考研 计算机网络 个人笔记总结 第一章:王道考研 计算机网络笔记 第一章:概述&计算机网络体系结构 后续章节将陆续更新- 第二章 一.物 ...

  5. 计算机组成原理-第二章 数据表示与运算

    计算机组成原理-第二章 数据表示与运算 一.数据的表示 1.数值型数据的表示(重点难点) 1.1数值型数据的表示--进位制 1.2数值型数据表示-码制 1.3数值型数据的表示--定点数 1.4数值型数 ...

  6. 2021-08-08概率论与数理统计-第二章

    文章目录 概率论与数理统计-第二章 概率论与数理统计-第二章

  7. 软件构造 第二章 第一节 软件生命周期和版本控制

    软件构造第二章 第一节 软件生命周期和版本控制 基本内容 Software Development Lifecycle (SDLC) Traditional software process mode ...

  8. 第二节认识计算机教案,第二章 第二节 局域网的构建 教学设计_博客

    <第二章 第二节 局域网的构建 教学设计_博客>由会员分享,可在线阅读,更多相关<第二章 第二节 局域网的构建 教学设计_博客(3页珍藏版)>请在装配图网上搜索. 1.第二章 ...

  9. ArcGIS for Desktop入门教程_第二章_Desktop简介 - ArcGIS知乎-新一代ArcGIS问答社区

    原文:ArcGIS for Desktop入门教程_第二章_Desktop简介 - ArcGIS知乎-新一代ArcGIS问答社区 1 Desktop简介 1.1 ArcGIS for Desktop ...

最新文章

  1. 57-高级路由:分发列表:多协议分发列表实验:DV、LS
  2. 《Elasticsearch 权威指南》阅读笔记
  3. Python进阶05 循环设计
  4. ltv价值 应用_用户终生价值Ltv是什么,在游戏设计中如何考虑?
  5. Linux CTF 逆向入门
  6. jupyter notebook中创建环境、安装使用pytorch
  7. cesium加载 gltf模型
  8. Spring动态的切换数据源
  9. 秒懂C#通过Emit动态生成代码
  10. DX11:先定一个小目标,比如:把DX11龙书上的知识点系统的总结下来
  11. # 数据结构---1.栈的实现
  12. Java利用接口计算立体图形的表面积和体积
  13. html中页码居中,如何把Word2007的页脚设置为页码并居中?
  14. [QNX Hypervisor 2.2用户手册]12.2 术语(二)
  15. 江苏大学计算机学院姚奕如,小博传递 || 江苏大学第一届计算机文化节成功举办!...
  16. Qt图表绘制(QtCharts)-绘制简单的盒须图[箱形图](12)
  17. 遍历某个文件夹中所有文件夹名和文件名
  18. bzoj 1718: [Usaco2006 Jan] Redundant Paths 分离的路径
  19. 为什么要学习Linux及其学习路线
  20. 为什么要研究大数据?

热门文章

  1. SHFormatDrive格式化硬盘
  2. Access在Win10连接失败的问题
  3. Halcon PDF文档(hdevelop_users_guide)学习总结之六——Halcon如何导出C++代码
  4. 计算机英语900句.pdf,计算机英语900句第一章第一课:概貌
  5. #includemmsystem头文件出错
  6. 阿里云数据库再添新成员,企业级MariaDB正式开卖!
  7. DevOpsSOP 基于阿里云VPC搭建Storm+Kafka+Zookeeper集群
  8. iOS开发 - ARC的开启与关闭
  9. 一个或多个音频服务未运行 win7 错误1079:此服务的账户不同于运行于同一进程上的其他服务账户...
  10. abap object-oriented–使用事件