Adding documentations to more classes

This commit is contained in:
Alexander Bock
2017-05-11 22:51:11 -04:00
parent b660a84464
commit 773828c057
8 changed files with 138 additions and 56 deletions
+55 -32
View File
@@ -24,6 +24,8 @@
#include <modules/base/rendering/renderablemodel.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/rendering/renderengine.h>
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/engine/configurationmanager.h>
@@ -34,6 +36,7 @@
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/time.h>
#include <ghoul/misc/invariants.h>
#include <openspace/engine/openspaceengine.h>
@@ -42,19 +45,44 @@
namespace {
const std::string _loggerCat = "RenderableModel";
const char* keyGeometry = "Geometry";
const char* KeyGeometry = "Geometry";
const char* KeyTexture = "Textures.Color";
const char* keyBody = "Body";
const char* keyStart = "StartTime";
const char* keyEnd = "EndTime";
const char* keyFading = "Shading.Fadeable";
const char* keyModelTransform = "Rotation.ModelTransform";
//const std::string keyGhosting = "Shading.Ghosting";
}
} // namespace
namespace openspace {
documentation::Documentation RenderableModel::Documentation() {
using namespace documentation;
return {
"RenderableModel",
"base_renderable_model",
{
{
KeyGeometry,
new ReferencingVerifier("base_geometry_model"),
"This specifies the model that is rendered by the Renderable.",
Optional::No
},
{
KeyTexture,
new StringVerifier,
"A color texture that can be applied to the model specified bny the "
"Geometry.",
Optional::Yes
}
}
};
}
RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
@@ -65,25 +93,31 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
, _texture(nullptr)
, _geometry(nullptr)
, _alpha(1.f)
//, _isGhost(false)
, _performShading("performShading", "Perform Shading", true)
, _frameCount(0)
{
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
ghoul_assert(success, "Name was not passed to RenderableModel");
ghoul_precondition(
dictionary.hasKeyAndValue<std::string>(SceneGraphNode::KeyName),
"Name was not passed to RenderableModel"
);
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
_geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary);
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableModel"
);
if (dictionary.hasKey(KeyGeometry)) {
std::string name = dictionary.value<std::string>(SceneGraphNode::KeyName);
ghoul::Dictionary dict = dictionary.value<ghoul::Dictionary>(KeyGeometry);
dict.setValue(SceneGraphNode::KeyName, name);
_geometry = modelgeometry::ModelGeometry::createFromDictionary(dict);
}
std::string texturePath = "";
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
_colorTexturePath = absPath(texturePath);
if (dictionary.hasKey(KeyTexture)) {
_colorTexturePath = absPath(dictionary.value<std::string>(KeyTexture));
}
addPropertySubOwner(_geometry.get());
@@ -92,17 +126,12 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
addProperty(_debugModelRotation);
//dictionary.getValue(keySource, _source);
//dictionary.getValue(keyDestination, _destination);
if (dictionary.hasKeyAndValue<glm::dmat3>(keyModelTransform))
if (dictionary.hasKeyAndValue<glm::dmat3>(keyModelTransform)) {
dictionary.getValue(keyModelTransform, _modelTransform);
else
}
else {
_modelTransform = glm::dmat3(1.f);
dictionary.getValue(keyBody, _target);
//openspace::SpiceManager::ref().addFrame(_target, _source);
//setBoundingSphere(pss(1.f, 9.f));
}
addProperty(_performShading);
if (dictionary.hasKeyAndValue<bool>(keyFading)) {
@@ -111,12 +140,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
_performFade = fading;
}
addProperty(_performFade);
//if (dictionary.hasKeyAndValue<bool>(keyGhosting)) {
// bool ghosting;
// dictionary.getValue(keyGhosting, ghosting);
// _isGhost = ghosting;
//}
}
bool RenderableModel::isReady() const {
+3 -6
View File
@@ -40,6 +40,8 @@
namespace openspace {
namespace documentation { struct Documentation; }
namespace modelgeometry {
class ModelGeometry;
}
@@ -56,6 +58,7 @@ public:
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
protected:
void loadTexture();
@@ -72,13 +75,7 @@ private:
glm::dmat3 _modelTransform;
float _alpha;
//glm::dmat3 _stateMatrix;
//std::string _source;
//std::string _destination;
std::string _target;
//bool _isGhost;
int _frameCount;
glm::dvec3 _sunPos;
@@ -23,6 +23,8 @@
****************************************************************************************/
#include <modules/base/rendering/screenspaceframebuffer.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/camera.h>
@@ -34,11 +36,27 @@
namespace openspace {
documentation::Documentation ScreenSpaceFramebuffer::Documentation() {
using namespace documentation;
return {
"ScreenSpace Framebuffer",
"base_screenspace_framebuffer",
{},
Exhaustive::Yes
};
}
ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary)
: ScreenSpaceRenderable(dictionary)
, _size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000))
, _framebuffer(nullptr)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ScreenSpaceFramebuffer"
);
_id = id();
setName("ScreenSpaceFramebuffer" + std::to_string(_id));
@@ -34,6 +34,9 @@
#include <modules/base/rendering/screenspaceimage.h>
namespace openspace {
namespace documentation { struct Documentation; }
/**
* @brief Creates a texture by rendering to a framebuffer, this is then used on a screen space plane.
* @details This class lets you ass renderfunctions that should render to a framebuffer with an attached texture.
@@ -54,6 +57,8 @@ public:
void addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction);
void removeAllRenderFunctions();
static documentation::Documentation Documentation();
private:
void createFragmentbuffer();
static int id();
+41 -11
View File
@@ -24,6 +24,9 @@
#include <modules/base/rendering/screenspaceimage.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/rendering/renderengine.h>
@@ -36,39 +39,66 @@ namespace {
const char* KeyName = "Name";
const char* KeyTexturePath = "TexturePath";
const char* KeyUrl = "URL";
}
} // namespace
namespace openspace {
documentation::Documentation ScreenSpaceImage::Documentation() {
using namespace openspace::documentation;
return {
"ScreenSpace Image",
"base_screenspace_image",
{
{
KeyName,
new StringVerifier,
"Specifies the GUI name of the ScreenspaceImage",
Optional::Yes
},
{
KeyTexturePath,
new StringVerifier,
"Specifies the image that is shown on the screenspace-aligned plane. If "
"this value is set and the URL is not, the disk image is used.",
Optional::Yes
}
}
};
}
ScreenSpaceImage::ScreenSpaceImage(const ghoul::Dictionary& dictionary)
: ScreenSpaceRenderable(dictionary)
, _downloadImage(false)
, _textureIsDirty(false)
, _texturePath("texturePath", "Texture path", "")
{
std::string name;
if (dictionary.getValue(KeyName, name)) {
setName(name);
} else {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ScreenSpaceImage"
);
if (dictionary.hasKey(KeyName)) {
setName(dictionary.value<std::string>(KeyName));
}
else {
static int id = 0;
setName("ScreenSpaceImage " + std::to_string(id));
++id;
}
addProperty(_texturePath);
std::string texturePath;
if (dictionary.getValue(KeyTexturePath, texturePath)) {
_texturePath = texturePath;
_texturePath.onChange([this]() { _textureIsDirty = true; });
_texturePath = dictionary.value<std::string>(KeyTexturePath);
}
if (dictionary.getValue(KeyUrl, _url)) {
_downloadImage = true;
}
}
ScreenSpaceImage::~ScreenSpaceImage() {}
_texturePath.onChange([this]() { _textureIsDirty = true; });
addProperty(_texturePath);
}
bool ScreenSpaceImage::initialize() {
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
+4 -1
View File
@@ -33,11 +33,12 @@
#include <ghoul/opengl/texture.h>
namespace openspace {
namespace documentation { struct Documentation; }
class ScreenSpaceImage : public ScreenSpaceRenderable {
public:
ScreenSpaceImage(const ghoul::Dictionary& dictionary);
~ScreenSpaceImage();
bool initialize() override;
bool deinitialize() override;
@@ -45,6 +46,8 @@ public:
void update() override;
bool isReady() const override;
static documentation::Documentation Documentation();
protected:
void loadTexture();
void updateTexture();