Property for rotation

This commit is contained in:
Agnes Heppich
2018-12-19 19:11:38 -05:00
parent a69b18f224
commit d20caa6380
2 changed files with 28 additions and 2 deletions

View File

@@ -92,6 +92,12 @@ namespace {
"all other transformations are applied."
};
constexpr openspace::properties::Property::PropertyInfo RotationVecInfo = {
"RotationVec",
"Rotation Vector",
"Rotation vector "
};
constexpr openspace::properties::Property::PropertyInfo LightSourcesInfo = {
"LightSources",
"Light Sources",
@@ -149,6 +155,12 @@ documentation::Documentation RenderableModel::Documentation() {
Optional::Yes,
ModelTransformInfo.description
},
{
RotationVecInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
RotationVecInfo.description
},
{
LightSourcesInfo.identifier,
new TableVerifier({
@@ -172,7 +184,8 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
, _diffuseIntensity(DiffuseIntensityInfo, 1.f, 0.f, 1.f)
, _specularIntensity(SpecularIntensityInfo, 1.f, 0.f, 1.f)
, _performShading(ShadingInfo, true)
, _modelTransform(ModelTransformInfo, glm::mat3(1.f))
, _modelTransform(ModelTransformInfo, glm::dmat3(1.0), glm::dmat3(-1.0), glm::dmat3(1.0))
, _rotationVec(RotationVecInfo, glm::dvec3(3.14), glm::dvec3(-3.14), glm::dvec3(2*(3.1415)))
, _lightSourcePropertyOwner({ "LightSources", "Light Sources" })
{
documentation::testSpecificationAndThrow(
@@ -238,6 +251,13 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
addProperty(_diffuseIntensity);
addProperty(_specularIntensity);
addProperty(_performShading);
addProperty(_modelTransform);
addProperty(_rotationVec);
_rotationVec.onChange([this]() {
_modelTransform = glm::mat4_cast(
glm::quat(_rotationVec));
});
}
bool RenderableModel::isReady() const {

View File

@@ -33,6 +33,10 @@
#include <openspace/properties/scalar/floatproperty.h>
#include <ghoul/opengl/uniformcache.h>
#include <memory>
#include <openspace/properties/matrix/dmat4property.h>
#include <openspace/properties/vector/vec3property.h>
namespace ghoul::opengl {
class ProgramObject;
@@ -73,11 +77,13 @@ private:
properties::StringProperty _colorTexturePath;
properties::FloatProperty _ambientIntensity;
properties::FloatProperty _diffuseIntensity;
properties::FloatProperty _specularIntensity;
properties::BoolProperty _performShading;
properties::Mat3Property _modelTransform;
properties::DMat4Property _modelTransform;
properties::Vec3Property _rotationVec;
ghoul::opengl::ProgramObject* _program = nullptr;
UniformCache(opacity, nLightSources, lightDirectionsViewSpace, lightIntensities,