mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 21:09:27 -06:00
Work on asset loading
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
local registerSpiceKernels = function (spiceAsset, kernels)
|
||||
local oldInit = spiceAsset.onInitialize;
|
||||
spiceAsset.onInitialize(function ()
|
||||
print "loading spice kernels...."
|
||||
for i, kernel in ipairs(kernels) do
|
||||
openspace.spice.loadKernel(kernel)
|
||||
end
|
||||
end)
|
||||
|
||||
local oldDeinit = spiceAsset.onDeinitialize;
|
||||
spiceAsset.onDeinitialize(function ()
|
||||
for i = #kernels, 1, -1 do
|
||||
kernel = kernels[i]
|
||||
@@ -16,6 +12,19 @@ local registerSpiceKernels = function (spiceAsset, kernels)
|
||||
end)
|
||||
end
|
||||
|
||||
local registerSceneGraphNodes = function (sceneAsset, nodes)
|
||||
sceneAsset.onInitialize(function ()
|
||||
for i, node in ipairs(nodes) do
|
||||
openspace.addSceneGraphNode(node)
|
||||
end
|
||||
end)
|
||||
sceneAsset.onDeinitialize(function ()
|
||||
for i = #nodes, 1, -1 do
|
||||
node = nodes[i]
|
||||
openspace.removeSceneGraphNode(node)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
asset.export("registerSceneGraphNodes", registerSceneGraphNodes);
|
||||
asset.export("registerSpiceKernels", registerSpiceKernels);
|
||||
asset.export("registerSynchronizations", registerSynchronizations);
|
||||
asset.export("registerSpiceKernels", registerSpiceKernels);
|
||||
@@ -1,18 +1,18 @@
|
||||
local assetHelper = asset.import("assethelper")
|
||||
local transforms = asset.import("./transforms")
|
||||
|
||||
assetHelper.registerSynchronizations(asset, {
|
||||
{
|
||||
Type = "HTTPSynchronization",
|
||||
--- todo...
|
||||
}
|
||||
})
|
||||
--assetHelper.registerSynchronizations(asset, {
|
||||
-- {
|
||||
-- Type = "HTTPSynchronization",
|
||||
-- --- todo...
|
||||
-- }
|
||||
--})
|
||||
|
||||
--asset.onSynchronize = function (onFinish)
|
||||
-- onFinish(true)
|
||||
--end
|
||||
|
||||
asset.Earth = {
|
||||
Earth = {
|
||||
Name = "Earth",
|
||||
Parent = transforms.EarthIau.Name,
|
||||
Renderable = {
|
||||
@@ -36,6 +36,5 @@ asset.Earth = {
|
||||
}
|
||||
|
||||
assetHelper.registerSceneGraphNodes(asset, {
|
||||
asset.Earth,
|
||||
asset.EarthMarker
|
||||
Earth
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@ local EarthBarycenter = {
|
||||
local EarthInertial = {
|
||||
-- The default reference frame for Earth-orbiting satellites
|
||||
Name = "EarthInertial",
|
||||
Parent = asset.EarthBarycenter.Name,
|
||||
Parent = EarthBarycenter.Name,
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "SpiceRotation",
|
||||
@@ -28,7 +28,7 @@ local EarthInertial = {
|
||||
|
||||
local EarthIau = {
|
||||
Name = "EarthIau",
|
||||
Parent = asset.EarthBarycenter.Name,
|
||||
Parent = EarthBarycenter.Name,
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "SpiceRotation",
|
||||
|
||||
@@ -2,15 +2,15 @@ local assetHelper = asset.import("assethelper")
|
||||
asset.import("spice/base")
|
||||
|
||||
-- Barycenter of the solar system, expressed in the Galactic frame
|
||||
asset.SolarSystemBarycenter = {
|
||||
local SolarSystemBarycenter = {
|
||||
Name = "SolarSystemBarycenter"
|
||||
-- No parent; this node is attached to the scene graph root
|
||||
}
|
||||
|
||||
-- Spice frame for the Sun
|
||||
asset.SunIau = {
|
||||
local SunIau = {
|
||||
Name = "SunIau",
|
||||
Parent = asset.SolarSystemBarycenter.Name,
|
||||
Parent = SolarSystemBarycenter.Name,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
@@ -29,3 +29,6 @@ assetHelper.registerSceneGraphNodes(asset, {
|
||||
asset.SolarSystemBarycenter,
|
||||
asset.SunIau
|
||||
})
|
||||
|
||||
asset.export("SolarSystemBarycenter", SolarSystemBarycenter)
|
||||
asset.export("SunIau", SunIau)
|
||||
@@ -334,7 +334,6 @@ void GUI::initialize() {
|
||||
style.GrabMinSize = 10.f;
|
||||
style.GrabRounding = 16.f;
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
||||
style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.13f, 0.13f, 0.96f);
|
||||
|
||||
@@ -618,10 +618,12 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) {
|
||||
_renderEngine->startFading(1, 3.0);
|
||||
|
||||
if (_scene) {
|
||||
_renderEngine->setCamera(_scene->camera());
|
||||
_navigationHandler->setCamera(_scene->camera());
|
||||
_navigationHandler->setFocusNode(_scene->camera()->parent());
|
||||
|
||||
Camera* camera = _scene->camera();
|
||||
if (camera) {
|
||||
_renderEngine->setCamera(camera);
|
||||
_navigationHandler->setCamera(camera);
|
||||
_navigationHandler->setFocusNode(camera->parent());
|
||||
}
|
||||
// Write keyboard documentation.
|
||||
if (configurationManager().hasKey(ConfigurationManager::KeyKeyboardShortcuts)) {
|
||||
keyBindingManager().writeDocumentation(
|
||||
@@ -1339,6 +1341,7 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
|
||||
{
|
||||
"addTag",
|
||||
&luascriptfunctions::addTag,
|
||||
{},
|
||||
"string, string",
|
||||
"Adds a tag (second argument) to a scene graph node (first argument)"
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ Asset* AssetLoader::loadAsset(std::string path) {
|
||||
}
|
||||
|
||||
ghoul::lua::runScriptFile(*_luaState, path);
|
||||
_importedAssets.emplace(asset->id(), std::move(asset));
|
||||
_importedAssets.emplace(rawAsset->id(), std::move(asset));
|
||||
|
||||
return rawAsset;
|
||||
}
|
||||
@@ -118,11 +118,11 @@ std::string AssetLoader::generateAssetPath(const std::string& baseDirectory,
|
||||
baseDirectory :
|
||||
_assetRootDirectory;
|
||||
|
||||
return directory.path() +
|
||||
return ghoul::filesystem::File(directory.path() +
|
||||
ghoul::filesystem::FileSystem::PathSeparator +
|
||||
assetPath +
|
||||
"." +
|
||||
AssetFileSuffix;
|
||||
AssetFileSuffix);
|
||||
}
|
||||
|
||||
Asset* AssetLoader::getAsset(std::string name) {
|
||||
|
||||
Reference in New Issue
Block a user