刚刚写了1,马上就写2,有点骗人的嫌疑 o(∩_∩)o...
做完了1的步骤之后,我们的代码应该是
#include "ExampleApplication.h"

class TutorialApplication : public ExampleApplication


{
protected:
public:
TutorialApplication()

{
}

~TutorialApplication()

{
}
protected:
void createScene(void)

{
mSceneMgr->setAmbientLight( ColourValue( 1, 1, 1 ) );
Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" );
SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" );
node1->attachObject( ent1 );
}
};
讲了半天结果只有createScene中的四行是刚刚加进去的。。。汗
还是这个例子,刚刚我们并没有指定要把Robot放到哪里,但是OGRE“擅作主张”的把它放在了“一个位置”,这是为什么呢?
接着看这段代码
Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" );
SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) );
node2->attachObject( ent2 );
这里的createChildSceneNode函数有两个参数,第二个参数明确的指定了这个节点"RobotNode2"对于根节点的
相对位置,顺便提一下,这个组织场景的方法貌似叫做节点树,以后会提到。
这个node相对于根节点的位置是(50,0,0),也就是说它的位置要由根节点移动(50,0,0)的距离
如果把第二行改为直接由node1创建子节点"RobotNode2",即
SceneNode *node2 = node1->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) );
这时node2是相对于node1移动(50,0,0)的距离而不是根节点,这点要注意。
如果这个节点树为rootNode->node1->node2,这个时候父节点变化则子节点跟着变化,而子节点变化的时候则对父节点无影响
OK,暂且说这些,还有些函数,等第三次笔记补齐