使用Ogre自带UI(SdkTrays)创建应用程序

(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模型文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值