Commit acc80564 authored by michal's avatar michal
Browse files

added some new classes for ephemeris rendering..

parent 9eaf25f3
No related merge requests found
Showing with 440 additions and 75 deletions
+440 -75
/*****************************************************************************************
* *
* 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 __RENDERABLETPATH_H__
#define __RENDERABLETPATH_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
//#include <openspace/util/runtimedata.h>
namespace openspace {
class RenderablePath : public Renderable{
public:
RenderablePath(const ghoul::Dictionary& dictionary);
~RenderablePath();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
properties::StringProperty _colorTexturePath; // not used now, will be later though.
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
void loadTexture();
/* typedef struct {
GLfloat location[4];
GLfloat velocity[4];
GLubyte padding[32]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
*/
// need to write robust method for vbo id selection
// (right now galactic grid has to be present) (why though?) solve later...
GLuint _vaoID = 6;
GLuint _vBufferID = 7;
GLuint _iBufferID = 8;
void nextIndex();
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
unsigned int _vtotal;
unsigned int _stride;
//Vertex* _varray;
std::vector<float> _varray;
int* _iarray;
bool* _updated;
psc _pscpos, _pscvel;
std::vector<std::pair<int, double>> _intervals;
double _increment;
// etc...
double _time = 0;
double _oldTime = 0;
};
}
#endif
\ No newline at end of file
......@@ -54,7 +54,7 @@ public:
typedef struct
{
GLfloat location[3];
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
/* GLfloat color[4];
......
openspace-data @ b8a3813f
Subproject commit cd11d1709b5614f74a2e3d0e5e23ff0f62337035
Subproject commit b8a3813febf60d4576ecbd2b2be75d80a6f00c42
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
openspace.time.setTime("2005-11-01T00:00:00")
openspace.time.setDeltaTime(20000000.0)
openspace.time.setDeltaTime(200000.0)
--openspace.time.setDeltaTime(30000.0)
print(openspace.time.currentTimeUTC())
......@@ -24,6 +24,11 @@
#version 430
uniform vec4 campos;
uniform vec4 objpos;
uniform vec4 camdir;
uniform float time;
uniform sampler2D texture1;
......@@ -36,11 +41,40 @@ in float s;
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
//#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
vec4 position = vec4(vs_position,s);
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
// directional lighting
vec3 origin = vec3(0.0);
vec4 spec = vec4(0.0);
vec4 tmp = camdir;
vec3 n = normalize(vs_normal.xyz);
vec3 e = normalize(tmp.xyz);
vec3 l_pos = vec3(0.0); // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float intensity = max(dot(n,l_dir), 0.0)*1.5;
float shine = 19.0;
vec4 specular = vec4(0.5);
vec4 ambient = vec4(0.0,0.0,0.0,1);
if(intensity > 0.f){
// halfway vector
vec3 h = normalize(l_dir + e);
// specular factor
float intSpec = max(dot(h,n),0.0);
spec = specular * pow(intSpec, shine);
}
diffuse = max(intensity * diffuse , ambient);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
......
......@@ -27,6 +27,8 @@
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
uniform vec4 camdir;
layout(location = 0) in vec4 in_position;
//in vec3 in_position;
layout(location = 1) in vec2 in_st;
......
......@@ -52,7 +52,6 @@ void main(void)
//color.a = 1-color.a;
diffuse = texture2D(texture1, texCoord)*color;
// diffuse = vec4(Color, 1.0);
vec4 position = vs_position;
......
......@@ -324,6 +324,7 @@ bool OpenSpaceEngine::initialize()
Spice::init();
Spice::ref().loadDefaultKernels(); // changeto: instantiate spicemanager, load kernels.
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/NewHorizonsJupiterEncounter/fov.tm"), "JUPITER_ENCOUNTER");
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"), "SPK_EARTH");
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/MAR063.bsp") , "SPK_MARS");
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/pck00010.tpc") , "PCK");
......
......@@ -143,8 +143,11 @@ void RenderablePlanet::render(const RenderData& data)
}
transform = transform* rot;
glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
glm::vec4 camSpaceEye = -(modelview*currentPosition.vec4());
// 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);
......
......@@ -110,6 +110,7 @@ void Renderable::setPscUniforms(ghoul::opengl::ProgramObject* program, const Cam
program->setUniform("campos", camera->position().vec4());
program->setUniform("objpos", position.vec4());
program->setUniform("camrot", camera->viewRotationMatrix());
//const glm::vec2 scaletmp(1, 1);
program->setUniform("scaling", camera->scaling());
}
......
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
#include <openspace/rendering/renderablepath.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/constants.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/spicemanager.h>
#include <iomanip>
#include <utility> // std::move
namespace {
const std::string _loggerCat = "RenderablePath";
}
namespace openspace{
RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINE_STRIP){
double lightTime = 0.0;
double planetYear = 31536000;
_time = SM.convertStringToTdbSeconds("2005 jan 09 00:00:00");
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
double et = _time - planetYear;
int segments = 40; // note to self: code not look nice. cleanup for clarity later.
psc pscpos, pscvel;
_isize = (segments+2);
_vsize = (segments+2);
//_varray = new float[_vsize];
_iarray = new int[_isize];
_updated = new bool[_vsize];
std::fill(_updated, _updated + _vsize, false);
//static_assert(sizeof(Vertex) == 64, "The size of the Vertex needs to be 64 for performance");
_increment = planetYear / segments;
for (int i = 0; i < segments+1; i++){
SM.getTargetPscState("EARTH", et, "GALACTIC", "LT+S", "SUN", pscpos, pscvel, lightTime);
psc tmppos = glm::vec4(i, i, i, 7);
_varray.push_back(tmppos[0]);
_varray.push_back(tmppos[1]);
_varray.push_back(tmppos[2]);
_varray.push_back(tmppos[3]);
//memcpy(_varray[i].location, glm::value_ptr(pscpos.vec4()), 4 * sizeof(double));
glm::vec4 color = glm::vec4(1, (i % 2 == 0), 1, 1);
_varray.push_back(color[0]);
_varray.push_back(color[1]);
_varray.push_back(color[2]);
_varray.push_back(color[3]);
_intervals.push_back(std::pair<int, double>(i, et));
_iarray[i] = i; // remove indx in this class at some point!
et += _increment;
}
_stride = 8;
_vsize = _varray.size();
_vtotal = static_cast<int>(_vsize / _stride);
/*
std::cout << "before : " << std::endl;
for (int i = 0; i < _vsize-1; i++){
std::cout << _varray[i] << std::endl;
}
/// how to std::move()
int m = 8;
for (int i = _vsize-1; i+1-m != 0; i--){
std:: cout << i << " " << i-m << std::endl;
_varray[i] = std::move(_varray[i - m]);
}
/*
std::cout << "after : " << std::endl;
for (int i = 0; i < _vsize - 1; i++){
std::cout << _varray[i] << std::endl;
}
*/
}
RenderablePath::~RenderablePath(){
deinitialize();
}
bool RenderablePath::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
loadTexture();
completeSuccess &= (_texture != nullptr);
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
GLsizei st = sizeof(GLfloat) * _stride;
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
return completeSuccess;
}
bool RenderablePath::deinitialize(){
delete _texture;
_texture = nullptr;
return true;
}
void RenderablePath::render(const RenderData& data){
assert(_programObject);
_programObject->activate();
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
// PowerScaledScalar scaling = camera->scaling();
PowerScaledScalar scaling = glm::vec2(1, -6);
glm::mat4 transform = glm::mat4(1);
// setup the data to the shader
//_programObject->setUniform("objectVelocity", pscvel.vec4());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
_programObject->setUniform("campos", campos.vec4());
_programObject->setUniform("objpos", currentPosition.vec4());
_programObject->setUniform("camrot", camrot);
_programObject->setUniform("scaling", scaling.vec2());
if (_oldTime != _time){
int m = 8;
for (int i = _vsize - 1; i + 1 - m != 0; i--){
_varray[i] = std::move(_varray[i - m]);
}
memcpy(&_varray[0], glm::value_ptr(_pscpos.vec4()), 4 * sizeof(double));
_varray[4] = 1;
_varray[5] = 1;
_varray[6] = 1;
_varray[7] = 1;
}_oldTime = _time;
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, _vtotal);
glBindVertexArray(0);
glPointSize(2.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, _vtotal);
glBindVertexArray(0);
_programObject->deactivate();
}
void RenderablePath::update(const UpdateData& data){
double lightTime;
_time = data.time;
SM.getTargetPscState("EARTH", data.time, "GALACTIC", "LT+S", "SUN", _pscpos, _pscvel, lightTime);
}
void RenderablePath::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
}
}
}
}
\ No newline at end of file
......@@ -25,7 +25,6 @@
// temporary includes (will fix as soon as I figure out how class hierarchy should work,
// ie after I see model on screen)
#include<fstream>
#include <openspace/objloadertemp/Geometry.h>
// open space includes
#include <openspace/rendering/renderablewavefrontobject.h>
......@@ -58,7 +57,7 @@ RenderableWavefrontObject::RenderableWavefrontObject(const ghoul::Dictionary& di
assert(success);
std::string path;
dictionary.getValue(constants::renderablestars::keyPathModule, path);
dictionary.getValue(constants::scenegraph::keyPathModule, path);
std::string texturePath = "";
if (dictionary.hasKey("Textures.Color")) {
......@@ -71,8 +70,15 @@ RenderableWavefrontObject::RenderableWavefrontObject(const ghoul::Dictionary& di
_mode = GL_TRIANGLES;
std::string filename;
std::string file;
dictionary.getValue(constants::renderablewavefrontobject::keyObjFile, file);
const std::string filename = FileSys.absolutePath(file);
std::cout << "OBJECT LOADER FILENAME : " << filename << std::endl;
std::ifstream ifile(filename.c_str());
if (ifile){
LDEBUG("Found file..\n");
ifile.close();
......@@ -83,6 +89,16 @@ RenderableWavefrontObject::RenderableWavefrontObject(const ghoul::Dictionary& di
}
void normalize(glm::vec3 v) {
float magnitude = 0.0f;
for (int i = 0; i < 3; i++)
magnitude += pow(v[i], 2.0f);
magnitude = sqrt(magnitude);
for (int i = 0; i < 3; i++)
v[i] /= magnitude;
}
void RenderableWavefrontObject::loadObj(const char *filename){
// temporary
int vertexSize = 0;
......@@ -104,7 +120,7 @@ void RenderableWavefrontObject::loadObj(const char *filename){
while (fgets(line, 150, fi) != NULL)
{
if (sscanf(line, "v %f%f%f", &f1, &f2, &f3)) {
vertexSize += 3;
vertexSize += 4;
}
if (sscanf(line, "vn %f%f%f", &f1, &f2, &f3)) {
vertexNormalSize += 3;
......@@ -124,7 +140,6 @@ void RenderableWavefrontObject::loadObj(const char *filename){
}
}
/* END LINE COUNT */
// allocate memory for all arrays
_isize = indicesSize;
_vsize = indicesSize;
......@@ -167,13 +182,10 @@ void RenderableWavefrontObject::loadObj(const char *filename){
}
if (sscanf(line, "vt %f%f%f", &f1, &f2, &f3)){
(tempVertexTextureArray)[w] = f1;
maxtex = ((tempVertexTextureArray)[w] > maxtex) ? (tempVertexTextureArray)[w] : maxtex;
w++;
(tempVertexTextureArray)[w] = f2;
maxtex = ((tempVertexTextureArray)[w] > maxtex) ? (tempVertexTextureArray)[w] : maxtex;
w++;
(tempVertexTextureArray)[w] = f3;
maxtex = ((tempVertexTextureArray)[w] > maxtex) ? (tempVertexTextureArray)[w] : maxtex;
w++;
}
if (vertexTextureSize > 0){
......@@ -191,7 +203,8 @@ void RenderableWavefrontObject::loadObj(const char *filename){
(tempNormalIndicesArray)[m] = i9 - 1;
m++;
}
}else{
}
else{
if (sscanf(line, "f %i//%i %i//%i %i//%i", &i1, &i2, &i3, &i4, &i5, &i6)){
(_iarray)[m] = i1 - 1;
(tempNormalIndicesArray)[m] = i2 - 1;
......@@ -206,40 +219,32 @@ void RenderableWavefrontObject::loadObj(const char *filename){
}
}
fclose(fi);
// end of file read
// creating the vertex array
i = 0; n = 0; m = 0;
int normalIndex = 0;
int textureIndex = 0;
int vertexIndex = 0;
while (m<_vsize){
while (m < _vsize){
normalIndex = tempNormalIndicesArray[m] * 3;
textureIndex = tempTextureIndicesArray[m] * 3;
vertexIndex = _iarray[m] * 3;
_iarray[m] = m;
_varray[m].location[3] = 6;
int q = 0;
while (q < 3){
_varray[m].location[q] = tempVertexArray[vertexIndex + q];
_varray[m].normal[q] = tempVertexNormalArray[normalIndex + q];
q++;
}
// needs to be added at some point...
/*
_varray[m].color[0] = 1;
_varray[m].color[1] = 1;
_varray[m].color[2] = 1;
_varray[m].color[3] = 1.0;
_varray[m].attribute[0] = 0;
_varray[m].attribute[1] = 0;
_varray[m].attribute[2] = 0;
_varray[m].float_attribute = 0;
*/
if (vertexTextureSize > 0){
_varray[m].tex[0] = tempVertexTextureArray[textureIndex];
_varray[m].tex[1] = tempVertexTextureArray[textureIndex + 1];
}else{
}
else{
_varray[m].tex[0] = 1.0;
_varray[m].tex[1] = 1.0;
}
......@@ -253,6 +258,7 @@ void RenderableWavefrontObject::loadObj(const char *filename){
free(tempTextureIndicesArray);
}
RenderableWavefrontObject::~RenderableWavefrontObject(){
deinitialize();
}
......@@ -267,27 +273,12 @@ bool RenderableWavefrontObject::initialize()
loadTexture();
completeSuccess &= (_texture != nullptr);
//completeSuccess &= _geometry->initialize(this);
// --------------------------------------------------------------------------------- powerscaled sphere -----
// Initialize and upload to graphics card
GLuint errorID;
if (_vaoID == 0) glGenVertexArrays(1, &_vaoID);
if (_vBufferID == 0) {
glGenBuffers(1, &_vBufferID);
if (_vBufferID == 0) {
LERROR("Could not create vertex buffer");
return false;
}
}
if (_iBufferID == 0) {
glGenBuffers(1, &_iBufferID);
if (_iBufferID == 0) {
LERROR("Could not create index buffer");
return false;
}
}
GLuint errorID;
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
// First VAO setup
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray, GL_STATIC_DRAW);
......@@ -296,11 +287,11 @@ bool RenderableWavefrontObject::initialize()
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
......@@ -317,6 +308,13 @@ bool RenderableWavefrontObject::initialize()
bool RenderableWavefrontObject::deinitialize()
{
delete[] _varray;
delete[] _iarray;
glDeleteBuffers(1, &_vBufferID);
glDeleteBuffers(1, &_iBufferID);
glDeleteVertexArrays(1, &_vaoID);
delete _texture;
_texture = nullptr;
return true;
......@@ -333,30 +331,34 @@ void RenderableWavefrontObject::render(const RenderData& data)
_programObject->activate();
// fetch data
psc currentPosition = data.position;
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
// PowerScaledScalar scaling = camera->scaling();
PowerScaledScalar scaling = glm::vec2(1, -6);
// 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));
glm::mat4 rot = glm::rotate(transform, 90.f, glm::vec3(1, 1, 0));
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = _stateMatrix[i][j];
}
}
transform = transform* rot;
transform = transform *rot;
glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
glm::vec4 camSpaceEye = -(modelview*currentPosition.vec4());
// setup the data to the shader
// 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);
setPscUniforms(_programObject, &data.camera, glm::vec4(0, 0, -1,8 ));
// Bind texture
ghoul::opengl::TextureUnit unit;
......@@ -365,7 +367,10 @@ void RenderableWavefrontObject::render(const RenderData& data)
_programObject->setUniform("texture1", unit);
// render
//_geometry->render();
glBindVertexArray(_vaoID); // select first VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
// disable shader
_programObject->deactivate();
......@@ -375,7 +380,7 @@ void RenderableWavefrontObject::render(const RenderData& data)
void RenderableWavefrontObject::update(const UpdateData& data)
{
// set spice-orientation in accordance to timestamp
//openspace::SpiceManager::ref().getPositionTransformMatrixGLM("GALACTIC", "IAU_EARTH", data.time, _stateMatrix);
openspace::SpiceManager::ref().getPositionTransformMatrixGLM("GALACTIC", "IAU_MARS", data.time, _stateMatrix);
}
......
......@@ -92,8 +92,8 @@ bool RenderEngine::initializeGL()
// set the close clip plane and the far clip plane to extreme values while in
// development
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f,100.0f);
sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 1000.00f);
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.01f,100.0f);
sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 1000.00f);
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.0001f, 100.0f);
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 200.0f);
......
......@@ -101,21 +101,6 @@ std::ifstream& RenderableStars::skipToLine(std::ifstream& file, unsigned int num
return file;
}
//these two methods exist only to debug geom shaders code.
float log10(float x){ return log(x)/ log(10.f); }
psc psc_addition(psc v1, psc v2) {
float k = 10.f;
float ds = v2[3] - v1[3];
if (ds >= 0) {
float p = pow(k, -ds);
return psc(v1[0]*p + v2[0], v1[1]*p + v2[1], v1[2]*p + v2[2], v2[3]);
}
else {
float p = pow(k, ds);
return psc(v1[0] + v2[0]*p, v1[1] + v2[1]*p, v1[2] + v2[2]*p, v1[3]);
}
}
//#define ROTATESTARS
......
......@@ -27,6 +27,7 @@
#include <cassert>
// renderables
#include <openspace/rendering/renderablewavefrontobject.h>
#include <openspace/rendering/stars/renderablestars.h>
#include <openspace/rendering/renderableephemeris.h>
#include <openspace/rendering/renderabletrail.h>
......@@ -69,6 +70,8 @@ void FactoryManager::initialize()
"RenderableTrail");
_manager->factory<Renderable>()->registerClass<RenderableSphericalGrid>(
"RenderableSphericalGrid");
_manager->factory<Renderable>()->registerClass<RenderableWavefrontObject>(
"RenderableWavefrontObject");
//_manager->factory<Renderable>()->registerClass<RenderableVolumeCL>(
// "RenderableVolumeCL");
_manager->factory<Renderable>()->registerClass<RenderableVolumeGL>(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment