代码如下:
1 #include <cstdlib>
2 #include <iostream>
3 #include <GEngine/Main.hpp>
4
5 using namespace std;
6
7 core::RefPtr<core::Image> skyimage[1];
8 core::RefPtr<core::Texture> skytexture[1];
9 core::RefPtr<core::Image> terrainimage[2];
10 core::RefPtr<core::Texture> terraintexture[2];
11
12 int main(int argc, char *argv[])
13 {
14 core::Device* device = core::InitDevice("盖莫引擎场景测试");
15
16 //! 获取资源管理器
17 core::ResourceManager *resourcemanager = device->GetResourceManager();
18
19 //! 获取场景管理器
20 core::RefPtr<core::SceneManager> scenemanager = core::SceneManager::GetSceneManager();
21
22 //! 获取新的摄像机并设置为活动摄像机
23 core::RefPtr<core::Camera> camera = scenemanager->CreateCamera("mycamera",
24 Vector3f(500,20,400),
25 Vector3f(503,20,400),
26 Vector3f(0,1,0));
27
28 //! 设置当前活动摄像机
29 scenemanager->SetActiveCamera(camera);
30
31 //! 获取天空顶图形和纹理
32 skyimage[0] = resourcemanager->GetImage("sky_image","..\\image//sky//top.jpg");
33 skytexture[0] = resourcemanager->GetTexture("sky_texture",skyimage[0]);
34 core::RefPtr<core::SkyDome> skydome = scenemanager->GetSkyDome(250,3,3,skytexture[0]);
35 skydome->SetRotationStep(0.03f);
36
37 //! 设置地形数据
38 terrainimage[0] = resourcemanager->GetImage("terrain_image","..\\terrain//terrain.bmp");
39 terrainimage[1] = resourcemanager->GetImage("terrain_detail","..\\terrain//detail.bmp");
40 terraintexture[0] = resourcemanager->GetTexture("terrain_texture1",terrainimage[0]);
41 terraintexture[1] = resourcemanager->GetTexture("terrain_texture2",terrainimage[1]);
42
43 ASSERT(terrainimage[0] || terrainimage[1]);
44 core::RefPtr<core::Terrain> terrain = scenemanager->GetTerrain("terrain1");
45 bool flag = terrain->Load("..\\terrain//terrain2.raw",1024);
46 terrain->SetStepSize(16);
47 terrain->SetTexture(terraintexture[1],terraintexture[0]);
48
49 //! 设置摄像机数据
50 camera->SetViewport(0,0,640,480);
51 camera->SetPerspective(45,640.0f/480.0f,0.1f,1000);
52
53 //! 获取输入系统指针
54 core::Input* input = device->GetInput();
55
56 //! 获取雾指针
57 core::RefPtr<core::Fog> fog = scenemanager->GetFog();
58 fog->SetColor(core::Color(0.3f,0.3f,0.2f));
59 fog->SetDensity(0.001f);
60 fog->SetQuality(0.003f);
61 fog->SetBound(0.1f,1000.0f);
62 fog->Render();
63
64 BEGIN_LOOP(device)
65 camera->SetPerspective(45,640.0f/480.0f,0.1f,1000);
66 camera->Render();
67 skydome->Render();
68 terrain->Render();
69 END_LOOP(device)
70
71 terrain->Deinit();
72
73 device->Close();
74 device->Drop();
75
76 system("PAUSE");
77 return EXIT_SUCCESS;
78 }
79
80
下面的是贴图
如果对盖莫引擎感兴趣,可通过邮件和我联系:ccsdu2009@sohu.com