日志系统:
日志记录了基于ogre的程序每次运行时的所有事件,系统初始化,状态,性能信息。输出的内容被放在磁盘文件上,文件缺省名是ogre.log。也可以手动显示创建日志系统,这需要在创建Root对象之前实施。
// create an instance of LogManager prior to using LogManager::getSingleton()
LogManager* logMgr = new LogManager;
Log *log = LogManager::getSingleton().createLog("mylog.log", true, true, false);
// third param is not used since we already created a log in the previous step
Root *root = new Root("", "");
可以用Ogre LogManager注册一个Log Listener, 以任何方式重定向log data。可以用这种方式来屏蔽任何日志信息。然后还一个更简单的方法达到上述目的:在实例化Root之前,当实例化一个LogManager后,不调用createLog()方法。
以下是实现日志信息截流的代码片断:
class MyLogListener : public LogListener
{
public:
void write (const String& name, const String& message,
LogMessageLevel level, bool maskDebug)
{
// redirect log output here as needed
};
MyLogListener *myListener = new MyLogListener;
// this is the same as calling LogManager::getSingletonPtr() after the
// LogManager has first been instanced; the same pointer value is returned
LogManager *logMgr = new LogManager;
LogMgr->addListener(myListener);
logMgr->createLog("mylog.log", true, false, true);
logMgr->setLogDetail(LL_NORMAL);
Root *root = new Root("", "", "mylog.log");
Ogre手动初始化
int main(int argc, char *argv[])
{

// tell Root not to load from any plugins or settings file
 Root *root = new Root("", "");

// Load feature plugins. Scene managers will register
 // themselves for all scene types they support
 root->loadPlugin("Plugin_CgProgramManager");
 root->loadPlugin("Plugin_OctreeSceneManager");

// load rendersystem plugin(s). The order is important in that GL
 // should be available on on platforms, while D3D9 would be available
 // only on Windows -- the try/catch will intercept the exception in this
 // case where D3D9 is not available and continue gracefully.
 try {
  root->loadPlugin("RenderSystem_GL");
  root->loadPlugin("RenderSystem_Direct3D9");
 }
 catch (...) {}

try {
  // We'll simulate the selection of a rendersystem on an arbirtary basis; normally
  // you would have your own code to present the user with options and select the
  // rendersystem on that basis. Since a GUI is beyond the scope of this example, we'll
  // just assume the user selected OpenGL.
  RenderSystemList *rList = root->getAvailableRenderers();
  RenderSystemList::iterator it = rList->begin();
  RenderSystem *rSys = 0;

while (it != rList->end()) {
   
   rSys = *(it++);
   if (rSys->getName().find("OpenGL")) {
   
    root->setRenderSystem(rSys);
    break;
   }
  }

// check to see if a render system was selected; if we reached the end of the list
  // without selecting a render system then none was found.
  if (rSys == 0) {
   delete root;
   std::cerr << "No RenderSystem available, exiting..." << std::endl;
   return -1;
  }

// We can initialize Root here if we want. "false" tells Root NOT to create
  // a render window for us
  root->initialise(false);

// set up the render window with all default params
  RenderWindow *window = rSys->createRenderWindow(
   "Manual Ogre Window", // window title
   800,     // window width, in pixels
   600,     // window height, in pixels
   false,     // fullscreen or not
   0);      // use defaults for all other values

// from here you can set up your camera and viewports as normal
  // get a pointer to the default base scene manager -- sufficient for our purposes
  SceneManager *sceneMgr = root->createSceneManager(ST_GENERIC);

// create a single camera, and a viewport that takes up the whole window (default behavior)
  Camera *camera = sceneMgr->createCamera("MainCam");
  Viewport *vp = window->addViewport(camera);
  vp->setDimensions(0.0f, 0.0f, 1.0f, 1.0f);
  camera->setAspectRatio((float)vp->getActualWidth() / (float) vp->getActualHeight());
  camera->setFarClipDistance(1000.0f);
  camera->setNearClipDistance(5.0f);

// Run the manual render loop. Since we are not using a frame listener in this case, we
  // will count to 15 seconds and then instead of exiting, we'll change the render window settings
  // and re-initialize it.
  bool renderLoop = true;
  Timer *timer = Ogre::PlatformManager::getSingleton().createTimer();
  timer->reset();
  float s = 0.0f;

while (renderLoop && window->isActive()) {

renderLoop = root->renderOneFrame();

// accumulate total elapsed time
   s += (float)timer->getMilliseconds() / 1000.0f;

// if greater than 15 seconds, break out of the loop
   if (s >= 15.0f)
    renderLoop = false;

// we must call the windowing system's message pump each frame to
   // allow Ogre to process messages
   //PlatformManager::getSingleton().messagePump();
  }
 }
 catch (Exception &e) {
  std::cerr << e.getFullDescription() << std::endl;
 }

delete root;
 return 0;
}

视口
通过视口上的一点与相机的原点产生世界空间中的一条光线
// x and y are in "normalized" (0.0 to 1.0) screen coordinates
Ray getCameraToViewportRay(Real x, Real y) const;

视口,创建多个视口,通过Z序(越高越在上) 确定覆盖效果,每个视口可以有不同的背景。
// assume window is a valid pointer to an existing render window, and
// a valid pointer to an existing camera instance
Viewport *vpTop, *vpBottom;
// second parameter is z-order, remaining params are position and size,
vpBottom = window->addViewport(camera, 0);
// create a smaller viewport on top, in the center, 25% of main vp size
vpTop = window->addViewport(camera, 1,
0.375f, 0.375f,
0.25, 0.25);
// set the background of the top window to blue (the default is black
// need to set the bottom window explicitly)
vpTop->setBackgroundColour(ColourValue(0.0f, 0.0f, 1.0f));
// an alternate way to set the color is to use the manifest constant
// vpTop->setBackgroundColour(ColourValue::Blue);
在多视口情况下,overlay缺省在每个视口中渲染。可以关掉。Skybox, Shadow也是如此。
vpTop->setOverlaysEnabled(false);
vpTop->setSkiesEnabled(false);
vpTop->setShadowsEnabled(true);

转载于:https://www.cnblogs.com/hf621222/archive/2013/05/27/3101088.html

《Pro Ogre 3D Programming》 读书笔记 之 第四章 开始使用OGRE (转)相关推荐

