|
HelloWorld是所有语言必学的入门程序,特此将代码奉上
#include <dtABC/application.h>
#include <dtCore/refptr.h>
namespace dtCore
{
class Object;
class OrbitMotionModel;
}
class HelloWorld:public dtABC::Application
{
public:
HelloWorld(const std::string &configFileName);
virtual ~HelloWorld();
virtual void Config();
private:
dtCore::RefPtr<dtCore::Object>mText;
dtCore::RefPtr<dtCore::OrbitMotionModel>mOrbitMotionModel;
};
#include "HelloWorld.h"
#include <dtCore/globals.h>
#include <dtCore/scene.h>
#include <dtCore/object.h>
#include <dtCore/transform.h>
#include <dtCore/orbitmotionmodel.h>
#include <osgDB/FileUtils>
using namespace dtCore;
HelloWorld::HelloWorld(const std::string &configFileName):
dtABC::Application(configFileName),
mText(0),
mOrbitMotionModel(0)
{
if(osgDB::findDataFile(configFileName).empty())
GenerateDefaultConfigFile();
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::Config()
{
mText = new dtCore::Object("Text");
mText->LoadFile("Hello.flt");
dtABC:GetScene()->AddDrawable(mText.get());
//////////////////////////////////////////////////////////////////////////
Transform camPos(0.f, -200.0f, 20.0, 0.f, 10.f, 0.f);
GetCamera()->SetTransform(camPos);
mOrbitMotionModel = new dtCore::OrbitMotionModel(GetKeyboard(), GetMouse());
mOrbitMotionModel->SetTarget(GetCamera());
}
int main()
{
dtCore::SetDataFilePathList(".;" + dtCore::GetDeltaDataPathList());
dtCore::RefPtr<HelloWorld>app = new HelloWorld("config.xml");
app->Config();
app->Run();
return 0;
}
本文来自新浪博客,转载请标明出处:http://blog.sina.com.cn/s/blog_613d5bdc0100em00.html |
|