这是使用盖莫游戏引擎(2.1.1)设计的天空顶小例
天空顶比较类似天空面
具体代码和图片如下:
#include <GEngine/Gaimo.hpp>
using namespace std;
using namespace core;
int Main()
{
//! 初始化引擎设备并得到设备指针
RefPtr<Device> device = InitDevice("天空顶测试");
//! 得到引擎场景指针
RefPtr<SceneManager> scenemanager = device->GetSceneManager();
//! 得到引擎资源指针
RefPtr<ResourceManager> resourcemanager = device->GetResourceManager();
//! 获取图形管理器指针
RefPtr<ImageManager> imagemanager = resourcemanager->GetImageManager();
//! 得到视频驱动器指针
RefPtr<VideoDriver> videodriver = device->GetVideoDriver();
//! 得到天空图形和纹理
RefPtr<Image> image = imagemanager->CreateObject("sky","..\\image\\sky\\top.jpg");
RefPtr<Texture> texture = resourcemanager->GetTextureManager()->CreateTexture("sky",image);
//! 得到天空盒指针
SkyDomeDesc desc;
desc.texture = texture;
RefPtr<Renderable> sky = scenemanager->CreateSkyDome(desc);
//! 获取摄像机指针
RefPtr<Camera> camera = scenemanager->GetCameraManager()->CreateCamera("camera",
Vector3f(),
Vector3f(100,60,0));
camera->SetViewPort(Recti(0,0,640,480));
camera->SetPerspective(45.0f,640.0f/480.0f,0.1f,600.0f);
//! 获取雾指针
RefPtr<Fog> fog = resourcemanager->GetFog("..\\script//fog.lua","fog");
fog->Render();
BEGIN_LOOP(device)
videodriver->SetClearBuffer(ENGINE_CLEAR_COLOR | ENGINE_CLEAR_DEPTH);
camera->Render();
sky->Render();
END_LOOP(device)
return 0;
}