  1. 【Python自然语言处理】读书笔记:第四章:编写结构化程序

    4 编写结构化程序 4.1 回到基础 1.赋值: 列表赋值是"引用",改变其中一个,其他都会改变 foo = ["1", "2"] bar ...

  2. 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第四章 使用SCAPY掌控网络(2)Scapy实现ARP缓存投毒

    黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第四章 使用SCAPY掌控网络(2)Scapy实现ARP缓存投毒 文章目录 黑帽python第二版(Bl ...

  3. 马丁福勒《UML精粹》读书笔记_第四章

    第四章 顺序图 顺序图是一个use case的一种实现.当考察单个use case内部若干对象的行为时,就应使用顺序图. 可参考"高焕堂<嵌入式UML设计>读书笔记_第五章&qu ...

  4. 锋利的Jquery【读书笔记】 -- 第四章 jQuery中的事件和动画

    锋利的Jquery读书笔记 第三章 jQuery中的DOM操作 jQuery中的事件 事件绑定 bind方法 合成事件 hover方法 toggle方法 事件冒泡 事件对象 停止事件冒泡 阻止默认行为 ...

  5. 《Java编程思想》第四版读书笔记 第十四章 类型信息

    2019独角兽企业重金招聘Python工程师标准>>> 14.2 RTTI运行时类型识别. Class对象包含了与类有关的信息,Java使用Class对象来执行其RTTI.每个类都有 ...

  6. 《linux程序设计》--读书笔记--第十四章信号量、共享内存和消息队列

    信号量:用于管理对资源的访问: 共享内存:用于在程序之间高效的共享数据: 消息队列:在程序之间传递数据的一种简单方法: 一.信号量 临界代码:需要确保只有一个进程或者一个执行线程可以进入这个临界代码并 ...

  7. jQuery 实战读书笔记之第四章:使用特性、属性和数据

    使用属性 /* 每个元素都有一或多个特性,,这些特性的用途是给出相应元素或其内容的附加信息.(出自 JavaScript 高级程序设计) */ /* 特性是固有的 JavaScript 对象 属性指的 ...

  8. Android深度探索(卷1)HAL与驱动开发 读书笔记(第四章)

    第四章  源代码的下载和编译 本章主要介绍使用Git下载两套源代码.一套是Android 源代码,另一套是Linux 内核源代码.主要介绍如何下载和编译Android源代码和Linux内核源代码. 4 ...

  9. 《分析服务从入门到精通读书笔记》第四章、创建父子维度(7)

    目的 父子维度的不同之处在于处于其包含了一个基于递归关系(Recursive relationship)的层次关系,比如,上级和下级雇员的层次结构关系是典型的递归关系.在一线工作的雇员会有一个主管,而 ...

  10. Linux内核分析 读书笔记 (第四章)

    第四章 进程调度 调度程序负责决定将哪个进程投入运行,何时运行以及运行多长时间.进程调度程序可看做在可运行态进程之间分配有限的处理器时间资源的内核子系统.只有通过调度程序的合理调度,系统资源才能最大限 ...

最新文章

  1. 2020-12-22 一些有用的开源软件
  2. shell 学习笔记(四)
  3. pythonanywhere.com的用法
  4. 【汇编语言】汇编语言如何编程,如何避免出错
  5. Google Chrome浏览器可能在您不知情的情况下破坏了您的测试
  6. codeforces 282A-C语言解题报告
  7. Linux异常进程kill无效的解决办法
  8. php加密解密文件内容,php文件加密解密 - osc_0g0vbf0z的个人空间 - OSCHINA - 中文开源技术交流社区...
  9. html网页背景图片 菜鸟教程,CSS3 背景
  10. Unity读取项目文件夹图片,PC端
  11. Matlab-输出函数表达
  12. c#网页设计 UI —登录注册界面
  13. 【词汇辨析】Primary, main, prime and major “主要的、首要的”
  14. Java对接高德地图计算距离_高德地图计算两点之间的距离java+html
  15. PHP的bz2压缩扩展工具
  16. 百度地图添加自定义点标记、文本标注、点标记
  17. 线性代数学习笔记——第七十三讲——实对称矩阵的特征值与特征向量
  18. python色卡_Python可视化|08-Palettable库中颜色条Colormap(四)
  19. 第十四课 斗地主项目课④ 游戏场景的ui
  20. POJ2018 Best Cow Fences —— 斜率优化DP

热门文章

  1. C#Winform中WebBrowser控件的特性和详细调用方法
  2. (转载)找工作那年,我真的哭了
  3. Linux系统编程三:使用man查看帮助文档
  4. 初识NB-IoT的机卡绑定
  5. c#利用泛型集合,为自己偷偷懒。
  6. tomcat,zookeeper,activeMQ,Kafka设置jvm参数
  7. HTMLCSS 第五天 笔记
  8. 响应头中content-type常用的类型有哪些?
  9. 剖析vector.erase()实现
  10. 动态规划-最少硬币问题