自己创建scene manager,载入bsp地图

class MyApplication :public ExampleApplication
{
public:MyApplication() {}~MyApplication(){}void createScene(){std::cout<<mSceneMgr->getTypeName()<<"::"<<mSceneMgr->getName()<<std::endl;}virtual void chooseSceneManager(){ResourceGroupManager::getSingleton().addResourceLocation("http://www.cnblogs.com/media/packs/chiropteraDM.pk3","Zip", ResourceGroupManager::getSingleton().getWorldResourceGroupName(), true);// index all files in the resource group which are not already indexed, of course we // should give the name of the resource group we want to index.ResourceGroupManager::getSingleton().initialiseResourceGroup(ResourceGroupManager::getSingleton().getWorldResourceGroupName());// create a bsp scene manager// BspSceneManager : identifying a unique SceneManager typemSceneMgr = mRoot->createSceneManager("BspSceneManager");// tell the bsp scene manager to load a map saved in the bsp file formatmSceneMgr->setWorldGeometry("maps/chiropteradm.bsp");}private:
};int main()
{MyApplication app;app.go();return 0;
}

 

 用quad加材质图画草

class MyApplication :public ExampleApplication
{
public:MyApplication() {}~MyApplication(){}void createScene(){// 先用定义的平面创建一个网格,再用创建的网格构造一个实体Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);Ogre::MeshManager::getSingleton().createPlane("plane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,plane,1500, 1500, 200, 200,true, 1, 5, 5, Ogre::Vector3::UNIT_Z);Ogre::Entity* entity = mSceneMgr->createEntity("grasspalne", "plane");mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entity);// 设置材质entity->setMaterialName("Examples/GrassFloor");// 创建方向光Ogre::Light* light = mSceneMgr->createLight("light1");light->setType(Ogre::Light::LT_DIRECTIONAL);light->setDirection(Ogre::Vector3(1, -1, 0));// 用manual object 绘制自己定义的物体Ogre::ManualObject* manual = mSceneMgr->createManualObject("grass");// param1--渲染manual object用到的材质(纹理)图// param2--顶点的格式manual->begin("Examples/GrassBlades", RenderOperation::OT_TRIANGLE_LIST);manual->position(5.0, 10.0, 0.0);manual->textureCoord(1, 0);manual->position(-5.0, -10.0, 0.0);manual->textureCoord(0, 1);manual->position(-5.0, 10.0, 0.0);manual->textureCoord(0, 0);// second trianglemanual->position(5.0, -10.0, 0.0);manual->textureCoord(1, 1);manual->position(5.0, 10.0, 0.0);manual->textureCoord(1, 0);manual->position(-5.0, -10.0, 0.0);manual->textureCoord(0, 1);manual->end();Ogre::SceneNode* grassNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("grassnode2");grassNode->attachObject(manual);}
};

  

画三个quad的草,每个quad之间夹角为60度

class MyApplication :public ExampleApplication
{
public:MyApplication() {}~MyApplication(){}void createScene(){// 先用定义的平面创建一个网格,再用创建的网格构造一个实体Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);Ogre::MeshManager::getSingleton().createPlane("plane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,plane,1500, 1500, 200, 200,true, 1, 5, 5, Ogre::Vector3::UNIT_Z);Ogre::Entity* entity = mSceneMgr->createEntity("grasspalne", "plane");mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entity);// 设置材质entity->setMaterialName("Examples/GrassFloor");// 创建方向光Ogre::Light* light = mSceneMgr->createLight("light1");light->setType(Ogre::Light::LT_DIRECTIONAL);light->setDirection(Ogre::Vector3(1, -1, 0));// 用manual object 绘制自己定义的物体Ogre::ManualObject* manual = mSceneMgr->createManualObject("grass");// param1--渲染manual object用到的材质(纹理)图// param2--顶点的格式manual->begin("Examples/GrassBlades", RenderOperation::OT_TRIANGLE_LIST);// first trianglemanual->position(5.0, 10.0, 0.0);manual->textureCoord(1, 0);manual->position(-5.0, 0.0, 0.0);manual->textureCoord(0, 1);manual->position(-5.0, 10.0, 0.0);manual->textureCoord(0, 0);// second trianglemanual->position(5.0, 0.0, 0.0);manual->textureCoord(1, 1);manual->position(5.0, 10.0, 0.0);manual->textureCoord(1, 0);manual->position(-5.0, 0.0, 0.0);manual->textureCoord(0, 1);// third trianglemanual->position(2.5, 0.0, 4.3);manual->textureCoord(1, 1);manual->position(-2.5, 10.0, -4.3);manual->textureCoord(0, 0);manual->position(-2.5, 0.0, -4.3);manual->textureCoord(0, 1);// fourth trianglemanual->position(2.5, 0.0, 4.3);manual->textureCoord(1, 1);manual->position(2.5, 10.0, 4.3);manual->textureCoord(1, 0);manual->position(-2.5, 10.0, -4.3);manual->textureCoord(0 ,0);//fifth trianglemanual->position(2.5, 0.0, -4.3);manual->textureCoord(1 ,1);manual->position(-2.5, 10.0, 4.3);manual->textureCoord(0, 0);manual->position(-2.5, 0.0, 4.3);manual->textureCoord(0, 1);//sixth trianglemanual->position(2.5, 0.0, -4.3);manual->textureCoord(1, 1);manual->position(-2.5, 10.0 ,4.3);manual->textureCoord(0, 0);manual->position(2.5, 10.0, -4.3);manual->textureCoord(1, 0);manual->end();Ogre::SceneNode* grassNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("grassnode2");grassNode->attachObject(manual);}
};

  

画50*50的草

