mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 19:09:23 -05:00
d77836d910
* Create a RenderableNodeLine example asset * First version of node direction hint renderable (arrow) * Add possibility to set length as a multiplier of the bounding sphere * Draw arrow cylinder using index array * Update exponents and min max values for lengths * Draw arrow head * Only update arrow geometry when positions change * Add some properties to control visuals of arrow * Implement invert option * Add normals and shading * Set arrow head size by length percentage instead of angle * Add bottom circle to cone * Cleanup and update examples * Remove non-existing property from example asset * Fix vertices not updating if anchor node was changed And some missing updates on property change * Start cleaning up some shape rendering helper functions * Cleanup code and move cylinder function to helper class * Refactor cylinder creation code (fewer loops over same vector) * Update transformations to correctly scale and place arrow * Add the cone to make the arrowhead * Update faulty triangle normals * Add property visibilities * Rename NodeDirectionHint to NodeArrow * Apply suggestions from code review Co-authored-by: Alexander Bock <alexander.bock@liu.se> --------- Co-authored-by: Alexander Bock <alexander.bock@liu.se>
78 lines
2.2 KiB
Lua
78 lines
2.2 KiB
Lua
local earth = asset.require("scene/solarsystem/planets/earth/earth")
|
|
local moon = asset.require("scene/solarsystem/planets/earth/moon/moon")
|
|
local mars = asset.require("scene/solarsystem/planets/mars/mars")
|
|
|
|
|
|
|
|
local EarthRadius = 6371000.0
|
|
|
|
local ArrowExample = {
|
|
Identifier = "RenderableNodeArrowExample",
|
|
Parent = earth.Earth.Identifier,
|
|
Renderable = {
|
|
Type = "RenderableNodeArrow",
|
|
StartNode = earth.Earth.Identifier,
|
|
EndNode = mars.Mars.Identifier,
|
|
Color = { 0.8, 1.0, 0.8 },
|
|
Offset = 2 * EarthRadius,
|
|
Length = 5 * EarthRadius,
|
|
Width = 900000.0
|
|
},
|
|
GUI = {
|
|
Name = "Node Arrow Example",
|
|
Path = "/Example",
|
|
Description = [[Example node direction arrow, using absolute sizes]]
|
|
}
|
|
}
|
|
|
|
-- Relative values: Multiplied with bounding sphere
|
|
local ArrowExample_RelativeUnits = {
|
|
Identifier = "RenderableNodeArrowExample_Relative",
|
|
Parent = earth.Earth.Identifier,
|
|
Renderable = {
|
|
Type = "RenderableNodeArrow",
|
|
StartNode = earth.Earth.Identifier,
|
|
EndNode = moon.Moon.Identifier,
|
|
Color = { 0.78, 0.0, 1.0 },
|
|
UseRelativeOffset = true,
|
|
UseRelativeLength = true,
|
|
Offset = 2.0,
|
|
Length = 5.0,
|
|
Width = 900000.0,
|
|
Invert = true -- Point to start node instead of end node
|
|
},
|
|
GUI = {
|
|
Name = "Node Arrow Example (relative units)",
|
|
Path = "/Example",
|
|
Description = [[Example node direction arrow, using relative sizes]]
|
|
}
|
|
}
|
|
|
|
|
|
asset.onInitialize(function()
|
|
openspace.addSceneGraphNode(ArrowExample)
|
|
openspace.addSceneGraphNode(ArrowExample_RelativeUnits)
|
|
end)
|
|
|
|
asset.onDeinitialize(function()
|
|
openspace.removeSceneGraphNode(ArrowExample_RelativeUnits)
|
|
openspace.removeSceneGraphNode(ArrowExample)
|
|
end)
|
|
|
|
asset.export(ArrowExample)
|
|
asset.export(ArrowExample_RelativeUnits)
|
|
|
|
|
|
|
|
asset.meta = {
|
|
Name = "RenderableNodeArrow Example asset",
|
|
Version = "1.0",
|
|
Description = [[Examples of the RenderableNodeArrow renderable, that can be used to draw
|
|
an arrow pointing from one scene graph node in the direction of another. Note that
|
|
the arrows are generated as objects in 3D space and need to have a size that is
|
|
suitable for their 3D context.]],
|
|
Author = "OpenSpace Team",
|
|
URL = "http://openspaceproject.com",
|
|
License = "MIT license"
|
|
}
|