Feature/virtualproperty (#286)

* Add virtual property owner to OpenSpaceEngine

* Ability to add and remove virtual properties

* Do not try to render empty PropertyOwner name
Compile fix for iswaComponent
Add example in default.scene

* Delete virtual properties also in the OpenSpaceEngine dtor

* Make RenderablePlanet not crash if the nighttextures are not present

* - Add VirtualPropertyManager to manage ownership of virtual properties
- Only execute regex when it was necessary
-
This commit is contained in:
Alexander Bock
2017-04-13 14:38:28 -04:00
committed by GitHub
parent 8a617ee254
commit 76aed0578c
18 changed files with 499 additions and 97 deletions
+1
View File
@@ -69,6 +69,7 @@ public:
GuiPropertyComponent _globalProperty;
GuiPropertyComponent _property;
GuiPropertyComponent _screenSpaceProperty;
GuiPropertyComponent _virtualProperty;
GuiTimeComponent _time;
GuiIswaComponent _iswa;
@@ -53,6 +53,7 @@ public:
void setSource(SourceFunction func);
void setVisibility(properties::Property::Visibility visibility);
void setHasRegularProperties(bool hasOnlyRegularProperties);
void render();
@@ -63,6 +64,10 @@ protected:
properties::Property::Visibility _visibility;
SourceFunction _function;
/// This is set to \c true if all properties contained in this GUIPropertyComponent
/// are regular, i.e., not containing wildcards, regex, or groups
/// This variable only has an impact on which \c setPropertyValue function is called
bool _hasOnlyRegularProperties = false;
};
} // namespace gui
+58 -19
View File
@@ -25,32 +25,71 @@
#ifndef __OPENSPACE_MODULE_ONSCREENGUI___RENDERPROPERTIES___H__
#define __OPENSPACE_MODULE_ONSCREENGUI___RENDERPROPERTIES___H__
#include <ghoul/misc/boolean.h>
#include <string>
namespace openspace {
namespace properties {
class Property;
}
} // namespace properties
void executeScript(const std::string& id, const std::string& value);
void renderBoolProperty(properties::Property* prop, const std::string& ownerName);
void renderOptionProperty(properties::Property* prop, const std::string& ownerName);
void renderSelectionProperty(properties::Property* prop, const std::string& ownerName);
void renderStringProperty(properties::Property* prop, const std::string& ownerName);
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName);
void renderIntProperty(properties::Property* prop, const std::string& ownerName);
void renderIVec2Property(properties::Property* prop, const std::string& ownerName);
void renderIVec3Property(properties::Property* prop, const std::string& ownerName);
void renderIVec4Property(properties::Property* prop, const std::string& ownerName);
void renderFloatProperty(properties::Property* prop, const std::string& ownerName);
void renderVec2Property(properties::Property* prop, const std::string& ownerName);
void renderVec3Property(properties::Property* prop, const std::string& ownerName);
void renderVec4Property(properties::Property* prop, const std::string& ownerName);
void renderDVec2Property(properties::Property* prop, const std::string& ownerName);
void renderDVec3Property(properties::Property* prop, const std::string& ownerName);
void renderDVec4Property(properties::Property* prop, const std::string& ownerName);
void renderTriggerProperty(properties::Property* prop, const std::string& ownerName);
using IsRegularProperty = ghoul::Boolean;
void executeScript(const std::string& id, const std::string& value,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderBoolProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderOptionProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderSelectionProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderStringProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderIntProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderIVec2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderIVec3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderIVec4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderFloatProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderVec2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderVec3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderVec4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderDVec2Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderDVec3Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderDVec4Property(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
void renderTriggerProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular = IsRegularProperty::Yes);
} // namespace openspace
+16 -3
View File
@@ -28,6 +28,7 @@
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/settingsengine.h>
#include <openspace/engine/virtualpropertymanager.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/interactionhandler.h>
#include <openspace/rendering/renderengine.h>
@@ -45,7 +46,7 @@ OnScreenGUIModule::OnScreenGUIModule()
: OpenSpaceModule("OnScreenGUI")
{
addPropertySubOwner(gui);
OsEng.registerModuleCallback(
OpenSpaceEngine::CallbackOption::Initialize,
[](){
@@ -66,17 +67,29 @@ OnScreenGUIModule::OnScreenGUIModule()
gui._screenSpaceProperty.setSource(
[]() {
const auto& ssr = OsEng.renderEngine().screenSpaceRenderables();
const std::vector<ScreenSpaceRenderable*>& ssr =
OsEng.renderEngine().screenSpaceRenderables();
return std::vector<properties::PropertyOwner*>(ssr.begin(), ssr.end());
}
);
gui._property.setSource(
[]() {
const auto& nodes = OsEng.renderEngine().scene()->allSceneGraphNodes();
const std::vector<SceneGraphNode*>& nodes =
OsEng.renderEngine().scene()->allSceneGraphNodes();
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
}
);
gui._virtualProperty.setSource(
[]() {
std::vector<properties::PropertyOwner*> res = {
&(OsEng.virtualPropertyManager())
};
return res;
}
);
}
);
+16
View File
@@ -227,6 +227,7 @@ GUI::GUI()
, _globalProperty("Global")
, _property("Properties")
, _screenSpaceProperty("ScreenSpace Properties")
, _virtualProperty("Virtual Properties")
, _currentVisibility(properties::Property::Visibility::All)
{
addPropertySubOwner(_help);
@@ -235,6 +236,7 @@ GUI::GUI()
addPropertySubOwner(_globalProperty);
addPropertySubOwner(_property);
addPropertySubOwner(_screenSpaceProperty);
addPropertySubOwner(_virtualProperty);
addPropertySubOwner(_time);
addPropertySubOwner(_iswa);
}
@@ -312,8 +314,12 @@ void GUI::initialize() {
style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.52f, 0.52f, 0.52f, 1.0f);
_property.initialize();
_property.setHasRegularProperties(true);
_screenSpaceProperty.initialize();
_screenSpaceProperty.setHasRegularProperties(true);
_globalProperty.initialize();
_globalProperty.setHasRegularProperties(true);
_virtualProperty.initialize();
_performance.initialize();
_help.initialize();
_iswa.initialize();
@@ -327,6 +333,7 @@ void GUI::deinitialize() {
_performance.deinitialize();
_globalProperty.deinitialize();
_screenSpaceProperty.deinitialize();
_virtualProperty.deinitialize();
_property.deinitialize();
delete iniFileBuffer;
@@ -465,6 +472,10 @@ void GUI::endFrame() {
_screenSpaceProperty.render();
}
if (_virtualProperty.isEnabled()) {
_virtualProperty.render();
}
if (_help.isEnabled()) {
_help.render();
}
@@ -559,6 +570,10 @@ void GUI::render() {
ImGui::Checkbox("Global Properties", &globalProperty);
_globalProperty.setEnabled(globalProperty);
bool virtualProperty = _virtualProperty.isEnabled();
ImGui::Checkbox("Virtual Properties", &virtualProperty);
_virtualProperty.setEnabled(virtualProperty);
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
bool iswa = _iswa.isEnabled();
ImGui::Checkbox("iSWA", &iswa);
@@ -617,6 +632,7 @@ void GUI::renderAndUpdatePropertyVisibility() {
_globalProperty.setVisibility(_currentVisibility);
_property.setVisibility(_currentVisibility);
_screenSpaceProperty.setVisibility(_currentVisibility);
_virtualProperty.setVisibility(_currentVisibility);
}
+2 -2
View File
@@ -38,8 +38,8 @@
namespace {
using json = nlohmann::json;
const std::string _loggerCat = "iSWAComponent";
}
const ImVec2 size = ImVec2(350, 500);
} // namespace
namespace openspace {
namespace gui {
@@ -69,6 +69,10 @@ void GuiPropertyComponent::setVisibility(properties::Property::Visibility visibi
_visibility = visibility;
}
void GuiPropertyComponent::setHasRegularProperties(bool hasOnlyRegularProperties) {
_hasOnlyRegularProperties = hasOnlyRegularProperties;
}
void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) {
if (owner->propertiesRecursive().empty()) {
return;
@@ -94,7 +98,9 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
}
}
ImGui::Spacing();
if (!subOwners.empty()) {
ImGui::Spacing();
}
using Properties = std::vector<properties::Property*>;
std::map<std::string, Properties> propertiesByGroup;
@@ -119,7 +125,9 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
}
}
ImGui::Spacing();
if (!propertiesByGroup.empty()) {
ImGui::Spacing();
}
for (properties::Property* prop : remainingProperies) {
renderProperty(prop, owner);
@@ -132,8 +140,6 @@ void GuiPropertyComponent::render() {
ImGui::Begin(name().c_str(), &v, size, 0.5f);
_isEnabled = v;
ImGui::Spacing();
if (_function) {
std::vector<properties::PropertyOwner*> owners = _function();
std::sort(
@@ -156,12 +162,16 @@ void GuiPropertyComponent::render() {
// Create a header in case we have multiple owners
return ImGui::CollapsingHeader(pOwner->name().c_str());
}
else {
// Otherwise, do nothing
else if (!pOwner->name().empty()) {
// If the owner has a name, print it first
ImGui::Text(pOwner->name().c_str());
ImGui::Spacing();
return true;
}
else {
// Otherwise, do nothing
return true;
}
};
if (header()) {
@@ -176,7 +186,7 @@ void GuiPropertyComponent::render() {
void GuiPropertyComponent::renderProperty(properties::Property* prop,
properties::PropertyOwner* owner)
{
using Func = std::function<void(properties::Property*, const std::string&)>;
using Func = std::function<void(properties::Property*, const std::string&, IsRegularProperty)>;
static const std::map<std::string, Func> FunctionMapping = {
{ "BoolProperty", &renderBoolProperty },
{ "DoubleProperty", &renderDoubleProperty},
@@ -204,7 +214,20 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop,
if (v >= propV) {
auto it = FunctionMapping.find(prop->className());
if (it != FunctionMapping.end()) {
it->second(prop, owner->name());
if (owner) {
it->second(
prop,
owner->name(),
IsRegularProperty(_hasOnlyRegularProperties)
);
}
else {
it->second(
prop,
"",
IsRegularProperty(_hasOnlyRegularProperties)
);
}
}
}
}
+124 -43
View File
@@ -46,13 +46,33 @@ void renderTooltip(Property* prop) {
}
}
void executeScript(const std::string& id, const std::string& value) {
void executeScriptSingle(const std::string& id, const std::string& value) {
std::string script =
"openspace.setPropertyValueSingle('" + id + "', " + value + ");";
OsEng.scriptEngine().queueScript(script, scripting::ScriptEngine::RemoteScripting::Yes);
}
void renderBoolProperty(Property* prop, const std::string& ownerName) {
void executeScriptGroup(const std::string& id, const std::string& value) {
std::string script =
"openspace.setPropertyValue('" + id + "', " + value + ");";
OsEng.scriptEngine().queueScript(script, scripting::ScriptEngine::RemoteScripting::Yes);
}
void executeScript(const std::string& id, const std::string& value,
IsRegularProperty isRegular)
{
if (isRegular) {
executeScriptSingle(id, value);
}
else {
executeScriptGroup(id, value);
}
}
void renderBoolProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
BoolProperty* p = static_cast<BoolProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -62,12 +82,15 @@ void renderBoolProperty(Property* prop, const std::string& ownerName) {
renderTooltip(prop);
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), value ? "true" : "false");
executeScript(p->fullyQualifiedIdentifier(), value ? "true" : "false", isRegular);
}
ImGui::PopID();
}
void renderOptionProperty(Property* prop, const std::string& ownerName) {
void renderOptionProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
OptionProperty* p = static_cast<OptionProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -94,12 +117,15 @@ void renderOptionProperty(Property* prop, const std::string& ownerName) {
}
}
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
}
ImGui::PopID();
}
void renderSelectionProperty(Property* prop, const std::string& ownerName) {
void renderSelectionProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
SelectionProperty* p = static_cast<SelectionProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -130,14 +156,17 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName) {
parameters += std::to_string(i) + ",";
}
parameters += "}";
executeScript(p->fullyQualifiedIdentifier(), parameters);
executeScript(p->fullyQualifiedIdentifier(), parameters, isRegular);
}
ImGui::TreePop();
}
ImGui::PopID();
}
void renderStringProperty(Property* prop, const std::string& ownerName) {
void renderStringProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
StringProperty* p = static_cast<StringProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -161,13 +190,20 @@ void renderStringProperty(Property* prop, const std::string& ownerName) {
if (hasNewValue) {
executeScript(p->fullyQualifiedIdentifier(), "'" + std::string(buffer) + "'");
executeScript(
p->fullyQualifiedIdentifier(),
"'" + std::string(buffer) + "'",
isRegular
);
}
ImGui::PopID();
}
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName) {
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
DoubleProperty* p = static_cast<DoubleProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -180,13 +216,16 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa
renderTooltip(prop);
if (value != static_cast<float>(p->value())) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
}
ImGui::PopID();
}
void renderIntProperty(Property* prop, const std::string& ownerName) {
void renderIntProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
IntProperty* p = static_cast<IntProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -199,13 +238,16 @@ void renderIntProperty(Property* prop, const std::string& ownerName) {
renderTooltip(prop);
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
}
ImGui::PopID();
}
void renderIVec2Property(Property* prop, const std::string& ownerName) {
void renderIVec2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
IVec2Property* p = static_cast<IVec2Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -224,14 +266,18 @@ void renderIVec2Property(Property* prop, const std::string& ownerName) {
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}"
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderIVec3Property(Property* prop, const std::string& ownerName) {
void renderIVec3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
IVec3Property* p = static_cast<IVec3Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -252,13 +298,17 @@ void renderIVec3Property(Property* prop, const std::string& ownerName) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "," +
std::to_string(value.z) + "}"
std::to_string(value.z) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderIVec4Property(Property* prop, const std::string& ownerName) {
void renderIVec4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
IVec4Property* p = static_cast<IVec4Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -283,15 +333,19 @@ void renderIVec4Property(Property* prop, const std::string& ownerName) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}"
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderFloatProperty(Property* prop, const std::string& ownerName) {
void renderFloatProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
FloatProperty* p = static_cast<FloatProperty*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -303,13 +357,16 @@ void renderFloatProperty(Property* prop, const std::string& ownerName) {
renderTooltip(prop);
if (value != p->value()) {
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular);
}
ImGui::PopID();
}
void renderVec2Property(Property* prop, const std::string& ownerName) {
void renderVec2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
Vec2Property* p = static_cast<Vec2Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -329,14 +386,18 @@ void renderVec2Property(Property* prop, const std::string& ownerName) {
if (value != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}"
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderVec3Property(Property* prop, const std::string& ownerName) {
void renderVec3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
Vec3Property* p = static_cast<Vec3Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -359,15 +420,19 @@ void renderVec3Property(Property* prop, const std::string& ownerName) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "}"
std::to_string(value.y) + "," +
std::to_string(value.z) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderVec4Property(Property* prop, const std::string& ownerName) {
void renderVec4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
Vec4Property* p = static_cast<Vec4Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -391,16 +456,20 @@ void renderVec4Property(Property* prop, const std::string& ownerName) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}"
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderDVec2Property(Property* prop, const std::string& ownerName) {
void renderDVec2Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
DVec2Property* p = static_cast<DVec2Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -420,14 +489,18 @@ void renderDVec2Property(Property* prop, const std::string& ownerName) {
if (glm::dvec2(value) != p->value()) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}"
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderDVec3Property(Property* prop, const std::string& ownerName) {
void renderDVec3Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
DVec3Property* p = static_cast<DVec3Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -453,15 +526,19 @@ void renderDVec3Property(Property* prop, const std::string& ownerName) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "}"
std::to_string(value.y) + "," +
std::to_string(value.z) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderDVec4Property(Property* prop, const std::string& ownerName) {
void renderDVec4Property(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
DVec4Property* p = static_cast<DVec4Property*>(prop);
std::string name = p->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
@@ -491,22 +568,26 @@ void renderDVec4Property(Property* prop, const std::string& ownerName) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}"
std::to_string(value.y) + "," +
std::to_string(value.z) + "," +
std::to_string(value.w) + "}",
isRegular
);
}
ImGui::PopID();
}
void renderTriggerProperty(Property* prop, const std::string& ownerName) {
void renderTriggerProperty(Property* prop, const std::string& ownerName,
IsRegularProperty isRegular)
{
ghoul_assert(prop, "prop must not be nullptr");
std::string name = prop->guiName();
ImGui::PushID((ownerName + "." + name).c_str());
bool pressed = ImGui::Button(name.c_str());
if (pressed) {
executeScript(prop->fullyQualifiedIdentifier(), "nil");
executeScript(prop->fullyQualifiedIdentifier(), "nil", isRegular);
}
renderTooltip(prop);
+5 -12
View File
@@ -292,16 +292,7 @@ bool RenderablePlanet::initialize() {
LERROR(ss.str());
}
loadTexture();
while ((err = glGetError()) != GL_NO_ERROR) {
const GLubyte * errString = gluErrorString(err);
std::stringstream ss;
ss << "Error loading textures. OpenGL error: " << errString << std::endl;
LERROR(ss.str());
}
_geometry->initialize(this);
_geometry->initialize(this);
_programObject->deactivate();
@@ -309,6 +300,8 @@ bool RenderablePlanet::initialize() {
const GLubyte * errString = gluErrorString(err);
LERROR("Shader Programs Creation. OpenGL error: " << errString);
}
loadTexture();
return isReady();
}
@@ -394,13 +387,13 @@ void RenderablePlanet::render(const RenderData& data) {
_programObject->setUniform("texture1", dayUnit);
// Bind possible night texture
if (_hasNightTexture) {
if (_hasNightTexture && _nightTexture) {
nightUnit.activate();
_nightTexture->bind();
_programObject->setUniform("nightTex", nightUnit);
}
if (_hasHeightTexture) {
if (_hasHeightTexture && _heightMapTexture) {
heightUnit.activate();
_heightMapTexture->bind();
_programObject->setUniform("heightTex", heightUnit);
@@ -46,7 +46,6 @@ public:
bool initialize(Renderable* parent) override;
void deinitialize() override;
void render() override;
PowerScaledSphere* _planet;
private:
void createSphere();