mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 11:09:37 -06:00
Update ghoul and add model animation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user