PeriDyno 1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RenderWindow.cpp
Go to the documentation of this file.
1#include "RenderWindow.h"
2
3#include "OrbitCamera.h"
4#include "TrackballCamera.h"
5
6#include <iostream>
7#include <sstream>
8
10{
11 // create a default camera
12 mCamera = std::make_shared<OrbitCamera>();
13 mCamera->setWidth(64);
14 mCamera->setHeight(64);
15 mCamera->registerPoint(0, 0);
16 mCamera->rotateToPoint(-32, 12);
17}
18
20{
21 mCamera->setWidth(w);
22 mCamera->setHeight(h);
23}
24
29
30void dyno::RenderWindow::saveScreen(unsigned int frame)
31{
32 if (frame % mSaveScreenInterval == 0)
33 {
34 std::stringstream adaptor;
35 adaptor << frame / mSaveScreenInterval;
36 std::string index_str;
37 adaptor >> index_str;
38 std::string file_name = mScreenRecordingPath + std::string("screen_capture_") + index_str + std::string(".bmp");
39
40 this->onSaveScreen(file_name);
41 }
42}
43
45{
46 mRenderParams.light.mainLightDirection = -dir;
47}
48
49const dyno::Selection& dyno::RenderWindow::select(int x, int y, int w, int h)
50{
51 selectedObject = mRenderEngine->select(x, y, w, h);
52
53 if (selectedObject.items.size() > 0)
55
56 return selectedObject;
57}
58
59void dyno::RenderWindow::select(std::shared_ptr<Node> node, int instance, int primitive)
60{
62 selectedObject.items.push_back({ node, instance, primitive});
63}
64
65std::shared_ptr<dyno::Node> dyno::RenderWindow::getCurrentSelectedNode()
66{
67 if(selectedObject.items.empty())
68 return 0;
69
70 return selectedObject.items[0].node;
71}
72
74{
75 printf("Select: (%d, %d), %d x %d, %u items\n", s.x, s.y, s.w, s.h, s.items.size());
76}
void saveScreen(unsigned int frame)
std::string mScreenRecordingPath
Selection selectedObject
virtual void onSaveScreen(const std::string &filename)
std::shared_ptr< Camera > mCamera
virtual void onSelected(const Selection &s)
RenderParams mRenderParams
std::shared_ptr< RenderEngine > mRenderEngine
virtual const Selection & select(int x, int y, int w, int h)
void setMainLightDirection(glm::vec3 dir)
virtual std::shared_ptr< Node > getCurrentSelectedNode()
virtual void setWindowSize(int w, int h)
std::vector< Item > items