Changes in ProjectionComponent initialization

- Remove parsing function
  - Make ProjectionComponent accept sub-dictionary
Remove "Rotation" key-value from RenderableModelProjection
  - Information moved into RenderableFOV to do conversion between object and frame
Changes in mod files to reflect ProjectionComponent and RenderableModelProjection changes
Added Documentation to
  - RenderablePlanetProjection
  - RenderableModelProjection
  - ProjectionComponent
  - PlanetGeometry
  - ModelGeometry
This commit is contained in:
Alexander Bock
2016-10-27 21:45:49 +02:00
parent f4beb5ed6a
commit 18b8aab898
26 changed files with 770 additions and 555 deletions

View File

@@ -22,20 +22,22 @@ return {
Observer = "NEW HORIZONS",
Target = "CALLISTO",
Aberration = "NONE",
AspectRatio = 2
AspectRatio = 2,
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Transform = {
Translation = {
@@ -74,7 +76,7 @@ return {
Position = {0, -10000000, 0}
},
},
},
},
-- CallistoTrail module
{
Name = "CallistoTrail",
@@ -93,7 +95,7 @@ return {
Type = "simple",
Color = "${COMMON_MODULE}/textures/glare_blue.png",
-- need to add different texture
},
},
},
}
}

View File

@@ -22,20 +22,22 @@ return {
Observer = "NEW HORIZONS",
Target = "EUROPA",
Aberration = "NONE",
AspectRatio = 2
AspectRatio = 2,
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Transform = {
Translation = {

View File

@@ -22,20 +22,22 @@ return {
Observer = "NEW HORIZONS",
Target = "GANYMEDE",
Aberration = "NONE",
AspectRatio = 2
AspectRatio = 2,
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Transform = {
Translation = {

View File

@@ -22,20 +22,22 @@ return {
Observer = "NEW HORIZONS",
Target = "IO",
Aberration = "NONE",
AspectRatio = 2
AspectRatio = 2,
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
},
Transform = {
Translation = {

View File

@@ -38,53 +38,54 @@ return {
Observer = "NEW HORIZONS",
Target = "JUPITER",
Aberration = "NONE",
AspectRatio = 2
},
DataInputTranslation = {
Instrument = {
LORRI = {
DetectorType = "Camera",
Spice = {"NH_LORRI"},
},
},
Target ={
Read = {
"TARGET_NAME",
"INSTRUMENT_HOST_NAME",
"INSTRUMENT_ID",
"START_TIME",
"STOP_TIME",
"DETECTOR_TYPE",
--"SEQUENCE_ID",
},
Convert = {
JRINGS = {"IMAGE-PLANE" },
J1IO = {"IO" },
J2EUROPA = {"EUROPA" },
J6HIMALIA = {"IMAGE-PLANE" },
J7ELARA = {"IMAGE-PLANE" },
CALIBRATION = {"CALIBRATION" },
JUPITER = {"JUPITER" },
CALLISTO = {"CALLISTO" },
GANYMEDE = {"GANYMEDE" },
EARTH = {"EARTH" },
NEWHORIZONS = {"NEW HORIZONS"},
CCD = {"CAMERA" },
FRAMECCD = {"SCANNER" },
AspectRatio = 2,
DataInputTranslation = {
Instrument = {
LORRI = {
DetectorType = "Camera",
Spice = {"NH_LORRI"},
},
},
Target ={
Read = {
"TARGET_NAME",
"INSTRUMENT_HOST_NAME",
"INSTRUMENT_ID",
"START_TIME",
"STOP_TIME",
"DETECTOR_TYPE",
--"SEQUENCE_ID",
},
Convert = {
JRINGS = {"IMAGE-PLANE" },
J1IO = {"IO" },
J2EUROPA = {"EUROPA" },
J6HIMALIA = {"IMAGE-PLANE" },
J7ELARA = {"IMAGE-PLANE" },
CALIBRATION = {"CALIBRATION" },
JUPITER = {"JUPITER" },
CALLISTO = {"CALLISTO" },
GANYMEDE = {"GANYMEDE" },
EARTH = {"EARTH" },
NEWHORIZONS = {"NEW HORIZONS"},
CCD = {"CAMERA" },
FRAMECCD = {"SCANNER" },
},
},
},
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO"
}
}
},
Transform = {

View File

@@ -90,7 +90,7 @@ return {
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = "models/NewHorizonsCleanModel.obj",
Magnification = 4,
-- Magnification = 4,
},
Textures = {
Type = "simple",
@@ -114,6 +114,10 @@ return {
SourceFrame = "NH_SPACECRAFT",
DestinationFrame = "GALACTIC",
},
Scale = {
Type = "StaticScale",
Scale = 1000
}
},
},
--NewHorizonsTrail module
@@ -150,7 +154,7 @@ return {
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = "models/Labels.obj",
Magnification = 4,
-- Magnification = 4,
},
Textures = {
Type = "simple",
@@ -166,7 +170,7 @@ return {
Fadeable = false,
Ghosting = false,
},
},
}
},
{

View File

@@ -22,38 +22,35 @@ return {
Parent = "PlutoBarycenter",
Renderable = {
Type = "RenderablePlanetProjection",
Frame = "IAU_CHARON",
Body = "CHARON",
Geometry = {
Type = "SimpleSphere",
Radius = { 6.035 , 5 },
Segments = 100
},
Textures = {
Type = "simple",
Color = ColorTexture,
Height = "textures/cpdem-Mcolor2-MLorriCA-lr-5_ZMfs-cyl.jpg",
Project = "textures/defaultProj.png",
Sequencing = "true",
},
Projection = {
Observer = "NEW HORIZONS",
Target = "CHARON",
Aberration = "NONE",
AspectRatio = 2
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"PLUTO",
"CHARON"
AspectRatio = 2,
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"PLUTO",
"CHARON"
}
}
},
Transform = {

View File

@@ -36,19 +36,14 @@ return {
Parent = "PlutoBarycenter",
Renderable = {
Type = "RenderablePlanetProjection",
Frame = "IAU_PLUTO",
Body = "PLUTO",
Geometry = {
Type = "SimpleSphere",
Radius = { 1.173 , 6 },
Segments = 100
},
Textures = {
Type = "simple",
Color = ColorTexture,
Height = "textures/pluto_shenk_heightmap.jpg",
Project = "textures/3.jpg",
Sequencing = "true"
},
Projection = {
Sequence = "${OPENSPACE_DATA}/scene/newhorizons/pluto/pluto/images",
@@ -57,103 +52,106 @@ return {
Observer = "NEW HORIZONS",
Target = "PLUTO",
Aberration = "NONE",
AspectRatio = 2
},
DataInputTranslation = {
Instrument = {
LORRI = {
DetectorType = "Camera",
Spice = {"NH_LORRI"},
},
RALPH_MVIC_PAN_FRAME = {
DetectorType = "Scanner",
StopCommand = "RALPH_ABORT",
Spice = {"NH_RALPH_MVIC_FT"},
},
RALPH_MVIC_COLOR = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = { "NH_RALPH_MVIC_NIR",
"NH_RALPH_MVIC_METHANE",
"NH_RALPH_MVIC_RED",
"NH_RALPH_MVIC_BLUE" },
},
RALPH_LEISA = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = {"NH_RALPH_LEISA"},
},
RALPH_MVIC_PAN1 = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = {"NH_RALPH_MVIC_PAN1"},
},
RALPH_MVIC_PAN2 = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = {"NH_RALPH_MVIC_PAN2"},
},
ALICE_Use_AIRGLOW = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_PIXELLIST",
Spice = {"NH_ALICE_AIRGLOW"},
},
ALICE_Use_AIRGLOW = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_HISTOGRAM",
Spice = {"NH_ALICE_AIRGLOW"},
},
ALICE_Use_SOCC = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_PIXELLIST",
Spice = {"NH_ALICE_SOC"},
},
ALICE_Use_SOCC = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_HISTOGRAM",
Spice = {"NH_ALICE_SOC"},
},
REX_START = {
DetectorType = "Scanner",
StopCommand = "REX_MODE_OFF",
Spice = { "NH_REX" },
}
},
Target ={
Read = {
"TARGET_NAME",
"INSTRUMENT_HOST_NAME",
"INSTRUMENT_ID",
"START_TIME",
"STOP_TIME",
"DETECTOR_TYPE",
--"SEQUENCE_ID",
},
Convert = {
PLUTO = {"PLUTO" },
NEWHORIZONS = {"NEW HORIZONS"},
CCD = {"CAMERA" },
FRAMECCD = {"SCANNER" },
AspectRatio = 2,
DataInputTranslation = {
Instrument = {
LORRI = {
DetectorType = "Camera",
Spice = {"NH_LORRI"},
},
RALPH_MVIC_PAN_FRAME = {
DetectorType = "Scanner",
StopCommand = "RALPH_ABORT",
Spice = {"NH_RALPH_MVIC_FT"},
},
RALPH_MVIC_COLOR = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = { "NH_RALPH_MVIC_NIR",
"NH_RALPH_MVIC_METHANE",
"NH_RALPH_MVIC_RED",
"NH_RALPH_MVIC_BLUE" },
},
RALPH_LEISA = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = {"NH_RALPH_LEISA"},
},
RALPH_MVIC_PAN1 = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = {"NH_RALPH_MVIC_PAN1"},
},
RALPH_MVIC_PAN2 = {
DetectorType = "Scanner",
StopCommand = "END_NOM",
Spice = {"NH_RALPH_MVIC_PAN2"},
},
ALICE_Use_AIRGLOW = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_PIXELLIST",
Spice = {"NH_ALICE_AIRGLOW"},
},
ALICE_Use_AIRGLOW = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_HISTOGRAM",
Spice = {"NH_ALICE_AIRGLOW"},
},
ALICE_Use_SOCC = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_PIXELLIST",
Spice = {"NH_ALICE_SOC"},
},
ALICE_Use_SOCC = {
DetectorType = "Scanner",
StopCommand = "ALICE_END_HISTOGRAM",
Spice = {"NH_ALICE_SOC"},
},
REX_START = {
DetectorType = "Scanner",
StopCommand = "REX_MODE_OFF",
Spice = { "NH_REX" },
}
},
Target ={
Read = {
"TARGET_NAME",
"INSTRUMENT_HOST_NAME",
"INSTRUMENT_ID",
"START_TIME",
"STOP_TIME",
"DETECTOR_TYPE",
--"SEQUENCE_ID",
},
Convert = {
PLUTO = {"PLUTO" },
NEWHORIZONS = {"NEW HORIZONS"},
CCD = {"CAMERA" },
FRAMECCD = {"SCANNER" },
},
},
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"PLUTO",
"CHARON",
"NIX",
"HYDRA",
"P5",
"P4",
}
},
Instrument = {
Name = "NH_LORRI",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.2907,
Aspect = 1,
Near = 0.2,
Far = 10000,
},
PotentialTargets = {
"PLUTO",
"CHARON",
"NIX",
"HYDRA",
"P5",
"P4",
}
},
Transform = {
Translation = {

View File

@@ -38,53 +38,51 @@ return {
Project = "textures/defaultProj.png",
Default = "textures/defaultProj.png"
},
Rotation = {
Source = "IAU_BENNU",
Destination = "GALACTIC"
},
Projection = {
Sequence = "InstrumentTimes",
SequenceType = "instrument-times",
Observer = "OSIRIS-REX",
Target = BENNU_BODY,
Aberration = "NONE",
AspectRatio = 2
},
DataInputTranslation = {
Instruments = {
ORX_OCAMS_POLYCAM = {
DetectorType = "Camera",
Spice = {"ORX_OCAMS_POLYCAM"},
Files = {
"BaseballDiamond_PolyCam.txt",
--"OrbitalB_Site08_PolyCamImages.txt",
"Recon_225m_Equatorial_PolyCam.txt",
AspectRatio = 2,
DataInputTranslation = {
Instruments = {
ORX_OCAMS_POLYCAM = {
DetectorType = "Camera",
Spice = {"ORX_OCAMS_POLYCAM"},
Files = {
"BaseballDiamond_PolyCam.txt",
--"OrbitalB_Site08_PolyCamImages.txt",
"Recon_225m_Equatorial_PolyCam.txt",
},
},
},
ORX_REXIS = {
DetectorType = "Camera",
Spice = {"ORX_REXIS"},
Files = {
"DetailedSurvey_EquatorialStations_Spectrometers.txt",
"Recon_225m_Equatorial_spectrometers.txt",
"Recon_525m_Equatorial_spectrometers.txt",
ORX_REXIS = {
DetectorType = "Camera",
Spice = {"ORX_REXIS"},
Files = {
"DetailedSurvey_EquatorialStations_Spectrometers.txt",
"Recon_225m_Equatorial_spectrometers.txt",
"Recon_525m_Equatorial_spectrometers.txt",
},
},
},
Target = {
Body = BENNU_BODY, -- Do we need this?
},
},
Target = {
Body = BENNU_BODY, -- Do we need this?
},
Instrument = { -- INVALID DATA - JUST FOR TESTING
Name = "ORX_OCAMS_POLYCAM",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.792,
Aspect = 1,
Near = 0.01,
Far = 1000000,
},
},
Instrument = { -- INVALID DATA - JUST FOR TESTING
Name = "ORX_OCAMS_POLYCAM",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 0.792,
Aspect = 1,
Near = 0.01,
Far = 1000000,
},
},
Transform = {

View File

@@ -137,6 +137,9 @@ return {
},
PotentialTargets = {
BENNU_BODY -- Bennu
},
FrameConversions = {
[BENNU_BODY] = "IAU_BENNU"
}
},
},

View File

@@ -17,22 +17,14 @@ return {
Renderable = {
Type = "RenderableModelProjection",
Body = "CHURYUMOV-GERASIMENKO",
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = "obj/67P_rotated_5_130.obj",
Magnification = 0,
},
Textures = {
Type = "simple",
Color = "textures/gray.jpg",
-- Color = "textures/may9_map.jpg",
Project = "textures/defaultProj.png",
Default = "textures/defaultProj.png"
},
Rotation = {
Source = "67P/C-G_CK",
Destination = "GALACTIC"
},
Projection = {
Sequence = "rosettaimages",
@@ -41,43 +33,45 @@ return {
Target = "CHURYUMOV-GERASIMENKO",
Aberration = "NONE",
TextureMap = true,
ShadowMap = true
},
DataInputTranslation = {
ShadowMap = true,
DataInputTranslation = {
Instrument = {
NAVCAM = {
DetectorType = "Camera",
Spice = {"ROS_NAVCAM-A"},
},
},
Target = {
Read = {
"TARGET_NAME",
"INSTRUMENT_HOST_NAME",
"INSTRUMENT_ID",
"START_TIME",
"STOP_TIME",
},
Convert = {
CHURYUMOV = {"CHURYUMOV-GERASIMENKO"},
ROSETTA = {"ROSETTA" },
--NAVCAM = {"NAVCAM"},
["ROSETTA-ORBITER"] = {"ROSETTA" },
CHURYUMOVGERASIMENKO11969R1 = {"CHURYUMOV-GERASIMENKO"},
CHURYUMOVGERASIMENKO = {"CHURYUMOV-GERASIMENKO"},
["CHURYUMOV-GERASIMENKO1(1969R1)"] = {"CHURYUMOV-GERASIMENKO"},
--NAVIGATIONCAMERA = {"NAVCAM" },
},
},
},
Instrument = {
NAVCAM = {
DetectorType = "Camera",
Spice = {"ROS_NAVCAM-A"},
},
},
Target = {
Read = {
"TARGET_NAME",
"INSTRUMENT_HOST_NAME",
"INSTRUMENT_ID",
"START_TIME",
"STOP_TIME",
},
Convert = {
CHURYUMOV = {"CHURYUMOV-GERASIMENKO"},
ROSETTA = {"ROSETTA" },
--NAVCAM = {"NAVCAM"},
["ROSETTA-ORBITER"] = {"ROSETTA" },
CHURYUMOVGERASIMENKO11969R1 = {"CHURYUMOV-GERASIMENKO"},
CHURYUMOVGERASIMENKO = {"CHURYUMOV-GERASIMENKO"},
["CHURYUMOV-GERASIMENKO1(1969R1)"] = {"CHURYUMOV-GERASIMENKO"},
--NAVIGATIONCAMERA = {"NAVCAM" },
},
Name = "ROS_NAVCAM-A",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 5.00,
Aspect = 1
},
},
Instrument = {
Name = "ROS_NAVCAM-A",
Method = "ELLIPSOID",
Aberration = "NONE",
Fovy = 5.00,
Aspect = 1
},
BoundingSphereRadius = 5000.0
},
Transform = {

View File

@@ -437,6 +437,9 @@ return {
},
PotentialTargets = {
"CHURYUMOV-GERASIMENKO"
},
FrameConversions = {
["CHURYUMOV-GERASIMENKO"] = "67P/C-G_CK"
}
},
},

View File

@@ -139,7 +139,9 @@ std::vector<Documentation> BaseModule::documentations() const {
SpiceRotation::Documentation(),
StaticScale::Documentation(),
StaticTranslation::Documentation(),
SpiceTranslation::Documentation()
SpiceTranslation::Documentation(),
modelgeometry::ModelGeometry::Documentation(),
planetgeometry::PlanetGeometry::Documentation()
};
}

View File

@@ -23,6 +23,8 @@
****************************************************************************************/
#include <modules/base/rendering/modelgeometry.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/filesystem/filesystem.h>
@@ -35,59 +37,70 @@ namespace {
const int8_t CurrentCacheVersion = 3;
const std::string keyType = "Type";
const std::string keyName = "Name";
const std::string keySize = "Magnification";
}
namespace openspace {
namespace modelgeometry {
Documentation ModelGeometry::Documentation() {
using namespace documentation;
return {
"Model Geometry",
"base_geometry_model",
{
{
keyType,
new StringVerifier,
"The type of the Model Geometry that should be generated",
Optional::No
},
{
keyGeomModelFile,
new StringVerifier,
"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.",
Optional::No
}
}
};
}
ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) {
std::string geometryType;
const bool success = dictionary.getValue(
keyType, geometryType);
if (!success) {
LERROR("ModelGeometry did not contain a correct value of the key '"
<< keyType << "'");
return nullptr;
if (!dictionary.hasKeyAndValue<std::string>(keyType)) {
throw ghoul::RuntimeError("Dictionary did not contain a key 'Type'");
}
ghoul::TemplateFactory<ModelGeometry>* factory
= FactoryManager::ref().factory<ModelGeometry>();
std::string geometryType = dictionary.value<std::string>(keyType);
auto factory = FactoryManager::ref().factory<ModelGeometry>();
ModelGeometry* result = factory->create(geometryType, dictionary);
if (result == nullptr) {
LERROR("Failed to create a ModelGeometry object of type '" << geometryType
<< "'");
return nullptr;
throw ghoul::RuntimeError(
"Failed to create a ModelGeometry object of type '" + geometryType + "'"
);
}
return result;
}
ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary)
: _parent(nullptr)
, _magnification("magnification", "Magnification", 1.f, 0.f, 10.f)
, _mode(GL_TRIANGLES)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ModelGeometry"
);
setName("ModelGeometry");
std::string name;
bool success = dictionary.getValue(keyName, name);
ghoul_assert(success, "Name tag was not present");
if (dictionary.hasKeyAndValue<double>(keySize))
_magnification = static_cast<float>(dictionary.value<double>(keySize));
success = dictionary.getValue(keyGeomModelFile, _file);
if (!success) {
LERROR("Geometric Model file of '" << name << "' did not provide a key '"
<< keyGeomModelFile << "'");
}
_file = FileSys.absolutePath(_file);
if (!FileSys.fileExists(_file, ghoul::filesystem::FileSystem::RawPath::Yes))
LERROR("Could not load the geometric model file '" << _file << "': File not found");
addProperty(_magnification);
_file = absPath(dictionary.value<std::string>(keyGeomModelFile));
}
double ModelGeometry::boundingRadius() const {
@@ -273,7 +286,6 @@ bool ModelGeometry::getIndices(std::vector<int>* indexList) {
}
void ModelGeometry::setUniforms(ghoul::opengl::ProgramObject& program) {
program.setUniform("_magnification", _magnification);
}
} // namespace modelgeometry

View File

@@ -27,6 +27,7 @@
#include <openspace/properties/propertyowner.h>
#include <openspace/documentation/documentation.h>
#include <openspace/properties/scalarproperty.h>
#include <modules/base/rendering/renderablemodel.h>
#include <ghoul/misc/dictionary.h>
@@ -59,13 +60,14 @@ public:
virtual void setUniforms(ghoul::opengl::ProgramObject& program);
static openspace::Documentation Documentation();
protected:
Renderable* _parent;
bool loadObj(const std::string& filename);
bool loadCachedFile(const std::string& filename);
bool saveCachedFile(const std::string& filename);
properties::FloatProperty _magnification;
GLuint _vaoID;
GLuint _vbo;

View File

@@ -25,6 +25,8 @@
#include <modules/base/rendering/planetgeometry.h>
#include <openspace/util/factorymanager.h>
#include <openspace/documentation/verifier.h>
namespace {
const std::string _loggerCat = "PlanetGeometry";
const std::string KeyType = "Type";
@@ -33,22 +35,38 @@ namespace {
namespace openspace {
namespace planetgeometry {
PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) {
std::string geometryType;
const bool success = dictionary.getValue(KeyType, geometryType);
if (!success) {
LERROR("PlanetGeometry did not contain a correct value of the key '"
<< KeyType << "'");
return nullptr;
}
ghoul::TemplateFactory<PlanetGeometry>* factory
= FactoryManager::ref().factory<PlanetGeometry>();
Documentation PlanetGeometry::Documentation() {
using namespace documentation;
return {
"Planet Geometry",
"base_geometry_planet",
{
{
KeyType,
new StringVerifier,
"The type of the PlanetGeometry that will can be constructed.",
Optional::No
}
}
};
}
PlanetGeometry* PlanetGeometry::createFromDictionary(const ghoul::Dictionary& dictionary)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"PlanetGeometry"
);
std::string geometryType = dictionary.value<std::string>(KeyType);
auto factory = FactoryManager::ref().factory<PlanetGeometry>();
PlanetGeometry* result = factory->create(geometryType, dictionary);
if (result == nullptr) {
LERROR("Failed to create a PlanetGeometry object of type '" << geometryType
<< "'");
return nullptr;
throw ghoul::RuntimeError(
"Failed to create a PlanetGeometry object of type '" + geometryType + "'"
);
}
return result;
}

View File

@@ -26,10 +26,11 @@
#define __PLANETGEOMETRY_H__
#include <openspace/properties/propertyowner.h>
#include <modules/base/rendering/renderableplanet.h>
#include <ghoul/misc/dictionary.h>
#include <openspace/documentation/documentation.h>
namespace openspace {
class Renderable;
namespace planetgeometry {
@@ -43,6 +44,8 @@ public:
virtual void deinitialize();
virtual void render() = 0;
static openspace::Documentation Documentation();
protected:
Renderable* _parent;
};

View File

@@ -71,4 +71,12 @@ void NewHorizonsModule::internalInitialize() {
fDecoder->registerClass<TargetDecoder>("Target");
}
std::vector<Documentation> NewHorizonsModule::documentations() const {
return {
RenderableModelProjection::Documentation(),
RenderablePlanetProjection::Documentation(),
ProjectionComponent::Documentation()
};
}
} // namespace openspace

View File

@@ -33,6 +33,8 @@ class NewHorizonsModule : public OpenSpaceModule {
public:
NewHorizonsModule();
std::vector<Documentation> documentations() const override;
protected:
void internalInitialize() override;
};

View File

@@ -46,6 +46,7 @@ namespace {
const std::string keyInstrumentMethod = "Instrument.Method";
const std::string keyInstrumentAberration = "Instrument.Aberration";
const std::string keyPotentialTargets = "PotentialTargets";
const std::string keyFrameConversions = "FrameConversions";
const int InterpolationSteps = 10;
const int Stride = 8;
@@ -94,6 +95,17 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
_potentialTargets[i] = target;
}
ghoul::Dictionary frameConversions;
success = dictionary.getValue(keyFrameConversions, frameConversions);
if (success) {
for (const std::string& key : frameConversions.keys()) {
openspace::SpiceManager::ref().addFrame(
key,
frameConversions.value<std::string>(key)
);
}
}
addProperty(_lineWidth);
addProperty(_drawSolid);
}

View File

@@ -24,6 +24,7 @@
#include <modules/newhorizons/rendering/renderablemodelprojection.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
@@ -38,17 +39,62 @@ namespace {
const std::string _loggerCat = "RenderableModelProjection";
const std::string keySource = "Rotation.Source";
const std::string keyDestination = "Rotation.Destination";
const std::string keyBody = "Body";
const std::string keyGeometry = "Geometry";
const std::string keyProjection = "Projection";
const std::string keyBoundingSphereRadius = "BoundingSphereRadius";
const std::string keyTextureColor = "Textures.Color";
const std::string keyTextureProject = "Textures.Project";
const std::string keyTextureDefault = "Textures.Default";
const std::string _destination = "GALACTIC";
}
namespace openspace {
Documentation RenderableModelProjection::Documentation() {
using namespace documentation;
return {
"Renderable Model Projection",
"newhorizons_renderable_modelprojection",
{
{
"Type",
new StringEqualVerifier("RenderableModelProjection"),
"",
Optional::No
},
{
keyGeometry,
new ReferencingVerifier("base_geometry_model"),
"The geometry that is used for rendering this model.",
Optional::No
},
{
keyProjection,
new ReferencingVerifier("newhorizons_projectioncomponent"),
"Contains information about projecting onto this planet.",
Optional::No
},
{
keyTextureColor,
new StringVerifier,
"The base texture for the model that is shown before any projection "
"occurred.",
Optional::No
},
{
keyBoundingSphereRadius,
new DoubleVerifier,
"The radius of the bounding sphere of this object. This has to be a "
"radius that is larger than anything that is rendered by it. It has to "
"be at least as big as the convex hull of the object. The default value "
"is 10e9 meters.",
Optional::Yes
}
}
};
}
RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
@@ -59,44 +105,35 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di
, _geometry(nullptr)
, _performShading("performShading", "Perform Shading", true)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableModelProjection"
);
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
ghoul_assert(success, "Name was not passed to RenderableModelProjection");
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
using modelgeometry::ModelGeometry;
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
_geometry = std::unique_ptr<ModelGeometry>(
ModelGeometry::createFromDictionary(geometryDictionary)
);
}
using ghoul::Dictionary;
Dictionary geometryDictionary = dictionary.value<Dictionary>(keyGeometry);
using modelgeometry::ModelGeometry;
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
_geometry = std::unique_ptr<ModelGeometry>(
ModelGeometry::createFromDictionary(geometryDictionary)
);
std::string texturePath = "";
success = dictionary.getValue(keyTextureColor, texturePath);
if (success)
_colorTexturePath = absPath(texturePath);
_colorTexturePath = absPath(dictionary.value<std::string>(keyTextureColor));
success = dictionary.getValue(keyTextureDefault, texturePath);
if (success)
_defaultProjImage = absPath(texturePath);
addPropertySubOwner(_geometry.get());
addPropertySubOwner(_projectionComponent);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModelProjection::loadTextures, this));
dictionary.getValue(keySource, _source);
dictionary.getValue(keyDestination, _destination);
dictionary.getValue(keyBody, _target);
bool completeSuccess = true;
completeSuccess &= _projectionComponent.initializeProjectionSettings(dictionary);
openspace::SpiceManager::ref().addFrame(_target, _source);
_projectionComponent.initialize(
dictionary.value<ghoul::Dictionary>(keyProjection)
);
float boundingSphereRadius = 1.0e9;
dictionary.getValue(keyBoundingSphereRadius, boundingSphereRadius);
@@ -104,9 +141,6 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di
Renderable::addProperty(_performShading);
Renderable::addProperty(_rotation);
success = _projectionComponent.initializeParser(dictionary);
ghoul_assert(success, "");
}
bool RenderableModelProjection::isReady() const {
@@ -139,15 +173,12 @@ bool RenderableModelProjection::initialize() {
completeSuccess &= loadTextures();
completeSuccess &= _projectionComponent.initialize();
completeSuccess &= _projectionComponent.initializeGL();
auto bs = getBoundingSphere();
completeSuccess &= _geometry->initialize(this);
setBoundingSphere(bs); // ignore bounding sphere set by geometry.
completeSuccess &= !_source.empty();
completeSuccess &= !_destination.empty();
return completeSuccess;
}
@@ -246,18 +277,12 @@ void RenderableModelProjection::update(const UpdateData& data) {
}
}
// set spice-orientation in accordance to timestamp
if (!_source.empty()) {
_stateMatrix = SpiceManager::ref().positionTransformMatrix(
_source, _destination, _time
);
}
double lt;
_stateMatrix = data.modelTransform.rotation;
glm::dvec3 p =
openspace::SpiceManager::ref().targetPosition(
"SUN", _target, "GALACTIC", {}, _time, lt
);
OsEng.renderEngine().scene()->sceneGraphNode("Sun")->worldPosition() -
data.modelTransform.translation;
_sunPosition = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
}
@@ -308,7 +333,6 @@ void RenderableModelProjection::imageProjectGPU(
void RenderableModelProjection::attitudeParameters(double time) {
try {
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, time);
_instrumentMatrix = SpiceManager::ref().positionTransformMatrix(_projectionComponent.instrumentId(), _destination, time);
}
catch (const SpiceManager::SpiceException& e) {

View File

@@ -28,6 +28,7 @@
#include <openspace/rendering/renderable.h>
#include <modules/newhorizons/util/projectioncomponent.h>
#include <openspace/documentation/documentation.h>
#include <modules/base/rendering/modelgeometry.h>
#include <modules/newhorizons/util/imagesequencer.h>
@@ -59,6 +60,8 @@ public:
ghoul::opengl::Texture& baseTexture() const;
static openspace::Documentation Documentation();
private:
bool loadTextures();
void attitudeParameters(double time);
@@ -83,11 +86,6 @@ private:
glm::dmat3 _stateMatrix;
glm::dmat3 _instrumentMatrix;
std::string _defaultProjImage;
std::string _source;
std::string _destination;
std::string _target;
// uniforms
glm::vec2 _camScaling;
glm::vec3 _up;

View File

@@ -26,6 +26,7 @@
#include <modules/base/rendering/planetgeometry.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
@@ -45,16 +46,64 @@
namespace {
const std::string _loggerCat = "RenderablePlanetProjection";
const std::string keyFrame = "Frame";
const std::string keyGeometry = "Geometry";
const std::string keyProjection = "Projection";
const std::string keyColorTexture = "Textures.Color";
const std::string keyHeightTexture = "Textures.Height";
const std::string keyRadius = "Geometry.Radius";
const std::string keyShading = "PerformShading";
const std::string keyBody = "Body";
const std::string _mainFrame = "GALACTIC";
}
namespace openspace {
Documentation RenderablePlanetProjection::Documentation() {
using namespace openspace::documentation;
return {
"Renderable Planet Projection",
"newhorizons_renderable_planetprojection",
{
{
"Type",
new StringEqualVerifier("RenderablePlanetProjection"),
"",
Optional::No
},
{
keyGeometry,
new ReferencingVerifier("base_geometry_planet"),
"The geometry that is used for rendering this planet.",
Optional::No
},
{
keyProjection,
new ReferencingVerifier("newhorizons_projectioncomponent"),
"Contains information about projecting onto this planet.",
Optional::No
},
{
keyColorTexture,
new StringVerifier,
"The path to the base color texture that is used on the planet prior to "
"any image projection. The path can use tokens of the form '${...}' or "
"be specified relative to the directory of the mod file.",
Optional::No
},
{
keyHeightTexture,
new StringVerifier,
"The path to the height map texture that is used on the planet. The path "
"can use tokens of the form '${...}' or be specified relative to the "
"directory of the mod file. If no height map is specified the planet "
"does not use a height field.",
Optional::Yes
}
}
};
}
RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("planetTexture", "RGB Texture")
@@ -68,6 +117,12 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _heightMapTexture(nullptr)
, _capture(false)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderablePlanetProject"
);
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
ghoul_assert(success, "");
@@ -83,11 +138,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
);
}
dictionary.getValue(keyFrame, _frame);
dictionary.getValue(keyBody, _body);
success = _projectionComponent.initializeProjectionSettings(dictionary);
ghoul_assert(success, "");
_projectionComponent.initialize(dictionary.value<ghoul::Dictionary>(keyProjection));
// TODO: textures need to be replaced by a good system similar to the geometry as soon
// as the requirements are fixed (ab)
@@ -117,9 +168,6 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
addProperty(_heightExaggeration);
addProperty(_debugProjectionTextureRotation);
success = _projectionComponent.initializeParser(dictionary);
ghoul_assert(success, "");
}
RenderablePlanetProjection::~RenderablePlanetProjection() {}
@@ -138,7 +186,7 @@ bool RenderablePlanetProjection::initialize() {
);
completeSuccess &= loadTextures();
completeSuccess &= _projectionComponent.initialize();
completeSuccess &= _projectionComponent.initializeGL();
completeSuccess &= _geometry->initialize(this);
if (completeSuccess) {
@@ -233,7 +281,6 @@ void RenderablePlanetProjection::imageProjectGPU(
void RenderablePlanetProjection::attitudeParameters(double time) {
// precomputations for shader
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, _mainFrame, time);
_instrumentMatrix = SpiceManager::ref().positionTransformMatrix(
_projectionComponent.instrumentId(), _mainFrame, time
);
@@ -256,12 +303,7 @@ void RenderablePlanetProjection::attitudeParameters(double time) {
glm::vec3(0, 1, 0)
);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
_transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
_transform = _transform * rot * roty * rotProp;
_transform = glm::mat4(_stateMatrix) * rot * roty * rotProp;
glm::dvec3 bs;
try {
@@ -411,6 +453,7 @@ void RenderablePlanetProjection::update(const UpdateData& data) {
}
}
_stateMatrix = data.modelTransform.rotation;
}
bool RenderablePlanetProjection::loadTextures() {

View File

@@ -26,10 +26,11 @@
#define __RENDERABLEPLANETPROJECTION_H__
#include <openspace/rendering/renderable.h>
#include <modules/newhorizons/util/projectioncomponent.h>
#include <modules/newhorizons/util/imagesequencer.h>
#include <modules/newhorizons/util/projectioncomponent.h>
#include <openspace/documentation/documentation.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/util/updatestructures.h>
@@ -56,6 +57,8 @@ public:
void update(const UpdateData& data) override;
ghoul::opengl::Texture& baseTexture() const;
static openspace::Documentation Documentation();
protected:
bool loadTextures();
void attitudeParameters(double time);
@@ -95,7 +98,6 @@ private:
std::vector<Image> _imageTimes;
std::string _body;
std::string _frame;
bool _capture;

View File

@@ -29,6 +29,7 @@
#include <modules/newhorizons/util/instrumenttimesparser.h>
#include <modules/newhorizons/util/labelparser.h>
#include <openspace/documentation/verifier.h>
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/filesystem/filesystem.h>
@@ -44,17 +45,18 @@ namespace {
const std::string keyInstrumentFovy = "Instrument.Fovy";
const std::string keyInstrumentAspect = "Instrument.Aspect";
const std::string keyProjObserver = "Projection.Observer";
const std::string keyProjTarget = "Projection.Target";
const std::string keyProjAberration = "Projection.Aberration";
const std::string keySequenceDir = "Projection.Sequence";
const std::string keySequenceType = "Projection.SequenceType";
const std::string keyTranslation = "DataInputTranslation";
const std::string keyNeedsTextureMapDilation = "Projection.TextureMap";
const std::string keyNeedsShadowing = "Projection.ShadowMap";
const std::string keyTextureMapAspectRatio = "Projection.AspectRatio";
const std::string keyProjObserver = "Observer";
const std::string keyProjTarget = "Target";
const std::string keyProjAberration = "Aberration";
const std::string keySequenceDir = "Sequence";
const std::string keySequenceType = "SequenceType";
const std::string keyNeedsTextureMapDilation = "TextureMap";
const std::string keyNeedsShadowing = "ShadowMap";
const std::string keyTextureMapAspectRatio = "AspectRatio";
const std::string sequenceTypeImage = "image-sequence";
const std::string sequenceTypePlaybook = "playbook";
@@ -72,6 +74,94 @@ namespace openspace {
using ghoul::Dictionary;
using glm::ivec2;
Documentation ProjectionComponent::Documentation() {
using namespace documentation;
return {
"Projection Component",
"newhorizons_projectioncomponent",
{
{
keyInstrument,
new StringAnnotationVerifier("A SPICE name of an instrument"),
"The instrument that is used to perform the projections",
Optional::No
},
{
keyInstrumentFovy,
new DoubleVerifier,
"The field of view in degrees along the y axis",
Optional::No
},
{
keyInstrumentAspect,
new DoubleVerifier,
"The aspect ratio of the instrument in relation between x and y axis",
Optional::No
},
{
keyProjObserver,
new StringAnnotationVerifier("A SPICE name of the observing object"),
"The observer that is doing the projection. This has to be a valid SPICE "
"name or SPICE integer.",
Optional::No
},
{
keyProjTarget,
new StringAnnotationVerifier("A SPICE name of the observed object"),
"The observed object that is projected on. This has to be a valid SPICE "
"name or SPICE integer.",
Optional::No
},
{
keyProjAberration,
new StringInListVerifier({
// from SpiceManager::AberrationCorrection::AberrationCorrection
"NONE", "LT", "LT+S", "CN", "CN+S", "XLT", "XLT+S", "XCN", "XCN+S"
}),
"The aberration correction that is supposed to be used for the "
"projection. The values for the correction correspond to the SPICE "
"definition as described in "
"ftp://naif.jpl.nasa.gov/pub/naif/toolkit_docs/IDL/cspice/spkezr_c.html",
Optional::No
},
{
keyPotentialTargets,
new StringListVerifier,
"The list of potential targets that are involved with the image "
"projection",
Optional::Yes
},
{
keyNeedsTextureMapDilation,
new BoolVerifier,
"Determines whether a dilation step of the texture map has to be "
"performed after each projection. This is necessary if the texture of "
"the projected object is a texture map where the borders are not "
"touching. The default value is 'false'.",
Optional::Yes
},
{
keyNeedsShadowing,
new BoolVerifier,
"Determines whether the object requires a self-shadowing algorithm. This "
"is necessary if the object is concave and might cast a shadow on itself "
"during presentation. The default value is 'false'.",
Optional::Yes
},
{
keyTextureMapAspectRatio,
new DoubleVerifier,
"Sets the desired aspect ratio of the projected texture. This might be "
"necessary as planets usually have 2x1 aspect ratios, whereas this does "
"not hold for non-planet objects (comets, asteroids, etc). The default "
"value is '1.0'.",
Optional::Yes
}
}
};
}
ProjectionComponent::ProjectionComponent()
: properties::PropertyOwner()
, _performProjection("performProjection", "Perform Projections", true)
@@ -96,7 +186,123 @@ ProjectionComponent::ProjectionComponent()
_applyTextureSize.onChange([this]() { _textureSizeDirty = true; });
}
bool ProjectionComponent::initialize() {
void ProjectionComponent::initialize(const ghoul::Dictionary& dictionary) {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ProjectionComponent"
);
_instrumentID = dictionary.value<std::string>(keyInstrument);
_projectorID = dictionary.value<std::string>(keyProjObserver);
_projecteeID = dictionary.value<std::string>(keyProjTarget);
_fovy = dictionary.value<double>(keyInstrumentFovy);
_aspectRatio = dictionary.value<double>(keyInstrumentAspect);
_aberration = SpiceManager::AberrationCorrection(
dictionary.value<std::string>(keyProjAberration)
);
if (dictionary.hasKeyAndValue<ghoul::Dictionary>(keyPotentialTargets)) {
ghoul::Dictionary potentialTargets = dictionary.value<ghoul::Dictionary>(
keyPotentialTargets
);
_potentialTargets.reserve(potentialTargets.size());
for (int i = 1; i <= potentialTargets.size(); ++i) {
_potentialTargets.emplace_back(
potentialTargets.value<std::string>(std::to_string(i))
);
}
}
if (dictionary.hasKeyAndValue<bool>(keyNeedsTextureMapDilation)) {
_dilation.isEnabled = dictionary.value<bool>(keyNeedsTextureMapDilation);
}
if (dictionary.hasKeyAndValue<bool>(keyNeedsShadowing)) {
_shadowing.isEnabled = dictionary.value<bool>(keyNeedsShadowing);
}
_projectionTextureAspectRatio = 1.f;
if (dictionary.hasKeyAndValue<double>(keyTextureMapAspectRatio)) {
_projectionTextureAspectRatio =
static_cast<float>(dictionary.value<double>(keyTextureMapAspectRatio));
}
std::string name;
dictionary.getValue(SceneGraphNode::KeyName, name);
std::vector<SequenceParser*> parsers;
std::string sequenceSource;
std::string sequenceType;
bool foundSequence = dictionary.getValue(keySequenceDir, sequenceSource);
if (foundSequence) {
sequenceSource = absPath(sequenceSource);
foundSequence = dictionary.getValue(keySequenceType, sequenceType);
//Important: client must define translation-list in mod file IFF playbook
if (dictionary.hasKey(keyTranslation)) {
ghoul::Dictionary translationDictionary;
//get translation dictionary
dictionary.getValue(keyTranslation, translationDictionary);
if (sequenceType == sequenceTypePlaybook) {
parsers.push_back(new HongKangParser(
name,
sequenceSource,
_projectorID,
translationDictionary,
_potentialTargets));
}
else if (sequenceType == sequenceTypeImage) {
parsers.push_back(new LabelParser(
name,
sequenceSource,
translationDictionary));
}
else if (sequenceType == sequenceTypeHybrid) {
//first read labels
parsers.push_back(new LabelParser(
name,
sequenceSource,
translationDictionary));
std::string _eventFile;
bool foundEventFile = dictionary.getValue("Projection.EventFile", _eventFile);
if (foundEventFile) {
//then read playbook
_eventFile = absPath(_eventFile);
parsers.push_back(new HongKangParser(
name,
_eventFile,
_projectorID,
translationDictionary,
_potentialTargets));
}
else {
LWARNING("No eventfile has been provided, please check modfiles");
}
}
else if (sequenceType == sequenceTypeInstrumentTimes) {
parsers.push_back(new InstrumentTimesParser(
name,
sequenceSource,
translationDictionary));
}
for (SequenceParser* parser : parsers) {
openspace::ImageSequencer::ref().runSequenceParser(parser);
delete parser;
}
}
else {
LWARNING("No playbook translation provided, please make sure all spice calls match playbook!");
}
}
}
bool ProjectionComponent::initializeGL() {
int maxSize = OpenGLCap.max2DTextureSize();
glm::ivec2 size;
@@ -193,131 +399,6 @@ bool ProjectionComponent::isReady() const {
return (_projectionTexture != nullptr);
}
bool ProjectionComponent::initializeProjectionSettings(const Dictionary& dictionary) {
bool completeSuccess = true;
completeSuccess &= dictionary.getValue(keyInstrument, _instrumentID);
completeSuccess &= dictionary.getValue(keyProjObserver, _projectorID);
completeSuccess &= dictionary.getValue(keyProjTarget, _projecteeID);
completeSuccess &= dictionary.getValue(keyInstrumentFovy, _fovy);
completeSuccess &= dictionary.getValue(keyInstrumentAspect, _aspectRatio);
ghoul_assert(completeSuccess, "All neccessary attributes not found in modfile");
std::string a = "NONE";
bool s = dictionary.getValue(keyProjAberration, a);
_aberration = SpiceManager::AberrationCorrection(a);
completeSuccess &= s;
ghoul_assert(completeSuccess, "All neccessary attributes not found in modfile");
if (dictionary.hasKeyAndValue<ghoul::Dictionary>(keyPotentialTargets)) {
ghoul::Dictionary potentialTargets = dictionary.value<ghoul::Dictionary>(
keyPotentialTargets
);
_potentialTargets.resize(potentialTargets.size());
for (int i = 0; i < potentialTargets.size(); ++i) {
std::string target;
potentialTargets.getValue(std::to_string(i + 1), target);
_potentialTargets[i] = target;
}
}
if (dictionary.hasKeyAndValue<bool>(keyNeedsTextureMapDilation)) {
_dilation.isEnabled = dictionary.value<bool>(keyNeedsTextureMapDilation);
}
if (dictionary.hasKeyAndValue<bool>(keyNeedsShadowing)) {
_shadowing.isEnabled = dictionary.value<bool>(keyNeedsShadowing);
}
_projectionTextureAspectRatio = 1.f;
if (dictionary.hasKeyAndValue<double>(keyTextureMapAspectRatio)) {
_projectionTextureAspectRatio =
static_cast<float>(dictionary.value<double>(keyTextureMapAspectRatio));
}
return completeSuccess;
}
bool ProjectionComponent::initializeParser(const ghoul::Dictionary& dictionary) {
bool completeSuccess = true;
std::string name;
dictionary.getValue(SceneGraphNode::KeyName, name);
std::vector<SequenceParser*> parsers;
std::string sequenceSource;
std::string sequenceType;
bool foundSequence = dictionary.getValue(keySequenceDir, sequenceSource);
if (foundSequence) {
sequenceSource = absPath(sequenceSource);
foundSequence = dictionary.getValue(keySequenceType, sequenceType);
//Important: client must define translation-list in mod file IFF playbook
if (dictionary.hasKey(keyTranslation)) {
ghoul::Dictionary translationDictionary;
//get translation dictionary
dictionary.getValue(keyTranslation, translationDictionary);
if (sequenceType == sequenceTypePlaybook) {
parsers.push_back(new HongKangParser(
name,
sequenceSource,
_projectorID,
translationDictionary,
_potentialTargets));
}
else if (sequenceType == sequenceTypeImage) {
parsers.push_back(new LabelParser(
name,
sequenceSource,
translationDictionary));
}
else if (sequenceType == sequenceTypeHybrid) {
//first read labels
parsers.push_back(new LabelParser(
name,
sequenceSource,
translationDictionary));
std::string _eventFile;
bool foundEventFile = dictionary.getValue("Projection.EventFile", _eventFile);
if (foundEventFile) {
//then read playbook
_eventFile = absPath(_eventFile);
parsers.push_back(new HongKangParser(
name,
_eventFile,
_projectorID,
translationDictionary,
_potentialTargets));
}
else {
LWARNING("No eventfile has been provided, please check modfiles");
}
}
else if (sequenceType == sequenceTypeInstrumentTimes) {
parsers.push_back(new InstrumentTimesParser(
name,
sequenceSource,
translationDictionary));
}
for(SequenceParser* parser : parsers){
openspace::ImageSequencer::ref().runSequenceParser(parser);
delete parser;
}
}
else {
LWARNING("No playbook translation provided, please make sure all spice calls match playbook!");
}
}
return completeSuccess;
}
void ProjectionComponent::imageProjectBegin() {
// keep handle to the current bound FBO
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO);

View File

@@ -26,6 +26,8 @@
#define __PROJECTIONCOMPONENT_H__
#include <openspace/properties/propertyowner.h>
#include <openspace/documentation/documentation.h>
#include <openspace/properties/scalarproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/properties/vectorproperty.h>
@@ -48,14 +50,12 @@ class ProjectionComponent : public properties::PropertyOwner {
public:
ProjectionComponent();
bool initialize();
void initialize(const ghoul::Dictionary& dictionary);
bool initializeGL();
bool deinitialize();
bool isReady() const;
bool initializeProjectionSettings(const ghoul::Dictionary& dictionary);
bool initializeParser(const ghoul::Dictionary& dictionary);
ghoul::opengl::Texture& depthTexture();
void imageProjectBegin();
void imageProjectEnd();
@@ -101,6 +101,8 @@ public:
float fieldOfViewY() const;
float aspectRatio() const;
static openspace::Documentation Documentation();
private:
bool generateProjectionLayerTexture(const glm::ivec2& size);
bool generateDepthTexture(const glm::ivec2& size);