Put ISWACygnets in sceneGraph

This commit is contained in:
Sebastian Piwell
2016-04-08 15:42:24 -04:00
parent 6a81065b42
commit a55d5e9e9a
11 changed files with 137 additions and 87 deletions

View File

@@ -7,14 +7,14 @@ return {
},
Modules = {
"sun",
"mercury",
"venus",
--"mercury",
--"venus",
"earth",
"mars",
"jupiter",
"saturn",
"uranus",
"neptune",
--"mars",
--"jupiter",
--"saturn",
--"uranus",
--"neptune",
"stars",
-- "stars-denver",
"milkyway",

View File

@@ -99,6 +99,9 @@ public:
SceneGraph& sceneGraph();
void addSceneGraphNode(SceneGraphNode* node){
_graph.addSceneGraphNode(node);
}
/**
* Returns the Lua library that contains all Lua functions available to change the
* scene graph. The functions contained are

View File

@@ -1,46 +1,50 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* 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. *
****************************************************************************************/
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* 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/iswa/iswamodule.h>
#include <modules/iswa/iswamodule.h>
#include <openspace/rendering/renderable.h>
#include <openspace/util/factorymanager.h>
#include <openspace/rendering/renderable.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/assert.h>
#include <modules/iswa/rendering/iswacontainer.h>
#include <modules/iswa/rendering/iswacontainer.h>
#include <modules/iswa/rendering/textureplane.h>
#include <modules/iswa/rendering/dataplane.h>
namespace openspace {
namespace openspace {
ISWAModule::ISWAModule()
: OpenSpaceModule("ISWA")
{}
ISWAModule::ISWAModule()
: OpenSpaceModule("ISWA")
{}
void ISWAModule::internalInitialize(){
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "No renderable factory existed");
void ISWAModule::internalInitialize(){
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "No renderable factory existed");
fRenderable->registerClass<ISWAContainer>("ISWAContainer");
}
}
fRenderable->registerClass<ISWAContainer>("ISWAContainer");
fRenderable->registerClass<TexturePlane>("TexturePlane");
fRenderable->registerClass<DataPlane>("DataPlane");
}
}

View File

