Test MAS model rendering with existing functionality

This commit is contained in:
Matthias Berg
2018-04-18 11:12:42 -04:00
parent 4ddcc3bef2
commit c87d784656
13 changed files with 153 additions and 13 deletions

53
data/assets/masTest.scene Normal file
View File

@@ -0,0 +1,53 @@
local assetHelper = asset.require('util/asset_helper')
local sceneHelper = asset.require('util/scene_helper')
local propertyHelper = asset.require('util/property_helper')
-- Specifying which other assets should be loaded in this scene
asset.require('spice/base')
assetHelper.requestAll(asset, 'scene/solarsystem/sun')
assetHelper.requestAll(asset, 'scene/digitaluniverse')
-- Load default key bindings applicable to most scenes
asset.require('util/default_keybindings')
asset.request('customization/globebrowsing')
local sunAsset = asset.require('scene/solarsystem/sun/sun')
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local masAsset = asset.require('scene/solarsystem/model/mas/mas')
asset.onInitialize(function ()
-- openspace.time.setTime("2017 JUN 01 00:00:00")
openspace.time.setTime(openspace.time.currentWallTime())
openspace.setDefaultDashboard()
openspace.setDefaultGuiSorting()
openspace.globebrowsing.loadWMSServersFromFile(
openspace.absPath("${DATA}/globebrowsing_servers.lua")
)
openspace.addVirtualProperty(
"BoolProperty",
"Show Trails",
"Scene.*Trail.renderable.Enabled",
"Disable or enable all trails of the sHmmcene at the same time",
true,
nil,
nil
)
openspace.navigation.setCameraState({
Focus = masAsset.Mas.Identifier,
Position = { 10000000000, 10000000000, 10000000000 },
Rotation = { 0.758797, 0.221490, -0.605693, -0.091135 },
})
end)
asset.onDeinitialize(function ()
sceneHelper.unbindKeys(Keybindings)
openspace.removeVirtualProperty("*Trail.renderable.Enabled")
end)

View File

@@ -0,0 +1 @@
asset.request('.model/mas')

View File

@@ -0,0 +1,36 @@
local assetHelper = asset.require("util/asset_helper")
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
asset.require("spice/base")
-- Volume module
local Mas = {
Identifier = "Mas",
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
Renderable = {
Type = "RenderableTimeVaryingVolume",
Dimensions = {699, 315, 295},
StepSize = "0.01",
TransferFunction = "${DATA}/mas-data/raw/basic.tf",
SourceDirectory = "${DATA}/mas-data/raw",
LowerValueBound = 1,
UpperValueBound = 1000,
MinValue = 0.0,
MaxValue = 56000.0,
GridType = "Spherical",
SecondsBefore = 24*60*60,
SecondsAfter = 5.0,
Time = "2012-07-01T00:00:00.001",
VisUnit = "rho",
},
Translation = {
Type = "StaticTranslation",
Position = {10000.0, 10000.0, 10000.0},
},
GUI = {
Path = "/Solar System/Mas",
Hidden = true
},
}
assetHelper.registerSceneGraphNodesAndExport(asset, {Mas})

View File

@@ -0,0 +1,9 @@
width 1024
lower 0.0
upper 1.0
mappingkey 0.15 250 0 0 0
mappingkey 0.20 250 0 0 20
mappingkey 0.35 250 20 0 20
mappingkey 0.40 250 0 0 0
mappingkey 0.60 250 0 0 0
mappingkey 0.80 0 0 200 255

View File

@@ -0,0 +1,21 @@
-- This is the BATSRUS batch conversion example..
path = "${DATA}/mas-sampledata/CORHEL_MAS/rawdata/";
baseNames = {"3d__var_1_e20120714-060000-000.out", "3d__var_1_e20120714-061015-031.out"}
tasks = {}
for i=1,#baseNames do
tasks[#tasks+1] = {
Type = "KameleonVolumeToRawTask",
Input = path .. baseNames[i] .. ".cdf",
Variable = "T",
Dimensions = {129, 101, 101},
LowerDomainBound = {-224, -32, -32},
UpperDomainBound = {32, 32, 32},
RawVolumeOutput = path .. baseNames[i] .. ".rawvolume",
DictionaryOutput = path .. baseNames[i] .. ".dictionary"
}
end
return tasks;

View File

