mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 17:30:04 -05:00
Add example to TimelineRotation. Also fix bug where a non-interpolating timelinerotation would disappear before the first keyframe (#3310)
* Add example to TimelineRotation. Also fix bug where a non-interpolating timelinerotation would disappear before the first keyframe --------- Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
-- No Interpolation
|
||||
-- This asset creates a SceneGraphNode that only displays coordinate axes. The rotation of
|
||||
-- the coordinate axes are determined by a timeline of individual rotations that are used
|
||||
-- without interpolating between the timeline entries. These rotations are keyframes that
|
||||
-- are used to change between different orientations. This example transitions between
|
||||
-- three rotations. In this example, the interpolation between entries is disabled, which
|
||||
-- will cause the coordinate axes to change their orientation abruptly when the rotation
|
||||
-- changes. If the interpolation were enabled, the orientation of the coordinate axes
|
||||
-- would transition seamlessly instead at the provided times. This example will only work
|
||||
-- if the in-game time is set to January 1st, 2000.
|
||||
|
||||
local Node = {
|
||||
Identifier = "TimelineRotation_Example_NoInterpolation",
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "TimelineRotation",
|
||||
Keyframes = {
|
||||
-- The first timeline entry
|
||||
["2000 JAN 01 00:00:00"] = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { math.pi, 0.0, 0.0 }
|
||||
},
|
||||
-- The second timeline entry
|
||||
["2000 JAN 01 12:00:00"] = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0.0, 0.0, 0.0 }
|
||||
},
|
||||
-- The third timeline entry
|
||||
["2000 JAN 01 23:59:59"] = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0.0, 0.0, math.pi }
|
||||
}
|
||||
},
|
||||
ShouldInterpolate = false
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableCartesianAxes"
|
||||
},
|
||||
GUI = {
|
||||
Name = "TimelineRotation - No Interpolation",
|
||||
Path = "/Examples"
|
||||
}
|
||||
}
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.addSceneGraphNode(Node)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
openspace.removeSceneGraphNode(Node)
|
||||
end)
|
||||
@@ -0,0 +1,47 @@
|
||||
-- Basic
|
||||
-- This asset creates a SceneGraphNode that only displays coordinate axes. The rotation of
|
||||
-- the coordinate axes are determined by a timeline of individual rotations. These rotations
|
||||
-- are keyframes that are used to seamlessly change between different orientations. This
|
||||
-- example transitions between three rotations over a long time span. This example will
|
||||
-- only work if the in-game time is set to January 1st, 2000.
|
||||
|
||||
local Node = {
|
||||
Identifier = "TimelineRotation_Example",
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "TimelineRotation",
|
||||
Keyframes = {
|
||||
-- The first timeline entry
|
||||
["2000 JAN 01 00:00:00"] = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { math.pi, 0.0, 0.0 }
|
||||
},
|
||||
-- The second timeline entry
|
||||
["2000 JAN 01 12:00:00"] = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0.0, 0.0, 0.0 }
|
||||
},
|
||||
-- The third timeline entry
|
||||
["2000 JAN 01 23:59:59"] = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0.0, 0.0, math.pi }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableCartesianAxes"
|
||||
},
|
||||
GUI = {
|
||||
Name = "TimelineRotation - Basic",
|
||||
Path = "/Examples"
|
||||
}
|
||||
}
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.addSceneGraphNode(Node)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
openspace.removeSceneGraphNode(Node)
|
||||
end)
|
||||
@@ -107,14 +107,8 @@ glm::dmat3 TimelineRotation::matrix(const UpdateData& data) const {
|
||||
return glm::dmat3(glm::slerp(prevRot, nextRot, t));
|
||||
}
|
||||
else {
|
||||
if (prevTime <= now && now < nextTime) {
|
||||
return prev->data->matrix(data);
|
||||
}
|
||||
else if (nextTime <= now) {
|
||||
return next->data->matrix(data);
|
||||
}
|
||||
return now < nextTime ? prev->data->matrix(data) : next->data->matrix(data);
|
||||
}
|
||||
return glm::dmat3(0.0);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user