程序开始基本都是一样的。
#include <dtCore/camera.h>
#include <dtCore/globals.h>
#include <dtCore/object.h>
#include <dtCore/transform.h>
#include <dtABC/application.h>
int main()
{
std::string dataPath = dtCore::GetDeltaDataPathList();
dtCore::SetDataFilePathList(dataPath + ";" +
dtCore::GetDeltaRootPath() + "/examples/data" + ";" +
dtCore::GetDeltaRootPath() + "/examples/testApp/;");
dtCore::RefPtr<dtABC::Application> app = new dtABC::Application( "config.xml" );
//load some terrain
dtCore::RefPtr<dtCore::Object> terrain = new dtCore::Object( "Terrain" );
terrain->LoadFile( "models/terrain_simple.ive" );
//terrain->LoadFile( "models/house1.ive" );
app->AddDrawable( terrain.get() );
//load an object
dtCore::RefPtr<dtCore::Object> brdm = new dtCore::Object( "BRDM" );
brdm->LoadFile( "models/brdm.ive" );
app->AddDrawable( brdm.get() );
osg::Vec3 brdmPosition( 0.0f, 0.0f, 3.5f );
osg::Vec3 brdmRotation( 190.0f, 0.0f, 0.0f );
dtCore::Transform trans;
trans.SetTranslation( brdmPosition );
trans.SetRotation( brdmRotation );
brdm->SetTransform( trans );
//adjust the Camera position
dtCore::Transform camPos;
osg::Vec3 camXYZ( 0.f, -30.f, 15.f );
osg::Vec3 lookAtXYZ ( brdmPosition );
osg::Vec3 upVec ( 0.f, 0.f, 1.f );
camPos.SetLookAt( camXYZ, lookAtXYZ, upVec );
app->GetCamera()->SetTransform( camPos );
app->Config();
app->Run();
return 0;
}