@@ -0,0 +1,12 @@
return {{
Type = "KameleonVolumeToRawTask",
Input = "${DATA}/mas-data/mas_merged_step_101.cdf",
Variable = "rho",
Dimensions = {699, 315, 295},
LowerDomainBound = {0, -90, 0},
UpperDomainBound = {2.5, 90, 360},
Time = "2017-06-01T00:00:00.001",
RawVolumeOutput = "${DATA}/mas-data/raw/mas_merged_step_101.cdf.rawvolume",
DictionaryOutput = "${DATA}/mas-data/raw/mas_merged_step_101.cdf.dictionary"
}}

8
data/tasks/inspect.task Normal file
View File

@@ -0,0 +1,8 @@
return {
{
Type = "KameleonDocumentationTask",
Input = "${DATA}/mas-data/mas_merged_step_101.cdf",
Output = "${DATA}/mas-data/output.html"
}
}

View File

@@ -43,7 +43,7 @@ public:
void setPath(const std::string& filepath);
ghoul::opengl::Texture& getTexture();
void bind();
void update();
void updateTexture();
glm::vec4 sample(size_t t);
size_t width();
void setCallback(TfChangedCallback callback);

View File

@@ -463,7 +463,7 @@ void RenderableMultiresVolume::initializeGL() {
success &= _atlasManager && _atlasManager->initialize();
_transferFunction->update();
_transferFunction->updateTexture();
success &= isReady();

View File

@@ -278,7 +278,6 @@ void RenderableTimeVaryingVolume::initializeGL() {
t.texture->uploadTexture();
}
_transferFunctionHandler->initialize();
_clipPlanes->initialize();
_raycaster = std::make_unique<volume::BasicVolumeRaycaster>(nullptr, _transferFunctionHandler, _clipPlanes);
@@ -360,6 +359,7 @@ void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path)
std::string timeString = dictionary.value<std::string>(KeyTime);
t.time = Time::convertTime(timeString);
// t.time = Time::convertTime("2012-07-01T00:00:00.001");
t.inRam = false;
t.onGpu = false;

View File

@@ -115,13 +115,13 @@ namespace openspace {
}
void TransferFunctionHandler::setHistogramProperty(std::shared_ptr<openspace::Histogram> histogram) {
// histogram->print();
_histogramProperty.setValue(histogram->getBinaryData());
}
void TransferFunctionHandler::setTexture() {
if (_transferFunctionProperty.value().createTexture(_texture)) {
uploadTexture();
useTxtTexture = false;
}
}
@@ -156,6 +156,7 @@ namespace openspace {
void TransferFunctionHandler::setFilepath(const std::string& path) {
_filePath = path;
_transferFunction->updateTexture();
}
ghoul::opengl::Texture& TransferFunctionHandler::getTexture() {

View File

@@ -67,7 +67,6 @@ public:
std::shared_ptr<openspace::TransferFunction> getTransferFunction();
private:
bool useTxtTexture = true;
properties::StringProperty _transferFunctionPath;
properties::StringProperty _dataUnit;
properties::StringProperty _minValue;

View File

@@ -87,13 +87,13 @@ void TransferFunction::setPath(const std::string& filepath) {
ghoul::opengl::Texture& TransferFunction::getTexture() {
ghoul_assert(_texture != nullptr, "Transfer function is null");
update();
updateTexture();
return *_texture.get();
}
void TransferFunction::update() {
/* if (_needsUpdate) {
if (hasExtension(_filepath, "txt")) {
void TransferFunction::updateTexture() {
if (_needsUpdate) {
if (hasExtension(_filepath, "tf")) {
setTextureFromTxt();
} else {
setTextureFromImage();
@@ -103,7 +103,7 @@ void TransferFunction::update() {
if (_tfChangedCallback) {
_tfChangedCallback(*this);
}
}*/
}
}
void TransferFunction::setCallback(TfChangedCallback callback) {
@@ -131,7 +131,7 @@ void TransferFunction::setTextureFromTxt(std::shared_ptr<ghoul::opengl::Texture>
std::string key;
iss >> key;
if(key == "width") {
if(key == "width") {
iss >> width;
} else if(key == "lower") {
iss >> lower;
@@ -240,12 +240,12 @@ glm::vec4 TransferFunction::sample(size_t offset) {
}
size_t TransferFunction::width() {
update();
updateTexture();
return _texture->width();
}
void TransferFunction::bind() {
update();
updateTexture();
_texture->bind();
}
}