|
|

楼主 |
发表于 2008-3-16 22:22:00
|
显示全部楼层
Re:我用OGRE自带的例子程序Demo_Ocean的框架结构,加不了地面
#pragma once
#ifndef _MyOgreDemo_H_
#define _MyOgreDemo_H_
#include "OgreCEGUIResourceProvider.h"
#include "CEGUI/CEGUI.h"
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"
#include "ExampleApplication.h"
#include "OgreConfigFile.h"
#include "OgreStringConverter.h"
#include "OgreException.h"
#include "OgreFrameListener.h"
#include "Ogre.h"
#include "CEGUI/CEGUIForwardRefs.h"
#include "OgreString.h"
#include "ExampleLoadingBar.h"
#include <OIS/OIS.h>
#include <cstdlib>
#define UVECTOR2(x, y) UVector2(cegui_reldim(x), cegui_reldim(y))//窗口点换算
//---------------------------------------------------------------------------
enum MovementType
{
mv_CAMERA, //移动相机,
mv_MODEL, //移动模型,
mv_LIGHT //移动光
};
class MyOgreDemo;
//public ExampleFrameListener, public OIS::MouseListener, public OIS::KeyListener
class MyOgreDemo_FrameListener : public Ogre::FrameListener, public OIS::MouseListener, public OIS::KeyListener//public Ogre::FrameListener, public OIS::KeyListener,public OIS::MouseListener
{
//速度定义
#define MINSPEED .150f
#define MOVESPEED 30
#define MAXSPEED 1.800f
protected:
MyOgreDemo* mMain;
OIS::Mouse *mMouse;
OIS::Keyboard *mKeyboard;
OIS::InputManager* mInputManager;
CEGUI::Renderer* mGuiRenderer;
CEGUI::Window* mGuiCurr;
CEGUI::Window *mExit;
float mAvgFrameTime;//平均每帧用的时间
Ogre::Vector3 mTranslateVector;//移动的向量
bool mMoveFwd;//前移
bool mMoveBck;//后移
bool mMoveLeft;//左移
bool mMoveRight;//右移
bool mLMBDown;//鼠标左键按下
bool mRMBDown;//鼠标右键按下
CEGUI: oint mLastMousePosition;//鼠标的位置
bool mLastMousePositionSet;//处理鼠标位置设置
float mRotX;//旋转X轴
float mRotY;//旋转Y轴
//float mRotScale ;//旋转速度
bool mProcessMovement;//是键盘引起的移动否
bool mUpdateMovement;//是鼠标引起的移动否
std::string mDebugText;
CEGUI::MouseButton convertOISButtonToCegui(int ois_button_id);
void CheckMovementKeys( CEGUI::Key::Scan keycode, bool state );//检测键盘是否被按下
void updateStats(void);
bool mQuit;
public:
MyOgreDemo_FrameListener(MyOgreDemo* main);
virtual ~MyOgreDemo_FrameListener();
bool frameStarted(const Ogre::FrameEvent& evt);
bool Exit(const CEGUI::EventArgs &e)
{
mQuit = true;
return true;
}
virtual bool keyPressed ( const OIS::KeyEvent &arg );
virtual bool keyReleased ( const OIS::KeyEvent &arg );
virtual bool mouseMoved ( const OIS::MouseEvent &arg );
virtual bool mousePressed ( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
virtual bool mouseReleased ( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
bool handleKeyDownEvent(const CEGUI::EventArgs& e);//键盘按键按下但未弹起事件
bool handleKeyUpEvent(const CEGUI::EventArgs& e);//键盘按键按下后已经弹起事件
bool handleMouseMove(const CEGUI::EventArgs& e);//鼠标移动事件
bool handleMouseButtonUp(const CEGUI::EventArgs& e);//鼠标按下后已经弹起事件
bool handleMouseButtonDown(const CEGUI::EventArgs& e);//鼠标按下但未弹起事件
bool handleMouseWheelEvent(const CEGUI::EventArgs& e);//鼠标滚轮移动事件
MovementType mMouseMovement;//键盘控制的移动物体类型
MovementType getMouseMovement(void) const { return mMouseMovement; }
};
class MyOgreDemo
{
public:
MyOgreDemo(void);
~MyOgreDemo(void);
void go(void);
Ogre::Camera* getCamera(void) const { return mCamera; }
Ogre::SceneManager* getSceneManager(void) const { return mSceneMgr; }
Ogre::RenderWindow* getRenderWindow(void) const { return mWindow; }
protected:
Ogre::Root* mRoot;
Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
// the scene node of the entity
Ogre::SceneNode* mMainNode;
ExampleLoadingBar mLoadingBar;
MyOgreDemo_FrameListener* mFrameListener;
Ogre::RenderWindow* mWindow;
CEGUI::OgreCEGUIRenderer* mGUIRenderer;
CEGUI::System* mGUISystem;
// These internal methods package up the stages in the startup process
//以下这些内在的函数方法包含了在初始化过程中不同时期的状态。
//setup函数初始化程序
bool setup(void);
/** 配置程序的环境. */
bool configure(void);
void chooseSceneManager(void);
void createCamera(void);
void createViewports(void);
/// Method which will define the source of resources (other than current folder)
//定位资源的出处(不仅仅是当前目录)
void setupResources(void);
void loadResources(void);
bool setupGUI(void);
void createScene(void);
void createFrameListener(void);
void initDemoEventWiring(void);//注册事件响应函数
};
#endif // end _MyOgreDemo_H_ |
|