Merge branch 'master' into thesis/2021/skybrowser

This commit is contained in:
Ylva Selling
2021-03-09 08:47:11 +01:00
135 changed files with 37286 additions and 16270 deletions
+1
View File
@@ -32,6 +32,7 @@ Thumbs.db
/logs/
/screenshots/
/recordings/
/user/
/sync/
/temp/
# Customization is not supposed to be committed
@@ -54,11 +54,12 @@ public:
*
* \param dir The directory from which to start the search from
*/
std::string useQtFileSystemModelToTraverseDir(std::string dir);
std::string useQtFileSystemModelToTraverseDir(std::string dir, bool usersAssets = false);
private:
void parseChildDirElements(QFileInfo item, std::string space, int level,
std::vector<std::string>& dirNames, std::vector<std::string>& output);
std::vector<std::string>& dirNames, std::vector<std::string>& output,
bool userAssets);
void parseChildFile(std::string res, bool& hasDirHeaderBeenAdded,
std::vector<std::string>& dirNames, std::vector<std::string>& output);
bool isApprovedPath(std::string path);
@@ -81,16 +81,21 @@ private:
QWidget* createCentralWidget();
void setBackgroundImage(const std::string& syncPath);
void openProfileEditor(const std::string& profile);
void openProfileEditor(const std::string& profile, bool isUserProfile);
void populateProfilesList(std::string preset);
void populateWindowConfigsList(std::string preset);
const std::string _assetPath;
const std::string _userAssetPath;
const std::string _configPath;
const std::string _userConfigPath;
const std::string _profilePath;
const std::string _userProfilePath;
const std::vector<std::string>& _readOnlyProfiles;
bool _shouldLaunch = false;
int _userAssetCount = 0;
int _userConfigCount = 0;
QComboBox* _profileBox = nullptr;
QComboBox* _windowConfigBox = nullptr;
@@ -43,10 +43,11 @@ public:
* \param profile The #openspace::Profile object containing all data of the
* new or imported profile.
* \param assetBasePath The path to the folder in which all of the assets are living
* \param userAssetBasePath The path to the folder in which the users' assets are living
* \param parent Pointer to parent Qt widget
*/
AssetsDialog(openspace::Profile& profile, const std::string& assetBasePath,
QWidget* parent);
const std::string& userAssetBasePath, QWidget* parent);
private slots:
void parseSelections();
@@ -148,8 +148,10 @@ public:
* Imports asset tree data for this model by recursively traversing the folder
* structure.
* \param assetBasePath The base path where to find all assets
* \param assetBasePath The base path where to find user assets
*/
void importModelData(const std::string& assetBasePath);
void importModelData(const std::string& assetBasePath,
const std::string& userAssetBasePath);
/**
* Returns bool for if item is checked/selected
@@ -46,13 +46,15 @@ public:
* new or imported profile.
* \param profileName The name of the profile to create
* \param assetBasePath The path to the folder where the assets live
* \param userAssetBasePath The path to the folder where the user assets live
* \param profileName The path to the folder in which all profiles live
* \param profilesReadOnly vector list of profile names that are read-only and must
* not be overwritten
* \param parent Pointer to parent Qt widget
*/
ProfileEdit(openspace::Profile& profile, const std::string& profileName,
std::string assetBasePath, std::string profileBasePath,
std::string assetBasePath, std::string userAssetBasePath,
std::string profileBasePath,
const std::vector<std::string>& profilesReadOnly, QWidget* parent);
/**
@@ -98,6 +100,7 @@ private:
openspace::Profile& _profile;
const std::string _assetBasePath;
const std::string _userAssetBasePath;
const std::string _profileBasePath;
bool _saveSelected = false;
const std::vector<std::string>& _readOnlyProfiles;
@@ -33,13 +33,13 @@ FileSystemAccess::FileSystemAccess(std::string fileExtension,
, _useCheckboxes(useCheckboxes)
{}
std::string FileSystemAccess::useQtFileSystemModelToTraverseDir(std::string dir) {
std::string FileSystemAccess::useQtFileSystemModelToTraverseDir(std::string dir, bool userAssets) {
_filesystemModel.setRootPath(QString::fromStdString(dir));
QModelIndex index = _filesystemModel.index(_filesystemModel.rootPath());
QFileInfo fileInfo = _filesystemModel.fileInfo(index);
std::vector<std::string> dirsNested;
std::vector<std::string> out;
parseChildDirElements(fileInfo, "", 0, dirsNested, out);
parseChildDirElements(fileInfo, "", 0, dirsNested, out, userAssets);
std::string combined;
for (const std::string& o : out) {
combined += o + "\n";
@@ -49,7 +49,7 @@ std::string FileSystemAccess::useQtFileSystemModelToTraverseDir(std::string dir)
void FileSystemAccess::parseChildDirElements(QFileInfo fileInfo, std::string space,
int level, std::vector<std::string>& dirNames,
std::vector<std::string>& output)
std::vector<std::string>& output, bool userAssets)
{
QDir dir(fileInfo.filePath());
bool hasDirHeaderBeenAdded = false;
@@ -58,11 +58,13 @@ void FileSystemAccess::parseChildDirElements(QFileInfo fileInfo, std::string spa
for (int i = 0; i < fileList.size(); i++) {
QFileInfo fi = fileList[i];
std::string res = space + fi.fileName().toStdString();
if (level == 0 && userAssets) {
res = "${USER_ASSETS}/" + res;
}
if (fi.isDir()) {
if (level != 0 || (level == 0 && isApprovedPath(res))) {
if (level != 0 || (level == 0 && (isApprovedPath(res) || userAssets))) {
dirNames.push_back(res);
parseChildDirElements(fi, (space + " "), level + 1, dirNames, output);
parseChildDirElements(fi, (space + " "), level + 1, dirNames, output, userAssets);
}
}
else {
@@ -37,6 +37,7 @@
#include <filesystem>
#include <iostream>
#include <random>
#include <QStandardItemModel>
using namespace openspace;
@@ -141,8 +142,11 @@ LauncherWindow::LauncherWindow(bool profileEnabled,
QWidget* parent)
: QMainWindow(parent)
, _assetPath(absPath(globalConfig.pathTokens.at("ASSETS")) + '/')
, _userAssetPath(absPath(globalConfig.pathTokens.at("USER_ASSETS")) + '/')
, _configPath(absPath(globalConfig.pathTokens.at("CONFIG")) + '/')
, _userConfigPath(absPath(globalConfig.pathTokens.at("USER_CONFIG")) + '/')
, _profilePath(absPath(globalConfig.pathTokens.at("PROFILES")) + '/')
, _userProfilePath(absPath(globalConfig.pathTokens.at("USER_PROFILES")) + '/')
, _readOnlyProfiles(globalConfig.readOnlyProfiles)
{
Q_INIT_RESOURCE(resources);
@@ -168,7 +172,6 @@ LauncherWindow::LauncherWindow(bool profileEnabled,
setCentralWidget(createCentralWidget());
populateProfilesList(globalConfig.profile);
_profileBox->setEnabled(profileEnabled);
@@ -242,7 +245,7 @@ QWidget* LauncherWindow::createCentralWidget() {
connect(
newButton, &QPushButton::released,
[this]() {
openProfileEditor("");
openProfileEditor("", true);
}
);
newButton->setObjectName("small");
@@ -254,7 +257,9 @@ QWidget* LauncherWindow::createCentralWidget() {
editButton, &QPushButton::released,
[this]() {
const std::string selection = _profileBox->currentText().toStdString();
openProfileEditor(selection);
int selectedIndex = _profileBox->currentIndex();
bool isUserProfile = selectedIndex <= _userAssetCount;
openProfileEditor(selection, isUserProfile);
}
);
editButton->setObjectName("small");
@@ -310,6 +315,7 @@ void LauncherWindow::populateProfilesList(std::string preset) {
namespace fs = std::filesystem;
_profileBox->clear();
_userAssetCount = 0;
if (!std::filesystem::exists(_profilePath)) {
LINFOC(
@@ -318,6 +324,26 @@ void LauncherWindow::populateProfilesList(std::string preset) {
);
return;
}
_profileBox->addItem(QString::fromStdString("--- User Profiles ---"));
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(_profileBox->model());
model->item(_userAssetCount)->setEnabled(false);
++_userAssetCount;
// Add all the files with the .profile extension to the dropdown
for (const fs::directory_entry& p : fs::directory_iterator(_userProfilePath)) {
if (p.path().extension() != ".profile") {
continue;
}
_profileBox->addItem(QString::fromStdString(p.path().stem().string()));
++_userAssetCount;
}
_profileBox->addItem(QString::fromStdString("--- OpenSpace Profiles ---"));
model = qobject_cast<const QStandardItemModel*>(_profileBox->model());
model->item(_userAssetCount)->setEnabled(false);
++_userAssetCount;
// Add all the files with the .profile extension to the dropdown
for (const fs::directory_entry& p : fs::directory_iterator(_profilePath)) {
if (p.path().extension() != ".profile") {
@@ -330,7 +356,6 @@ void LauncherWindow::populateProfilesList(std::string preset) {
const int idx = _profileBox->findText(QString::fromStdString(std::move(preset)));
if (idx != -1) {
_profileBox->setCurrentIndex(idx);
}
}
@@ -338,6 +363,24 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) {
namespace fs = std::filesystem;
_windowConfigBox->clear();
_userConfigCount = 0;
_windowConfigBox->addItem(QString::fromStdString("--- User Configurations ---"));
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(_windowConfigBox->model());
model->item(_userConfigCount)->setEnabled(false);
++_userConfigCount;
// Add all the files with the .xml extension to the dropdown
for (const fs::directory_entry& p : fs::directory_iterator(_userConfigPath)) {
if (p.path().extension() != ".xml") {
continue;
}
_windowConfigBox->addItem(QString::fromStdString(p.path().stem().string()));
++_userConfigCount;
}
_windowConfigBox->addItem(QString::fromStdString("--- OpenSpace Configurations ---"));
model = qobject_cast<const QStandardItemModel*>(_windowConfigBox->model());
model->item(_userConfigCount)->setEnabled(false);
if (std::filesystem::exists(_configPath)) {
// Add all the files with the .xml extension to the dropdown
for (const fs::directory_entry& p : fs::directory_iterator(_configPath)) {
@@ -368,8 +411,9 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) {
}
}
void LauncherWindow::openProfileEditor(const std::string& profile) {
void LauncherWindow::openProfileEditor(const std::string& profile, const bool isUserProfile) {
std::optional<Profile> p;
std::string saveProfilePath = isUserProfile ? _userProfilePath : _profilePath;
if (profile.empty()) {
// If the requested profile is the empty string, then we want to create a new one
@@ -378,17 +422,20 @@ void LauncherWindow::openProfileEditor(const std::string& profile) {
else {
// Otherwise, we want to load that profile
std::string fullProfilePath = _profilePath + profile + ".profile";
std::string fullProfilePath = saveProfilePath + profile + ".profile";
p = loadProfileFromFile(this, fullProfilePath);
if (!p.has_value()) {
return;
}
}
ProfileEdit editor(*p, profile, _assetPath, _profilePath, _readOnlyProfiles, this);
ProfileEdit editor(*p, profile, _assetPath, _userAssetPath, saveProfilePath, _readOnlyProfiles, this);
editor.exec();
if (editor.wasSaved()) {
const std::string path = _profilePath + editor.specifiedFilename() + ".profile";
if (editor.specifiedFilename() != profile) {
saveProfilePath = _userProfilePath;
}
const std::string path = saveProfilePath + editor.specifiedFilename() + ".profile";
saveProfile(this, path, *p);
populateProfilesList(editor.specifiedFilename());
}
@@ -407,5 +454,10 @@ std::string LauncherWindow::selectedProfile() const {
}
std::string LauncherWindow::selectedWindowConfig() const {
return _windowConfigBox->currentText().toStdString();
if (_windowConfigBox->currentIndex() > _userAssetCount) {
return "${CONFIG}/" + _windowConfigBox->currentText().toStdString();
}
else {
return "${USER_CONFIG}/" + _windowConfigBox->currentText().toStdString();
}
}
@@ -59,7 +59,13 @@ namespace {
void traverseToFindFilesystemMatch(AssetTreeModel& model, QModelIndex parent,
int nRows, const std::string& path)
{
const size_t slash = path.find_first_of('/', 0);
int startIndex = 0;
std::string token = "${USER_ASSETS}/";
if (path.find(token) == 0) {
startIndex = token.length();
}
const size_t slash = path.find_first_of('/', startIndex);
const bool endOfPath = (slash == std::string::npos);
std::string firstDir = endOfPath ? "" : path.substr(0, slash);
@@ -117,12 +123,12 @@ namespace {
} // namespace
AssetsDialog::AssetsDialog(openspace::Profile& profile, const std::string& assetBasePath,
QWidget* parent)
const std::string& userAssetBasePath, QWidget* parent)
: QDialog(parent)
, _profile(profile)
{
setWindowTitle("Assets");
_assetTreeModel.importModelData(assetBasePath);
_assetTreeModel.importModelData(assetBasePath, userAssetBasePath);
createWidgets();
}
@@ -145,7 +145,8 @@ AssetTreeModel::AssetTreeModel(QObject* parent)
);
}
void AssetTreeModel::importModelData(const std::string& assetBasePath) {
void AssetTreeModel::importModelData(const std::string& assetBasePath,
const std::string& userAssetBasePath) {
FileSystemAccess assets(
".asset",
{ "scene", "global", "customization", "examples", "util" },
@@ -153,7 +154,7 @@ void AssetTreeModel::importModelData(const std::string& assetBasePath) {
true
);
std::string assetList = assets.useQtFileSystemModelToTraverseDir(assetBasePath);
assetList += assets.useQtFileSystemModelToTraverseDir(userAssetBasePath, true);
std::istringstream iss(assetList);
ImportElement rootElem = { "", 0, false };
@@ -94,12 +94,15 @@ namespace {
} // namespace
ProfileEdit::ProfileEdit(Profile& profile, const std::string& profileName,
std::string assetBasePath, std::string profileBasePath,
std::string assetBasePath,
std::string userAssetBasePath,
std::string profileBasePath,
const std::vector<std::string>& readOnlyProfiles,
QWidget* parent)
: QDialog(parent)
, _profile(profile)
, _assetBasePath(std::move(assetBasePath))
, _userAssetBasePath(std::move(userAssetBasePath))
, _profileBasePath(std::move(profileBasePath))
, _readOnlyProfiles(readOnlyProfiles)
{
@@ -427,7 +430,7 @@ void ProfileEdit::openKeybindings() {
void ProfileEdit::openAssets() {
_errorMsg->clear();
AssetsDialog(_profile, _assetBasePath, this).exec();
AssetsDialog(_profile, _assetBasePath, _userAssetBasePath, this).exec();
_assetsLabel->setText(labelText(_profile.assets().size(), "Assets"));
_assetsEdit->setText(QString::fromStdString(summarizeAssets(_profile.assets())));
}
+4 -2
View File
@@ -1016,7 +1016,7 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC
}
}
else {
config = "${CONFIG}/" + config + xmlExt;
config += xmlExt;
}
global::configuration->windowConfiguration = config;
}
@@ -1162,7 +1162,6 @@ int main(int argc, char* argv[]) {
global::openSpaceEngine->registerPathTokens();
bool hasSGCTConfig = false;
bool hasProfile = false;
std::string sgctFunctionName;
@@ -1178,6 +1177,9 @@ int main(int argc, char* argv[]) {
sgctFunctionName
);
//TODO consider LFATAL if ${USER} doens't exist rather then recurisve create.
global::openSpaceEngine->createUserDirectoriesIfNecessary();
// (abock, 2020-12-07) For some reason on Apple the keyboard handler in CEF will call
// the Qt one even if the QApplication was destroyed, leading to invalid memory
// access. The only way we could fix this for the release was to keep the
+4
View File
@@ -106,6 +106,10 @@ void performTasks(const std::string& path) {
int main(int argc, char** argv) {
using namespace openspace;
ghoul::logging::LogManager::initialize(
ghoul::logging::LogLevel::Debug,
ghoul::logging::LogManager::ImmediateFlush::Yes
);
ghoul::initialize();
global::create();
+4 -1
View File
@@ -98,7 +98,10 @@ int main(int argc, char** argv) {
settings.changeHostPassword = defaultChangeHostPassword.str();
}
ghoul::logging::LogManager::initialize(
ghoul::logging::LogLevel::Debug,
ghoul::logging::LogManager::ImmediateFlush::Yes
);
LINFO(fmt::format("Connection password: {}", settings.password));
LINFO(fmt::format("Host password: {}", settings.changeHostPassword));
+27 -6
View File
@@ -1,16 +1,14 @@
local assetHelper = asset.require('util/asset_helper')
local color = {0.0, 1.0, 1.0}
-- @TODO (emmbr 2020-02-03) Potential threading issue later on? This will run on the main thread
local singeColorTexturePath = openspace.createSingeColorImage("example_ring_color", color)
local cyanTexture = openspace.createSingeColorImage("example_disc_color1", {0.0, 1.0, 1.0})
local purpleTexture = openspace.createSingeColorImage("example_disc_color2", {0.5, 0.0, 0.5})
local BasicDisc = {
Identifier = "BasicDisc",
Parent = "Root",
Renderable = {
Type = "RenderableDisc",
Texture = singeColorTexturePath,
Texture = cyanTexture,
Size = 1e10,
Width = 0.5
},
@@ -20,6 +18,29 @@ local BasicDisc = {
}
}
-- Elliptic discs can be created using a non-uniform scaling
-- For a full disc, use a width of 1.0
local FullEllipticDisc = {
Identifier = "FullEllipticDisc",
Transform = {
Scale = {
Type = "NonUniformStaticScale",
Scale = {2.0, 1.0, 1.0}
}
},
Renderable = {
Type = "RenderableDisc",
Texture = purpleTexture,
Size = 2e10,
Width = 1.0
},
GUI = {
Name = "Full Elliptic Disc",
Path = "/Examples/Discs"
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
BasicDisc
BasicDisc,
FullEllipticDisc
})
+1 -1
View File
@@ -17,7 +17,7 @@ local radialGrid = {
Color = { 0.6, 1.0, 0.7 },
LineWidth = 3.0,
GridSegments = { 3, 4 },
OuterSize = 1.0,
OuterRadius = 1.0,
InnerRadius = 0.2,
Enabled = false
},
+52
View File
@@ -0,0 +1,52 @@
local assetHelper = asset.require('util/asset_helper')
local scale = 149597870700 -- 1 AU
local circle = {
Identifier = "ExampleCircle",
Transform = {
Scale = {
Type = "StaticScale",
Scale = scale
}
},
Renderable = {
Type = "RenderableRadialGrid",
Color = { 0.6, 0.6, 0.8 },
LineWidth = 3.0,
GridSegments = { 1, 1 },
CircleSegments = 64,
OuterRadius = 1.0
},
GUI = {
Name = "Example Circle",
Path = "/Examples/Primitives"
}
}
local ellipse = {
Identifier = "ExampleEllipse",
Transform = {
Scale = {
Type = "NonUniformStaticScale",
Scale = {1.5, 1.0, 1.0}
}
},
Renderable = {
Type = "RenderableRadialGrid",
Color = { 0.6, 0.8, 0.6 },
LineWidth = 3.0,
GridSegments = { 1, 1 },
CircleSegments = 64,
OuterRadius = scale
},
GUI = {
Name = "Example Ellipse",
Path = "/Examples/Primitives"
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
circle,
ellipse
})
@@ -1,6 +1,8 @@
local habitableZoneTextures =
asset.require('./../habitable_zones/habitable_zone_textures').TexturesPath
local sunTextures = asset.require('scene/solarsystem/sun/sun_textures').TexturesPath
local TexturesPath = asset.syncedResource({
Name = "Exoplanet Textures",
Type = "HttpSynchronization",
@@ -13,27 +15,34 @@ asset.onInitialize(function ()
local noDataTexture = TexturesPath .. "/grid-32.png"
local discTexture = TexturesPath .. "/disc_bw_texture.png"
local starGlareTexture = sunTextures .. "/halo.png"
local hzTexture = habitableZoneTextures .. "/hot_to_cold_faded.png"
-- Set the default textures used for the exoplanet system creation
-- (Check if already set, to not override value in config file)
local p = "Modules.Exoplanets.StarTexture";
if(openspace.getPropertyValue(p) == "") then
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, starTexture)
end
local p = "Modules.Exoplanets.StarGlareTexture";
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, starGlareTexture)
end
p = "Modules.Exoplanets.NoDataTexture";
if(openspace.getPropertyValue(p) == "") then
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, noDataTexture)
end
p = "Modules.Exoplanets.OrbitDiscTexture";
if(openspace.getPropertyValue(p) == "") then
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, discTexture)
end
p = "Modules.Exoplanets.HabitableZoneTexture";
if(openspace.getPropertyValue(p) == "") then
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, hzTexture)
end
end)
@@ -9,7 +9,7 @@ local sync = asset.syncedResource({
Name = "Orion Nebula Model",
Type = "HttpSynchronization",
Identifier = "orion_nebula_model",
Version = 1
Version = 2
})
local NebulaHolder = {
@@ -59,11 +59,7 @@ local OrionNebulaModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = sync .. "/orion_nebula.obj",
ColorTexture = sync .. "/heic0601a_masked.png"
}},
GeometryFile = sync .. "/orion_nebula.obj",
Opacity = 1.0,
DisableFaceCulling = false,
SpecularIntensity = 0.0,
@@ -92,11 +88,7 @@ local OrionNebulaShocksModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = sync .. "/orishocks.obj",
ColorTexture = "${DATA}/colors/pink.png"
}},
GeometryFile = sync .. "/orishocks.obj",
Opacity = 1.0,
DisableFaceCulling = false,
SpecularIntensity = 0.0,
@@ -125,11 +117,7 @@ local OrionNebulaProplydsModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = sync .. "/proplyds.obj",
ColorTexture = "${DATA}/colors/pink.png"
}},
GeometryFile = sync .. "/proplyds.obj",
Opacity = 1.0,
DisableFaceCulling = false,
SpecularIntensity = 0.0,
@@ -56,11 +56,7 @@ local Apollo11Model = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/Apollo_CSM_shrunk_rotated_xy_double_size.obj",
ColorTexture = models .. "/gray.png"
}},
GeometryFile = models .. "/Apollo_CSM_shrunk_rotated_xy_double_size.obj",
LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier)
},
GUI = {
@@ -175,11 +171,7 @@ local Apollo11LemDescentModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = lem_model.modelFolder .. "/lmremoved.obj",
ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg"
}},
GeometryFile = lem_model.modelFolder .. "/lmremoved.obj",
SpecularIntensity = 0.0,
RotationVector = { 273.750,28.0,309.85 },
LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier)
@@ -205,11 +197,7 @@ local Apollo11LemLandedModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj",
ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg"
}},
GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj",
SpecularIntensity = 0.0,
RotationVector = { 273.750,28.0,309.85 },
LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier)
@@ -36,11 +36,7 @@ local Apollo11LemModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj",
ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg"
}},
GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj",
RotationVector = { 91.044090,171.229706,111.666664 },
LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier)
},
@@ -34,11 +34,7 @@ local Apollo17LemModel = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = model.modelFolder .. "/LM-2_ver2clean.obj",
ColorTexture = model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg"
}},
GeometryFile = model.modelFolder .. "/LM-2_ver2clean.obj",
SpecularIntensity = 0.0,
RotationVector = { 110.255219,171.229706,126.666664 },
LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier)
@@ -1,51 +0,0 @@
--apollo_lem.asset (hopeful title)
-- This asset exports a function to create an Apollo Lunar Excursion Module (LEM).
-- Instead of hard-coding the scene graph node parent,
-- client assets can decide which object that the LEM should be attached to.
-- Usage example: createLem(Apollo11Lem.Idenfitier)
-- ...where Apollo11Lem is the scene graph node identifier to attach the LEM to.
local asset_helper = asset.require('util/asset_helper')
local sun_transforms = asset.require('scene/solarsystem/sun/transforms')
local models = asset.syncedResource({
Name = "Apollo Models",
Type = "HttpSynchronization",
Identifier = "apollo_lem_model",
Version = 1
})
local partsInfo = {
-- Data is structured as: Geometry file name (except .obj suffix), texture file name, shading
-- Exterior
{ "black", "black.png", true },
{ "blue_glass", "blue_glass.png", true },
{ "booster", "booster3.png", true },
{ "bright_white", "white.png", true },
{ "dark_grey_dish", "dark_gray.png", true },
{ "dull_white", "dull_white.png", true },
{ "gold", "gold.png", true },
{ "light_grey", "light_gray.png", true },
{ "mid_grey", "gray.png", true },
{ "orange", "orange.png", true },
{ "texture_lem_flag", "texture_lem_flag.png", true },
{ "texture_lem_unitedstates", "texture_lem_unitedstates.png", true },
{ "yellow_buttons", "yellow.png", true }
}
asset.export("createLem", function (parentNodeIdentifier)
local parts = {}
for i, info in ipairs(partsInfo) do
parts[#parts + 1] = asset_helper.createModelPart(
parentNodeIdentifier,
sun_transforms.SolarSystemBarycenter.Identifier,
models,
info[1],
info[2],
info[3]
)
end
return parts
end)
@@ -2,7 +2,7 @@ local modelFolder = asset.syncedResource({
Name = "Apollo Lem Models",
Type = "HttpSynchronization",
Identifier = "apollo_lem_model",
Version = 3
Version = 4
})
asset.export('modelFolder', modelFolder)
@@ -650,11 +650,7 @@ local Dawn = {
Renderable = {
Type = "RenderableModel",
Body = "DAWN",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/mainbodydawn.obj",
ColorTexture = textures .. "/gray.png"
}},
GeometryFile = models .. "/mainbodydawn.obj",
LightSources = LightSources
},
GUI = {
@@ -682,11 +678,7 @@ local DawnSolarArray1 = {
Renderable = {
Type = "RenderableModel",
Body = "DAWN",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/solarpanelleft.obj",
ColorTexture = textures .. "/gray.png"
}},
GeometryFile = models .. "/solarpanelleft.obj",
LightSources = LightSources
},
GUI = {
@@ -713,11 +705,7 @@ local DawnSolarArray2 = {
Renderable = {
Type = "RenderableModel",
Body = "DAWN",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/solarpanelright.obj",
ColorTexture = textures .. "/gray.png"
}},
GeometryFile = models .. "/solarpanelright.obj",
LightSources = LightSources
},
GUI = {
@@ -45,11 +45,7 @@ local Vesta = {
},
Renderable = {
Type = "RenderableModelProjection",
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = models .. "/VestaComet_5000.obj",
ColorTexture = textures .. "/dummy.jpg"
},
GeometryFile = models .. "/VestaComet_5000.obj",
BoundingSphereRadius = 10.0,
Projection = {
Sequence = images,
@@ -2,19 +2,11 @@ local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require('./transforms')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local textures = asset.syncedResource({
Name = "Gaia Textures",
Type = "HttpSynchronization",
Identifier = "gaia_textures",
Version = 1
})
local model = asset.syncedResource({
Name = "Gaia Model",
Type = "HttpSynchronization",
Identifier = "gaia_model",
Version = 1
Version = 2
})
@@ -39,11 +31,7 @@ local Gaia = {
Renderable = {
Type = "RenderableModel",
Body = "GAIA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = model .. "/gaia.obj",
ColorTexture = textures .. "/gaia-baked.png"
}},
GeometryFile = model .. "/gaia.obj",
LightSources = {
{
Type = "SceneGraphLightSource",
@@ -2,65 +2,13 @@ asset.require('spice/base')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local assetHelper = asset.require('util/asset_helper')
local models_chutes = asset.syncedResource({
local models = asset.syncedResource({
Name = "Insight Models Chutes",
Type = "HttpSynchronization",
Identifier = "insight_models_chutes",
Version = 1
Identifier = "insight_models",
Version = 2
})
local models_cruise_arrays = asset.syncedResource({
Name = "Insight Models Cruise Arrays",
Type = "HttpSynchronization",
Identifier = "insight_models_cruise_arrays",
Version = 1
})
local models_cruise_cone = asset.syncedResource({
Name = "Insight Models Cruise Cone",
Type = "HttpSynchronization",
Identifier = "insight_models_cruise_cone",
Version = 1
})
local models_lander_lander_deck = asset.syncedResource({
Name = "Insight Models Lander Deck",
Type = "HttpSynchronization",
Identifier = "insight_models_lander_lander_deck",
Version = 1
})
local models_lander_legs_deploy = asset.syncedResource({
Name = "Insight Models Lander Legs Deploy",
Type = "HttpSynchronization",
Identifier = "insight_models_lander_legs_deploy",
Version = 1
})
local models_lander_legs_stow = asset.syncedResource({
Name = "Insight Models Lander Legs Stow",
Type = "HttpSynchronization",
Identifier = "insight_models_lander_legs_stow",
Version = 1
})
local models_lander_panels_deploy = asset.syncedResource({
Name = "Insight Models Lander Panels Deploy",
Type = "HttpSynchronization",
Identifier = "insight_models_lander_panels_deploy",
Version = 1
})
local models_lander_panels_stow = asset.syncedResource({
Name = "Insight Models Lander Panels Stow",
Type = "HttpSynchronization",
Identifier = "insight_models_lander_panels_stow",
Version = 1
})
local ikernels = asset.syncedResource({
Name = "Insight Kernels",
Type = "HttpSynchronization",
@@ -167,11 +115,7 @@ local Insight_Entry_CapsuleA = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_cruise_cone .. "/cruise_insight_doubleside2_newcapsule_diffuse.obj",
ColorTexture = models_cruise_cone .. "/insight_newcapsule_diffuse.jpg"
}},
GeometryFile = models .. "/cruise_insight_doubleside2_newcapsule_diffuse.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -192,11 +136,7 @@ local Insight_Entry_Capsule_Ring = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_cruise_cone .. "/insight_cruise_cone_ring_foil_gold.obj",
ColorTexture = models_cruise_cone .. "/foil_gold_ramp.png"
}},
GeometryFile = models .. "/insight_cruise_cone_ring_foil_gold.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -217,11 +157,7 @@ local Insight_Entry_Capsule_Plugs = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_cruise_cone .. "/insight_cruise_cone_capsule_diffuse.obj",
ColorTexture = models_cruise_cone .. "/insight_capsule_diffuse.png"
}},
GeometryFile = models .. "/insight_cruise_cone_capsule_diffuse.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -242,11 +178,7 @@ local Insight_Entry_Heatshield = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_cruise_cone .. "/insight_cruise_heatshield_foil_gold.obj",
ColorTexture = models_cruise_cone .. "/foil_gold_ramp.png"
}},
GeometryFile = models .. "/insight_cruise_heatshield_foil_gold.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -267,11 +199,7 @@ local Insight_Parachute_0 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_chutes .. "/insight_chute_frame01_diff1.obj",
ColorTexture = models_chutes .. "/chute_diff.png"
}},
GeometryFile = models .. "/insight_chute_frame01_diff1.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -292,11 +220,7 @@ local Insight_Parachute_Cords_0 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_chutes .. "/insight_chute_frame01_cords1.obj",
ColorTexture = models_chutes .. "/foil_gold_ramp.png"
}},
GeometryFile = models .. "/insight_chute_frame01_cords1.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -317,11 +241,7 @@ local Insight_Parachute_20 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_chutes .. "/insight_chute_frame20_diff1.obj",
ColorTexture = models_chutes .. "/chute_diff.png"
}},
GeometryFile = models .. "/insight_chute_frame20_diff1.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -342,11 +262,7 @@ local Insight_Parachute_Cords_20 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_chutes .. "/insight_chute_frame20_cords1.obj",
ColorTexture = models_chutes .. "/foil_gold_ramp.png"
}},
GeometryFile = models .. "/insight_chute_frame20_cords1.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -367,11 +283,7 @@ local Insight_Parachute_40 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_chutes .. "/chute_doubleside_frame40_diff.obj",
ColorTexture = models_chutes .. "/chute_diff.png"
}},
GeometryFile = models .. "/chute_doubleside_frame40_diff.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -392,11 +304,7 @@ local Insight_Parachute_Cords_40 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_chutes .. "/insight_chute_frame40_cords1.obj",
ColorTexture = models_chutes .. "/foil_gold_ramp.png"
}},
GeometryFile = models .. "/insight_chute_frame40_cords1.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -417,11 +325,7 @@ local Insight_Lander_A001 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO01.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_01.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -442,11 +346,7 @@ local Insight_Lander_A002 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO02.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_02.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO02.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -467,11 +367,7 @@ local Insight_Lander_A003 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO03.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_03.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO03.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -492,11 +388,7 @@ local Insight_Lander_A004 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO04.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_04.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO04.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -517,11 +409,7 @@ local Insight_Lander_A005 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO05.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_05.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO05.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -542,11 +430,7 @@ local Insight_Lander_A006 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO06.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_06.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO06.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -567,11 +451,7 @@ local Insight_Lander_A007 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO07.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_07.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO07.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -592,11 +472,7 @@ local Insight_Lander_A008 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO08.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_08.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_AO08.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -617,11 +493,7 @@ local Insight_Lander_foil1 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_foil1.obj",
ColorTexture = models_lander_lander_deck .. "/foil_silver_ramp.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_foil1.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -642,11 +514,7 @@ local Insight_Lander_Tex01 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_tex01.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_tex_01.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_tex01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -667,11 +535,7 @@ local Insight_Lander_Tex02 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_tex02.obj",
ColorTexture = models_lander_lander_deck .. "/InSIGHT_tex_02.jpg"
}},
GeometryFile = models .. "/insight_lander_deck_tex02.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -692,11 +556,7 @@ local Insight_Legs_Stowed_tex = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_legs_stow .. "/insight_lander_legs_stow_tex01.obj",
ColorTexture = models_lander_legs_stow .. "/InSIGHT_tex_01.jpg"
}},
GeometryFile = models .. "/insight_lander_legs_stow_tex01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -717,11 +577,7 @@ local Insight_Legs_Stowed_AO06 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_legs_stow .. "/insight_lander_legs_stow_AO06.obj",
ColorTexture = models_lander_legs_stow .. "/InSIGHT_AO_06.jpg"
}},
GeometryFile = models .. "/insight_lander_legs_stow_AO06.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -742,11 +598,7 @@ local Insight_Legs_Deployed_tex = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_legs_deploy .. "/insight_lander_legs_deploy_tex01.obj",
ColorTexture = models_lander_legs_deploy .. "/InSIGHT_tex_01.jpg"
}},
GeometryFile = models .. "/insight_lander_legs_deploy_tex01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -767,11 +619,7 @@ local Insight_Legs_Deployed_AO06 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_legs_deploy .. "/insight_lander_legs_deploy_AO06.obj",
ColorTexture = models_lander_legs_deploy .. "/InSIGHT_AO_06.jpg"
}},
GeometryFile = models .. "/insight_lander_legs_deploy_AO06.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -792,11 +640,7 @@ local Insight_Panels_Stowed_tex = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_tex01.obj",
ColorTexture = models_lander_panels_stow .. "/InSIGHT_tex_01.jpg"
}},
GeometryFile = models .. "/insight_lander_panels_stow_tex01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -817,11 +661,7 @@ local Insight_Panels_Stowed_tex2 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_tex02.obj",
ColorTexture = models_lander_panels_stow .. "/InSIGHT_tex_02.jpg"
}},
GeometryFile = models .. "/insight_lander_panels_stow_tex02.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -842,11 +682,7 @@ local Insight_Panels_Stowed_AO01 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_AO01.obj",
ColorTexture = models_lander_panels_stow .. "/InSIGHT_AO_01.jpg"
}},
GeometryFile = models .. "/insight_lander_panels_stow_AO01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -867,11 +703,7 @@ local Insight_Panels_Deployed_tex = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_tex01.obj",
ColorTexture = models_lander_panels_deploy .. "/InSIGHT_tex_01.jpg"
}},
GeometryFile = models .. "/insight_lander_panels_deploy_tex01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -892,11 +724,7 @@ local Insight_Panels_Deployed_tex2 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_tex02.obj",
ColorTexture = models_lander_panels_deploy .. "/InSIGHT_tex_02.jpg"
}},
GeometryFile = models .. "/insight_lander_panels_deploy_tex02.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -917,11 +745,7 @@ local Insight_Panels_Deployed_AO06 = {
Parent = Insight.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_AO01.obj",
ColorTexture = models_lander_panels_deploy .. "/InSIGHT_AO_01.jpg"
}},
GeometryFile = models .. "/insight_lander_panels_deploy_AO01.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources,
},
@@ -3,18 +3,11 @@ local transforms = asset.require('scene/solarsystem/planets/jupiter/transforms')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local textures = asset.syncedResource({
Name = "Juno Textures",
Type = "HttpSynchronization",
Identifier = "juno_textures",
Version = 1
})
local model = asset.syncedResource({
Name = "Juno Model",
Type = "HttpSynchronization",
Identifier = "juno_model",
Version = 1
Version = 2
})
@@ -157,11 +150,7 @@ local Juno = {
},
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = model .. "/Juno.obj",
ColorTexture = textures .. "/gray.png"
}},
GeometryFile = model .. "/Juno.obj",
ModelTransform = RotationMatrix,
LightSources = assetHelper.getDefaultLightSources(sunTransforms.SolarSystemBarycenter.Identifier)
},
@@ -189,7 +178,7 @@ local JunoTrail = {
Color = { 0.70, 0.50, 0.20 },
StartTime = "2016 JUL 01",
EndTime = "2016 DEC 13",
SampleInterval = 2
SampleInterval = 3600
},
GUI = {
Name = "Juno Trail",
@@ -7,7 +7,7 @@ local models = asset.syncedResource({
Name = "Messenger Models",
Type = "HttpSynchronization",
Identifier = "messenger_model",
Version = 1
Version = 2
})
local kernels = asset.syncedResource({
@@ -92,11 +92,7 @@ local MessengerProbeBlack = {
Parent = Messenger.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/MessengerProbe_black.obj",
ColorTexture = models .. "/Tex_black.png"
}},
GeometryFile = models .. "/MessengerProbe_black.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -111,11 +107,7 @@ local MessengerProbeFoil = {
Parent = Messenger.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/MessengerProbe_foil.obj",
ColorTexture = models .. "/foil_n2.png"
}},
GeometryFile = models .. "/MessengerProbe_foil.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -130,11 +122,7 @@ local MessengerProbeHeatShield = {
Parent = Messenger.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/MessengerProbe_heatShield.obj",
ColorTexture = models .. "/AO_heatshield4.png"
}},
GeometryFile = models .. "/MessengerProbe_heatShield.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -149,11 +137,7 @@ local MessengerProbeMetal = {
Parent = Messenger.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/MessengerProbe_metal.obj",
ColorTexture = models .. "/Tex_grey.png"
}},
GeometryFile = models .. "/MessengerProbe_metal.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -169,11 +153,7 @@ local MessengerProbePanels = {
Parent = Messenger.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/MessengerProbe_panels.obj",
ColorTexture = models .. "/Messenger_tex.png"
}},
GeometryFile = models .. "/MessengerProbe_panels.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -14,11 +14,7 @@ local Labels = {
Renderable = {
Type = "RenderableModel",
Body = "NEW HORIZONS",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/Labels.obj",
ColorTexture = textures .. "/labels.png"
}},
GeometryFile = models .. "/Labels.obj",
AmbientIntensity = 0.8
},
GUI = {
@@ -2,18 +2,11 @@ local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require('./transforms')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local textures = asset.syncedResource({
Name = "New Horizons Textures",
Type = "HttpSynchronization",
Identifier = "newhorizons_textures",
Version = 3
})
local models = asset.syncedResource({
Name = "New Horizons Model",
Type = "HttpSynchronization",
Identifier = "newhorizons_model",
Version = 1
Version = 2
})
local NewHorizons = {
@@ -22,11 +15,7 @@ local NewHorizons = {
Renderable = {
Type = "RenderableModel",
Body = "NEW HORIZONS",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/NewHorizonsCleanModel.obj",
ColorTexture = textures .. "/NHTexture.jpg"
}},
GeometryFile = models .. "/NewHorizonsCleanModel.obj",
AmbientIntensity = 0.0,
DiffuseIntensity = 1.0,
SpecularIntensity = 1.0,
@@ -51,5 +40,4 @@ local NewHorizons = {
}
assetHelper.registerSceneGraphNodesAndExport(asset, { NewHorizons })
asset.export("NewHorizonsTextures", textures)
asset.export("NewHorizonsModels", models)
@@ -2,15 +2,6 @@ local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require('./transforms')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local textures = asset.syncedResource({
Name = "Bennu Textures",
Type = "HttpSynchronization",
Identifier = "bennu_textures",
Version = 1
})
local models = asset.syncedResource({
Name = "Bennu Models",
Type = "HttpSynchronization",
@@ -34,11 +25,7 @@ local Bennu = {
Renderable = {
Type = "RenderableModelProjection",
Body = BENNU_BODY,
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = models .. "/BennuTextured.obj",
ColorTexture = textures .. "/gray.png"
},
GeometryFile = models .. "/BennuUntextured.obj",
Projection = {
Sequence = asset.localResource('InstrumentTimes'),
SequenceType = "instrument-times",
@@ -12,18 +12,11 @@ local kernels = asset.syncedResource({
Version = 1
})
local textures = asset.syncedResource({
Name = "Osiris Rex Textures",
Type = "HttpSynchronization",
Identifier = "osirisrex_textures",
Version = 1
})
local models = asset.syncedResource({
Name = "Osiris Rex Models",
Type = "HttpSynchronization",
Identifier = "osirisrex_models",
Version = 1
Version = 2
})
local BENNU_BODY = "2101955"
@@ -216,11 +209,7 @@ local OsirisRex = {
Renderable = {
Type = "RenderableModel",
Body = "OSIRIS-REX",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/orx_base_resized_12_sep_2016.obj",
ColorTexture = textures .. "/osirisTex.png"
}},
GeometryFile = models .. "/orx_base_resized_12_sep_2016.obj",
LightSources = LightSources
},
GUI = {
@@ -246,11 +235,7 @@ local PolyCam = {
Renderable = {
Type = "RenderableModel",
Body = "OSIRIS-REX",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/orx_polycam_resized_12_sep_2016.obj",
ColorTexture = textures .. "/osirisTex.png"
}},
GeometryFile = models .. "/orx_polycam_resized_12_sep_2016.obj",
LightSources = LightSources
},
GUI = {
@@ -265,11 +250,7 @@ local Rexis = {
Renderable = {
Type = "RenderableModel",
Body = "OSIRIS-REX",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/orx_rexis_resized_12_sep_2016.obj",
ColorTexture = textures .. "/osirisTex.png"
}},
GeometryFile = models .. "/orx_rexis_resized_12_sep_2016.obj",
LightSources = LightSources
},
Transform = {
File diff suppressed because it is too large Load Diff
@@ -54,11 +54,7 @@ local Comet67P = {
},
Renderable = {
Type = "RenderableModelProjection",
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = models .. "/67P_rotated_5_130.obj",
ColorTexture = textures .. "/gray.jpg"
},
GeometryFile = models .. "/67P_rotated_5_130.obj",
Projection = {
Sequence = { imagesDestination },
SequenceType = "image-sequence",
@@ -3,19 +3,11 @@ local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local transforms = asset.require('./67p')
local textures = asset.syncedResource({
Name = "Rosetta Textures",
Type = "HttpSynchronization",
Identifier = "rosetta_textures",
Version = 2
})
local models = asset.syncedResource({
Name = "Rosetta Models",
Type = "HttpSynchronization",
Identifier = "rosetta_model",
Version = 3
Version = 4
})
local kernels = asset.syncedResource({
@@ -138,11 +130,7 @@ local RosettaBlackFoil = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/black_foil.obj",
ColorTexture = textures .. "/foil_silver_ramp.png"
}},
GeometryFile = models .. "/black_foil.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -158,11 +146,7 @@ local RosettaBlackParts = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/black_parts.obj",
ColorTexture = textures .. "/foil_silver_ramp.png"
}},
GeometryFile = models .. "/black_parts.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -178,11 +162,7 @@ local RosettaDish = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/dish.obj",
ColorTexture = textures .. "/dish_AO.png"
}},
GeometryFile = models .. "/dish.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -198,11 +178,7 @@ local RosettaParts = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/parts.obj",
ColorTexture = textures .. "/parts2_AO.png"
}},
GeometryFile = models .. "/parts.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -218,11 +194,7 @@ local RosettaSilverFoil = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/silver_foil.obj",
ColorTexture = textures .. "/foil_silver_ramp.png"
}},
GeometryFile = models .. "/silver_foil.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -238,11 +210,7 @@ local RosettaVents = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/vents.obj",
ColorTexture = textures .. "/tex_01.png"
}},
GeometryFile = models .. "/vents.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -258,11 +226,7 @@ local RosettaWingA = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .."/wingA.obj",
ColorTexture = textures .. "/tex_01.png"
}},
GeometryFile = models .."/wingA.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -278,11 +242,7 @@ local RosettaWingB = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/wingB.obj",
ColorTexture = textures .. "/tex_01.png"
}},
GeometryFile = models .. "/wingB.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -298,11 +258,7 @@ local RosettaYellowFoil = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/yellow_foil.obj",
ColorTexture = textures .. "/foil_gold_ramp.png"
}},
GeometryFile = models .. "/yellow_foil.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -347,11 +303,7 @@ local PhilaeFoil = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/lander_foil.obj",
ColorTexture = textures .. "/foil_silver_ramp.png"
}},
GeometryFile = models .. "/lander_foil.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -367,11 +319,7 @@ local PhilaeLids = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/lander_lids.obj",
ColorTexture = textures .. "/parts2_AO.png"
}},
GeometryFile = models .. "/lander_lids.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -387,11 +335,7 @@ local PhilaeParts = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/lander_parts.obj",
ColorTexture = textures .. "/foil_silver_ramp.png"
}},
GeometryFile = models .. "/lander_parts.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -407,11 +351,7 @@ local PhilaeSolarPanels = {
Renderable = {
Type = "RenderableModel",
Body = "ROSETTA",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/lander_solarp.obj",
ColorTexture = textures .. "/tex_01.png"
}},
GeometryFile = models .. "/lander_solarp.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -463,7 +403,7 @@ local ImagePlane = {
Spacecraft = "ROSETTA",
Instrument = "ROS_NAVCAM-A",
Moving = false,
Texture = textures .. "/defaultProj.png"
Texture = models .. "/defaultProj.png"
},
GUI = {
Name = "Rosetta Image Plane",
@@ -0,0 +1,8 @@
local models = asset.syncedResource({
Name = "New Horizons Model",
Type = "HttpSynchronization",
Identifier = "voyager_model",
Version = 1
})
asset.export('modelFolder', models)
@@ -1,14 +1,6 @@
local assetHelper = asset.require('util/asset_helper')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local models = asset.syncedResource({
Name = "Voyager 1 Models",
Type = "HttpSynchronization",
Identifier = "voyager1_model",
Version = 1
})
local models = asset.require("./model" ).modelFolder;
local kernels = asset.syncedResource({
Name = "Voyager 1 Kernels",
@@ -80,11 +72,7 @@ local Voyager1Main = {
Parent = Voyager1.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/voyager-main.obj",
ColorTexture = models .. "/voyager-main.jpg"
}},
GeometryFile = models .. "/voyager-main.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -99,11 +87,7 @@ local Voyager1Antenna = {
Parent = Voyager1.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/voyager-antenna.obj",
ColorTexture = models .. "/voyager-antenna.png"
}},
GeometryFile = models .. "/voyager-antenna.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -1,15 +1,8 @@
local assetHelper = asset.require('util/asset_helper')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local models = asset.require("./model" ).modelFolder;
local models = asset.syncedResource({
Name = "Voyager 2 Models",
Type = "HttpSynchronization",
Identifier = "voyager2_model",
Version = 1
})
local kernels = asset.syncedResource({
Name = "Voyager 2 Kernels",
Type = "HttpSynchronization",
@@ -83,11 +76,7 @@ local Voyager2Main = {
Parent = Voyager2.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/voyager-main.obj",
ColorTexture = models .. "/voyager-main.jpg"
}},
GeometryFile = models .. "/voyager-main.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -102,11 +91,7 @@ local Voyager2Antenna = {
Parent = Voyager2.Identifier,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/voyager-antenna.obj",
ColorTexture = models .. "/voyager-antenna.png"
}},
GeometryFile = models .. "/voyager-antenna.obj",
ModelTransform = RotationMatrix,
LightSources = LightSources
},
@@ -59,153 +59,36 @@ local initializeAndAddNodes = function()
},
Renderable = {
Type = "RenderableModel",
Geometry = {
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/0.obj",
ColorTexture = models .. "/0.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/1.obj",
ColorTexture = models .. "/1.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/2.obj",
ColorTexture = models .. "/2.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/3.obj",
ColorTexture = models .. "/3.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/4.obj",
ColorTexture = models .. "/4.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/5.obj",
ColorTexture = models .. "/5.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/6.obj",
ColorTexture = models .. "/6.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/7.obj",
ColorTexture = models .. "/7.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/8.obj",
ColorTexture = models .. "/8.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/10.obj",
ColorTexture = models .. "/10.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/11.obj",
ColorTexture = models .. "/11.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/13.obj",
ColorTexture = models .. "/13.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/14.obj",
ColorTexture = models .. "/14.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/15.obj",
ColorTexture = models .. "/15.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/16.obj",
ColorTexture = models .. "/16.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/17.obj",
ColorTexture = models .. "/17.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/19.obj",
ColorTexture = models .. "/19.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/21.obj",
ColorTexture = models .. "/21.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/22.obj",
ColorTexture = models .. "/22.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/23.obj",
ColorTexture = models .. "/23.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/24.obj",
ColorTexture = models .. "/24.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/25.obj",
ColorTexture = models .. "/25.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/foilsilver.obj",
ColorTexture = models .. "/foilsilver.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/olive.obj",
ColorTexture = models .. "/olive.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/basemetal.obj",
ColorTexture = models .. "/basemetal.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/white_20.obj",
ColorTexture = models .. "/white_20.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/plasticblack.obj",
ColorTexture = models .. "/plasticblack.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/ecostresswhite.obj",
ColorTexture = models .. "/ecostresswhite.png"
},
{
Type = "MultiModelGeometry",
GeometryFile = models .. "/plain.obj",
ColorTexture = models .. "/plain.png"
},
GeometryFile = {
models .. "/0.obj",
models .. "/1.obj",
models .. "/2.obj",
models .. "/3.obj",
models .. "/4.obj",
models .. "/5.obj",
models .. "/6.obj",
models .. "/7.obj",
models .. "/8.obj",
models .. "/10.obj",
models .. "/11.obj",
models .. "/13.obj",
models .. "/14.obj",
models .. "/15.obj",
models .. "/16.obj",
models .. "/17.obj",
models .. "/19.obj",
models .. "/21.obj",
models .. "/22.obj",
models .. "/23.obj",
models .. "/24.obj",
models .. "/25.obj",
models .. "/foilsilver.obj",
models .. "/olive.obj",
models .. "/basemetal.obj",
models .. "/white_20.obj",
models .. "/plasticblack.obj",
models .. "/ecostresswhite.obj",
models .. "/plain.obj"
},
LightSources = {
{
@@ -21,7 +21,19 @@ local Saturn = {
SegmentsPerPatch = 64,
Layers = {},
Rings = {
Texture = texturesPath .. "/saturn_rings.png",
-- Single Texture Values:
--Texture = texturesPath .. "/saturn_rings.png",
--ColorFilter = 0.15,
-- MultiTexture Valeus:
TextureFwrd = texturesPath .. "/forward_original_single.png",
TextureBckwrd = texturesPath .. "/back_original_single.png",
TextureUnlit = texturesPath .. "/unlit_original_single.png",
TextureColor = texturesPath .. "/color_original_single.png",
TextureTransparency = texturesPath .. "/trans_original_single.png",
ColorFilter = 0.8,
NightFactor = 1.0,
Size = 140445000,
Offset = { 74500 / 140445.100671159, 1.0 }, -- min / max extend
},
@@ -2,6 +2,6 @@ local TexturesPath = asset.syncedResource({
Type = "HttpSynchronization",
Name = "Saturn textures",
Identifier = "saturn_textures",
Version = 3
Version = 4
})
asset.export("TexturesPath", TexturesPath)
+1 -5
View File
@@ -165,11 +165,7 @@ local createModelPart = function (parent, sunLightSourceNode, models, geometry,
Parent = parent,
Renderable = {
Type = "RenderableModel",
Geometry = {{
Type = "MultiModelGeometry",
GeometryFile = models .. "/" .. geometry .. ".obj",
ColorTexture = models .. "/" .. texture
}},
GeometryFile = models .. "/" .. geometry .. ".obj",
LightSources = lightSources,
PerformShading = performShading,
DisableFaceCulling = true
@@ -99,6 +99,7 @@ public:
void writeSceneDocumentation();
void writeStaticDocumentation();
void createUserDirectoriesIfNecessary();
/**
* Returns the Lua library that contains all Lua functions available to affect the
-4
View File
@@ -38,8 +38,6 @@ set(HEADER_FILES
dashboard/dashboarditemvelocity.h
lightsource/cameralightsource.h
lightsource/scenegraphlightsource.h
rendering/modelgeometry.h
rendering/multimodelgeometry.h
rendering/grids/renderableboxgrid.h
rendering/grids/renderablegrid.h
rendering/grids/renderableradialgrid.h
@@ -91,8 +89,6 @@ set(SOURCE_FILES
dashboard/dashboarditemvelocity.cpp
lightsource/cameralightsource.cpp
lightsource/scenegraphlightsource.cpp
rendering/modelgeometry.cpp
rendering/multimodelgeometry.cpp
rendering/grids/renderableboxgrid.cpp
rendering/grids/renderablegrid.cpp
rendering/grids/renderableradialgrid.cpp
+3 -12
View File
@@ -51,8 +51,6 @@
#include <modules/base/rendering/renderabletrailtrajectory.h>
#include <modules/base/rendering/renderableplaneimagelocal.h>
#include <modules/base/rendering/renderableplaneimageonline.h>
#include <modules/base/rendering/modelgeometry.h>
#include <modules/base/rendering/multimodelgeometry.h>
#include <modules/base/rendering/screenspacedashboard.h>
#include <modules/base/rendering/screenspaceimagelocal.h>
#include <modules/base/rendering/screenspaceimageonline.h>
@@ -87,10 +85,6 @@ ghoul::opengl::TextureManager BaseModule::TextureManager;
BaseModule::BaseModule() : OpenSpaceModule(BaseModule::Name) {}
void BaseModule::internalInitialize(const ghoul::Dictionary&) {
FactoryManager::ref().addFactory(
std::make_unique<ghoul::TemplateFactory<modelgeometry::ModelGeometry>>(),
"ModelGeometry"
);
FactoryManager::ref().addFactory(
std::make_unique<ghoul::TemplateFactory<ScreenSpaceRenderable>>(),
"ScreenSpaceRenderable"
@@ -179,10 +173,6 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
fLightSource->registerClass<CameraLightSource>("CameraLightSource");
fLightSource->registerClass<SceneGraphLightSource>("SceneGraphLightSource");
auto fGeometry = FactoryManager::ref().factory<modelgeometry::ModelGeometry>();
ghoul_assert(fGeometry, "Model geometry factory was not created");
fGeometry->registerClass<modelgeometry::MultiModelGeometry>("MultiModelGeometry");
}
void BaseModule::internalDeinitializeGL() {
@@ -207,6 +197,8 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
RenderableModel::Documentation(),
RenderableNodeLine::Documentation(),
RenderablePlane::Documentation(),
RenderablePlaneImageLocal::Documentation(),
RenderablePlaneImageOnline::Documentation(),
RenderableRadialGrid::Documentation(),
RenderableDisc::Documentation(),
RenderableSphere::Documentation(),
@@ -225,6 +217,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
TimelineRotation::Documentation(),
LuaScale::Documentation(),
NonUniformStaticScale::Documentation(),
StaticScale::Documentation(),
TimeDependentScale::Documentation(),
@@ -237,8 +230,6 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
SceneGraphLightSource::Documentation(),
CameraLightSource::Documentation(),
modelgeometry::ModelGeometry::Documentation(),
};
}
@@ -58,7 +58,7 @@ namespace {
struct [[codegen::Dictionary(RenderableBoxGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
std::optional<glm::vec3> color [[codegen::color()]];
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
@@ -65,7 +65,7 @@ namespace {
struct [[codegen::Dictionary(RenderableGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
std::optional<glm::vec3> color [[codegen::color()]];
// [[codegen::verbatim(SegmentsInfo.description)]]
std::optional<glm::ivec2> segments;
@@ -80,7 +80,7 @@ namespace {
struct [[codegen::Dictionary(RenderableRadialGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
std::optional<glm::vec3> color [[codegen::color()]];
// [[codegen::verbatim(GridSegmentsInfo.description)]]
std::optional<glm::ivec2> gridSegments;
@@ -59,7 +59,7 @@ namespace {
struct [[codegen::Dictionary(RenderableSphericalGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
std::optional<glm::vec3> color [[codegen::color()]];
// [[codegen::verbatim(SegmentsInfo.description)]]
std::optional<int> segments;
-344
View File
@@ -1,344 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderable.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/memorymanager.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/invariants.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/misc/templatefactory.h>
#include <fstream>
namespace {
constexpr const char* _loggerCat = "ModelGeometry";
constexpr const char* KeyType = "Type";
constexpr const char* KeyGeomModelFile = "GeometryFile";
constexpr const char* KeyColorTexture = "ColorTexture";
constexpr const int8_t CurrentCacheVersion = 3;
} // namespace
namespace openspace::modelgeometry {
documentation:: Documentation ModelGeometry::Documentation() {
using namespace documentation;
return {
"Model Geometry",
"base_geometry_model",
{
{
KeyType,
new StringVerifier,
Optional::No,
"The type of the Model Geometry that should be generated"
},
{
KeyGeomModelFile,
new StringVerifier,
Optional::No,
"The file that should be loaded in this ModelGeometry. The file can "
"contain filesystem tokens or can be specified relatively to the "
"location of the .mod file."
},
{
KeyColorTexture,
new StringVerifier,
Optional::Yes,
"This value points to a color texture file that is applied to the "
"geometry rendered in this object."
}
}
};
}
ghoul::mm_unique_ptr<ModelGeometry> ModelGeometry::createFromDictionary(
const ghoul::Dictionary& dictionary)
{
if (!dictionary.hasValue<std::string>(KeyType)) {
throw ghoul::RuntimeError("Dictionary did not contain a key 'Type'");
}
const std::string& geometryType = dictionary.value<std::string>(KeyType);
auto factory = FactoryManager::ref().factory<ModelGeometry>();
ModelGeometry* geometry = factory->create(
geometryType,
dictionary,
&global::memoryManager->PersistentMemory
);
return ghoul::mm_unique_ptr<ModelGeometry>(geometry);
}
ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ModelGeometry"
);
_file = absPath(dictionary.value<std::string>(KeyGeomModelFile));
if (dictionary.hasKey(KeyColorTexture)) {
_colorTexturePath = absPath(dictionary.value<std::string>(KeyColorTexture));
}
}
double ModelGeometry::boundingRadius() const {
return _boundingRadius;
}
void ModelGeometry::bindTexture() {
if (_texture) {
_texture->bind();
}
}
void ModelGeometry::render() {
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glDrawElements(
_mode,
static_cast<GLsizei>(_indices.size()),
GL_UNSIGNED_INT,
nullptr
);
glBindVertexArray(0);
}
void ModelGeometry::changeRenderMode(GLenum mode) {
_mode = mode;
}
bool ModelGeometry::initialize(Renderable* parent) {
ZoneScoped
float maximumDistanceSquared = 0;
for (const Vertex& v : _vertices) {
maximumDistanceSquared = glm::max(
glm::pow(v.location[0], 2.f) +
glm::pow(v.location[1], 2.f) +
glm::pow(v.location[2], 2.f), maximumDistanceSquared);
}
_boundingRadius = maximumDistanceSquared;
parent->setBoundingSphere(glm::sqrt(maximumDistanceSquared));
if (_vertices.empty()) {
return false;
}
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vbo);
glGenBuffers(1, &_ibo);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(
GL_ARRAY_BUFFER,
_vertices.size() * sizeof(Vertex),
_vertices.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr);
glVertexAttribPointer(
1,
2,
GL_FLOAT,
GL_FALSE,
sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)) // NOLINT
);
glVertexAttribPointer(
2,
3,
GL_FLOAT,
GL_FALSE,
sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)) // NOLINT
);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glBufferData(
GL_ELEMENT_ARRAY_BUFFER,
_indices.size() * sizeof(int),
_indices.data(),
GL_STATIC_DRAW
);
glBindVertexArray(0);
if (!_colorTexturePath.empty()) {
_texture = ghoul::io::TextureReader::ref().loadTexture(
absPath(_colorTexturePath)
);
if (_texture) {
LDEBUGC(
"RenderableModel",
fmt::format("Loaded texture from '{}'", absPath(_colorTexturePath))
);
_texture->uploadTexture();
_texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_texture->purgeFromRAM();
}
}
return true;
}
void ModelGeometry::deinitialize() {
glDeleteBuffers(1, &_vbo);
glDeleteVertexArrays(1, &_vaoID);
glDeleteBuffers(1, &_ibo);
_texture = nullptr;
}
bool ModelGeometry::loadObj(const std::string& filename) {
const std::string& cachedFile = FileSys.cacheManager()->cachedFilename(
filename,
ghoul::filesystem::CacheManager::Persistent::Yes
);
const bool hasCachedFile = FileSys.fileExists(cachedFile);
if (hasCachedFile) {
LINFO(fmt::format("Cached file '{}' used for file '{}", cachedFile, filename));
const bool success = loadCachedFile(cachedFile);
if (success) {
return true;
}
else {
FileSys.cacheManager()->removeCacheFile(filename);
}
}
else {
LINFO(fmt::format(
"Cached file '{}' for file '{}' not found",
cachedFile,
filename
));
}
LINFO(fmt::format("Loading Model file '{}'", filename));
const bool modelSuccess = loadModel(filename);
if (!modelSuccess) {
return false;
}
LINFO("Saving cache");
const bool cacheSuccess = saveCachedFile(cachedFile);
return cacheSuccess;
}
bool ModelGeometry::saveCachedFile(const std::string& filename) {
std::ofstream fileStream(filename, std::ofstream::binary);
if (fileStream.good()) {
fileStream.write(
reinterpret_cast<const char*>(&CurrentCacheVersion),
sizeof(int8_t)
);
const int64_t vSize = _vertices.size();
fileStream.write(reinterpret_cast<const char*>(&vSize), sizeof(int64_t));
const int64_t iSize = _indices.size();
fileStream.write(reinterpret_cast<const char*>(&iSize), sizeof(int64_t));
fileStream.write(
reinterpret_cast<const char*>(_vertices.data()),
sizeof(Vertex) * vSize
);
fileStream.write(
reinterpret_cast<const char*>(_indices.data()),
sizeof(int) * iSize
);
return fileStream.good();
}
else {
LERROR(fmt::format("Error opening file '{}' for save cache file", filename));
return false;
}
}
bool ModelGeometry::loadCachedFile(const std::string& filename) {
std::ifstream fileStream(filename, std::ifstream::binary);
if (fileStream.good()) {
int8_t version = 0;
fileStream.read(reinterpret_cast<char*>(&version), sizeof(int8_t));
if (version != CurrentCacheVersion) {
LINFO("The format of the cached file has changed, deleting old cache");
fileStream.close();
FileSys.deleteFile(filename);
return false;
}
int64_t vSize;
fileStream.read(reinterpret_cast<char*>(&vSize), sizeof(int64_t));
int64_t iSize;
fileStream.read(reinterpret_cast<char*>(&iSize), sizeof(int64_t));
if (vSize == 0 || iSize == 0) {
LERROR(
fmt::format("Error opening file '{}' for loading cache file", filename)
);
return false;
}
_vertices.resize(vSize);
_indices.resize(iSize);
fileStream.read(
reinterpret_cast<char*>(_vertices.data()), sizeof(Vertex) * vSize
);
fileStream.read(reinterpret_cast<char*>(_indices.data()), sizeof(int) * iSize);
return fileStream.good();
}
else {
LERROR(fmt::format(
"Error opening file '{}' for loading cache file",
filename
));
return false;
}
}
void ModelGeometry::setUniforms(ghoul::opengl::ProgramObject&) {}
} // namespace openspace::modelgeometry
-93
View File
@@ -1,93 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__
#define __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__
#include <ghoul/misc/managedmemoryuniqueptr.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/opengl/texture.h>
#include <memory>
namespace ghoul { class Dictionary; }
namespace ghoul::opengl { class ProgramObject; }
namespace openspace { class Renderable; }
namespace openspace::documentation { struct Documentation; }
namespace openspace::modelgeometry {
class ModelGeometry {
public:
struct Vertex {
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
};
static ghoul::mm_unique_ptr<ModelGeometry> createFromDictionary(
const ghoul::Dictionary& dictionary
);
ModelGeometry(const ghoul::Dictionary& dictionary);
virtual ~ModelGeometry() = default;
virtual bool initialize(Renderable* parent);
virtual void deinitialize();
void bindTexture();
void render();
virtual bool loadModel(const std::string& filename) = 0;
void changeRenderMode(const GLenum mode);
//bool getVertices(std::vector<Vertex>* vertexList);
//bool getIndices(std::vector<int>* indexList);
double boundingRadius() const;
virtual void setUniforms(ghoul::opengl::ProgramObject& program);
static documentation::Documentation Documentation();
protected:
bool loadObj(const std::string& filename);
bool loadCachedFile(const std::string& filename);
bool saveCachedFile(const std::string& filename);
GLuint _vaoID = 0;
GLuint _vbo = 0;
GLuint _ibo = 0 ;
GLenum _mode = GL_TRIANGLES;
double _boundingRadius = 0.0;
std::string _colorTexturePath;
std::unique_ptr<ghoul::opengl::Texture> _texture;
std::vector<Vertex> _vertices;
std::vector<int> _indices;
std::string _file;
};
} // namespace openspace::modelgeometry
#endif // __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__
@@ -1,60 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/rendering/multimodelgeometry.h>
#include <ghoul/io/model/modelreadermultiformat.h>
#include <cstring>
namespace openspace::modelgeometry {
MultiModelGeometry::MultiModelGeometry(const ghoul::Dictionary& dictionary)
: ModelGeometry(dictionary)
{
loadObj(_file);
}
bool MultiModelGeometry::loadModel(const std::string& filename) {
std::vector<ghoul::io::ModelReaderBase::Vertex> vertices;
std::vector<int> indices;
ghoul::io::ModelReaderMultiFormat().loadModel(filename, vertices, indices);
_vertices.reserve(vertices.size());
for (const ghoul::io::ModelReaderBase::Vertex& v : vertices) {
Vertex vv {};
memcpy(vv.location, v.location, sizeof(GLfloat) * 3);
vv.location[3] = 1.0;
//memcpy(vv.location, glm::value_ptr(p.vec4()), sizeof(GLfloat) * 4);
memcpy(vv.tex, v.tex, sizeof(GLfloat) * 2);
memcpy(vv.normal, v.normal, sizeof(GLfloat) * 3);
_vertices.push_back(vv);
}
_indices.resize(indices.size());
std::copy(indices.begin(), indices.end(), _indices.begin());
return true;
}
} // namespace openspace::modelgeometry
@@ -60,13 +60,13 @@ namespace {
struct [[codegen::Dictionary(RenderableCartesianAxes)]] Parameters {
// [[codegen::verbatim(XColorInfo.description)]]
std::optional<glm::vec3> xColor;
std::optional<glm::vec3> xColor [[codegen::color()]];
// [[codegen::verbatim(YColorInfo.description)]]
std::optional<glm::vec3> yColor;
std::optional<glm::vec3> yColor [[codegen::color()]];
// [[codegen::verbatim(ZColorInfo.description)]]
std::optional<glm::vec3> zColor;
std::optional<glm::vec3> zColor [[codegen::color()]];
};
#include "renderablecartesianaxes_codegen.cpp"
@@ -83,24 +83,9 @@ documentation::Documentation RenderableCartesianAxes::Documentation() {
RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _program(nullptr)
, _xColor(
XColorInfo,
glm::vec3(1.f, 0.f, 0.f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _yColor(
YColorInfo,
glm::vec3(0.f, 1.f, 0.f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _zColor(
ZColorInfo,
glm::vec3(0.f, 0.f, 1.f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _xColor(XColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
, _yColor(YColorInfo, glm::vec3(0.f, 1.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
, _zColor(ZColorInfo, glm::vec3(0.f, 0.f, 1.f), glm::vec3(0.f), glm::vec3(1.f))
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_xColor = p.xColor.value_or(_xColor);
+22 -38
View File
@@ -35,6 +35,8 @@
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
#include <filesystem>
#include <optional>
namespace {
constexpr const char _loggerCat[] = "RenderableDisc";
@@ -63,36 +65,26 @@ namespace {
"based on the given size and this value should be set between 0 and 1. A value "
"of 1 results in a full circle and 0.5 a disc with an inner radius of 0.5*size."
};
struct [[codegen::Dictionary(RenderableDisc)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::filesystem::path texture;
// [[codegen::verbatim(SizeInfo.description)]]
std::optional<float> size;
// [[codegen::verbatim(WidthInfo.description)]]
std::optional<float> width;
};
#include "renderabledisc_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableDisc::Documentation() {
using namespace documentation;
return {
"Renderable Disc",
"renderable_disc",
{
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description
},
{
SizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
SizeInfo.description
},
{
WidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
WidthInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_disc";
return doc;
}
RenderableDisc::RenderableDisc(const ghoul::Dictionary& dictionary)
@@ -101,27 +93,20 @@ RenderableDisc::RenderableDisc(const ghoul::Dictionary& dictionary)
, _size(SizeInfo, 1.f, 0.f, 1e13f)
, _width(WidthInfo, 0.5f, 0.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableDisc"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
_texturePath = p.texture.string();
_texturePath.onChange([&]() { _texture->loadFromFile(_texturePath); });
addProperty(_texturePath);
if (dictionary.hasKey(SizeInfo.identifier)) {
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
}
_size = p.size.value_or(_size);
setBoundingSphere(_size);
_size.onChange([&]() { _planeIsDirty = true; });
addProperty(_size);
if (dictionary.hasKey(WidthInfo.identifier)) {
_width = static_cast<float>(dictionary.value<double>(WidthInfo.identifier));
}
_width = p.width.value_or(_width);
addProperty(_width);
addProperty(_opacity);
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
@@ -173,7 +158,6 @@ void RenderableDisc::render(const RenderData& data, RendererTasks&) {
data.camera.projectionMatrix() * glm::mat4(modelViewTransform)
);
_shader->setUniform(_uniformCache.width, _width);
_shader->setUniform(_uniformCache.opacity, _opacity);
ghoul::opengl::TextureUnit unit;
+2 -2
View File
@@ -194,7 +194,7 @@ namespace {
std::optional<Orientation> labelOrientationOption;
// [[codegen::verbatim(LabelColorInfo.description)]]
std::optional<glm::vec3> labelColor;
std::optional<glm::vec3> labelColor [[codegen::color()]];
// [[codegen::verbatim(LabelTextInfo.description)]]
std::optional<std::string> labelText;
@@ -511,7 +511,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_fadeEndUnitOption = AU;
}
addProperty(_fadeEndUnitOption);
_fadeEndSpeed = p.fadeEndSpeed.value_or(_fadeEndSpeed);
addProperty(_fadeEndSpeed);
}
+89 -34
View File
@@ -25,7 +25,6 @@
#include <modules/base/rendering/renderablemodel.h>
#include <modules/base/basemodule.h>
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/globals.h>
@@ -34,17 +33,20 @@
#include <openspace/util/updatestructures.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/lightsource.h>
#include <ghoul/io/model/modelgeometry.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/invariants.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
namespace {
constexpr const char* _loggerCat = "RenderableModel";
constexpr const char* ProgramName = "ModelProgram";
constexpr const char* KeyGeometry = "Geometry";
constexpr const char* KeyGeomModelFile = "GeometryFile";
constexpr const char* KeyForceRenderInvisible = "ForceRenderInvisible";
constexpr const int DefaultBlending = 0;
constexpr const int AdditiveBlending = 1;
@@ -60,10 +62,10 @@ namespace {
{ "Color Adding", ColorAddingBlending }
};
constexpr const std::array<const char*, 13> UniformNames = {
constexpr const std::array<const char*, 12> UniformNames = {
"opacity", "nLightSources", "lightDirectionsViewSpace", "lightIntensities",
"modelViewTransform", "normalTransform", "projectionTransform",
"performShading", "texture1", "ambientIntensity", "diffuseIntensity",
"performShading", "ambientIntensity", "diffuseIntensity",
"specularIntensity", "opacityBlending"
};
@@ -145,17 +147,21 @@ documentation::Documentation RenderableModel::Documentation() {
"base_renderable_model",
{
{
KeyGeometry,
new TableVerifier({
{
"*",
new ReferencingVerifier("base_geometry_model"),
Optional::Yes
}
}),
KeyGeomModelFile,
new OrVerifier({ new StringVerifier, new StringListVerifier }),
Optional::No,
"The file or files that should be loaded in this RenderableModel. The file can "
"contain filesystem tokens or can be specified relatively to the "
"location of the .mod file. "
"This specifies the model that is rendered by the Renderable."
},
{
KeyForceRenderInvisible,
new BoolVerifier,
Optional::Yes,
"Set if invisible parts (parts with no textures or materials) of the model "
"should be forced to render or not."
},
{
AmbientIntensityInfo.identifier,
new DoubleVerifier,
@@ -263,13 +269,71 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(KeyForceRenderInvisible)) {
_forceRenderInvisible = dictionary.value<bool>(KeyForceRenderInvisible);
if (dictionary.hasKey(KeyGeometry)) {
ghoul::Dictionary dict = dictionary.value<ghoul::Dictionary>(KeyGeometry);
for (int i = 1; i <= dict.size(); ++i) {
std::string key = std::to_string(i);
ghoul::Dictionary geom = dict.value<ghoul::Dictionary>(key);
_geometry.push_back(modelgeometry::ModelGeometry::createFromDictionary(geom));
if (!_forceRenderInvisible) {
// Asset file have specifically said to not render invisible parts,
// do not notify in the log if invisible parts are detected and dropped
_notifyInvisibleDropped = false;
}
}
if (dictionary.hasKey(KeyGeomModelFile)) {
std::string file;
if (dictionary.hasValue<std::string>(KeyGeomModelFile)) {
// Handle single file
file = absPath(dictionary.value<std::string>(KeyGeomModelFile));
_geometry = ghoul::io::ModelReader::ref().loadModel(
file,
ghoul::io::ModelReader::ForceRenderInvisible(_forceRenderInvisible),
ghoul::io::ModelReader::NotifyInvisibleDropped(_notifyInvisibleDropped)
);
}
else if (dictionary.hasValue<ghoul::Dictionary>(KeyGeomModelFile)) {
LWARNING("Loading a model with several files is deprecated and will be "
"removed in a future release"
);
ghoul::Dictionary fileDictionary = dictionary.value<ghoul::Dictionary>(
KeyGeomModelFile
);
std::vector<std::unique_ptr<ghoul::modelgeometry::ModelGeometry>> geometries;
for (std::string_view k : fileDictionary.keys()) {
// Handle each file
file = absPath(fileDictionary.value<std::string>(k));
geometries.push_back(ghoul::io::ModelReader::ref().loadModel(
file,
ghoul::io::ModelReader::ForceRenderInvisible(_forceRenderInvisible),
ghoul::io::ModelReader::NotifyInvisibleDropped(_notifyInvisibleDropped)
));
}
if (!geometries.empty()) {
std::unique_ptr<ghoul::modelgeometry::ModelGeometry> combinedGeometry =
std::move(geometries[0]);
// Combine all models into one ModelGeometry
for (unsigned int i = 1; i < geometries.size(); ++i) {
for (ghoul::io::ModelMesh& mesh : geometries[i]->meshes()) {
combinedGeometry->meshes().push_back(
std::move(mesh)
);
}
for (ghoul::modelgeometry::ModelGeometry::TextureEntry& texture :
geometries[i]->textureStorage())
{
combinedGeometry->textureStorage().push_back(
std::move(texture)
);
}
}
_geometry = std::move(combinedGeometry);
_geometry->calculateBoundingRadius();
}
}
}
@@ -383,16 +447,14 @@ void RenderableModel::initializeGL() {
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
for (const ghoul::mm_unique_ptr<modelgeometry::ModelGeometry>& geom : _geometry) {
geom->initialize(this);
}
_geometry->initialize();
_geometry->calculateBoundingRadius();
setBoundingSphere(glm::sqrt(_geometry->boundingRadius()));
}
void RenderableModel::deinitializeGL() {
for (const ghoul::mm_unique_ptr<modelgeometry::ModelGeometry>& geom : _geometry) {
geom->deinitialize();
}
_geometry.clear();
_geometry->deinitialize();
_geometry.reset();
BaseModule::ProgramObjectManager.release(
ProgramName,
@@ -493,14 +555,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
glDisable(GL_DEPTH_TEST);
}
ghoul::opengl::TextureUnit unit;
unit.activate();
_program->setUniform(_uniformCache.texture, unit);
for (const ghoul::mm_unique_ptr<modelgeometry::ModelGeometry>& geom : _geometry) {
geom->setUniforms(*_program);
geom->bindTexture();
geom->render();
}
_geometry->render(*_program);
if (_disableFaceCulling) {
glEnable(GL_CULL_FACE);
}
+7 -3
View File
@@ -34,6 +34,7 @@
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
#include <ghoul/io/model/modelreader.h>
#include <ghoul/opengl/uniformcache.h>
#include <memory>
@@ -42,6 +43,8 @@ namespace ghoul::opengl {
class Texture;
} // namespace ghoul::opengl
namespace ghoul::modelgeometry { class ModelGeometry; }
namespace openspace {
struct RenderData;
@@ -49,7 +52,6 @@ struct UpdateData;
class LightSource;
namespace documentation { struct Documentation; }
namespace modelgeometry { class ModelGeometry; }
class RenderableModel : public Renderable {
public:
@@ -68,7 +70,9 @@ public:
static documentation::Documentation Documentation();
private:
std::vector<ghoul::mm_unique_ptr<modelgeometry::ModelGeometry>> _geometry;
std::unique_ptr<ghoul::modelgeometry::ModelGeometry> _geometry;
bool _forceRenderInvisible = false;
bool _notifyInvisibleDropped = true;
properties::FloatProperty _ambientIntensity;
@@ -87,7 +91,7 @@ private:
ghoul::opengl::ProgramObject* _program = nullptr;
UniformCache(opacity, nLightSources, lightDirectionsViewSpace, lightIntensities,
modelViewTransform, normalTransform, projectionTransform,
performShading, texture, ambientIntensity, diffuseIntensity,
performShading, ambientIntensity, diffuseIntensity,
specularIntensity, opacityBlending) _uniformCache;
std::vector<std::unique_ptr<LightSource>> _lightSources;
@@ -93,7 +93,7 @@ namespace {
std::optional<std::string> endNode;
// [[codegen::verbatim(LineColorInfo.description)]]
std::optional<glm::vec3> color;
std::optional<glm::vec3> color [[codegen::color()]];
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
@@ -128,7 +128,7 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
_lineColor = p.color.value_or(_lineColor);
addProperty(_lineColor);
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
+18 -1
View File
@@ -70,19 +70,29 @@ namespace {
"This determines the blending mode that is applied to this plane."
};
constexpr openspace::properties::Property::PropertyInfo MultiplyColorInfo = {
"MultiplyColor",
"Multiply Color",
"If set, the plane's texture is multiplied with this color. "
"Useful for applying a color grayscale images."
};
struct [[codegen::Dictionary(RenderablePlane)]] Parameters {
// [[codegen::verbatim(BillboardInfo.description)]]
std::optional<bool> billboard;
// [[codegen::verbatim(SizeInfo.description)]]
float size;
enum class BlendMode {
Normal,
Additive
};
// [[codegen::verbatim(BlendModeInfo.description)]]
std::optional<BlendMode> blendMode;
// [[codegen::verbatim(BlendModeInfo.description)]]
std::optional<glm::vec3> multiplyColor [[codegen::color()]];
};
#include "renderableplane_codegen.cpp"
} // namespace
@@ -100,6 +110,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _billboard(BillboardInfo, false)
, _size(SizeInfo, 10.f, 0.f, 1e25f)
, _multiplyColor(MultiplyColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
{
Parameters p = codegen::bake<Parameters>(dictionary);
@@ -141,11 +152,15 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
}
}
_multiplyColor = p.multiplyColor.value_or(_multiplyColor);
addProperty(_billboard);
addProperty(_size);
_size.onChange([this](){ _planeIsDirty = true; });
addProperty(_multiplyColor);
setBoundingSphere(_size);
}
@@ -238,6 +253,8 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) {
_shader->setUniform("texture1", unit);
_shader->setUniform("multiplyColor", _multiplyColor);
bool usingFramebufferRenderer = global::renderEngine->rendererImplementation() ==
RenderEngine::RendererImplementation::Framebuffer;
+2
View File
@@ -31,6 +31,7 @@
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul::filesystem { class File; }
@@ -75,6 +76,7 @@ private:
properties::BoolProperty _billboard;
properties::FloatProperty _size;
properties::Vec3Property _multiplyColor;
ghoul::opengl::ProgramObject* _shader = nullptr;
@@ -46,10 +46,10 @@ namespace {
};
constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = {
"RenderableType",
"RenderableType",
"This value specifies if the plane should be rendered in the Background,"
"Opaque, Transparent, or Overlay rendering step."
"RenderableType",
"RenderableType",
"This value specifies if the plane should be rendered in the Background,"
"Opaque, Transparent, or Overlay rendering step."
};
struct [[codegen::Dictionary(RenderablePlaneImageLocal)]] Parameters {
@@ -80,6 +80,16 @@ namespace openspace {
documentation::Documentation RenderablePlaneImageLocal::Documentation() {
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_plane_image_local";
// @TODO cleanup
// Insert the parents documentation entries until we have a verifier that can deal
// with class hierarchy
documentation::Documentation parentDoc = RenderablePlane::Documentation();
doc.entries.insert(
doc.entries.end(),
parentDoc.entries.begin(),
parentDoc.entries.end()
);
return doc;
}
@@ -95,7 +105,7 @@ RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& di
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
addProperty(_texturePath);
_texturePath.onChange([this]() {loadTexture(); });
_texturePath.onChange([this]() { loadTexture(); });
_textureFile->setCallback(
[this](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
@@ -54,6 +54,16 @@ namespace openspace {
documentation::Documentation RenderablePlaneImageOnline::Documentation() {
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_plane_image_online";
// @TODO cleanup
// Insert the parents documentation entries until we have a verifier that can deal
// with class hierarchy
documentation::Documentation parentDoc = RenderablePlane::Documentation();
doc.entries.insert(
doc.entries.end(),
parentDoc.entries.begin(),
parentDoc.entries.end()
);
return doc;
}
+71 -11
View File
@@ -28,15 +28,27 @@ in vec2 vs_st;
in vec3 vs_normalViewSpace;
in vec4 vs_positionCameraSpace;
in float vs_screenSpaceDepth;
in mat3 TBN;
uniform float ambientIntensity = 0.2;
uniform float diffuseIntensity = 1.0;
uniform float specularIntensity = 1.0;
uniform bool performShading = true;
uniform bool use_forced_color = false;
uniform bool has_texture_diffuse;
uniform bool has_texture_normal;
uniform bool has_texture_specular;
uniform bool has_color_specular;
uniform bool opacityBlending = false;
uniform sampler2D texture1;
uniform sampler2D texture_diffuse;
uniform sampler2D texture_normal;
uniform sampler2D texture_specular;
uniform vec3 color_diffuse;
uniform vec3 color_specular;
uniform int nLightSources;
uniform vec3 lightDirectionsViewSpace[8];
@@ -44,23 +56,71 @@ uniform float lightIntensities[8];
uniform float opacity = 1.0;
const vec3 SpecularAlbedo = vec3(1.0);
Fragment getFragment() {
// Render invisible mesh with flashy procedural material
if (use_forced_color) {
Fragment frag;
vec3 adjustedPos = floor(vs_positionCameraSpace.xyz * 3.0);
float chessboard = adjustedPos.x + adjustedPos.y + adjustedPos.z;
chessboard = fract(chessboard * 0.5);
chessboard *= 2;
// Pink and complementary green in a chessboard pattern
frag.color.rgb = mix(vec3(1.0, 0.0, 0.8), vec3(0.0, 1.0, 0.2), chessboard);
frag.color.a = opacity;
frag.depth = vs_screenSpaceDepth;
frag.gPosition = vs_positionCameraSpace;
frag.gNormal = vec4(vs_normalViewSpace, 0.0);
frag.disableLDR2HDR = true;
return frag;
}
vec3 diffuseAlbedo;
if (has_texture_diffuse) {
diffuseAlbedo = texture(texture_diffuse, vs_st).rgb;
}
else {
diffuseAlbedo = color_diffuse;
}
if (opacity == 0.0) {
discard;
}
vec3 diffuseAlbedo = texture(texture1, vs_st).rgb;
Fragment frag;
if (performShading) {
vec3 specularAlbedo;
if (has_texture_specular) {
specularAlbedo = texture(texture_specular, vs_st).rgb;
}
else {
if (has_color_specular) {
specularAlbedo = color_specular;
}
else {
specularAlbedo = vec3(1.0);
}
}
// Some of these values could be passed in as uniforms
const vec3 lightColorAmbient = vec3(1.0);
const vec3 lightColor = vec3(1.0);
vec3 n = normalize(vs_normalViewSpace);
vec3 n;
if (has_texture_normal) {
vec3 normalAlbedo = texture(texture_normal, vs_st).rgb;
normalAlbedo = normalize(normalAlbedo * 2.0 - 1.0);
n = normalize(TBN * normalAlbedo);
}
else {
n = normalize(vs_normalViewSpace);
}
vec3 c = normalize(vs_positionCameraSpace.xyz);
vec3 color = ambientIntensity * lightColorAmbient * diffuseAlbedo;
@@ -73,12 +133,12 @@ Fragment getFragment() {
float specularCosineFactor = dot(c,r);
const float specularPower = 100.0;
vec3 diffuseColor =
diffuseIntensity * lightColor * diffuseAlbedo *
max(diffuseCosineFactor, 0);
vec3 diffuseColor =
diffuseIntensity * lightColor * diffuseAlbedo *
max(diffuseCosineFactor, 0);
vec3 specularColor =
specularIntensity * lightColor * SpecularAlbedo *
specularIntensity * lightColor * specularAlbedo *
pow(max(specularCosineFactor, 0), specularPower);
color += lightIntensities[i] * (diffuseColor + specularColor);
@@ -107,4 +167,4 @@ Fragment getFragment() {
frag.disableLDR2HDR = true;
return frag;
}
}
+14
View File
@@ -29,11 +29,13 @@
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
layout(location = 3) in vec3 in_tangent;
out vec2 vs_st;
out vec3 vs_normalViewSpace;
out float vs_screenSpaceDepth;
out vec4 vs_positionCameraSpace;
out mat3 TBN;
uniform mat4 modelViewTransform;
uniform mat4 projectionTransform;
@@ -49,4 +51,16 @@ void main() {
vs_screenSpaceDepth = positionScreenSpace.w;
vs_normalViewSpace = normalize(mat3(normalTransform) * in_normal);
// TBN matrix for normal mapping
vec3 T = normalize(vec3(modelViewTransform * vec4(in_tangent, 0.0)));
vec3 N = normalize(vec3(modelViewTransform * vec4(in_normal, 0.0)));
// Re-orthogonalize T with respect to N
T = normalize(T - dot(T, N) * N);
// Retrieve perpendicular vector B with cross product of T and N
vec3 B = normalize(cross(N, T));
TBN = mat3(T, B, N);
}
+5 -3
View File
@@ -32,7 +32,7 @@ in vec3 vs_gNormal;
uniform sampler2D texture1;
uniform bool additiveBlending;
uniform float opacity = 1.0;
uniform vec3 multiplyColor;
Fragment getFragment() {
Fragment frag;
@@ -43,6 +43,8 @@ Fragment getFragment() {
frag.color = texture(texture1, vec2(1 - vs_st.s, vs_st.t));
}
frag.color.rgb *= multiplyColor;
frag.color.a *= opacity;
if (frag.color.a == 0.0) {
discard;
@@ -54,9 +56,9 @@ Fragment getFragment() {
frag.blend = BLEND_MODE_ADDITIVE;
}
// G-Buffer
// G-Buffer
frag.gPosition = vs_gPosition;
frag.gNormal = vec4(vs_gNormal, 1.0);
return frag;
}
@@ -234,7 +234,7 @@ namespace {
std::optional<std::string> file;
// [[codegen::verbatim(ColorInfo.description)]]
glm::vec3 color;
glm::vec3 color [[codegen::color()]];
// [[codegen::verbatim(SpriteTextureInfo.description)]]
std::optional<std::string> texture;
@@ -277,7 +277,7 @@ namespace {
std::optional<bool> drawLabels;
// [[codgen::verbatim(TextColorInfo.description)]]
std::optional<glm::vec3> textColor;
std::optional<glm::vec3> textColor [[codegen::color()]];
// [[codgen::verbatim(TextOpacityInfo.description)]]
std::optional<float> textOpacity;
@@ -151,7 +151,7 @@ namespace {
std::optional<Unit> unit;
// [[codegen::verbatim(TextColorInfo.description)]]
std::optional<glm::vec3> textColor;
std::optional<glm::vec3> textColor [[codegen::color()]];
// [[codegen::verbatim(TextOpacityInfo.description)]]
std::optional<float> textOpacity;
@@ -180,7 +180,7 @@ namespace {
std::optional<float> scaleFactor;
// [[codegen::verbatim(TextColorInfo.description)]]
std::optional<glm::vec3> textColor;
std::optional<glm::vec3> textColor [[codegen::color()]];
// [[codegen::verbatim(TextOpacityInfo.description)]]
std::optional<float> textOpacity;
@@ -381,7 +381,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
}
_planeMinSize = p.planeMinSize.value_or(_planeMinSize);
if (p.planeMinSize.has_value()) {
addProperty(_planeMinSize);
}
@@ -88,7 +88,7 @@ namespace {
std::string file;
// Astronomical Object Color (r,g,b)
glm::vec3 color;
glm::vec3 color [[codegen::color()]];
enum class Unit {
Meter [[codegen::key("m")]],
+1 -1
View File
@@ -56,7 +56,7 @@ bool hasSufficientData(const ExoplanetDataEntry& p) {
return validStarPosition && hasSemiMajorAxis && hasOrbitalPeriod;
}
glm::vec3 starColor(float bv) {
glm::vec3 computeStarColor(float bv) {
std::ifstream colorMap(absPath(BvColormapPath), std::ios::in);
if (!colorMap.good()) {
+1 -1
View File
@@ -99,7 +99,7 @@ bool isValidPosition(const glm::vec3& pos);
bool hasSufficientData(const ExoplanetDataEntry& p);
// Compute star color in RGB from b-v color index
glm::vec3 starColor(float bv);
glm::vec3 computeStarColor(float bv);
glm::dmat4 computeOrbitPlaneRotationMatrix(float i, float bigom = 180.f,
float omega = 90.f);
+50 -12
View File
@@ -33,8 +33,7 @@
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scene.h>
#include <openspace/util/factorymanager.h>
#include <thread>
#include <chrono>
#include <filesystem>
#include "exoplanetsmodule_lua.inl"
@@ -51,6 +50,13 @@ namespace {
"The path to a grayscale image that is used for the host star surfaces"
};
constexpr const openspace::properties::Property::PropertyInfo StarGlareTextureInfo = {
"StarGlareTexture",
"Star Glare Texture",
"The path to a grayscale image that is used for the glare effect of the "
"host stars"
};
constexpr const openspace::properties::Property::PropertyInfo NoDataTextureInfo = {
"NoDataTexture",
"No Data Star Texture",
@@ -115,19 +121,22 @@ namespace {
struct [[codegen::Dictionary(ExoplanetsModule)]] Parameters {
// [[codegen::verbatim(DataFolderInfo.description)]]
std::optional<std::string> dataFolder;
std::optional<std::filesystem::path> dataFolder [[codegen::directory()]];
// [[codegen::verbatim(StarTextureInfo.description)]]
std::optional<std::string> starTexture;
std::optional<std::filesystem::path> starTexture;
// [[codegen::verbatim(StarGlareTextureInfo.description)]]
std::optional<std::filesystem::path> starGlareTexture;
// [[codegen::verbatim(NoDataTextureInfo.description)]]
std::optional<std::string> noDataTexture;
std::optional<std::filesystem::path> noDataTexture;
// [[codegen::verbatim(OrbitDiscTextureInfo.description)]]
std::optional<std::string> orbitDiscTexture;
std::optional<std::filesystem::path> orbitDiscTexture;
// [[codegen::verbatim(HabitableZoneTextureInfo.description)]]
std::optional<std::string> habitableZoneTexture;
std::optional<std::filesystem::path> habitableZoneTexture;
// [[codegen::verbatim(ShowComparisonCircleInfo.description)]]
std::optional<bool> showComparisonCircle;
@@ -152,6 +161,7 @@ ExoplanetsModule::ExoplanetsModule()
: OpenSpaceModule(Name)
, _exoplanetsDataFolder(DataFolderInfo)
, _starTexturePath(StarTextureInfo)
, _starGlareTexturePath(StarGlareTextureInfo)
, _noDataTexturePath(NoDataTextureInfo)
, _orbitDiscTexturePath(OrbitDiscTextureInfo)
, _habitableZoneTexturePath(HabitableZoneTextureInfo)
@@ -164,12 +174,15 @@ ExoplanetsModule::ExoplanetsModule()
addProperty(_exoplanetsDataFolder);
addProperty(_starTexturePath);
addProperty(_starGlareTexturePath);
addProperty(_noDataTexturePath);
addProperty(_orbitDiscTexturePath);
addProperty(_habitableZoneTexturePath);
addProperty(_showComparisonCircle);
addProperty(_showHabitableZone);
addProperty(_useOptimisticZone);
addProperty(_habitableZoneOpacity);
}
@@ -189,6 +202,10 @@ std::string ExoplanetsModule::starTexturePath() const {
return _starTexturePath;
}
std::string ExoplanetsModule::starGlareTexturePath() const {
return _starGlareTexturePath;
}
std::string ExoplanetsModule::noDataTexturePath() const {
return _noDataTexturePath;
}
@@ -258,16 +275,37 @@ scripting::LuaLibrary ExoplanetsModule::luaLibrary() const {
void ExoplanetsModule::internalInitialize(const ghoul::Dictionary& dict) {
const Parameters p = codegen::bake<Parameters>(dict);
_exoplanetsDataFolder = p.dataFolder.value_or(_exoplanetsDataFolder);
_starTexturePath = p.starTexture.value_or(_starTexturePath);
_noDataTexturePath = p.noDataTexture.value_or(_noDataTexturePath);
_orbitDiscTexturePath = p.orbitDiscTexture.value_or(_orbitDiscTexturePath);
_habitableZoneTexturePath = p.habitableZoneTexture.value_or(_habitableZoneTexturePath);
if (p.dataFolder.has_value()) {
_exoplanetsDataFolder = p.dataFolder.value().string();
}
if (p.starTexture.has_value()) {
_starTexturePath = p.starTexture.value().string();
}
if (p.starGlareTexture.has_value()) {
_starGlareTexturePath = p.starGlareTexture.value().string();
}
if (p.noDataTexture.has_value()) {
_noDataTexturePath = p.noDataTexture.value().string();
}
if (p.orbitDiscTexture.has_value()) {
_orbitDiscTexturePath = p.orbitDiscTexture.value().string();
}
if (p.habitableZoneTexture.has_value()) {
_habitableZoneTexturePath = p.habitableZoneTexture.value().string();
}
_showComparisonCircle = p.showComparisonCircle.value_or(_showComparisonCircle);
_showHabitableZone = p.showHabitableZone.value_or(_showHabitableZone);
_useOptimisticZone = p.useOptimisticZone.value_or(_useOptimisticZone);
_habitableZoneOpacity = p.habitableZoneOpacity.value_or(_habitableZoneOpacity);
auto fTask = FactoryManager::ref().factory<Task>();
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fTask, "No task factory existed");
+4
View File
@@ -44,6 +44,7 @@ public:
std::string exoplanetsDataPath() const;
std::string lookUpTablePath() const;
std::string starTexturePath() const;
std::string starGlareTexturePath() const;
std::string noDataTexturePath() const;
std::string orbitDiscTexturePath() const;
std::string habitableZoneTexturePath() const;
@@ -60,12 +61,15 @@ protected:
properties::StringProperty _exoplanetsDataFolder;
properties::StringProperty _starTexturePath;
properties::StringProperty _starGlareTexturePath;
properties::StringProperty _noDataTexturePath;
properties::StringProperty _orbitDiscTexturePath;
properties::StringProperty _habitableZoneTexturePath;
properties::BoolProperty _showComparisonCircle;
properties::BoolProperty _showHabitableZone;
properties::BoolProperty _useOptimisticZone;
properties::FloatProperty _habitableZoneOpacity;
};
+45 -2
View File
@@ -176,16 +176,17 @@ void createExoplanetSystem(const std::string& starName) {
}
std::string colorLayers;
std::optional<glm::vec3> starColor = std::nullopt;
const float bv = system.starData.bv;
if (!std::isnan(bv)) {
const glm::vec3 color = starColor(bv);
starColor = computeStarColor(bv);
const std::string starTexture = module->starTexturePath();
colorLayers =
"{"
"Identifier = 'StarColor',"
"Type = 'SolidColor',"
"Color = " + ghoul::to_string(color) + ","
"Color = " + ghoul::to_string(*starColor) + ","
"BlendMode = 'Normal',"
"Enabled = true"
"},"
@@ -502,6 +503,48 @@ void createExoplanetSystem(const std::string& starName) {
"openspace.addSceneGraphNode(" + zoneDiscNode + ");",
scripting::ScriptEngine::RemoteScripting::Yes
);
// Star glare
if (starColor.has_value()) {
// This is a little magic to make the size of the glare dependent on the
// size and the temperature of the star. It's kind of based on the fact that
// the luminosity of a star is proportional to: (radius^2)*(temperature^4)
// Maybe a better option would be to compute the size based on the aboslute
// magnitude or star luminosity, but for now this looks good enough.
float size = 59.f * radiusInMeter;
if (hasTeff) {
constexpr const float sunTeff = 5780.f;
size *= std::pow(system.starData.teff / sunTeff, 2.0);
}
const std::string glareTexture = module->starGlareTexturePath();
const std::string starGlare = "{"
"Identifier = '" + starIdentifier + "_Glare',"
"Parent = '" + starIdentifier + "',"
"Renderable = {"
"Type = 'RenderablePlaneImageLocal',"
"Size = " + ghoul::to_string(size) + ","
"Origin = 'Center',"
"Billboard = true,"
"Texture = openspace.absPath('"
+ formatPathToLua(glareTexture) +
"'),"
"BlendMode = 'Additive',"
"Opacity = 0.65,"
"MultiplyColor = " + ghoul::to_string(*starColor) + ""
"},"
"GUI = {"
"Name = '" + sanitizedStarName + " Glare',"
"Path = '" + guiPath + "'"
"}"
"}";
openspace::global::scriptEngine->queueScript(
"openspace.addSceneGraphNode(" + starGlare + ");",
scripting::ScriptEngine::RemoteScripting::Yes
);
}
}
}
@@ -36,6 +36,8 @@
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
#include <filesystem>
#include <optional>
namespace {
constexpr const std::array<const char*, 6> UniformNames = {
@@ -71,42 +73,29 @@ namespace {
"relative to the size of the semi-major axis. That is, 0 means no deviation "
"from the semi-major axis and 1 is a whole semi-major axis's worth of deviation."
};
struct [[codegen::Dictionary(RenderableOrbitDisc)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::filesystem::path texture;
// [[codegen::verbatim(SizeInfo.description)]]
float size;
// [[codegen::verbatim(EccentricityInfo.description)]]
float eccentricity;
// [[codegen::verbatim(OffsetInfo.description)]]
std::optional<glm::vec2> offset;
};
#include "renderableorbitdisc_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableOrbitDisc::Documentation() {
using namespace documentation;
return {
"Renderable Orbit Disc",
"exoplanets_renderable_orbit_disc",
{
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description
},
{
SizeInfo.identifier,
new DoubleVerifier,
Optional::No,
SizeInfo.description
},
{
EccentricityInfo.identifier,
new DoubleVerifier,
Optional::No,
EccentricityInfo.description
},
{
OffsetInfo.identifier,
new DoubleVector2Verifier,
Optional::Yes,
OffsetInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "exoplanets_renderableorbitdisc";
return doc;
}
RenderableOrbitDisc::RenderableOrbitDisc(const ghoul::Dictionary& dictionary)
@@ -116,31 +105,23 @@ RenderableOrbitDisc::RenderableOrbitDisc(const ghoul::Dictionary& dictionary)
, _eccentricity(EccentricityInfo, 0.f, 0.f, 1.f)
, _offset(OffsetInfo, glm::vec2(0.f), glm::vec2(0.f), glm::vec2(1.f))
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableOrbitDisc"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasKey(OffsetInfo.identifier)) {
_offset = dictionary.value<glm::dvec2>(OffsetInfo.identifier);
}
_offset = p.offset.value_or(_offset);
_offset.onChange([&]() { _planeIsDirty = true; });
addProperty(_offset);
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
_size = p.size;
_size.onChange([&]() { _planeIsDirty = true; });
addProperty(_size);
setBoundingSphere(_size + _offset.value().y * _size);
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
_texturePath = p.texture.string();
_texturePath.onChange([&]() { _texture->loadFromFile(_texturePath); });
addProperty(_texturePath);
_eccentricity = static_cast<float>(
dictionary.value<double>(EccentricityInfo.identifier)
);
_eccentricity = p.eccentricity;
_eccentricity.onChange([&]() { _planeIsDirty = true; });
addProperty(_eccentricity);
@@ -449,13 +449,13 @@ documentation::Documentation ExoplanetsDataPreparationTask::documentation() {
{
{
KeyInputDataFile,
new StringAnnotationVerifier("A valid filepath"),
new FileVerifier,
Optional::No,
"The csv file to extract data from"
},
{
KeyInputSpeck,
new StringAnnotationVerifier("A file path to a speck file"),
new FileVerifier,
Optional::No,
"The speck file with star locations"
},
@@ -473,9 +473,10 @@ documentation::Documentation ExoplanetsDataPreparationTask::documentation() {
},
{
KeyTeffToBv,
new StringAnnotationVerifier("A valid filepath"),
new FileVerifier,
Optional::No,
"The path to a teff to bv conversion file"
"The path to a teff to bv conversion file. Should be a txt file where "
"each line has the format 'teff,bv'"
}
}
};
+2
View File
@@ -92,6 +92,8 @@ set(SOURCE_FILES
source_group("Source Files" FILES ${SOURCE_FILES})
set(SHADER_FILES
shaders/advanced_rings_vs.glsl
shaders/advanced_rings_fs.glsl
shaders/blending.hglsl
shaders/globalrenderer_vs.glsl
shaders/localrenderer_vs.glsl
@@ -0,0 +1,143 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
#define NSSamplesMinusOne #{nShadowSamples}
#define NSSamples (NSSamplesMinusOne + 1)
in vec2 vs_st;
in float vs_screenSpaceDepth;
in vec4 shadowCoords;
uniform sampler2DShadow shadowMapTexture;
uniform sampler1D ringTextureFwrd;
uniform sampler1D ringTextureBckwrd;
uniform sampler1D ringTextureUnlit;
uniform sampler1D ringTextureColor;
uniform sampler1D ringTextureTransparency;
uniform vec2 textureOffset;
uniform float colorFilterValue;
uniform vec3 sunPosition;
uniform vec3 sunPositionObj;
uniform vec3 camPositionObj;
uniform float _nightFactor;
uniform float zFightingPercentage;
// temp
in vec4 fragPosInLightSpace;
Fragment getFragment() {
// Moving the origin to the center
vec2 st = (vs_st - vec2(0.5)) * 2.0;
// The length of the texture coordinates vector is our distance from the center
float radius = length(st);
// We only want to consider ring-like objects so we need to discard everything else
if (radius > 1.0) {
discard;
}
// Remapping the texture coordinates
// Radius \in [0,1], texCoord \in [textureOffset.x, textureOffset.y]
// textureOffset.x -> 0
// textureOffset.y -> 1
float texCoord = (radius - textureOffset.x) / (textureOffset.y - textureOffset.x);
if (texCoord < 0.f || texCoord > 1.f) {
discard;
}
vec4 colorBckwrd = texture(ringTextureBckwrd, texCoord);
vec4 colorFwrd = texture(ringTextureFwrd, texCoord);
vec4 colorMult = texture(ringTextureColor, texCoord);
vec4 transparency = texture(ringTextureTransparency, texCoord);
float lerpFactor = dot(camPositionObj, sunPositionObj);
// Jon Colors:
//vec4 diffuse = mix(colorFwrd * vec4(1, 0.88, 0.82, 1.0), colorBckwrd * vec4(1, 0.88, 0.82, 1.0), lerpFactor);
vec4 diffuse = mix(colorFwrd * colorMult, colorBckwrd * colorMult, lerpFactor);
diffuse.a = colorFilterValue * transparency.a;
float colorValue = length(diffuse.rgb) / 0.57735026919;
if (colorValue < 0.1) {
discard;
}
// shadow == 1.0 means it is not in shadow
float shadow = 1.0;
if (shadowCoords.z >= 0) {
vec4 normalizedShadowCoords = shadowCoords;
normalizedShadowCoords.z = normalizeFloat(zFightingPercentage * normalizedShadowCoords.w);
normalizedShadowCoords.xy = normalizedShadowCoords.xy / normalizedShadowCoords.w;
normalizedShadowCoords.w = 1.0;
float sum = 0;
#for i in 0..#{nShadowSamples}
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, -NSSamples + #{i}));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, 0));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(-NSSamples + #{i}, NSSamples - #{i}));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , -NSSamples + #{i}));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( 0 , NSSamples - #{i}));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, -NSSamples + #{i}));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, 0));
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2( NSSamples - #{i}, NSSamples - #{i}));
#endfor
sum += textureProjOffset(shadowMapTexture, normalizedShadowCoords, ivec2(0, 0));
shadow = clamp(sum / (8.0 * NSSamples + 1.f), 0.35, 1.0);
}
// The normal for the one plane depends on whether we are dealing
// with a front facing or back facing fragment
vec3 normal;
// The plane is oriented on the xz plane
// WARNING: This might not be the case for Uranus
if (gl_FrontFacing) {
normal = vec3(-1.0, 0.0, 0.0);
}
else {
normal = vec3(1.0, 0.0, 0.0);
}
// Reduce the color of the fragment by the user factor
// if we are facing away from the Sun
if (dot(sunPosition, normal) < 0) {
diffuse.xyz = vec3(1.0, 0.97075, 0.952) *
texture(ringTextureUnlit, texCoord).xyz *
_nightFactor;
}
Fragment frag;
frag.color = diffuse * shadow;
frag.depth = vs_screenSpaceDepth;
frag.gPosition = vec4(1e30, 1e30, 1e30, 1.0);
frag.gNormal = vec4(normal, 1.0);
return frag;
}
@@ -22,26 +22,32 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_BASE___MULTIMODELGEOMETRY___H__
#define __OPENSPACE_MODULE_BASE___MULTIMODELGEOMETRY___H__
#version __CONTEXT__
#include <modules/base/rendering/modelgeometry.h>
#include "PowerScaling/powerScaling_vs.hglsl"
namespace openspace {
class RenderableModel;
class RenderableModelProjection;
} // namespace openspace
layout(location = 0) in vec2 in_position;
layout(location = 1) in vec2 in_st;
namespace openspace::modelgeometry {
out vec2 vs_st;
out float vs_screenSpaceDepth;
out vec4 vs_positionViewSpace;
out vec4 shadowCoords;
class MultiModelGeometry : public ModelGeometry {
public:
MultiModelGeometry(const ghoul::Dictionary& dictionary);
uniform dmat4 modelViewProjectionMatrix;
private:
virtual bool loadModel(const std::string& filename) override;
};
// ShadowMatrix is the matrix defined by:
// textureCoordsMatrix * projectionMatrix * combinedViewMatrix * modelMatrix
// where textureCoordsMatrix is just a scale and bias computation: [-1,1] to [0,1]
uniform dmat4 shadowMatrix;
} // namespace openspace::modelgeometry
void main() {
vs_st = in_st;
#endif // __OPENSPACE_MODULE_BASE___MULTIMODELGEOMETRY___H__
dvec4 positionClipSpace = modelViewProjectionMatrix * dvec4(in_position, 0.0, 1.0);
vec4 positionClipSpaceZNorm = z_normalization(vec4(positionClipSpace));
shadowCoords = vec4(shadowMatrix * dvec4(in_position, 0.0, 1.0));
vs_screenSpaceDepth = positionClipSpaceZNorm.w;
gl_Position = positionClipSpaceZNorm;
}
@@ -217,7 +217,7 @@ documentation::Documentation GlobeLabelsComponent::Documentation() {
},
{
LabelsColorInfo.identifier,
new DoubleVector3Verifier,
new Color3Verifier,
Optional::Yes,
LabelsColorInfo.description
},
+1 -1
View File
@@ -108,7 +108,7 @@ namespace {
std::optional<std::string> description;
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
std::optional<glm::vec3> color [[codegen::color()]];
// Specifies the type of layer that is to be added. If this value is not
// specified, the layer is a DefaultTileLayer
@@ -68,7 +68,7 @@ documentation::Documentation LayerAdjustment::Documentation() {
},
{
KeyChromaKeyColor,
new DoubleVector3Verifier,
new Color3Verifier,
Optional::Yes,
"Specifies the chroma key used when selecting 'ChromaKey' for the 'Type'."
},
@@ -949,7 +949,7 @@ TileMetaData RawTileDataReader::tileMetaData(RawTile& rawTile,
bool allIsMissing = true;
for (int y = 0; y < region.numPixels.y; ++y) {
const size_t yi = (region.numPixels.y - 1 - y) * bytesPerLine;
const size_t yi = (static_cast<unsigned long long>(region.numPixels.y) - 1 - y) * bytesPerLine;
size_t i = 0;
for (int x = 0; x < region.numPixels.x; ++x) {
for (size_t raster = 0; raster < _initData.nRasters; ++raster) {
+44 -41
View File
@@ -567,8 +567,50 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
addProperty(_generalProperties.performShading);
addProperty(_generalProperties.useAccurateNormals);
addProperty(_generalProperties.eclipseShadowsEnabled);
addProperty(_generalProperties.eclipseHardShadows);
// ================================================================
// ======== Reads Shadow (Eclipses) Entries in asset file =========
// ================================================================
if (dictionary.hasValue<ghoul::Dictionary>(KeyShadowGroup)) {
ghoul::Dictionary shadowDictionary =
dictionary.value<ghoul::Dictionary>(KeyShadowGroup);
std::vector<std::pair<std::string, double>> sourceArray;
ghoul::Dictionary sources = shadowDictionary.value<ghoul::Dictionary>("Sources");
for (std::string_view k : sources.keys()) {
ghoul::Dictionary source = sources.value<ghoul::Dictionary>(k);
std::string name = source.value<std::string>("Name");
double radius = source.value<double>("Radius");
sourceArray.emplace_back(name, radius);
}
std::vector<std::pair<std::string, double>> casterArray;
ghoul::Dictionary casters = shadowDictionary.value<ghoul::Dictionary>("Casters");
for (std::string_view k : casters.keys()) {
ghoul::Dictionary caster = casters.value<ghoul::Dictionary>(k);
std::string name = caster.value<std::string>("Name");
double radius = caster.value<double>("Radius");
casterArray.emplace_back(name, radius);
}
std::vector<Ellipsoid::ShadowConfiguration> shadowConfArray;
for (const std::pair<std::string, double>& source : sourceArray) {
for (const std::pair<std::string, double>& caster : casterArray) {
Ellipsoid::ShadowConfiguration sc;
sc.source = source;
sc.caster = caster;
shadowConfArray.push_back(sc);
}
}
_ellipsoid.setShadowConfigurationArray(shadowConfArray);
}
if (!_ellipsoid.shadowConfigurationArray().empty()) {
addProperty(_generalProperties.eclipseShadowsEnabled);
addProperty(_generalProperties.eclipseHardShadows);
}
_shadowMappingPropertyOwner.addProperty(_generalProperties.shadowMapping);
_shadowMappingPropertyOwner.addProperty(_generalProperties.zFightingPercentage);
@@ -625,45 +667,6 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
_localChunkBuffer.resize(2048);
_traversalMemory.resize(512);
// ================================================================
// ======== Reads Shadow (Eclipses) Entries in asset file =========
// ================================================================
if (dictionary.hasValue<ghoul::Dictionary>(KeyShadowGroup)) {
ghoul::Dictionary shadowDictionary =
dictionary.value<ghoul::Dictionary>(KeyShadowGroup);
std::vector<std::pair<std::string, double>> sourceArray;
ghoul::Dictionary sources = shadowDictionary.value<ghoul::Dictionary>("Sources");
for (std::string_view k : sources.keys()) {
ghoul::Dictionary source = sources.value<ghoul::Dictionary>(k);
std::string name = source.value<std::string>("Name");
double radius = source.value<double>("Radius");
sourceArray.emplace_back(name, radius);
}
std::vector<std::pair<std::string, double>> casterArray;
ghoul::Dictionary casters = shadowDictionary.value<ghoul::Dictionary>("Casters");
for (std::string_view k : casters.keys()) {
ghoul::Dictionary caster = casters.value<ghoul::Dictionary>(k);
std::string name = caster.value<std::string>("Name");
double radius = caster.value<double>("Radius");
casterArray.emplace_back(name, radius);
}
std::vector<Ellipsoid::ShadowConfiguration> shadowConfArray;
for (const std::pair<std::string, double>& source : sourceArray) {
for (const std::pair<std::string, double>& caster : casterArray) {
Ellipsoid::ShadowConfiguration sc;
sc.source = source;
sc.caster = caster;
shadowConfArray.push_back(sc);
}
}
_ellipsoid.setShadowConfigurationArray(shadowConfArray);
}
// Labels Dictionary
if (dictionary.hasValue<ghoul::Dictionary>(KeyLabels)) {
_labelsDictionary = dictionary.value<ghoul::Dictionary>(KeyLabels);
+464 -44
View File
@@ -41,6 +41,7 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
@@ -54,10 +55,17 @@ namespace {
constexpr const std::array<const char*, 9> UniformNames = {
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "_nightFactor",
"sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture",
"sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture",
"zFightingPercentage"
};
constexpr const std::array<const char*, 15> UniformNamesAdvancedRings = {
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "_nightFactor",
"sunPosition", "sunPositionObj", "camPositionObj", "ringTextureFwrd",
"ringTextureBckwrd", "ringTextureUnlit", "ringTextureColor",
"ringTextureTransparency", "shadowMatrix", "shadowMapTexture", "zFightingPercentage"
};
constexpr const std::array<const char*, 3> GeomUniformNames = {
"modelViewProjectionMatrix", "textureOffset", "ringTexture"
};
@@ -69,6 +77,41 @@ namespace {
"texture which is used for these rings."
};
constexpr openspace::properties::Property::PropertyInfo TextureFwrdInfo = {
"TextureFwrd",
"TextureFwrd",
"This value is the path to a texture on disk that contains a one-dimensional "
"texture which is used for forward scattering light in these rings."
};
constexpr openspace::properties::Property::PropertyInfo TextureBckwrdInfo = {
"TextureBckwrd",
"TextureBckwrd",
"This value is the path to a texture on disk that contains a one-dimensional "
"texture which is used for backward scattering light in these rings."
};
constexpr openspace::properties::Property::PropertyInfo TextureUnlitInfo = {
"TextureUnlit",
"TextureUnlit",
"This value is the path to a texture on disk that contains a one-dimensional "
"texture which is used for unlit part in these rings."
};
constexpr openspace::properties::Property::PropertyInfo TextureColorInfo = {
"TextureColor",
"TextureColor",
"This value is the path to a texture on disk that contains a one-dimensional "
"texture color which is used for unlit part in these rings."
};
constexpr openspace::properties::Property::PropertyInfo TextureTransparencyInfo = {
"TextureTransparency",
"TextureTransparency",
"This value is the path to a texture on disk that contains a one-dimensional "
"texture transparency which is used for unlit part in these rings."
};
constexpr openspace::properties::Property::PropertyInfo SizeInfo = {
"Size",
"Size",
@@ -128,6 +171,36 @@ documentation::Documentation RingsComponent::Documentation() {
Optional::Yes,
TextureInfo.description
},
{
TextureFwrdInfo.identifier,
new StringVerifier,
Optional::Yes,
TextureFwrdInfo.description
},
{
TextureBckwrdInfo.identifier,
new StringVerifier,
Optional::Yes,
TextureBckwrdInfo.description
},
{
TextureUnlitInfo.identifier,
new StringVerifier,
Optional::Yes,
TextureUnlitInfo.description
},
{
TextureColorInfo.identifier,
new StringVerifier,
Optional::Yes,
TextureColorInfo.description
},
{
TextureTransparencyInfo.identifier,
new StringVerifier,
Optional::Yes,
TextureTransparencyInfo.description
},
{
SizeInfo.identifier,
new DoubleVerifier,
@@ -171,6 +244,11 @@ documentation::Documentation RingsComponent::Documentation() {
RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary)
: properties::PropertyOwner({ "Rings" })
, _texturePath(TextureInfo)
, _textureFwrdPath(TextureFwrdInfo)
, _textureBckwrdPath(TextureBckwrdInfo)
, _textureUnlitPath(TextureUnlitInfo)
, _textureColorPath(TextureColorInfo)
, _textureTransparencyPath(TextureTransparencyInfo)
, _size(SizeInfo, 1.f, 0.f, 1e25f)
, _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f))
, _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f)
@@ -209,21 +287,71 @@ void RingsComponent::initialize() {
_size.onChange([&]() { _planeIsDirty = true; });
addProperty(_size);
_texturePath = absPath(
_ringsDictionary.value<std::string>(TextureInfo.identifier)
);
_textureFile = std::make_unique<File>(_texturePath);
if (_ringsDictionary.hasKey(TextureInfo.identifier)) {
_texturePath = absPath(
_ringsDictionary.value<std::string>(TextureInfo.identifier)
);
_textureFile = std::make_unique<File>(_texturePath);
_texturePath.onChange([&]() { loadTexture(); });
addProperty(_texturePath);
_textureFile->setCallback([&](const File&) { _textureIsDirty = true; });
}
if (_ringsDictionary.hasKey(TextureFwrdInfo.identifier)) {
_textureFwrdPath = absPath(
_ringsDictionary.value<std::string>(TextureFwrdInfo.identifier)
);
_textureFileForwards = std::make_unique<File>(_textureFwrdPath);
_textureFwrdPath.onChange([&]() { loadTexture(); });
addProperty(_textureFwrdPath);
_textureFileForwards->setCallback([&](const File&) { _textureIsDirty = true; });
}
if (_ringsDictionary.hasKey(TextureBckwrdInfo.identifier)) {
_textureBckwrdPath = absPath(
_ringsDictionary.value<std::string>(TextureBckwrdInfo.identifier)
);
_textureFileBackwards = std::make_unique<File>(_textureBckwrdPath);
_textureBckwrdPath.onChange([&]() { loadTexture(); });
addProperty(_textureBckwrdPath);
_textureFileBackwards->setCallback([&](const File&) { _textureIsDirty = true; });
}
if (_ringsDictionary.hasKey(TextureUnlitInfo.identifier)) {
_textureUnlitPath = absPath(
_ringsDictionary.value<std::string>(TextureUnlitInfo.identifier)
);
_textureFileUnlit = std::make_unique<File>(_textureUnlitPath);
_textureUnlitPath.onChange([&]() { loadTexture(); });
addProperty(_textureUnlitPath);
_textureFileUnlit->setCallback([&](const File&) { _textureIsDirty = true; });
}
if (_ringsDictionary.hasKey(TextureColorInfo.identifier)) {
_textureColorPath = absPath(
_ringsDictionary.value<std::string>(TextureColorInfo.identifier)
);
_textureFileColor = std::make_unique<File>(_textureColorPath);
_textureColorPath.onChange([&]() { loadTexture(); });
addProperty(_textureColorPath);
_textureFileColor->setCallback([&](const File&) { _textureIsDirty = true; });
}
if (_ringsDictionary.hasKey(TextureTransparencyInfo.identifier)) {
_textureTransparencyPath = absPath(
_ringsDictionary.value<std::string>(TextureTransparencyInfo.identifier)
);
_textureFileTransparency = std::make_unique<File>(_textureTransparencyPath);
_textureTransparencyPath.onChange([&]() { loadTexture(); });
addProperty(_textureTransparencyPath);
_textureFileTransparency->setCallback([&](const File&) { _textureIsDirty = true; });
}
if (_ringsDictionary.hasValue<glm::dvec2>(OffsetInfo.identifier)) {
_offset = _ringsDictionary.value<glm::dvec2>(OffsetInfo.identifier);
}
addProperty(_offset);
_texturePath.onChange([&]() { loadTexture(); });
addProperty(_texturePath);
_textureFile->setCallback([&](const File&) { _textureIsDirty = true; });
if (_ringsDictionary.hasValue<double>(NightFactorInfo.identifier)) {
_nightFactor = static_cast<float>(
_ringsDictionary.value<double>(NightFactorInfo.identifier)
@@ -261,6 +389,7 @@ bool RingsComponent::isReady() const {
void RingsComponent::initializeGL() {
ZoneScoped
loadTexture();
compileShadowShader();
try {
@@ -285,7 +414,6 @@ void RingsComponent::initializeGL() {
glGenBuffers(1, &_vertexPositionBuffer);
createPlane();
loadTexture();
}
void RingsComponent::deinitializeGL() {
@@ -297,6 +425,13 @@ void RingsComponent::deinitializeGL() {
_textureFile = nullptr;
_texture = nullptr;
_textureFileForwards = nullptr;
_textureForwards = nullptr;
_textureFileBackwards = nullptr;
_textureBackwards = nullptr;
_textureFileUnlit = nullptr;
_textureUnlit = nullptr;
global::renderEngine->removeRenderProgram(_shader.get());
_shader = nullptr;
@@ -326,34 +461,144 @@ void RingsComponent::draw(const RenderData& data,
* modelTransform;
ghoul::opengl::TextureUnit ringTextureUnit;
ghoul::opengl::TextureUnit ringTextureFwrdUnit;
ghoul::opengl::TextureUnit ringTextureBckwrdUnit;
ghoul::opengl::TextureUnit ringTextureUnlitUnit;
ghoul::opengl::TextureUnit ringTextureColorUnit;
ghoul::opengl::TextureUnit ringTextureTransparencyUnit;
if (renderPass == GeometryAndShading) {
_shader->setUniform(
_uniformCache.modelViewProjectionMatrix,
modelViewProjectionTransform
);
_shader->setUniform(_uniformCache.textureOffset, _offset);
_shader->setUniform(_uniformCache.colorFilterValue, _colorFilter);
_shader->setUniform(_uniformCache.nightFactor, _nightFactor);
_shader->setUniform(_uniformCache.sunPosition, _sunPosition);
_shader->setUniform(_uniformCache.zFightingPercentage, _zFightingPercentage);
if (_isAdvancedTextureEnabled) {
_shader->setUniform(
_uniformCacheAdvancedRings.modelViewProjectionMatrix,
modelViewProjectionTransform
);
_shader->setUniform(_uniformCacheAdvancedRings.textureOffset, _offset);
_shader->setUniform(_uniformCacheAdvancedRings.colorFilterValue, _colorFilter);
_shader->setUniform(_uniformCacheAdvancedRings.nightFactor, _nightFactor);
_shader->setUniform(_uniformCacheAdvancedRings.sunPosition, _sunPosition);
const glm::dmat4 inverseModelTransform = glm::inverse(modelTransform);
ringTextureUnit.activate();
_texture->bind();
_shader->setUniform(_uniformCache.ringTexture, ringTextureUnit);
glm::vec3 sunPositionObjectSpace = glm::normalize(
glm::vec3(inverseModelTransform * glm::vec4(_sunPosition, 0.0))
);
// Adding the model transformation to the final shadow matrix so we have a
// complete transformation from the model coordinates to the clip space of
// the light position.
_shader->setUniform(
_uniformCache.shadowMatrix,
shadowData.shadowMatrix * modelTransform
);
_shader->setUniform(
_uniformCacheAdvancedRings.sunPositionObj,
sunPositionObjectSpace
);
_shader->setUniform(
_uniformCacheAdvancedRings.zFightingPercentage,
_zFightingPercentage
);
_shader->setUniform(
_uniformCacheAdvancedRings.modelViewProjectionMatrix,
modelViewProjectionTransform
);
ghoul::opengl::TextureUnit shadowMapUnit;
shadowMapUnit.activate();
glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture);
ringTextureFwrdUnit.activate();
_textureForwards->bind();
_shader->setUniform(
_uniformCacheAdvancedRings.ringTextureFwrd,
ringTextureFwrdUnit
);
_shader->setUniform(_uniformCache.shadowMapTexture, shadowMapUnit);
ringTextureBckwrdUnit.activate();
_textureBackwards->bind();
_shader->setUniform(
_uniformCacheAdvancedRings.ringTextureBckwrd,
ringTextureBckwrdUnit
);
ringTextureUnlitUnit.activate();
_textureUnlit->bind();
_shader->setUniform(
_uniformCacheAdvancedRings.ringTextureUnlit,
ringTextureUnlitUnit
);
ringTextureColorUnit.activate();
_textureColor->bind();
_shader->setUniform(
_uniformCacheAdvancedRings.ringTextureColor,
ringTextureColorUnit
);
ringTextureTransparencyUnit.activate();
_textureTransparency->bind();
_shader->setUniform(
_uniformCacheAdvancedRings.ringTextureTransparency,
ringTextureTransparencyUnit
);
// Adding the model transformation to the final shadow matrix so we have a
// complete transformation from the model coordinates to the clip space of
// the light position.
_shader->setUniform(
_uniformCacheAdvancedRings.shadowMatrix,
shadowData.shadowMatrix * modelTransform
);
const glm::dmat4 camToObjectTransform = glm::inverse(
data.camera.combinedViewMatrix()
* modelTransform
);
_camPositionObjectSpace = glm::normalize(
glm::vec3(camToObjectTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0))
);
_shader->setUniform(
_uniformCacheAdvancedRings.camPositionObj,
_camPositionObjectSpace
);
ghoul::opengl::TextureUnit shadowMapUnit;
shadowMapUnit.activate();
glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture);
_shader->setUniform(_uniformCacheAdvancedRings.shadowMapTexture, shadowMapUnit);
glEnable(GL_DEPTH_TEST);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else {
_shader->setUniform(
_uniformCache.modelViewProjectionMatrix,
modelViewProjectionTransform
);
_shader->setUniform(_uniformCache.textureOffset, _offset);
_shader->setUniform(_uniformCache.colorFilterValue, _colorFilter);
_shader->setUniform(_uniformCache.nightFactor, _nightFactor);
_shader->setUniform(_uniformCache.sunPosition, _sunPosition);
_shader->setUniform(_uniformCache.zFightingPercentage, _zFightingPercentage);
_shader->setUniform(
_uniformCache.modelViewProjectionMatrix,
modelViewProjectionTransform
);
ringTextureUnit.activate();
_texture->bind();
_shader->setUniform(_uniformCache.ringTexture, ringTextureUnit);
// Adding the model transformation to the final shadow matrix so we have a
// complete transformation from the model coordinates to the clip space of
// the light position.
_shader->setUniform(
_uniformCache.shadowMatrix,
shadowData.shadowMatrix * modelTransform
);
ghoul::opengl::TextureUnit shadowMapUnit;
shadowMapUnit.activate();
glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture);
_shader->setUniform(_uniformCache.shadowMapTexture, shadowMapUnit);
}
glEnable(GL_DEPTH_TEST);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else if (renderPass == GeometryOnly) {
_geometryOnlyShader->setUniform(
@@ -363,7 +608,13 @@ void RingsComponent::draw(const RenderData& data,
_geometryOnlyShader->setUniform(_geomUniformCache.textureOffset, _offset);
ringTextureUnit.activate();
_texture->bind();
if (_isAdvancedTextureEnabled) {
_textureForwards->bind();
}
else {
_texture->bind();
}
_geometryOnlyShader->setUniform(_geomUniformCache.ringTexture, ringTextureUnit);
}
@@ -377,6 +628,8 @@ void RingsComponent::draw(const RenderData& data,
if (renderPass == GeometryAndShading) {
_shader->deactivate();
global::renderEngine->openglStateCache().resetBlendState();
//global::renderEngine->openglStateCache().resetDepthState();
}
else if (renderPass == GeometryOnly) {
_geometryOnlyShader->deactivate();
@@ -416,9 +669,11 @@ void RingsComponent::update(const UpdateData& data) {
}
void RingsComponent::loadTexture() {
using namespace ghoul::io;
using namespace ghoul::opengl;
if (!_texturePath.value().empty()) {
using namespace ghoul::io;
using namespace ghoul::opengl;
std::unique_ptr<Texture> texture = TextureReader::ref().loadTexture(
absPath(_texturePath)
);
@@ -439,6 +694,143 @@ void RingsComponent::loadTexture() {
);
}
}
if (!_textureFwrdPath.value().empty()) {
std::unique_ptr<Texture> textureForwards = TextureReader::ref().loadTexture(
absPath(_textureFwrdPath)
);
if (textureForwards) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded forwards scattering texture from '{}'",
absPath(_textureFwrdPath)
)
);
_textureForwards = std::move(textureForwards);
_textureForwards->uploadTexture();
_textureForwards->setFilter(
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_textureFileForwards = std::make_unique<ghoul::filesystem::File>(
_textureFwrdPath
);
_textureFileForwards->setCallback(
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
}
}
if (!_textureBckwrdPath.value().empty()) {
std::unique_ptr<Texture> textureBackwards = TextureReader::ref().loadTexture(
absPath(_textureBckwrdPath)
);
if (textureBackwards) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded backwards scattering texture from '{}'",
absPath(_textureBckwrdPath)
)
);
_textureBackwards = std::move(textureBackwards);
_textureBackwards->uploadTexture();
_textureBackwards->setFilter(
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_textureFileBackwards = std::make_unique<ghoul::filesystem::File>(
_textureBckwrdPath
);
_textureFileBackwards->setCallback(
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
}
}
if (!_textureUnlitPath.value().empty()) {
std::unique_ptr<Texture> textureUnlit = TextureReader::ref().loadTexture(
absPath(_textureUnlitPath)
);
if (textureUnlit) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded unlit texture from '{}'",
absPath(_textureUnlitPath)
)
);
_textureUnlit = std::move(textureUnlit);
_textureUnlit->uploadTexture();
_textureUnlit->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_textureFileUnlit = std::make_unique<ghoul::filesystem::File>(_textureUnlitPath);
_textureFileUnlit->setCallback(
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
}
}
if (!_textureColorPath.value().empty()) {
std::unique_ptr<Texture> textureColor = TextureReader::ref().loadTexture(
absPath(_textureColorPath)
);
if (textureColor) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded color texture from '{}'",
absPath(_textureColorPath)
)
);
_textureColor = std::move(textureColor);
_textureColor->uploadTexture();
_textureColor->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_textureFileColor = std::make_unique<ghoul::filesystem::File>(_textureColorPath);
_textureFileColor->setCallback(
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
}
}
if (!_textureTransparencyPath.value().empty()) {
std::unique_ptr<Texture> textureTransparency = TextureReader::ref().loadTexture(
absPath(_textureTransparencyPath)
);
if (textureTransparency) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded unlit texture from '{}'",
absPath(_textureUnlitPath)
)
);
_textureTransparency = std::move(textureTransparency);
_textureTransparency->uploadTexture();
_textureTransparency->setFilter(
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
);
_textureFileTransparency = std::make_unique<ghoul::filesystem::File>(
_textureTransparencyPath
);
_textureFileTransparency->setCallback(
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
}
}
_isAdvancedTextureEnabled = _textureForwards && _textureBackwards && _textureUnlit;
}
void RingsComponent::createPlane() {
@@ -489,14 +881,42 @@ void RingsComponent::compileShadowShader() {
try {
global::renderEngine->removeRenderProgram(_shader.get());
_shader = global::renderEngine->buildRenderProgram(
"RingsProgram",
absPath("${MODULE_GLOBEBROWSING}/shaders/rings_vs.glsl"),
absPath("${MODULE_GLOBEBROWSING}/shaders/rings_fs.glsl"),
dict
);
// _shader = global::renderEngine->buildRenderProgram(
// "RingsProgram",
// absPath("${MODULE_GLOBEBROWSING}/shaders/rings_vs.glsl"),
// absPath("${MODULE_GLOBEBROWSING}/shaders/rings_fs.glsl"),
// dict
// );
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
// ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
// Uses multiple textures for the Rings
// See https://bjj.mmedia.is/data/s_rings/index.html for theory behind it
if (_isAdvancedTextureEnabled) {
_shader = global::renderEngine->buildRenderProgram(
"AdvancedRingsProgram",
absPath("${MODULE_GLOBEBROWSING}/shaders/advanced_rings_vs.glsl"),
absPath("${MODULE_GLOBEBROWSING}/shaders/advanced_rings_fs.glsl"),
dict
);
ghoul::opengl::updateUniformLocations(
*_shader,
_uniformCacheAdvancedRings,
UniformNamesAdvancedRings
);
}
else {
// Uses simple texture for the Rings
_shader = global::renderEngine->buildRenderProgram(
"RingsProgram",
absPath("${MODULE_GLOBEBROWSING}/shaders/rings_vs.glsl"),
absPath("${MODULE_GLOBEBROWSING}/shaders/rings_fs.glsl"),
dict
);
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
}
catch (const ghoul::RuntimeError& e) {
LERROR(e.message);
@@ -78,6 +78,11 @@ private:
void compileShadowShader();
properties::StringProperty _texturePath;
properties::StringProperty _textureFwrdPath;
properties::StringProperty _textureBckwrdPath;
properties::StringProperty _textureUnlitPath;
properties::StringProperty _textureColorPath;
properties::StringProperty _textureTransparencyPath;
properties::FloatProperty _size;
properties::Vec2Property _offset;
properties::FloatProperty _nightFactor;
@@ -91,18 +96,35 @@ private:
UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor,
sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage
) _uniformCache;
UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor,
sunPosition, sunPositionObj, camPositionObj, ringTextureFwrd, ringTextureBckwrd,
ringTextureUnlit, ringTextureColor, ringTextureTransparency, shadowMatrix,
shadowMapTexture, zFightingPercentage
) _uniformCacheAdvancedRings;
UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture
) _geomUniformCache;
std::unique_ptr<ghoul::opengl::Texture> _texture;
std::unique_ptr<ghoul::opengl::Texture> _textureForwards;
std::unique_ptr<ghoul::opengl::Texture> _textureBackwards;
std::unique_ptr<ghoul::opengl::Texture> _textureUnlit;
std::unique_ptr<ghoul::opengl::Texture> _textureTransparency;
std::unique_ptr<ghoul::opengl::Texture> _textureColor;
std::unique_ptr<ghoul::filesystem::File> _textureFile;
std::unique_ptr<ghoul::filesystem::File> _textureFileForwards;
std::unique_ptr<ghoul::filesystem::File> _textureFileBackwards;
std::unique_ptr<ghoul::filesystem::File> _textureFileUnlit;
std::unique_ptr<ghoul::filesystem::File> _textureFileColor;
std::unique_ptr<ghoul::filesystem::File> _textureFileTransparency;
ghoul::Dictionary _ringsDictionary;
bool _textureIsDirty = false;
bool _isAdvancedTextureEnabled = false;
GLuint _quad = 0;
GLuint _vertexPositionBuffer = 0;
bool _planeIsDirty = false;
glm::vec3 _sunPosition = glm::vec3(0.f);
glm::vec3 _camPositionObjectSpace = glm::vec3(0.f);
};
} // namespace openspace
+1 -1
View File
@@ -78,4 +78,4 @@ create_new_module(
${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES}
)
include_external_library(${imgui_module} PRIVATE Imgui ${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui)
include_external_library(${imgui_module} PUBLIC Imgui ${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui)
+2
View File
@@ -29,5 +29,7 @@ add_library(Imgui
${PROJECT_SOURCE_DIR}/imgui.cpp
${PROJECT_SOURCE_DIR}/imgui_demo.cpp
${PROJECT_SOURCE_DIR}/imgui_draw.cpp
${PROJECT_SOURCE_DIR}/imgui_tables.cpp
${PROJECT_SOURCE_DIR}/imgui_widgets.cpp
)
target_include_directories(Imgui PUBLIC ${PROJECT_SOURCE_DIR})
-21
View File
@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+1 -1
View File
@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014-2017 Omar Cornut and ImGui contributors
Copyright (c) 2014-2021 Omar Cornut
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
-247
View File
@@ -1,247 +0,0 @@
dear imgui,
=====
[![Build Status](https://travis-ci.org/ocornut/imgui.svg?branch=master)](https://travis-ci.org/ocornut/imgui)
[![Coverity Status](https://scan.coverity.com/projects/4720/badge.svg)](https://scan.coverity.com/projects/4720)
(This library is free but needs your support to sustain its development. There are lots of desirable new features and maintenance to do. If you are an individual using dear imgui, please consider donating via Patreon or PayPal. If your company is using dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail.)
Monthly donations via Patreon:
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/imgui)
One-off donations via PayPal:
<br>[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
Dear ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
Dear ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
- imgui.cpp
- imgui.h
- imgui_demo.cpp
- imgui_draw.cpp
- imgui_internal.h
- imconfig.h (empty by default, user-editable)
- stb_rect_pack.h
- stb_textedit.h
- stb_truetype.h
No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
Your code passes mouse/keyboard inputs and settings to Dear ImGui (see example applications for more details). After Dear ImGui is setup, you can use it like in this example:
![screenshot of sample code alongside its output with dear imgui](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/code_sample_01.png)
Dear ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
_A common misunderstanding is to think that immediate mode gui == immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes, as the gui functions are called by the user. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
Dear ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
Binaries/Demo
-------------
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
- [imgui-demo-binaries-20171013.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20171013.zip) (Windows binaries, Dear ImGui 1.52 WIP built 2017/10/13, 5 executables)
Bindings
--------
Integrating Dear ImGui within your custom engine is a matter of wiring mouse/keyboard inputs and providing a render function that can bind a texture and render simple textured triangles. The examples/ folder is populated with applications doing just that. If you are an experienced programmer it should take you less than an hour to integrate Dear ImGui in your custom engine, but make sure to spend time reading the FAQ, the comments and other documentation!
_NB: those third-party bindings may be more or less maintained, more or less close to the spirit of original API and therefore I cannot give much guarantee about them. People who create language bindings sometimes haven't used the C++ API themselves (for the good reason that they aren't C++ users). Dear ImGui was designed with C++ in mind and some of the subtleties may be lost in translation with other languages. If your language supports it, I would suggest replicating the function overloading and default parameters used in the original, else the API may be harder to use. In doubt, please check the original C++ version first!_
Languages:
- C (cimgui): thin c-api wrapper for ImGui https://github.com/Extrawurst/cimgui
- C#/.Net (ImGui.NET): An ImGui wrapper for .NET Core https://github.com/mellinoe/ImGui.NET
- D (DerelictImgui): Dynamic bindings for the D programming language: https://github.com/Extrawurst/DerelictImgui
- Go (go-imgui): https://github.com/Armored-Dragon/go-imgui
- Lua: https://github.com/patrickriordan/imgui_lua_bindings
- Pascal (imgui-pas) https://github.com/dpethes/imgui-pas
- Python (CyImGui): Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
- Python (pyimgui): Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
- Rust (imgui-rs): Rust bindings for dear imgui https://github.com/Gekkio/imgui-rs
Frameworks:
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
- Unmerged PR: DirectX12: https://github.com/ocornut/imgui/pull/301
- Unmerged PR: SDL2 + OpenGLES + Emscripten: https://github.com/ocornut/imgui/pull/336
- Unmerged PR: FreeGlut + OpenGL2: https://github.com/ocornut/imgui/pull/801
- Unmerged PR: Native Win32 and OSX: https://github.com/ocornut/imgui/pull/281
- Unmerged PR: Android: https://github.com/ocornut/imgui/pull/421
- Cinder: https://github.com/simongeilfus/Cinder-ImGui
- cocos2d-x: https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551
- Flexium/SFML (FlexGUI): https://github.com/DXsmiley/FlexGUI
- Irrlicht (IrrIMGUI): https://github.com/ZahlGraf/IrrIMGUI
- Ogre: https://bitbucket.org/LMCrashy/ogreimgui/src
- openFrameworks (ofxImGui): https://github.com/jvcleave/ofxImGui
- LÖVE: https://github.com/slages/love-imgui
- NanoRT (software raytraced) https://github.com/syoyo/imgui/tree/nanort/examples/raytrace_example
- Qt3d https://github.com/alpqr/imgui-qt3d
- Unreal Engine 4: https://github.com/segross/UnrealImGui or https://github.com/sronsse/UnrealEngine_ImGui
- SFML: https://github.com/EliasD/imgui-sfml or https://github.com/Mischa-Alff/imgui-backends
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/).
Please contact me with the Issues tracker or Twitter to fix/update this list.
Gallery
-------
See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for some user creations.
Also see the [Mega screenshots](https://github.com/ocornut/imgui/issues/1273) for an idea of the available features.
![screenshot 1](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/examples_01.png)
[![screenshot game](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v149/gallery_TheDragonsTrap-01-thumb.jpg)](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
![screenshot 2](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/examples_02.png)
[![screenshot profiler](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler-880.jpg)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
![screenshot picker](https://user-images.githubusercontent.com/8225057/29062188-471e95ba-7c53-11e7-9618-c4484c0b75fe.PNG)
![screenshot 5](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v151/menus.png)
![screenshot 6](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/skinning_sample_02.png)
![screenshot 7](https://cloud.githubusercontent.com/assets/8225057/7903336/96f0fb7c-07d0-11e5-95d6-41c6a1595e5a.png)
Dear ImGui can load TTF/OTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
```
ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
// For Microsoft IME, pass your HWND to enable IME positioning:
io.ImeWindowHandle = my_hwnd;
```
![Japanese screenshot](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/code_sample_01_jp.png)
References
----------
The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.
- [Johannes 'johno' Norneby's article](http://www.johno.se/book/imgui.html).
- [A presentation by Rickard Gustafsson and Johannes Algelind](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/Advanced%20Computer%20Graphics/IMGUI.pdf).
- [Jari Komppa's tutorial on building an ImGui library](http://iki.fi/sol/imgui/).
- [Casey Muratori's original video that popularized the concept](https://mollyrocket.com/861).
- [Nicolas Guillemot's CppCon'16 flashtalk about Dear ImGui](https://www.youtube.com/watch?v=LSRJ1jZq90k).
- [Thierry Excoffier's Zero Memory Widget](http://perso.univ-lyon1.fr/thierry.excoffier/ZMW/).
See the [Links page](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to different languages and frameworks.
Frequently Asked Question (FAQ)
-------------------------------
<b>Where is the documentation?</b>
- The documentation is at the top of imgui.cpp + effectively imgui.h.
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowTestWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
<b>Which version should I get?</b>
I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master. The library is fairly stable and regressions tend to be fixed fast when reported. You may also want to checkout the [navigation branch](https://github.com/ocornut/imgui/tree/navigation) if you want to use Dear ImGui with a gamepad (it is also possible to map keyboard inputs to some degree). The Navigation branch is being kept up to date with Master.
<b>Why the odd dual naming, "dear imgui" vs "ImGui"?</b>
The library started its life and is best known as "ImGui" only due to the fact that I didn't give it a proper name when I released it. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations. It seemed confusing and unfair to hog the name. To reduce the ambiguity without affecting existing codebases, I have decided on an alternate, longer name "dear imgui" that people can use to refer to this specific library in ambiguous situations.
<b>What is ImTextureID and how do I display an image?</b>
<br><b>I integrated Dear ImGui in my engine and the text or lines are blurry..</b>
<br><b>I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..</b>
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs.</b>
<br><b>How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?</b>
<br><b>How can I load a different font than the default?</b>
<br><b>How can I easily use icons in my application?</b>
<br><b>How can I load multiple fonts?</b>
<br><b>How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?</b>
<br><b>How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)</b>
<br><b>How can I use the drawing facilities without an Dear ImGui window? (using ImDrawList API)</b>
See the FAQ in imgui.cpp for answers.
<b>How do you use Dear ImGui on a platform that may not have a mouse or keyboard?</b>
I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. Dear ImGui allows to increase the hit box of widgets (via the _style.TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate. You can also checkout the beta [navigation branch](https://github.com/ocornut/imgui/tree/navigation) which provides support for using Dear ImGui with a game controller.
<b>Can you create elaborate/serious tools with Dear ImGui?</b>
Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools).
Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might requires you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful.
<b>Is Dear ImGui fast?</b>
Probably fast enough for most uses. Down to the foundation of its visual design, Dear ImGui is engineered to be fairly performant both in term of CPU and GPU usage. Running elaborate code and creating elaborate UI will of course have a cost but Dear ImGui aims to minimize it.
Mileage may vary but the following screenshot can give you a rough idea of the cost of running and rendering UI code (In the case of a trivial demo application like this one, your driver/os setup are likely to be the bottleneck. Testing performance as part of a real application is recommended).
![performance screenshot](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v138/performance_01.png)
This is showing framerate for the full application loop on my 2011 iMac running Windows 7, OpenGL, AMD Radeon HD 6700M with an optimized executable. In contrast, librairies featuring higher-quality rendering and layouting techniques may have a higher resources footprint.
If you intend to display large lists of items (say, 1000+) it can be beneficial for your code to perform clipping manually - one way is using helpers such as ImGuiListClipper - in order to avoid submitting them to Dear ImGui in the first place. Even though ImGui will discard your clipped items it still needs to calculate their size and that overhead will add up if you have thousands of items. If you can handle clipping and height positionning yourself then browsing a list with millions of items isn't a problem.
<b>Can you reskin the look of Dear ImGui?</b>
You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimised to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Below is a screenshot from [LumixEngine](https://github.com/nem0/LumixEngine) with custom colors + a docking/tabs extension (both of which you can find in the Issues section and will eventually be merged):
![LumixEngine](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v151/lumix-201710-rearranged.png)
<b>Why using C++ (as opposed to C)?</b>
Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost-insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
There is an reasonably maintained [c-api for ImGui](https://github.com/Extrawurst/cimgui) by Stephan Dilly designed for binding in other languages. I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Links](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to other languages.
Support dear imgui
------------------
<b>How can I help financing further development of Dear ImGui?</b>
Your contributions are keeping the library alive. If you are an individual using dear imgui, please consider donating to enable me to spend more time improving the library.
Monthly donations via Patreon:
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/imgui)
One-off donations via PayPal:
<br>[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
If your company uses dear imgui, please consider financial support (e.g. sponsoring a few weeks/months of development). I can invoice for private support, custom development etc. E-mail: omarcornut at gmail. Thanks!
Credits
-------
Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
I first discovered imgui principles at [Q-Games](http://www.q-games.com) where Atman had dropped his own simple imgui implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating on it.
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
Embeds [stb_textedit.h, stb_truetype.h, stb_rectpack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
Ongoing dear imgui development is financially supported on [**Patreon**](http://www.patreon.com/imgui).
Double-chocolate sponsors:
- Media Molecule
- Mobigame
- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
- Aras Pranckevičius
- Lizardcube
- Greggman
Salty caramel supporters:
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse.
Caramel supporters:
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić.
And other supporters; thanks!
(Please contact me or PR if you would like to be added or removed from this list)
License
-------
Dear ImGui is licensed under the MIT License, see LICENSE for more information.
+82 -25
View File
@@ -1,42 +1,79 @@
//-----------------------------------------------------------------------------
// USER IMPLEMENTATION
// This file contains compile-time options for ImGui.
// Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO().
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
//-----------------------------------------------------------------------------
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
//-----------------------------------------------------------------------------
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
//-----------------------------------------------------------------------------
#pragma once
//---- Define assertion handler. Defaults to calling assert().
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )
//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//---- Include imgui_user.h at the end of imgui.h
//---- Disable all of Dear ImGui or don't implement standard windows.
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty.
//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
//---- Include imgui_user.h at the end of imgui.h as a convenience
//#define IMGUI_INCLUDE_IMGUI_USER_H
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
//---- Don't implement test window functionality (ShowTestWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
//---- It is very strongly recommended to NOT disable the test windows. Please read the comment at the top of imgui_demo.cpp to learn why.
//#define IMGUI_DISABLE_TEST_WINDOWS
//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself.
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends)
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
//#define IMGUI_USE_BGRA_PACKED_COLOR
//---- Implement STB libraries in a namespace to avoid linkage conflicts
//#define IMGUI_STB_NAMESPACE ImGuiStb
//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
//#define IMGUI_USE_WCHAR32
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
//---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
// Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
// #define IMGUI_USE_STB_SPRINTF
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
// On Windows you may use vcpkg with 'vcpkg install freetype' + 'vcpkg integrate install'.
//#define IMGUI_ENABLE_FREETYPE
//---- Use stb_truetype to build and rasterize the font atlas (default)
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
//#define IMGUI_ENABLE_STB_TRUETYPE
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
/*
#define IM_VEC2_CLASS_EXTRA \
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
@@ -47,15 +84,35 @@
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/
//---- Use 32-bit vertex indices (instead of default: 16-bit) to allow meshes with more than 64K vertices
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
//#define ImDrawIdx unsigned int
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
//struct ImDrawList;
//struct ImDrawCmd;
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
//#define ImDrawCallback MyImDrawCallback
//---- Debug Tools: Macro to break in Debugger
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
//#define IM_DEBUG_BREAK IM_ASSERT(0)
//#define IM_DEBUG_BREAK __debugbreak()
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
// This adds a small runtime cost which is why it is not enabled by default.
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
//---- Debug Tools: Enable slower asserts
//#define IMGUI_DEBUG_PARANOID
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
//---- e.g. create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers.
/*
namespace ImGui
{
void Value(const char* prefix, const MyMatrix44& v, const char* float_format = NULL);
void MyFunction(const char* name, const MyMatrix44& v);
}
*/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More