也许有人可以找到我的问题的答案。几个月前,我尝试遵循 OGre3D wiki 中的基本教程 #7 但放弃了,因为我无法解决这个问题。我再次拿起它,我在任何地方都找不到任何帮助。我已经使用了很多很多次的搜索引擎,其中包括精确的短语。
#ifndef __BasicTutorial7_h_
#define __BasicTutorial7_h_
#include "BaseApplication.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#include "../res/resource.h"
#endif
#include <CEGUI/cegui/include/CEGUI.h>
#include <CEGUI/cegui/include/RendererModules/Ogre/CEGUIOgreRenderer.h>
class BasicTutorial7 : public BaseApplication
{
public:
BasicTutorial7(void);
virtual ~BasicTutorial7(void);
protected:
CEGUI::OgreRenderer* mRenderer;
virtual void createScene(void);
virtual void createFrameListener(void);
// Ogre::FrameListener
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
// OIS::KeyListener
virtual bool keyPressed( const OIS::KeyEvent &arg );
virtual bool keyReleased( const OIS::KeyEvent &arg );
// OIS::MouseListener
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 quit(const CEGUI::EventArgs &e);
};
#endif // #ifndef __BasicTutorial7_h_
#include "BasicTutorial7.h"
CEGUI::MouseButton convertButton(OIS::MouseButtonID buttonID)
{
switch (buttonID)
{
case OIS::MB_Left:
return CEGUI::LeftButton;
case OIS::MB_Right:
return CEGUI::RightButton;
case OIS::MB_Middle:
return CEGUI::MiddleButton;
default:
return CEGUI::LeftButton;
}
}
//-------------------------------------------------------------------------------------
BasicTutorial7::BasicTutorial7(void)
{
}
//-------------------------------------------------------------------------------------
BasicTutorial7::~BasicTutorial7(void)
{
}
//-------------------------------------------------------------------------------------
void BasicTutorial7::createScene(void)
{
mRenderer = &CEGUI::OgreRenderer::bootstrapSystem(); //Fire up CEGUI.
/* The code in this comment block I added after following another small tutorial on cegui's wiki. All it gave me was a access violation exception no matter what path I specified. If you wish to get the error I'm getting, remove this code or keep it commented when you copy & paste into your compiler for testing.
CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
(CEGUI::System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory("schemes", "C:/Users/t/Documents/Visual Studio 2010/OgreSDK/include/CEGUI/datafiles/schemes/");
rp->setResourceGroupDirectory("imagesets", "C:/Users/t/Documents/Visual Studio 2010/OgreSDK/include/CEGUI/datafiles");
rp->setResourceGroupDirectory("fonts", "C:/Users/t/Documents/Visual Studio 2010/OgreSDK/include/CEGUI/datafiles");
rp->setResourceGroupDirectory("layouts", "C:/Users/t/Documents/Visual Studio 2010/OgreSDK/include/CEGUI/datafiles");
rp->setResourceGroupDirectory("looknfeels", "C:/Users/t/Documents/Visual Studio 2010/OgreSDK/include/CEGUI/datafiles");
rp->setResourceGroupDirectory("lua_scripts", "C:/Users/t/Documents/Visual Studio 2010/OgreSDK/include/CEGUI/datafiles");
*/
CEGUI::Imageset::setDefaultResourceGroup("imageset"); //Add the resource groups.
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeel");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::SchemeManager::getSingleton().create("TaharezLook.Scheme"); //Set the skin for CEGUI.
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow"); //Set the mouse cursor skin. First parameter specifies the resource group, the second the actual Image.
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window *sheet = wmgr.createWindow("DefaultWindow", "CEGUIDemo/Sheet");
CEGUI::Window *quit = wmgr.createWindow("TaharezLook/Button", "CEGUIDemo/QuitButton" );
quit->setText("Quit");
quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05,0) ) );
sheet->addChildWindow(quit);
CEGUI::System::getSingleton().setGUISheet(sheet);
quit->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BasicTutorial7::quit, this ) );
mSceneMgr->setAmbientLight(Ogre::ColourValue(1, 1, 1));
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, 0, -300));
headNode->attachObject(ogreHead);
Ogre::TexturePtr tex = mRoot->getTextureManager()->createManual(
"RTT",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
512,
512,
0,
Ogre::PF_R8G8B8,
Ogre::TU_RENDERTARGET);
Ogre::RenderTexture *rtex = tex->getBuffer()->getRenderTarget();
Ogre::Camera *cam = mSceneMgr->createCamera("RTTCam");
cam->setPosition(100, -100, -400);
cam->lookAt(0, 0, -300);
Ogre::Viewport *v = rtex->addViewport(cam);
v->setOverlaysEnabled(false);
v->setClearEveryFrame(true);
v->setBackgroundColour(Ogre::ColourValue::Black);
CEGUI::Texture &guiTex = mRenderer->createTexture(tex);
CEGUI::Imageset &imageSet =
CEGUI::ImagesetManager::getSingleton().create("RTTImageset", guiTex);
imageSet.defineImage("RTTImage",
CEGUI::Point(0.0f, 0.0f),
CEGUI::Size(guiTex.getSize().d_width,
guiTex.getSize().d_height),
CEGUI::Point(0.0f, 0.0f));
CEGUI::Window *si = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "RTTWindow");
si->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.04f,0) ) );
si->setPosition(CEGUI::UVector2( CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.0f,0) ) );
si->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imageSet.getImage("RTTImage")));
sheet->addChildWindow(si);
}
//-------------------------------------------------------------------------------------
void BasicTutorial7::createFrameListener(void)
{
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem( pl );
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);
//Set initial mouse clipping size
windowResized(mWindow);
//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
mRoot->addFrameListener(this);
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
return false;
if(mShutDown)
return false;
//Need to capture/update each device
mKeyboard->capture();
mMouse->capture();
//Need to inject timestamps to CEGUI System.
CEGUI::System::getSingleton().injectTimePulse(evt.timeSinceLastFrame);
return true;
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::keyPressed( const OIS::KeyEvent &arg )
{
CEGUI::System &sys = CEGUI::System::getSingleton();
sys.injectKeyDown(arg.key);
sys.injectChar(arg.text);
return true;
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::keyReleased( const OIS::KeyEvent &arg )
{
CEGUI::System::getSingleton().injectKeyUp(arg.key);
return true;
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::mouseMoved( const OIS::MouseEvent &arg )
{
CEGUI::System &sys = CEGUI::System::getSingleton();
sys.injectMouseMove(arg.state.X.rel, arg.state.Y.rel);
// Scroll wheel.
if (arg.state.Z.rel)
sys.injectMouseWheelChange(arg.state.Z.rel / 120.0f);
return true;
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id));
return true;
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
CEGUI::System::getSingleton().injectMouseButtonUp(convertButton(id));
return true;
}
//-------------------------------------------------------------------------------------
bool BasicTutorial7::quit(const CEGUI::EventArgs &e)
{
mShutDown = true;
return true;
}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus
extern "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
BasicTutorial7 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
我正在使用的教程:基本教程 7
当我运行 Ogre 时,我得到这个错误:
“OGRE_EXCEPTION(5:ItemIdentityException):在 ResourceGroupManager::openResource 中找不到名为“schemes”的资源组,位于 ..\OgreMain\src\OgreResourceGroupMananger.cpp(第 688 行)。