@@ -90,6 +90,7 @@ bool DataPlane::deinitialize(){
void DataPlane::render(const RenderData& data){
std::cout << "rendering" << std::endl;
if(_texture){
psc position = _parent->worldPosition();
glm::mat4 transform = glm::mat4(1.0);

View File

@@ -44,7 +44,7 @@ bool ISWAContainer::initialize(){
addISWACygnet("${OPENSPACE_DATA}/BATSRUS.cdf");
// addISWACygnet(5, "Screen");
addISWACygnet(7, "Sun");
// addISWACygnet(7, "Sun");
return true;
}

View File

@@ -58,12 +58,12 @@ ISWACygnet::~ISWACygnet(){}
void ISWACygnet::registerProperties(){
// OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
// OsEng.gui()._iSWAproperty.registerProperty(&_updateInterval);
// OsEng.gui()._iSWAproperty.registerProperty(&_delete);
}
void ISWACygnet::unregisterProperties(){
OsEng.gui()._iSWAproperty.unregisterProperties(name());
// OsEng.gui()._iSWAproperty.unregisterProperties(name());
}
void ISWACygnet::setParent(){

View File

@@ -52,8 +52,8 @@ public:
ISWACygnet(const ghoul::Dictionary& dictionary);
~ISWACygnet();
// virtual bool initialize() = 0;
// virtual bool deinitialize() = 0;
virtual bool initialize() = 0;
virtual bool deinitialize() = 0;
// virtual void render(const RenderData& data) = 0;
// virtual void update(const UpdateData& data) = 0;

View File

@@ -61,7 +61,10 @@ namespace openspace{
const std::string& extension = ghoul::filesystem::File(absPath(metadata->path)).fileExtension();
std::shared_ptr<ISWACygnet> cygnet;
if(extension == "cdf"){
if(extension == "plain"){
LWARNING("This cygnet image does not exist");
return nullptr;
}else if(extension == "cdf"){
if(!FileSys.fileExists(absPath(metadata->path))) {
LERROR("Could not find cdf file: " << absPath(metadata->path));
@@ -69,53 +72,80 @@ namespace openspace{
}
std::shared_ptr<KameleonWrapper> kw = std::make_shared<KameleonWrapper>(absPath(metadata->path));
ghoul::Dictionary metadataDic =
{
{std::string("Name"), std::string("DataPlane")},
{std::string("StartTime"), std::string("")},
{std::string("EndTime"), std::string("")},
{std::string("Id"), metadata->id},
{std::string("Path"), metadata->path},
{std::string("Scale"), std::make_shared<glm::vec4>(kw->getModelScaleScaled())},
{std::string("Offset"), std::make_shared<glm::vec4>(kw->getModelBarycenterOffsetScaled())},
{std::string("Parent"), kw->getParent()},
{std::string("Frame"), kw->getFrame()},
{std::string("KW"), kw}
};
auto parentNode = OsEng.renderEngine().scene()->sceneGraphNode(kw->getParent());
cygnet = std::make_shared<DataPlane>(metadataDic);
}else if(extension == "plain"){
LWARNING("This cygnet image does not exist");
return nullptr;
}else {
auto node = OsEng.renderEngine().scene()->sceneGraphNode(metadata->parent);
if(node){
if(parentNode){
ghoul::Dictionary metadataDic =
{
{std::string("Name"), std::string("TexturePlane")},
// {std::string("Name"), std::string("DataPlane")},
{std::string("Type"), std::string("DataPlane")},
{std::string("StartTime"), std::string("")},
{std::string("EndTime"), std::string("")},
{std::string("Id"), metadata->id},
{std::string("Path"), metadata->path},
{std::string("Frame"), std::string("GALACTIC")},
{std::string("Parent"), metadata->parent},
{std::string("Scale"), std::make_shared<glm::vec4>(3,3,3,10)},
{std::string("Offset"), std::make_shared<glm::vec4>(0,0,0,1)}
{std::string("Id"), metadata->id},
{std::string("Path"), metadata->path},
{std::string("Scale"), std::make_shared<glm::vec4>(kw->getModelScaleScaled())},
{std::string("Offset"), std::make_shared<glm::vec4>(kw->getModelBarycenterOffsetScaled())},
{std::string("Parent"), kw->getParent()},
{std::string("Frame"), kw->getFrame()},
{std::string("KW"), kw}
};
ghoul::Dictionary nodeDic =
{
{std::string("Name"), std::string("DataPlane")},
{std::string("Parent"), kw->getParent()},
{std::string("Renderable"), metadataDic}
};
SceneGraphNode* cygnetNode = SceneGraphNode::createFromDictionary(nodeDic);
cygnetNode->setParent(parentNode);
parentNode->addChild(cygnetNode);
OsEng.renderEngine().scene()->addSceneGraphNode(cygnetNode);
cygnetNode->initialize();
cygnet = std::make_shared<TexturePlane>(metadataDic);
}
// cygnet = std::make_shared<DataPlane>(metadataDic);
}else {
auto parentNode = OsEng.renderEngine().scene()->sceneGraphNode(metadata->parent);
if(parentNode){
ghoul::Dictionary metadataDic =
{
// {std::string("Name"), std::string("TexturePlane")},
{std::string("Type"), std::string("TexturePlane")},
{std::string("StartTime"), std::string("")},
{std::string("EndTime"), std::string("")},
{std::string("Id"), metadata->id},
{std::string("Path"), metadata->path},
{std::string("Frame"), std::string("GALACTIC")},
{std::string("Parent"), metadata->parent},
{std::string("Scale"), std::make_shared<glm::vec4>(3,3,3,10)},
{std::string("Offset"), std::make_shared<glm::vec4>(0,0,0,1)}
};
ghoul::Dictionary nodeDic =
{
{std::string("Name"), std::string("TexturePlane")},
{std::string("Parent"), metadata->parent},
{std::string("Renderable"), metadataDic}
};
// SceneGraphNode*
SceneGraphNode* cygnetNode = SceneGraphNode::createFromDictionary(nodeDic);
cygnetNode->setParent(parentNode);
parentNode->addChild(cygnetNode);
OsEng.renderEngine().scene()->addSceneGraphNode(cygnetNode);
cygnetNode->initialize();
}else{
OsEng.renderEngine().registerScreenSpaceRenderable(std::make_shared<ScreenSpaceCygnet>(metadata));
return nullptr;
}
}
cygnet->initialize();
return cygnet;
} else {
return nullptr;
// cygnet->initialize();
// return cygnet;
}
return nullptr;
}
void ISWAManager::addISWACygnet(std::string info){
@@ -129,8 +159,12 @@ namespace openspace{
if(cygnetId != 0)
_container->addISWACygnet(cygnetId, data);
else
_container->addISWACygnet("${OPENSPACE_DATA}/"+data);
else{
std::shared_ptr<Metadata> mdata = std::make_shared<Metadata>();
mdata->id = 0;
mdata->path = absPath("${OPENSPACE_DATA}/"+data);
createISWACygnet(mdata);
}
}
void ISWAManager::deleteISWACygnet(std::string name){

View File

@@ -145,7 +145,7 @@ void Scene::update(const UpdateData& data) {
// _graph.addSceneGraphNode(node);
// ONCE = true;
//}
// ISWAManagar::ref().update();
for (SceneGraphNode* node : _graph.nodes()) {
try {
node->update(data);
@@ -166,6 +166,7 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) {
for (SceneGraphNode* node : _graph.nodes()) {
node->render(data, tasks);
}
std::cout << std::endl;
}
void Scene::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath) {

View File

@@ -380,6 +380,7 @@ bool SceneGraph::addSceneGraphNode(SceneGraphNode* node) {
_nodes.push_back(internalNode);
sortTopologically();
std::cout << "Added the node" << std::endl;
return true;
}

View File

@@ -247,6 +247,12 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
RenderData newData = {data.camera, thisPosition, data.doPerformanceMeasurement};
std::cout << name() << " ";
if(_renderable){
std::cout << _renderableVisible << " " << _renderable->isVisible() << " " << _renderable->isReady() << " " << _renderable->isEnabled() << std::endl;
}else{
std::cout << "No Renderable" << std::endl;
}
_performanceRecord.renderTime = 0;
if (_renderableVisible && _renderable->isVisible() && _renderable->isReady() && _renderable->isEnabled()) {
if (data.doPerformanceMeasurement) {