查看: 2046|回复: 0

hello world编写

[复制链接]

该用户从未签到

发表于 2009-7-31 09:11:21 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表