mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-14 23:50:24 -06:00
solved merge conflict, fix for close(socket) in paralellconnection
This commit is contained in:
@@ -26,6 +26,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
|
||||
|
||||
set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.h
|
||||
@@ -37,7 +38,6 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/wavefrontgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/dynamicephemeris.h
|
||||
@@ -48,6 +48,7 @@ source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.cpp
|
||||
@@ -59,7 +60,6 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/wavefrontgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/dynamicephemeris.cpp
|
||||
@@ -96,4 +96,4 @@ create_new_module(
|
||||
"Base"
|
||||
base_module
|
||||
${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES}
|
||||
)
|
||||
)
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <modules/base/rendering/renderableplane.h>
|
||||
#include <modules/base/rendering/simplespheregeometry.h>
|
||||
#include <modules/base/rendering/modelgeometry.h>
|
||||
#include <modules/base/rendering/wavefrontgeometry.h>
|
||||
#include <modules/base/rendering/multimodelgeometry.h>
|
||||
|
||||
#include <modules/base/ephemeris/staticephemeris.h>
|
||||
#include <modules/base/ephemeris/dynamicephemeris.h>
|
||||
@@ -84,7 +84,7 @@ void BaseModule::internalInitialize() {
|
||||
|
||||
auto fModelGeometry = FactoryManager::ref().factory<modelgeometry::ModelGeometry>();
|
||||
ghoul_assert(fModelGeometry, "Model geometry factory was not created");
|
||||
fModelGeometry->registerClass<modelgeometry::WavefrontGeometry>("WavefrontGeometry");
|
||||
fModelGeometry->registerClass<modelgeometry::MultiModelGeometry>("MultiModelGeometry");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -28,11 +28,10 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <modules/base/rendering/wavefrontgeometry.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ModelGeometry";
|
||||
const std::string keyObjFile = "ObjFile";
|
||||
const std::string keyGeomModelFile = "GeometryFile";
|
||||
const int8_t CurrentCacheVersion = 3;
|
||||
const std::string keyType = "Type";
|
||||
const std::string keyName = "Name";
|
||||
@@ -77,15 +76,15 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary)
|
||||
if (dictionary.hasKeyAndValue<double>(keySize))
|
||||
_magnification = static_cast<float>(dictionary.value<double>(keySize));
|
||||
|
||||
success = dictionary.getValue(keyObjFile, _file);
|
||||
success = dictionary.getValue(keyGeomModelFile, _file);
|
||||
if (!success) {
|
||||
LERROR("WaveFrontGeometry of '" << name << "' did not provide a key '"
|
||||
<< keyObjFile << "'");
|
||||
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 OBJ file '" << _file << "': File not found");
|
||||
LERROR("Could not load the geometric model file '" << _file << "': File not found");
|
||||
|
||||
|
||||
addProperty(_magnification);
|
||||
@@ -145,93 +144,95 @@ void ModelGeometry::deinitialize() {
|
||||
}
|
||||
|
||||
bool ModelGeometry::loadObj(const std::string& filename) {
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
|
||||
filename,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
|
||||
filename,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
);
|
||||
|
||||
bool hasCachedFile = FileSys.fileExists(cachedFile);
|
||||
if (hasCachedFile) {
|
||||
LINFO("Cached file '" << cachedFile << "' used for Model file '" << filename << "'");
|
||||
bool hasCachedFile = FileSys.fileExists(cachedFile);
|
||||
if (hasCachedFile) {
|
||||
LINFO("Cached file '" << cachedFile << "' used for Model file '" << filename << "'");
|
||||
|
||||
bool success = loadCachedFile(cachedFile);
|
||||
if (success)
|
||||
return true;
|
||||
else
|
||||
FileSys.cacheManager()->removeCacheFile(filename);
|
||||
// Intentional fall-through to the 'else' computation to generate the cache
|
||||
// file for the next run
|
||||
}
|
||||
else {
|
||||
LINFO("Cache for Model '" << filename << "' not found");
|
||||
}
|
||||
LINFO("Loading Model file '" << filename << "'");
|
||||
bool success = loadModel(filename);
|
||||
if (!success)
|
||||
//return false;
|
||||
bool success = loadCachedFile(cachedFile);
|
||||
if (success)
|
||||
return true;
|
||||
else
|
||||
FileSys.cacheManager()->removeCacheFile(filename);
|
||||
// Intentional fall-through to the 'else' computation to generate the cache
|
||||
// file for the next run
|
||||
}
|
||||
else {
|
||||
LINFO("Cached file '" << cachedFile << "' used for Model file '" << filename << "' not found");
|
||||
}
|
||||
|
||||
LINFO("Saving cache");
|
||||
success = saveCachedFile(cachedFile);
|
||||
LINFO("Loading Model file '" << filename << "'");
|
||||
bool success = loadModel(filename);
|
||||
|
||||
return success;
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
LINFO("Saving cache");
|
||||
success = saveCachedFile(cachedFile);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
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));
|
||||
std::ofstream fileStream(filename, std::ofstream::binary);
|
||||
if (fileStream.good()) {
|
||||
fileStream.write(reinterpret_cast<const char*>(&CurrentCacheVersion),
|
||||
sizeof(int8_t));
|
||||
|
||||
int64_t vSize = _vertices.size();
|
||||
fileStream.write(reinterpret_cast<const char*>(&vSize), sizeof(int64_t));
|
||||
int64_t iSize = _indices.size();
|
||||
fileStream.write(reinterpret_cast<const char*>(&iSize), sizeof(int64_t));
|
||||
int64_t vSize = _vertices.size();
|
||||
fileStream.write(reinterpret_cast<const char*>(&vSize), sizeof(int64_t));
|
||||
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);
|
||||
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("Error opening file '" << filename << "' for save cache file");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return fileStream.good();
|
||||
}
|
||||
else {
|
||||
LERROR("Error opening file '" << filename << "' for save cache file");
|
||||
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;
|
||||
}
|
||||
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, iSize;
|
||||
fileStream.read(reinterpret_cast<char*>(&vSize), sizeof(int64_t));
|
||||
fileStream.read(reinterpret_cast<char*>(&iSize), sizeof(int64_t));
|
||||
int64_t vSize, iSize;
|
||||
fileStream.read(reinterpret_cast<char*>(&vSize), sizeof(int64_t));
|
||||
fileStream.read(reinterpret_cast<char*>(&iSize), sizeof(int64_t));
|
||||
|
||||
if (vSize == 0 || iSize == 0) {
|
||||
LERROR("Error opening file '" << filename << "' for loading cache file");
|
||||
return false;
|
||||
}
|
||||
if (vSize == 0 || iSize == 0) {
|
||||
LERROR("Error opening file '" << filename << "' for loading cache file");
|
||||
return false;
|
||||
}
|
||||
|
||||
_vertices.resize(vSize);
|
||||
_indices.resize(iSize);
|
||||
_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);
|
||||
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("Error opening file '" << filename << "' for loading cache file");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return fileStream.good();
|
||||
}
|
||||
else {
|
||||
LERROR("Error opening file '" << filename << "' for loading cache file");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ModelGeometry::getVertices(std::vector<Vertex>* vertexList) {
|
||||
vertexList->clear();
|
||||
|
||||
90
modules/base/rendering/multimodelgeometry.cpp
Normal file
90
modules/base/rendering/multimodelgeometry.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/base/rendering/multimodelgeometry.h>
|
||||
|
||||
#include "ghoul/logging/logmanager.h"
|
||||
#include "ghoul/io/model/modelreadermultiformat.h"
|
||||
#include "ghoul/opengl/vertexbufferobject.h"
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "MultiModelGeometry";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
namespace modelgeometry {
|
||||
|
||||
MultiModelGeometry::MultiModelGeometry(const ghoul::Dictionary& dictionary)
|
||||
: ModelGeometry(dictionary)
|
||||
{
|
||||
loadObj(_file);
|
||||
}
|
||||
|
||||
bool MultiModelGeometry::initialize(Renderable* parent)
|
||||
{
|
||||
bool success = ModelGeometry::initialize(parent);
|
||||
return success;
|
||||
}
|
||||
|
||||
void MultiModelGeometry::deinitialize()
|
||||
{
|
||||
ModelGeometry::deinitialize();
|
||||
}
|
||||
|
||||
bool MultiModelGeometry::loadModel(const std::string& filename)
|
||||
{
|
||||
try {
|
||||
ghoul::io::ModelReaderMultiFormat modelReader;
|
||||
|
||||
std::vector<ghoul::io::ModelReaderBase::Vertex> vertices;
|
||||
std::vector<int> indices;
|
||||
|
||||
modelReader.loadModel(filename, vertices, indices);
|
||||
|
||||
_vertices.reserve(vertices.size());
|
||||
for (const auto & v : vertices)
|
||||
{
|
||||
Vertex vv;
|
||||
memcpy(vv.location, v.location, sizeof(GLfloat) * 3);
|
||||
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());
|
||||
}
|
||||
catch (ghoul::io::ModelReaderBase::ModelReaderException & e)
|
||||
{
|
||||
// Log error reading geometry file.
|
||||
LERROR(e.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace modelgeometry
|
||||
} // namespace openspace
|
||||
51
modules/base/rendering/multimodelgeometry.h
Normal file
51
modules/base/rendering/multimodelgeometry.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __MULTIMODELGEOMETRY_H__
|
||||
#define __MULTIMODELGEOMETRY_H__
|
||||
|
||||
#include <modules/base/rendering/modelgeometry.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableModel;
|
||||
class RenderableModelProjection;
|
||||
|
||||
namespace modelgeometry {
|
||||
|
||||
class MultiModelGeometry : public ModelGeometry {
|
||||
public:
|
||||
MultiModelGeometry(const ghoul::Dictionary& dictionary);
|
||||
|
||||
bool initialize(Renderable* parent) override;
|
||||
void deinitialize() override;
|
||||
|
||||
private:
|
||||
bool loadModel(const std::string& filename);
|
||||
};
|
||||
|
||||
} // namespace modelgeometry
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __MULTIMODELOBJECT_H__
|
||||
1
modules/newhorizons/include.cmake
Normal file
1
modules/newhorizons/include.cmake
Normal file
@@ -0,0 +1 @@
|
||||
set(DEFAULT_MODULE ON)
|
||||
@@ -369,16 +369,16 @@ void RenderablePlanetProjection::imageProjectGPU(){
|
||||
_fboProgramObject->setUniform("boresight" , _boresight);
|
||||
|
||||
if (_geometry->hasProperty("radius")){
|
||||
boost::any r = _geometry->property("radius")->get();
|
||||
if (glm::vec4* radius = boost::any_cast<glm::vec4>(&r)){
|
||||
ghoul::any r = _geometry->property("radius")->get();
|
||||
if (glm::vec4* radius = ghoul::any_cast<glm::vec4>(&r)){
|
||||
_fboProgramObject->setUniform("radius", radius);
|
||||
}
|
||||
}else{
|
||||
LERROR("Geometry object needs to provide radius");
|
||||
}
|
||||
if (_geometry->hasProperty("segments")){
|
||||
boost::any s = _geometry->property("segments")->get();
|
||||
if (int* segments = boost::any_cast<int>(&s)){
|
||||
ghoul::any s = _geometry->property("segments")->get();
|
||||
if (int* segments = ghoul::any_cast<int>(&s)){
|
||||
_fboProgramObject->setAttribute("segments", segments[0]);
|
||||
}
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user