TDME2  1.9.200
EnvMapEditorTabView.cpp
Go to the documentation of this file.
2 
3 #include <memory>
4 #include <string>
5 
6 #include <tdme/tdme.h>
13 #include <tdme/engine/Camera.h>
14 #include <tdme/engine/Engine.h>
16 #include <tdme/engine/Light.h>
17 #include <tdme/engine/Object.h>
19 #include <tdme/engine/Timing.h>
24 #include <tdme/utilities/Console.h>
26 
27 using std::make_unique;
28 using std::string;
29 using std::unique_ptr;
30 
32 
51 
52 EnvMapEditorTabView::EnvMapEditorTabView(EditorView* editorView, const string& tabId, Scene* scene, Prototype* prototype)
53 {
54  this->editorView = editorView;
55  this->tabId = tabId;
56  this->popUps = editorView->getPopUps();
57  this->scene = unique_ptr<Scene>(scene);
58  this->prototype = unique_ptr<Prototype>(prototype);
59  engine = unique_ptr<Engine>(Engine::createOffScreenInstance(512, 512, true, true, true));
60  engine->setSceneColor(Color4(39.0f / 255.0f, 39.0f / 255.0f, 39.0f / 255.0f, 1.0f));
61  engine->setSkyShaderEnabled(true);
62 }
63 
65 }
66 
68 {
69 }
70 
72 {
73  envMapEditorTabController->updateInfoText(MutableString(engine->getTiming()->getAvarageFPS()).append(" FPS"));
74  engine->display();
75 }
76 
78 {
79  try {
80  envMapEditorTabController = make_unique<EnvMapEditorTabController>(this);
82  } catch (Exception& exception) {
83  Console::println("EnvMapEditorTabView::initialize(): An error occurred: " + string(exception.what()));
84  }
85  // TODO: load settings
86  // TODO: reloadTabOutliner
87  // environment mapping
88  auto environmentMapping = new EnvironmentMapping("sky_environment_mapping", Engine::getEnvironmentMappingWidth(), Engine::getEnvironmentMappingHeight(), BoundingBox(Vector3(-30.0f, 0.0f, -30.0f), Vector3(30.0f, 60.0f, -30.0f)));
89  environmentMapping->setFrustumCulling(false);
90  environmentMapping->setTranslation(Vector3(64.0f, -5.0f, 73.0f));
91  environmentMapping->setTimeRenderUpdateFrequency(prototype->getEnvironmentMapTimeRenderUpdateFrequency());
92  environmentMapping->setRenderPassMask(prototype->getEnvironmentMapRenderPassMask());
93  environmentMapping->update();
94  engine->addEntity(environmentMapping);
95  // camera
96  auto cam = engine->getCamera();
97  cam->setZNear(0.1f);
98  cam->setZFar(150.0f);
99  cam->setLookFrom(Vector3(81.296799f, 15.020234f, 101.091347f));
100  cam->setLookAt(Vector3(57.434414f, 0.695241f, 67.012329f));
101  // scene
102  SceneConnector::setLights(engine.get(), scene.get());
103  SceneConnector::addScene(engine.get(), scene.get(), false, false, false, false, false);
104 }
105 
107 {
108  engine->reset();
109 }
110 
112 }
113 
115  return engine.get();
116 }
117 
119  envMapEditorTabController->setOutlinerAddDropDownContent();
120  envMapEditorTabController->setOutlinerContent();
123 }
124 
127 }
128 
130  envMapEditorTabController->setOutlinerContent();
132 }
133 
135  auto environmentMapping = dynamic_cast<EnvironmentMapping*>(engine->getEntity("sky_environment_mapping"));
136  return environmentMapping->getTranslation();
137 }
138 
140  auto environmentMapping = dynamic_cast<EnvironmentMapping*>(engine->getEntity("sky_environment_mapping"));
141  environmentMapping->setTranslation(translation);
142  environmentMapping->update();
143 }
144 
146  auto environmentMapping = dynamic_cast<EnvironmentMapping*>(engine->getEntity("sky_environment_mapping"));
147  return environmentMapping->getRenderPassMask();
148 }
149 
151  auto environmentMapping = dynamic_cast<EnvironmentMapping*>(engine->getEntity("sky_environment_mapping"));
152  environmentMapping->setRenderPassMask(renderPassMask);
153 }
154 
156  auto environmentMapping = dynamic_cast<EnvironmentMapping*>(engine->getEntity("sky_environment_mapping"));
157  return environmentMapping->getTimeRenderUpdateFrequency();
158 }
159 
161  auto environmentMapping = dynamic_cast<EnvironmentMapping*>(engine->getEntity("sky_environment_mapping"));
162  environmentMapping->setTimeRenderUpdateFrequency(frequency);
163 }
164 
165 void EnvMapEditorTabView::saveFile(const string& pathName, const string& fileName) {
166  PrototypeWriter::write(pathName, fileName, prototype.get());
167 }
Color 4 definition class.
Definition: Color4.h:18
Engine main class.
Definition: Engine.h:131
Environment mapping entity.
const Vector3 & getTranslation() const override
void setTranslation(const Vector3 &translation) override
Set translation.
void setRenderPassMask(int32_t renderPassMask)
Set up render pass mask.
void setTimeRenderUpdateFrequency(int64_t frequency)
Set up render update time frequency.
Light representation.
Definition: Light.h:33
Object to be used with engine class.
Definition: Object.h:60
Scene engine/physics connector.
Timing class.
Definition: Timing.h:16
Represents a material.
Definition: Material.h:23
Represents specular material properties.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
Prototype definition.
Definition: Prototype.h:55
Scene definition.
Definition: Scene.h:50
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
void restoreOutlinerState(const TabView::OutlinerState &outlinerState)
Restore outliner state.
void storeOutlinerState(TabView::OutlinerState &outlinerState)
Store outliner state.
void saveFile(const string &pathName, const string &fileName)
Saving prototype as tenvmap prototype.
void handleInputEvents() override
Handle input events that have not yet been processed.
void setEnvironmentMapTranslation(const Vector3 &translation)
Set environment map translation.
unique_ptr< EnvMapEditorTabController > envMapEditorTabController
void setEnvironmentMapRenderPassMask(int32_t renderPassMask)
Set environment map render passes.
void setEnvironmentMapFrequency(int64_t frequency)
Set environment map frequency.
EditorScreenController * getScreenController()
Definition: EditorView.h:69
Console class.
Definition: Console.h:29
Mutable utf8 aware string class.
Definition: MutableString.h:23
MutableString & append(char c)
Append character.
std::exception Exception
Exception base class.
Definition: Exception.h:18