Support loading of .asset and .scene files

Fix hardcoded paths to placeholder image add placeholder image to repository
Disable launcher in SyncWidget to keep it compiling until deletion
This commit is contained in:
Alexander Bock
2017-12-23 08:08:12 +01:00
parent ca6263ed1e
commit 4b65e20570
8 changed files with 60 additions and 17 deletions
+2 -2
View File
@@ -134,8 +134,8 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
setLayout(layout);
ghoul::initialize();
_downloadManager = std::make_unique<openspace::DownloadManager>(
"http://data.openspaceproject.com/request", DownloadApplicationVersion);
// _downloadManager = std::make_unique<openspace::DownloadManager>(
// "http://data.openspaceproject.com/request", DownloadApplicationVersion);
libtorrent::error_code ec;
_session->listen_on(std::make_pair(20280, 20290), ec);
Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

+1 -1
View File
@@ -220,7 +220,7 @@ void RenderableModel::update(const UpdateData&) {
_programObject->rebuildFromFile();
}
_sunPos = OsEng.renderEngine().scene()->sceneGraphNode("Sun")->worldPosition();
_sunPos = OsEng.renderEngine().scene()->sceneGraphNode("SolarSystemBarycenter")->worldPosition();
}
void RenderableModel::loadTexture() {
@@ -46,7 +46,7 @@ HongKangParser::HongKangParser(std::string name, std::string fileName,
ghoul::Dictionary translationDictionary,
std::vector<std::string> potentialTargets)
: _defaultCaptureImage(
absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder.png")
absPath("${OPENSPACE_DATA}/placeholder.png")
)
, _name(std::move(name))
, _fileName(std::move(fileName))
@@ -68,7 +68,7 @@ namespace {
constexpr const char* sequenceTypeInstrumentTimes = "instrument-times";
const char* placeholderFile =
"${OPENSPACE_DATA}/scene/common/textures/placeholder.png";
"${OPENSPACE_DATA}/placeholder.png";
constexpr const char* _loggerCat = "ProjectionComponent";
@@ -48,14 +48,20 @@ namespace openspace {
TorrentSynchronization::TorrentSynchronization(const ghoul::Dictionary& dict,
const std::string& synchronizationRoot,
TorrentClient* torrentClient)
: openspace::ResourceSynchronization(dict)
: ResourceSynchronization(dict)
, _synchronizationRoot(synchronizationRoot)
, _torrentClient(torrentClient)
{
documentation::testSpecificationAndThrow(
ResourceSynchronization::Documentation(),
dict,
"ResourceSynchronization::TorrentSynchronization"
);
documentation::testSpecificationAndThrow(
Documentation(),
dict,
"TorrentSynchroniztion"
"TorrentSynchronization::TorrentSynchronization"
);
_identifier = dict.value<std::string>(KeyIdentifier);
+1 -1
View File
@@ -60,7 +60,7 @@ bool MissionManager::hasCurrentMission() const {
void MissionManager::loadMission(const std::string& filename) {
ghoul_assert(!filename.empty(), "filename must not be empty");
ghoul_assert(!FileSys.containsToken(filename), "filename must not contain tokens");
ghoul_assert(FileSys.fileExists(filename), "filename must exist");
ghoul_assert(FileSys.fileExists(filename), "filename " + filename + " must exist");
// Changing the values might invalidate the _currentMission iterator
std::string currentMission = hasCurrentMission() ? _currentMission->first : "";
+46 -9
View File
@@ -34,6 +34,8 @@
#include <ghoul/misc/onscopeexit.h>
#include <ghoul/filesystem/filesystem.h>
#include <fmt/format.h>
#include "assetloader_lua.inl"
namespace {
@@ -56,6 +58,7 @@ namespace {
const char* _loggerCat = "AssetLoader";
const char* AssetFileSuffix = "asset";
const char* SceneFileSuffix = "scene";
enum class PathType : int {
RelativeToAsset = 0,
@@ -288,16 +291,50 @@ std::string AssetLoader::generateAssetPath(const std::string& baseDirectory,
prefix = _assetRootDirectory + ghoul::filesystem::FileSystem::PathSeparator;
}
// Support paths with and without ".asset" suffix.
std::string suffix = std::string(".") + AssetFileSuffix;
if (assetPath.size() > suffix.size() &&
assetPath.substr(assetPath.size() - suffix.size()) == suffix)
{
suffix = "";
// Construct the full path including the .asset extension
std::string assetSuffix = std::string(".") + AssetFileSuffix;
bool hasAssetSuffix =
(assetPath.size() > assetSuffix.size()) &&
(assetPath.substr(assetPath.size() - assetSuffix.size()) == assetSuffix);
std::string fullAssetPath =
hasAssetSuffix ?
prefix + assetPath :
prefix + assetPath + assetSuffix;
bool fullAssetPathExists = FileSys.fileExists(FileSys.absPath(fullAssetPath));
// Construct the full path including the .scene extension
std::string sceneSuffix = std::string(".") + SceneFileSuffix;
bool hasSceneSuffix =
(assetPath.size() > sceneSuffix.size()) &&
(assetPath.substr(assetPath.size() - sceneSuffix.size()) == sceneSuffix);
std::string fullScenePath =
hasSceneSuffix ?
prefix + assetPath :
prefix + assetPath + sceneSuffix;
bool fullScenePathExists = FileSys.fileExists(FileSys.absPath(fullScenePath));
if (fullAssetPathExists && fullScenePathExists) {
LWARNING(
fmt::format(
"'{}' and '{}' file found with non-specific request '{}'. Loading '{}'. "
"Explicitly add extension to suppress this warning.",
fullAssetPath,
fullScenePath,
prefix + assetPath,
fullAssetPath
)
);
return ghoul::filesystem::File(FileSys.absPath(fullAssetPath));
}
return ghoul::filesystem::File(FileSys.absPath(
prefix + assetPath + suffix
));
if (fullScenePathExists) {
return ghoul::filesystem::File(FileSys.absPath(fullScenePath));
}
// We don't check whether the file exists here as the error will be more
// comprehensively logged by Lua either way
return ghoul::filesystem::File(FileSys.absPath(fullAssetPath));
}
std::shared_ptr<Asset> AssetLoader::getAsset(std::string name) {