第四章 Frame Listeners and Unbuffered Input
来源:互联网 发布:照片找人软件 编辑:程序博客网 时间:2024/06/06 15:47
BasicTutorial4.h
#include "BaseApplication.h"class BasicTutorial4:public BaseApplication{public:BasicTutorial4(void);virtual ~BasicTutorial4(void);protected:virtual void createScene(void);virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);private:bool processUnbufferInput(const Ogre::FrameEvent& evt);};
BasicTutorial4.cpp
#include "BasicTutorial4.h"BasicTutorial4::BasicTutorial4(void){}BasicTutorial4::~BasicTutorial4(void){}void BasicTutorial4::createScene(void){mSceneMgr->setAmbientLight(Ogre::ColourValue(0.25,0.25,0.25));Ogre::Entity* ninjaEntity=mSceneMgr->createEntity("Ninja","ninja.mesh");Ogre::SceneNode* node=mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode");node->attachObject(ninjaEntity);Ogre::Light* pointLight=mSceneMgr->createLight("pointLight");pointLight->setType(Ogre::Light::LT_POINT);pointLight->setPosition(Ogre::Vector3(250,150,250));pointLight->setDiffuseColour(Ogre::ColourValue::White);pointLight->setSpecularColour(Ogre::ColourValue::White);}bool BasicTutorial4::processUnbufferInput(const Ogre::FrameEvent& evt){static bool mMouseDown = false;static Ogre::Real mToggle=0.0;static Ogre::Real mRotate=0.13;static Ogre::Real mMove=20;bool currMouse=mMouse->getMouseState().buttonDown(OIS::MB_Left);if(currMouse && ! mMouseDown){Ogre::Light* light=mSceneMgr->getLight("pointLight");light->setVisible(!light->isVisible());}mMouseDown = currMouse;mToggle-=evt.timeSinceLastFrame;if((mToggle<0.0f) && mKeyboard->isKeyDown(OIS::KC_1)){mToggle=0.5f;Ogre::Light* light=mSceneMgr->getLight("pointLight");light->setVisible(!light->isVisible());}Ogre::Vector3 transVector= Ogre::Vector3::ZERO;if(mKeyboard->isKeyDown(OIS::KC_I)){transVector.z -= mMove;}if(mKeyboard->isKeyDown(OIS::KC_K)){transVector.z+=mMove;}if(mKeyboard->isKeyDown(OIS::KC_J)){if(mKeyboard->isKeyDown(OIS::KC_LSHIFT)){mSceneMgr->getSceneNode("NinjaNode")->yaw(Ogre::Degree(mRotate*5));}else{transVector.x-=mMove;}}if(mKeyboard->isKeyDown(OIS::KC_L)){if(mKeyboard->isKeyDown(OIS::KC_LSHIFT)){mSceneMgr->getSceneNode("NinjaNode")->yaw(Ogre::Degree(-mRotate*5));}else{transVector.x+=mMove;}}if(mKeyboard->isKeyDown(OIS::KC_U)){transVector.y+=mMove;}if(mKeyboard->isKeyDown(OIS::KC_O)){transVector.y-=mMove;}mSceneMgr->getSceneNode("NinjaNode")->translate(transVector*evt.timeSinceLastFrame,Ogre::Node::TS_LOCAL);//since we are trying to make the ninja go forward when we press I, we need it to go in the direction that the node is actually facing, so we use the local transformation space./*There is another way we can do this (though it is less direct). We could have gotten the orientation of the node, a quaternion, and multiplied this by the direction vector toget the same result. This would be perfectly valid:mSceneMgr->getSceneNode("NinjaNode")->translate(mSceneMgr->getSceneNode("NinjaNode")->getOrientation() * transVector * evt.timeSinceLastFrame, Ogre::Node::TS_WORLD);*/return true;}bool BasicTutorial4::frameRenderingQueued(const Ogre::FrameEvent& evt){bool ret=BaseApplication::frameRenderingQueued(evt);if(!processUnbufferInput(evt))return false;return ret;}#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32#define WIN32_LEAN_AND_MEAN#include "windows.h"#endif #ifdef __cplusplusextern "C" {#endif #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )#else int main(int argc, char *argv[])#endif { // Create application object BasicTutorial4 app; try { app.go(); } catch( Ogre::Exception& e ) {#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);#else std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl;#endif } return 0; } #ifdef __cplusplus}#endif
- 第四章 Frame Listeners and Unbuffered Input
- OGRE基础教程四 Frame Listeners and Unbuffered Input
- Mogre学习系列(4)Frame Listeners 和Windows.Forms Input
- 9.user input and frame listener
- iOS编程第四版第七章---Delegation and Text Input
- Location managers, providers, and listeners
- Servlet Filters and Event Listeners
- 第四章 A Frame with a View
- listeners
- How to: Create and Initialize Trace Listeners
- Unbuffered low-level IO and Buffered high-level IO
- 【recommend】Tracing in .NET and Implementing Your Own Trace Listeners
- Words and Their Stories: Some of Our Listeners' Favorite Sayings
- How to use SCAN and node listeners with different ports?
- 23.5 Application events and listeners Application 的事件监听器
- frameset and frame , 连接
- Emacs Frame and buffer
- JavaScript -- Frame and window
- 关键字typedef
- 修改了下exeScope的导出函数功能,让它只导出函数名。。。
- Matlab中下标,斜体,符号及希腊字母的使用方法
- AsyncTask的缺陷
- 预编译头的作用
- 第四章 Frame Listeners and Unbuffered Input
- DOCSIS config file-Configuration-File-Specific Settings
- CM Address Acquisition, Filtering and Forwarding Rules
- DOCSIS config file-Configuration File and Registration Settings
- 硬盘检测修复工具
- 解决Boost.Regex对中文支持不好的问题
- 程序人生--2009年(55)
- 回复网友提问:云计算,大数据,数据库,数据仓库之间是什么关系
- socket