⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutorialapplication.cpp

📁 使用stl技术,(还没看,是听说的)
💻 CPP
字号:
// TutorialApplication.cpp: implementation of the TutorialApplication class.
//
//////////////////////////////////////////////////////////////////////

#include "TutorialApplication.h"

class TutorialFrameListener : public ExampleFrameListener
{
protected:
     SceneNode* mShipNode;

public:
    TutorialFrameListener(RenderWindow* win, Camera* cam, SceneNode* shipNode) : 
        ExampleFrameListener(win, cam)
    { 
        mShipNode = shipNode;
    };
    bool frameStarted(const FrameEvent& evt);
};

bool TutorialFrameListener::frameStarted(const FrameEvent& evt)
{
	Real MoveFactor = 80.0 * evt.timeSinceLastFrame;

	mInputDevice->capture();

	if(mInputDevice->isKeyDown(Ogre::KC_UP))
		mShipNode->translate(0.0, MoveFactor, 0.0);

	if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
		mShipNode->translate(0.0, -MoveFactor, 0.0);

	if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
		mShipNode->translate(-MoveFactor, 0.0, 0.0);

	if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
		mShipNode->translate(MoveFactor, 0.0, 0.0);

	return true;
}

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

TutorialApplication::TutorialApplication()
{

}


TutorialApplication::~TutorialApplication()
{

}


void TutorialApplication::createScene()
{
	// Create the SkyBox
	mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");

	// Create our ship entity
	mShip = mSceneMgr->createEntity("razor", "razor.mesh");

	// Create our SceneNode
	mShipNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();

	// Attach the ship entity to the sceneNode
	mShipNode->attachObject(mShip);

	// lets make it brighter
	mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
}

void TutorialApplication::createFrameListener(void)
{
	mFrameListener = new TutorialFrameListener(mWindow, mCamera, mShipNode);
	mRoot->addFrameListener(mFrameListener);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -