Update ghoul and add model animation

This commit is contained in:
Malin Ejdbo
2021-03-16 09:05:32 +01:00
parent aebe6c1217
commit 323e9b2fb5
3 changed files with 20 additions and 2 deletions

View File

@@ -150,6 +150,10 @@ namespace {
// In format 'YYYY MM DD hh:mm:ss'.
std::optional<std::string> animationStartTime [[codegen::dateTime()]];
// The time scale for the animation relative to seconds.
// Ex if animation is in milli seconds then AnimationTimeScale = 1000
std::optional<float> animationTimeScale;
// [[codegen::verbatim(AmbientIntensityInfo.description)]]
std::optional<double> ambientIntensity;
@@ -231,6 +235,10 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
}
}
if (p.animationStartTime.has_value()) {
_animationStart = *p.animationStartTime;
}
if (std::holds_alternative<std::string>(p.geometryFile)) {
// Handle single file
std::string file;
@@ -288,6 +296,10 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
}*/
}
if (p.animationTimeScale.has_value()) {
_geometry->setTimeScale(*p.animationTimeScale);
}
if (p.modelTransform.has_value()) {
_modelTransform = *p.modelTransform;
}
@@ -516,11 +528,16 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
_program->deactivate();
}
void RenderableModel::update(const UpdateData&) {
void RenderableModel::update(const UpdateData& data) {
if (_program->isDirty()) {
_program->rebuildFromFile();
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
double realtiveTime = data.time.j2000Seconds() - data.time.convertTime(_animationStart);
if (_geometry->hasAnimation()) {
_geometry->update(realtiveTime);
}
}
} // namespace openspace