ultimatepp/bazaar/SurfaceCtrl_Demo/main.cpp
xemuth 20702f1a4a SurfaceCtrl_Demo: trying to implement earth with texture
git-svn-id: svn://ultimatepp.org/upp/trunk@14889 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-08-23 22:55:18 +00:00

59 lines
1.5 KiB
C++

#include "SurfaceCtrl_Demo.h"
namespace Upp{
SurfaceCtrl_Demo::SurfaceCtrl_Demo()
{
CtrlLayout(*this, "SurfaceCtrl demo. STL viewer");
filename.SetText( GetFileDirectory(__FILE__) + "Stanford_Bunny_sample.stl" );
butOpen.WhenAction = [&] {
try {
Object3D& obj = canvas.CreateObject();
obj.LoadModel(~filename).AttachTexture(obj.InsertTexture(TM_WATER),0,1).GenerateTextureCoordinate(0,1).Init();
//obj.LoadModel(~filename).Init();
obj.GetTransform().Rotate(90.0f,glm::vec3(1.0f,0.0f,0.0f));
obj.GetTransform().SetScale(glm::vec3(1.0f,1.0f,1.0f));
obj.SetLineWidth(2.0f);
canvas.SetDefaultShader(obj);
canvas.Refresh();
} catch (Exc e) {
Exclamation(DeQtf(e));
}
};
OpenEarth.WhenAction = [&]{
try {
Object3D& obj = canvas.CreateObject();
obj.LoadModel(GetFileDirectory(__FILE__) + "Earth 2K.obj").AttachTexture(obj.InsertTexture(GetFileDirectory(__FILE__) + "Diffuse_2K.png"),0,obj.GetMeshes().GetCount()).Init();
canvas.SetDefaultShader(obj);
canvas.Refresh();
} catch (Exc e) {
Exclamation(DeQtf(e));
}
};
canvas.WhenPaint = [&] {
canvas.DrawAllObjects();
};
Sizeable().Zoomable();
}
void SurfaceCtrl_Demo::Layout(){
canvas.GLResize(GetSize().cx,GetSize().cy);
}
bool SurfaceCtrl_Demo::Key(dword key, int count){
return canvas.Key(key,count);
}
}
GUI_APP_MAIN
{
Upp::StdLogSetup( Upp::LOG_COUT | Upp::LOG_FILE);
Upp::SurfaceCtrl_Demo().Run();
}