 1 class MyApplication :public ExampleApplication 2 { 3 public: 4     MyApplication() {} 5     ~MyApplication() 6     {} 7  8     void createScene() 9     {10         // 先用定义的平面创建一个网格,再用创建的网格构造一个实体11         Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);12         Ogre::MeshManager::getSingleton().createPlane("plane", 13             ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,14             plane,15             1500, 1500, 200, 200,16             true, 1, 5, 5, Ogre::Vector3::UNIT_Z);17         Ogre::Entity* entity = mSceneMgr->createEntity("grasspalne", "plane");18         mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entity);19         // 设置材质20         entity->setMaterialName("Examples/GrassFloor");21         // 创建方向光22         Ogre::Light* light = mSceneMgr->createLight("light1");23         light->setType(Ogre::Light::LT_DIRECTIONAL);24         light->setDirection(Ogre::Vector3(1, -1, 0));25 26         // 用manual object 绘制自己定义的物体27         Ogre::ManualObject* manual = mSceneMgr->createManualObject("grass");28         // param1--渲染manual object用到的材质(纹理)图29 // param2--顶点的格式30         manual->begin("Examples/GrassBlades", RenderOperation::OT_TRIANGLE_LIST);31 32 33         // first triangle34         manual->position(5.0, 10.0, 0.0);35         manual->textureCoord(1, 0);36         manual->position(-5.0, 0.0, 0.0);37         manual->textureCoord(0, 1);38         manual->position(-5.0, 10.0, 0.0);39         manual->textureCoord(0, 0);40         // second triangle41         manual->position(5.0, 0.0, 0.0);42         manual->textureCoord(1, 1);43         manual->position(5.0, 10.0, 0.0);44         manual->textureCoord(1, 0);45         manual->position(-5.0, 0.0, 0.0);46         manual->textureCoord(0, 1);47 48         // third triangle49         manual->position(2.5, 0.0, 4.3);50         manual->textureCoord(1, 1);51         manual->position(-2.5, 10.0, -4.3);52         manual->textureCoord(0, 0);53         manual->position(-2.5, 0.0, -4.3);54         manual->textureCoord(0, 1);55         // fourth triangle56         manual->position(2.5, 0.0, 4.3);57         manual->textureCoord(1, 1);58         manual->position(2.5, 10.0, 4.3);59         manual->textureCoord(1, 0);60         manual->position(-2.5, 10.0, -4.3);61         manual->textureCoord(0 ,0);62 63         //fifth triangle64         manual->position(2.5, 0.0, -4.3);65         manual->textureCoord(1 ,1);66         manual->position(-2.5, 10.0, 4.3);67         manual->textureCoord(0, 0);68         manual->position(-2.5, 0.0, 4.3);69         manual->textureCoord(0, 1);70         //sixth triangle71         manual->position(2.5, 0.0, -4.3);72         manual->textureCoord(1, 1);73         manual->position(-2.5, 10.0 ,4.3);74         manual->textureCoord(0, 0);75         manual->position(2.5, 10.0, -4.3);76         manual->textureCoord(1, 0);77 78         manual->end();79 80         //Ogre::SceneNode* grassNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("grassnode2");81 //grassNode->attachObject(manual);82 83 //Convert this object to a Mesh84         manual->convertToMesh("BladeOfGrass");85         std::stringstream os;86         for (int i=0 ;i<50; ++i)87         {88             for (int j=0; j<50; ++j)89             {90                 os<<i<<j;91                 Ogre::Entity* ent = mSceneMgr->createEntity(os.str(), "BladeOfGrass");92                 Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(93                     os.str(), Ogre::Vector3(i * 3, -10, j * 3));94                 node->attachObject(ent);95             }96         }97     }98 };

用索引列表表示三角形+StaticGeometry 提高渲染效率

class MyApplication :public ExampleApplication
{
public:MyApplication() {}~MyApplication(){}void createScene(){// 先用定义的平面创建一个网格,再用创建的网格构造一个实体Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);Ogre::MeshManager::getSingleton().createPlane("plane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,plane,1500, 1500, 200, 200,true, 1, 5, 5, Ogre::Vector3::UNIT_Z);Ogre::Entity* entity = mSceneMgr->createEntity("grasspalne", "plane");mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entity);// 设置材质entity->setMaterialName("Examples/GrassFloor");// 创建方向光Ogre::Light* light = mSceneMgr->createLight("light1");light->setType(Ogre::Light::LT_DIRECTIONAL);light->setDirection(Ogre::Vector3(1, -1, 0));// 用manual object 绘制自己定义的物体Ogre::ManualObject* manual = mSceneMgr->createManualObject("grass");// param1--渲染manual object用到的材质(纹理)图// param2--顶点的格式manual->begin("Examples/GrassBlades", RenderOperation::OT_TRIANGLE_LIST);// first trianglemanual->position(5.0, 10.0, 0.0);   // indice = 0manual->textureCoord(1, 0);manual->position(-5.0, 0.0, 0.0); // indice = 1manual->textureCoord(0, 1);manual->position(-5.0, 10.0, 0.0); // indice =2manual->textureCoord(0, 0);// second trianglemanual->position(5.0, 0.0, 0.0); //indice = 3manual->textureCoord(1, 1);//manual->position(5.0, 10.0, 0.0);//manual->textureCoord(1, 0);//manual->position(-5.0, 0.0, 0.0);//manual->textureCoord(0, 1);// third trianglemanual->position(2.5, 0.0, 4.3); //indice=4manual->textureCoord(1, 1);manual->position(-2.5, 10.0, -4.3); //indice=5manual->textureCoord(0, 0);manual->position(-2.5, 0.0, -4.3); //indice=6manual->textureCoord(0, 1);// fourth triangle//manual->position(2.5, 0.0, 4.3);//manual->textureCoord(1, 1);manual->position(2.5, 10.0, 4.3);  //indice=7manual->textureCoord(1, 0);//manual->position(-2.5, 10.0, -4.3);//manual->textureCoord(0 ,0);//fifth trianglemanual->position(2.5, 0.0, -4.3); //indice=8manual->textureCoord(1 ,1);manual->position(-2.5, 10.0, 4.3); //indice=9manual->textureCoord(0, 0);manual->position(-2.5, 0.0, 4.3); //indice=10manual->textureCoord(0, 1);//sixth triangle//manual->position(2.5, 0.0, -4.3);//manual->textureCoord(1, 1);//manual->position(-2.5, 10.0 ,4.3);//manual->textureCoord(0, 0);manual->position(2.5, 10.0, -4.3); //indice=11manual->textureCoord(1, 0);//using indicesmanual->index(0);manual->index(1);manual->index(2);manual->index(0);manual->index(3);manual->index(1);manual->index(4);manual->index(5);manual->index(6);manual->index(4);manual->index(5);manual->index(7);manual->index(8);manual->index(9);manual->index(10);manual->index(8);manual->index(9);manual->index(11);manual->end();// 对于大量的、静止的模型用StaticGeometry可提高渲染效率// 只适用于用索引列表表示的模型// 模型加入StaticGeometry后不能再移动Ogre::StaticGeometry* field = mSceneMgr->createStaticGeometry("fieldOfGrass");//Convert this object to a Meshmanual->convertToMesh("BladeOfGrass");for (int i=0 ;i<50; ++i){for (int j=0; j<50; ++j){Ogre::Entity* ent = mSceneMgr->createEntity("BladeOfGrass");field->addEntity(ent, Ogre::Vector3(i * 3, -10, j * 3));}}// 计算加入到field中的所有实体的位置field->build();}
};int main()
{MyApplication app;app.go();return 0;
}

  

  

Ogre 2011-11-30相关推荐

  1. 重新开始 2011/11/25

    在csdn上写过几篇文章,始终没有坚持下来,也是由于自己没有一个明确的目标的缘故:当自己感觉乱的时候,总是想改变点东西,重新开始,改变了博客类的东西就真的能重新开始吗?现在我想换个博客就换个博客,这是 ...

  2. pandas使用normalize函数将dataframe中的时间(time)数据列转化为日期(date)数据列(例如,从2019-12-25 11:30:00到2019-12-25)

    pandas使用normalize函数将dataframe中的时间(time)数据列转化为日期(date)数据列(例如,从2019-12-25 11:30:00到2019-12-25) 目录

  3. 有關window.showModalDialog的應用11/30

    需求: 有一個頁面A 在A中當光標點到某一欄位時開啟小視窗可錄入大量的文字 設計: 在該欄位中用onfocus事件,用window.showModalDialog開啟小視窗B中 如果該欄位有資料,則開 ...

  4. 11.28 限定某个目录禁止解析php 11.29 限制user_agent 11.30/11.31 php相关配置

    - 11.28 限定某个目录禁止解析php - 11.29 限制user_agent - 11.30/11.31 php相关配置 - 扩展 - apache开启压缩 http://ask.apelea ...

  5. daily scrum 11.30

      今日任务 做了什么 明日任务 李嘉良 (18)写换皮肤功能 努力实现换肤功能中 continue 王泓洋 (29)优化metro图标 问了几个同学新的metro设计怎么样 与项目284沟通,完善一 ...

  6. 实验室每日一题 2020.11.30

    实验室每日一题 2020.11.30 先打开没有加密的文本文档,里面有一串密文,根据结尾的+推测应该是XXencode,直接找个在线网站解密,又得到一串密文:fwilvyhublqwhuhvwlqj, ...

  7. 2018/11/30 快手面试总结

    2018/11/30 快手面试总结 1.简历还需要优化调整: 2.面试官会提问一些基础和算法(也会让你手写代码) 比如: 二叉树的中序遍历 ArrayList删除中间元素的代码手写 spring Be ...

  8. 11月最新新萝卜家园GhostXP SP3 电脑城装机极致版系统2011.11

    新萝卜家园GhostXP SP3电脑城装机极致版2011.11+ 一.主要更新: ========================== * 更新了系统补丁和Office2003所有补丁到2011-11 ...

  9. 2022 CCF 非专业级别软件能力认证第一轮 (CSP-J1)入门级 C++语言试题 认证时间:2022 年 9 月 18 日 09:30~11:30

    今天的考试题,有点乱 2022 CCF 非专业级别软件能力认证第一轮 (CSP-J1)入门级 C++语言试题 认证时间:2022 年 9 月 18 日 09:30~11:30 考生注意事项:  试题 ...

  10. 《nature》2020.11.30期,重症COVID-19的主要遗传危险因素来自尼安德特人

    <nature>最新2020.11.30期快报! 1.重症COVID-19的主要遗传危险因素来自尼安德特人 严重COVID-19的风险是由一个遗传自尼安德特人的基因组片段引起的,南亚和欧洲 ...

最新文章

  1. Altium Designer原理图模板设计
  2. solr学习之(七)_学习solr的理由(solr的特点和应用领域)
  3. [architecture]-ARMv8/armv7/linux的栈/sp的学习和总结
  4. 机器学习算法Python实现:word2vec 求词语相似度
  5. bzoj5093: [Lydsy1711月赛]图的价值
  6. 用户管理实例 之 添加、查询
  7. ucenter php7.0版,UCenter1.5.0/UCenter Home1.5/Discuz! 7.0
  8. 别人25岁就拥有了自己的事业,我30岁还在打工
  9. 477. 汉明距离总和
  10. BZOJ1196 [HNOI2006]公路修建问题 【二分 + Kruskal】
  11. the problem was occurred when start ADT
  12. endnote修改正文中参考文献标注_如何在Endnote中修改参考文献格式
  13. 高老师的架构设计_隽语集(CC_1051)
  14. php源码 拼车网顺风车_基于ThinkPHP框架开发的在线微信拼车系统完整PHP源码+支付微信支付...
  15. 在线教育项目【老师服务】
  16. 题解-hzy loves segment tree I
  17. python写界面文字游戏_Python:pygame游戏编程之旅五(游戏界面文字处理详解)
  18. 【TCP/IP学习笔记1】 C语言讲解
  19. QGC地面站使用教程
  20. 织梦dedecms资源素材教程下载网站模板源码(带手机移动端)附安装教程

热门文章

  1. postgres循环sql
  2. raid操作相关命令笔记
  3. linux文件层级、目录、文件基本操作介绍
  4. 《途客圈创业记:不疯魔,不成活》一一1.6 申请助跑计划
  5. SQL Server-表表达式基础回顾(二十四)
  6. 分手后我还能和你做朋友么(转)
  7. android自定义数字键盘和字母键盘,Android自定义键盘的实现(数字键盘和字母键盘)...
  8. mysql的extract_mysql中json_extract函数的使用?作用是什么?
  9. android小闹钟课程设计,《小闹钟》教学设计
  10. SpringSecurity 认证通过后显示当前认证用户名