ultimatepp/bazaar/SurfaceCtrl_Demo/main.cpp
xemuth a2f68f3919 SurfaceCtrl_Demo: removed landscape
git-svn-id: svn://ultimatepp.org/upp/trunk@14922 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-08-27 16:17:51 +00:00

70 lines
1.8 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).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/earth.obj").AttachTexture(obj.InsertTexture(GetFileDirectory(__FILE__) + "earth/earth.png",-1,FLIP_MIRROR_VERT),0,obj.GetMeshes().GetCount()).Init();
obj.GetTransform().Rotate(-180,glm::vec3(1.0f,0.0f,0.0f));
canvas.SetDefaultShader(obj);
canvas.Refresh();
} catch (Exc e) {
Exclamation(DeQtf(e));
}
};
Ultimate.WhenAction = [&]{
try {
Object3D& obj = canvas.CreateObject();
obj.LoadModel(GetFileDirectory(__FILE__) + "ultimate/upp.obj").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();
}