1.认识Ogre SDK
Ogre的SDK主要有以下内容,其中bin和lib中都有两文件夹,debug和release。因为Ogre提供了debug-build和release-build两个build版本,debug-build允许做debug,而release-build优化了程序运行的性能。
bin:Ogre程序执行时需要用到的一些dll,还包含一些.cfg文件。
lib:Ogre程序执行时需要用到的一些lib,这些lib文件指示了该链接哪些dll。
include:存放头文件的文件夹。
.cfg:包含了一些配置信息。
ogre.cfg:有关显示效果等的配置。
plugins.cfg:列出了程序所使用到的插件。(Ogre提供了一些接口,插件通过这些接口为Ogre提供了更多的扩展性能)
resources.cfg:列出了程序所用到的各种资源。
OgreMain.dll:最重要的dll。
2.Loading the first model
void createScene()
{
Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity", "Sinbad.mesh");
Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
mSceneMgr->getRootSceneNode()->addChild(node);
node->attachObject(ent);
}
3.Scene Graph
a.Ogre利用scene graph来组织场景。scene graph是一个树结构,有一个RootSceneNode,旗下还有许多其他scene node。scene node下面可以放两种东西,一是scene node,二是entity、light、particle system等,entity本身不是children,也不能有children,他们是叶子结点。
b.Scene Graph很重要的一个概念是一个node的变换是相对于其parent node的,即一个scene node的最终变换是其自己的变换与其所有parent scene node变换的叠加。
c.Scene Node
·平移、放缩。
setPostion和translate方法的区别是translate是在当前位置的基础上进行移动。同理的还有setScale和scale方法。
·pitch、yaw和roll
pitch绕x轴旋转,yaw绕y轴旋转,roll绕z轴旋转。We can either use Ogre::Degree(degree) or Ogre::Radian(radian) to specify how much we want to rotate.
·local、parent、world三个变换空间
local是以自己为坐标系的原点(即向前为z轴,左手边为x轴,上边为y轴);
parent是根据parent node的坐标系作变换;
world是根据world坐标系作变换。