(1)主程序界面采用SampleBrowser
包含文件为FileSystemLayerImpl.h,FileSystemLayerImpl.cpp,SampleBrowser.h和SampleBrowser.cpp共四个文件。创建项目的时候选择Windows应用程序。
(2)运行程序根据Ogre自带例子修改,创建的时候选择DLL。
代码如下:
MotionView.h
#ifndef __MotionViewer_H__
#define __MotionViewer_H__
#include "SdkSample.h"
using namespace Ogre;
using namespace OgreBites;
class _OgreSampleClassExport MotionViewer : public SdkSample
{
public:
MotionViewer()
{
mInfo["Title"] = "Motion Viewer";
mInfo["Description"] = "Demonstrates the cube mapping feature where a wrap-around environment is reflected "
"off of an object. Uses render-to-texture to create dynamic cubemaps.";
mInfo["Thumbnail"] = "thumb_cubemap.png";
mInfo["Category"] = "Unsorted";
}
void testCapabilities(const RenderSystemCapabilities* caps)
{
if (!caps->hasCapability(RSC_CUBEMAPPING))
{
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "Your graphics card does not support cube mapping, "
"so you cannot run this sample. Sorry!", "CubeMappingSample::testCapabilities");
}
}
bool frameRenderingQueued(const FrameEvent& evt)
{
return SdkSample::frameRenderingQueued(evt); // don't forget the parent updates!
}
protected:
void setupContent()
{
// setup some basic lighting for our scene
mSceneMgr->setAmbientLight(ColourValue(1.0, 1.0, 1.0));
mSceneMgr->createLight()->setPosition(20, 80, 3000);
// create an ogre head, give it the dynamic cube map material, and place it at the origin
mHead = mSceneMgr->createEntity("MyModel", "ogrehead.mesh");
mSceneMgr->getRootSceneNode()->attachObject(mHead);
// set our camera to orbit around the head and show cursor
mCameraMan->setStyle(CS_ORBIT);
mTrayMgr->showCursor();
}
Entity* mHead;
};
#endif
MotionViewer.cpp
#include "SamplePlugin.h"
#include "MotionViewer.h"
using namespace Ogre;
using namespace OgreBites;
#ifndef OGRE_STATIC_LIB
SamplePlugin* sp;
Sample* s;
extern "C" _OgreSampleExport void dllStartPlugin()
{
s = new MotionViewer;
sp = OGRE_NEW SamplePlugin(s->getInfo()["Title"] + " Sample");
sp->addSample(s);
Root::getSingleton().installPlugin(sp);
}
extern "C" _OgreSampleExport void dllStopPlugin()
{
Root::getSingleton().uninstallPlugin(sp);
OGRE_DELETE sp;
delete s;
}
#endif
(3)修改resources.cfg只包含用到的资源文件
[Essential]
FileSystem=../media/thumbnails
Zip=../media/SdkTrays.zip
[Popular]
FileSystem=../media
(4)dll文件只需保留OgreMain.dll、OIS.dll和RenderSystem_Direct3D9.dll。当然需要修改plugins文件。
(5)lib需要OgreMain.lib、OIS.lib和RenderSystem_Direct3D9.lib以及Boost的libboost_date_time-vc90-mt-1_44.lib、libboost_date_time-vc90-mt-gd-1_44.lib、libboost_thread-vc90-mt-1_44.lib和libboost_thread-vc90-mt-gd-1_44.lib。
(6)包含文件需要OgreSDK中include文件夹中的OGRE和OIS,以及boost_1_44文件夹下的boost文件夹。
(7)media文件夹只需保留SdkTrays.zip,文件夹thumbnails(只需包含一张例子所需图片)和例子加载的ogrehead模型文件。