教程:http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+1&structure=Tutorials 总结
void TutorialApplication::createScene(void) { // Create your scene here :) // Set the scene's ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5, 0.5)); mCamera->setPosition(0, 47, 222); // Create an Entity Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); // Create a SceneNode and attach the Entity to it Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode"); headNode->attachObject(ogreHead); // 1.Entity, mesh, SceneNode, SceneManager的概念 /*An Entity represents anything that has an Ogre mesh.A SceneNode is used to hold properties like location, scale, and rotation.It is also the anchor that attaches your Entities to your scene and allows them to be rendered on screen.Finally, The SceneManager is the object that orchestrates it all.It has methods that allow you to create Entities and SceneNodes and keep them organized within a complicated scene. */ // 2.Entity,SceneNode的常用方法 // Entity有setVisible,isVisible,getName, getParentSceneNode方法,Entity来自于mesh,一个mesh可以创建多个Entity. // SceneNode有setPosition,translate,setScale,rotate,roll,pitch,yaw,SceneNode上面的所有物体都会做相应的变换。 // numAttachedObjects,detachObject,detachAllObjects。 // 3.Ogre坐标系 // OGRE中是用相对坐标系,且是右手坐标系,所以旋转都是右手坐标系的。 // 4.创建Entity命名唯一,挂接Entity到SceneNode上不能循环 // 如果同样的网格资源创建Entity,不能用一个相同的命名的节点存放且资源名称要正确,否则会导致OGRE资源异常; // 类似于节点中循环挂接Entity异常. //OGRE EXCEPTION(6:FileNotFoundException) : Cannot locate resource orgehead.mesh in resource group Autodetect //or any other group.in ResourceGroupManager::openResource at ..\..\OgreMain\src\OgreResourceGroupManager.cpp(line 757) Ogre::Entity* ogreEntity2 = mSceneMgr->createEntity("Head2", "ogrehead.mesh");// 不能用Head,ogrehead.mesh要拼写正确 Ogre::SceneNode* headNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode2"); headNode2->setPosition(84, 48, 0); headNode2->attachObject(ogreEntity2); /*Ogre::Entity* ogreEntity2 = mSceneMgr->createEntity("ogrehead.mesh"); Ogre::SceneNode* ogreNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(84, 48, 0)); ogreNode2->attachObject(ogreEntity2);*/ Ogre::Entity* ogreEntity3 = mSceneMgr->createEntity("ogrehead.mesh"); Ogre::SceneNode* ogreNode3 = mSceneMgr->getRootSceneNode()->createChildSceneNode(); ogreNode3->setPosition(0, 104, 0); ogreNode3->setScale(2, 1.2, 1); ogreNode3->attachObject(ogreEntity3); Ogre::Entity* ogreEntity4 = mSceneMgr->createEntity("ogrehead.mesh"); Ogre::SceneNode* ogreNode4 = mSceneMgr->getRootSceneNode()->createChildSceneNode(); ogreNode4->setPosition(-84, 48, 0); ogreNode4->roll(Ogre::Degree(-90)); ogreNode4->attachObject(ogreEntity4); // Create a Light and set its position Ogre::Light* light = mSceneMgr->createLight("MainLight"); light->setPosition(20.0f, 80.0f, 50.0f); }
其它类和整个运行框架见:
http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+1&structure=Tutorials