minor changes, testing

This commit is contained in:
michal
2014-11-26 11:22:11 -05:00
parent 4c8814b237
commit c154141b8b
16 changed files with 369 additions and 33 deletions
@@ -31,6 +31,8 @@
#include <openspace/properties/stringproperty.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/opengl/framebufferobject.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
@@ -60,7 +62,11 @@ private:
properties::StringProperty _colorTexturePath;
properties::StringProperty _projectionTexturePath;
ghoul::opengl::FramebufferObject fbo;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::ProgramObject* _writeToTextureProgramObject;
ghoul::opengl::Texture* _texture;
ghoul::opengl::Texture* _textureProj;
planetgeometryprojection::PlanetGeometryProjection* _geometry;
@@ -0,0 +1,71 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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 __RENDERABLEPLANET_H__
#define __RENDERABLEPLANET_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/util/updatestructures.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
namespace openspace {
namespace planetgeometry {
class PlanetGeometry;
}
class RenderablePlanet : public Renderable {
public:
RenderablePlanet(const ghoul::Dictionary& dictionary);
~RenderablePlanet();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
protected:
void loadTexture();
private:
properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
planetgeometry::PlanetGeometry* _geometry;
glm::dmat3 _stateMatrix;
std::string _target;
};
} // namespace openspace
#endif // __RENDERABLEPLANET_H__
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
openspace.time.setTime("2007-02-28T11:48:16.364")
openspace.time.setTime("2007-02-26T17:38:00.00")
--openspace.time.setTime("2006-08-22T20:00:00")
--openspace.time.setDeltaTime(200000.0)
+1 -4
View File
@@ -78,7 +78,7 @@ void main()
// PROJECTIVE TEXTURE
vec4 projTexColor = textureProj(texture2, ProjTexCoord);
vec4 shaded = max(intensity * diffuse, ambient);
vec4 shaded = diffuse;//max(intensity * diffuse, ambient);
if (ProjTexCoord[0] > 0.0 ||
ProjTexCoord[1] > 0.0 ||
ProjTexCoord[0] < ProjTexCoord[2] ||
@@ -89,10 +89,7 @@ void main()
}else{
diffuse = shaded;
}
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
+1
View File
@@ -51,6 +51,7 @@ out vec4 ProjTexCoord;
void main()
{
// Radius = 0.71492 *10^8;
vs_boresight = boresight;
// set variables
vs_st = in_st;
+33
View File
@@ -0,0 +1,33 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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. *
****************************************************************************************/
#version 430
in vec4 vs_position;
out vec4 color;
void main()
{
color = vec4(1);
}
+34
View File
@@ -0,0 +1,34 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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. *
****************************************************************************************/
#version 430
layout(location = 0) in vec4 in_position;
out vec4 vs_position;
void main(){
vs_position = in_position;
}
+1 -21
View File
@@ -291,27 +291,7 @@ bool OpenSpaceEngine::initialize() {
LERROR("Error loading leap second kernel '" << leapSecondKernel << "'");
return false;
}
//// metakernel loading doesnt seem to work... it should. to tired to even
//// CK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/ck/merged_nhpc_2006_v011.bc");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/ck/merged_nhpc_2007_v006.bc");
//// FK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/fk/nh_v200.tf");
//// IK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/ik/nh_lorri_v100.ti");
//// LSK already loaded
////PCK
////SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/pck/pck00008.tpc");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/pck/new_horizons_413.tsc");
////SPK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/de413.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/jup260.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/nh_nep_ura_000.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/nh_recon_e2j_v1.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/nh_recon_j2sep07_prelimv1.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/sb_2002jf56_2.bsp");
FactoryManager::initialize();
scriptEngine().initialize();
@@ -51,6 +51,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _colorTexturePath("colorTexture", "Color Texture")
, _projectionTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _writeToTextureProgramObject(nullptr)
, _texture(nullptr)
, _textureProj(nullptr)
, _geometry(nullptr)
@@ -102,6 +103,9 @@ bool RenderablePlanetProjection::initialize(){
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("projectiveProgram", _programObject);
if (_writeToTextureProgramObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("writeToTextureProgram", _writeToTextureProgramObject);
loadTexture();
completeSuccess &= (_texture != nullptr);
@@ -195,18 +199,37 @@ void RenderablePlanetProjection::render(const RenderData& data)
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_programObject->setUniform("texture1", unit);
_programObject->setUniform("texture1", unit); // jupiter
ghoul::opengl::TextureUnit unit2;
unit2.activate();
_textureProj->bind();
_programObject->setUniform("texture2", unit2);
_programObject->setUniform("texture2", unit2); // proj
// render
_geometry->render();
// disable shader
_programObject->deactivate();
/*
fbo.activate();
//glViewport(0, 0, 1024, 1024);
_writeToTextureProgramObject->activate();
GLfloat vertices[] = { -1, -1, 0, // bottom left corner
-1, 1, 0, // top left corner
1, 1, 0, // top right corner
1, -1, 0 }; // bottom right corner
GLubyte indices[] = { 0, 1, 2, // first triangle (bottom left - top left - top right)
0, 2, 3 }; // second triangle (bottom left - top right - bottom right)
glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
_writeToTextureProgramObject->deactivate();
fbo.deactivate();
*/
}
void RenderablePlanetProjection::update(const UpdateData& data){
@@ -229,8 +252,13 @@ void RenderablePlanetProjection::loadTexture()
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
fbo.activate();
fbo.attachTexture(_texture, GL_COLOR_ATTACHMENT0, 0, 0);
fbo.deactivate();
}
}
delete _textureProj;
_textureProj = nullptr;
if (_colorTexturePath.value() != "") {
+179
View File
@@ -0,0 +1,179 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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. *
****************************************************************************************/
// open space includes
#include <openspace/rendering/planets/renderableplanet.h>
#include <openspace/util/constants.h>
#include <openspace/rendering/planets/planetgeometry.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/engine/openspaceengine.h>
#include <sgct.h>
namespace {
const std::string _loggerCat = "RenderablePlanet";
}
namespace openspace {
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _geometry(nullptr)
{
std::string name;
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
assert(success);
std::string path;
success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
assert(success);
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(
constants::renderableplanet::keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
}
dictionary.getValue(constants::renderableplanet::keyFrame, _target);
// TODO: textures need to be replaced by a good system similar to the geometry as soon
// as the requirements are fixed (ab)
std::string texturePath = "";
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
_colorTexturePath = path + "/" + texturePath;
addPropertySubOwner(_geometry);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
}
RenderablePlanet::~RenderablePlanet(){
deinitialize();
}
bool RenderablePlanet::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("pscShader", _programObject);
loadTexture();
completeSuccess &= (_texture != nullptr);
completeSuccess &= _geometry->initialize(this);
return completeSuccess;
}
bool RenderablePlanet::deinitialize(){
_geometry->deinitialize();
delete _geometry;
_geometry = nullptr;
delete _texture;
_texture = nullptr;
return true;
}
void RenderablePlanet::render(const RenderData& data)
{
if (!_programObject) return;
if (!_texture) return;
// activate shader
_programObject->activate();
// scale the planet to appropriate size since the planet is a unit sphere
glm::mat4 transform = glm::mat4(1);
//earth needs to be rotated for that to work.
glm::mat4 rot = glm::rotate(transform, 90.f, glm::vec3(1, 0, 0));
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = _stateMatrix[i][j];
}
}
transform = transform* rot;
if (_target == "IAU_JUPITER"){ //x = 0.935126
transform *= glm::scale(glm::mat4(1), glm::vec3(1, 0.93513, 1));
}
glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz;
// setup the data to the shader
// _programObject->setUniform("camdir", camSpaceEye);
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
// Bind texture
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_programObject->setUniform("texture1", unit);
// render
_geometry->render();
// disable shader
_programObject->deactivate();
}
void RenderablePlanet::update(const UpdateData& data){
// set spice-orientation in accordance to timestamp
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, "GALACTIC", data.time, _stateMatrix);
}
void RenderablePlanet::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
_texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
}
}
}
} // namespace openspace
+1 -2
View File
@@ -164,7 +164,6 @@ void RenderableTrail::sendToGPU(){
glBindVertexArray(0);
}
bool RenderableTrail::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
@@ -176,7 +175,7 @@ bool RenderableTrail::initialize(){
completeSuccess &= (_texture != nullptr);
_startTrail;
SpiceManager::ref().getETfromDate("2007 feb 28 11:48:00.000", _startTrail);
SpiceManager::ref().getETfromDate("2007 feb 26 17:38:00.000", _startTrail);
_dtEt = _startTrail;
fullYearSweep();
+9
View File
@@ -169,6 +169,15 @@ bool SceneGraph::initialize()
typedef std::chrono::duration<double, std::ratio<1> > second_;
std::chrono::time_point<clock_> beginning(clock_::now());
// pscstandard
tmpProgram = ProgramObject::Build("writeToTextureProgram",
"${SHADERS}/writeToTexture_vs.glsl",
"${SHADERS}/writeToTexture_fs.glsl",
cb);
if (!tmpProgram) return false;
_programs.push_back(tmpProgram);
OsEng.ref().configurationManager().setValue("writeToTextureProgram", tmpProgram);
// pscstandard
tmpProgram = ProgramObject::Build("projectiveProgram",
"${SHADERS}/projectiveTexture_vs.glsl",
-1
View File
@@ -85,7 +85,6 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
_varray[nr].normal[1] = normal[1];
_varray[nr].normal[2] = normal[2];
//std::cout << _varray[nr].location[0] << " " << _varray[nr].location[1] << " " << _varray[nr].location[2] << " " << _varray[nr].location[3] << std::endl;
_varray[nr].tex[0] = t1;
_varray[nr].tex[1] = t2;
++nr;