Added documentation to more classes

This commit is contained in:
Alexander Bock
2017-07-24 17:22:19 -04:00
parent 1a475ef570
commit 20e944f86f
17 changed files with 723 additions and 352 deletions

View File

@@ -39,62 +39,138 @@
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
namespace {
const char* _loggerCat = "RenderablePlaneTexture";
enum Origin {
LowerLeft = 0,
LowerRight,
UpperLeft,
UpperRight,
Center
};
static const openspace::properties::Property::PropertyInfo TextureInfo = {
"Texture",
"Texture",
"The OpenGL name of the texture that is displayed on this plane."
};
static const openspace::properties::Property::PropertyInfo BillboardInfo = {
"Billboard",
"Billboard mode",
"This value specifies whether the plane is a billboard, which means that it is "
"always facing the camera. If this is false, it can be oriented using other "
"transformations."
};
static const openspace::properties::Property::PropertyInfo SizeInfo = {
"Size",
"Size (in meters)",
"This value specifies the size of the plane in meters."
};
static const openspace::properties::Property::PropertyInfo OriginInfo = {
"Origin",
"Texture Coordinate Origin",
"The origin of the texture coorinate system."
};
} // namespace
namespace openspace {
documentation::Documentation RenderableDebugPlane::Documentation() {
using namespace documentation;
return {
"RenderableDebugPlane",
"debugging_renderable_debugplane",
{
{
TextureInfo.identifier,
new IntVerifier,
TextureInfo.description,
Optional::Yes
},
{
BillboardInfo.identifier,
new BoolVerifier,
BillboardInfo.description,
Optional::Yes
},
{
SizeInfo.identifier,
new DoubleVerifier,
SizeInfo.description,
Optional::Yes
},
{
OriginInfo.identifier,
new StringInListVerifier(
{ "LowerLeft", "LowerRight", "UpperLeft", "UpperRight", "Center" }
),
OriginInfo.description,
Optional::Yes
}
},
Exhaustive::Yes
};
}
RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texture({ "Texture", "Texture", "" }, -1, -1, 255) // @TODO Missing documentation
, _billboard({ "Billboard", "Billboard", "" }, false) // @TODO Missing documentation
, _size({ "Size", "Size", "" }, 10.f, 0.f, std::pow(10.f, 25.f)) // @TODO Missing documentation
, _origin(Origin::Center)
, _texture(TextureInfo, -1, -1, 512)
, _billboard(BillboardInfo, false)
, _size(SizeInfo, 10.f, 0.f, 1e25f)
, _origin(OriginInfo, properties::OptionProperty::DisplayType::Dropdown)
, _shader(nullptr)
, _quad(0)
, _vertexPositionBuffer(0)
{
dictionary.getValue("Size", _size);
if (dictionary.hasKey("Name")){
dictionary.getValue("Name", _nodeName);
if (dictionary.hasKey(TextureInfo.identifier)) {
_texture = static_cast<int>(dictionary.value<double>(TextureInfo.identifier));
}
if (dictionary.hasKey("Texture")) {
int t;
dictionary.getValue("Texture", t);
_texture = t;
if (dictionary.hasKey(SizeInfo.identifier)) {
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
}
std::string origin;
if (dictionary.getValue("Origin", origin)) {
if (dictionary.hasKey(BillboardInfo.identifier)) {
_billboard = dictionary.value<bool>(BillboardInfo.identifier);
}
_origin.addOptions({
{ LowerLeft, "LowerLeft" },
{ LowerRight, "LowerRight" },
{ UpperLeft, "UpperLeft" },
{ UpperRight, "UpperRight" },
{ Center, "Center" }
});
_origin.setValue(Center);
if (dictionary.hasKey(OriginInfo.identifier)) {
const std::string origin = dictionary.value<std::string>(OriginInfo.identifier);
if (origin == "LowerLeft") {
_origin = Origin::LowerLeft;
_origin = LowerLeft;
}
else if (origin == "LowerRight") {
_origin = Origin::LowerRight;
_origin = LowerRight;
}
else if (origin == "UpperLeft") {
_origin = Origin::UpperLeft;
_origin = UpperLeft;
}
else if (origin == "UpperRight") {
_origin = Origin::UpperRight;
_origin = UpperRight;
}
else if (origin == "Center") {
_origin = Origin::Center;
_origin = Center;
}
}
// Attempt to get the billboard value
bool billboard = false;
if (dictionary.getValue("Billboard", billboard)) {
_billboard = billboard;
else {
_origin = Center;
}
int texture;
if (dictionary.getValue("Texture", texture))
_texture = texture;
addProperty(_texture);
addProperty(_billboard);
@@ -105,13 +181,13 @@ RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary)
setBoundingSphere(_size);
}
RenderableDebugPlane::~RenderableDebugPlane() {
}
RenderableDebugPlane::~RenderableDebugPlane() {}
bool RenderableDebugPlane::isReady() const {
bool ready = true;
if (!_shader)
if (!_shader) {
ready &= false;
}
return ready;
}
@@ -120,19 +196,14 @@ bool RenderableDebugPlane::initialize() {
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
createPlane();
if (_shader == nullptr) {
// Plane Program
if (!_shader) {
RenderEngine& renderEngine = OsEng.renderEngine();
_shader = renderEngine.buildRenderProgram("PlaneProgram",
"${MODULE_BASE}/shaders/plane_vs.glsl",
"${MODULE_BASE}/shaders/plane_fs.glsl"
);
if (!_shader)
return false;
}
return isReady();
}
@@ -154,8 +225,9 @@ bool RenderableDebugPlane::deinitialize() {
void RenderableDebugPlane::render(const RenderData& data, RendererTasks&) {
glm::mat4 transform = glm::mat4(1.0);
if (_billboard)
if (_billboard) {
transform = glm::inverse(glm::mat4(data.camera.viewRotationMatrix()));
}
// Activate shader
_shader->activate();
@@ -176,11 +248,13 @@ void RenderableDebugPlane::render(const RenderData& data, RendererTasks&) {
}
void RenderableDebugPlane::update(const UpdateData&) {
if (_shader->isDirty())
if (_shader->isDirty()) {
_shader->rebuildFromFile();
}
if (_planeIsDirty)
if (_planeIsDirty) {
createPlane();
}
}
void RenderableDebugPlane::createPlane() {