mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-01 09:08:49 -06:00
adding changes for rudimental target switching, needs work.
This commit is contained in:
@@ -49,21 +49,23 @@ public:
|
||||
bool sequenceReset();
|
||||
|
||||
bool getImagePath(double& _currentTime, std::string& path, bool closedInterval = false);
|
||||
bool getImagePath(std::string _currentTime, std::string& path, bool closedInterval = false);
|
||||
double getNextCaptureTime();
|
||||
double getIntervalLength(){ return _intervalLength; };
|
||||
std::string& getActiveInstrument(){ return _activeInstrument; };
|
||||
|
||||
|
||||
static ImageSequencer* _sequencer;
|
||||
|
||||
private:
|
||||
double nextCaptureTime(double _time);
|
||||
|
||||
void createImage(double t1, double t2, std::string path = "dummypath");
|
||||
void createImage(double t1, double t2, std::string instrument, std::string path = "dummypath");
|
||||
|
||||
double _nextCapture;
|
||||
double _intervalLength;
|
||||
|
||||
std::string _defaultCaptureImage;
|
||||
std::string _activeInstrument;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Submodule openspace-data updated: 05740b37f8...e118d32086
@@ -151,7 +151,7 @@ void RenderableModel::render(const RenderData& data)
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("_performShading", _performShading);
|
||||
_programObject->setUniform("_performShading", false);
|
||||
|
||||
|
||||
// Bind texture
|
||||
|
||||
@@ -74,7 +74,7 @@ void WavefrontGeometry::loadObj(const char *filename){
|
||||
// temporary
|
||||
const char *mtl_basepat = filename;
|
||||
|
||||
std::string err = tinyobj::LoadObj(shapes, materials, filename, mtl_basepat);
|
||||
std::string err = tinyobj::LoadObj(shapes, materials, filename, NULL);
|
||||
|
||||
_isize = shapes[0].mesh.indices.size();
|
||||
_vsize = shapes[0].mesh.indices.size(); // shapes[0].mesh.positions.size() + shapes[0].mesh.positions.size() / 3;
|
||||
@@ -88,7 +88,7 @@ void WavefrontGeometry::loadObj(const char *filename){
|
||||
_iarray[f] = shapes[0].mesh.indices[f];
|
||||
}
|
||||
|
||||
//shapes[0].mesh.texcoords.resize(2 * _isize);
|
||||
shapes[0].mesh.texcoords.resize(2 * _isize);
|
||||
int p = 0;
|
||||
for (auto v : shapes[0].mesh.indices) {
|
||||
_varray[p].location[0] = shapes[0].mesh.positions[3 * v + 0];
|
||||
@@ -100,29 +100,14 @@ void WavefrontGeometry::loadObj(const char *filename){
|
||||
_varray[p].normal[1] = shapes[0].mesh.normals[3 * v + 1];
|
||||
_varray[p].normal[2] = shapes[0].mesh.normals[3 * v + 2];
|
||||
|
||||
|
||||
_varray[p].tex[0] = shapes[0].mesh.texcoords[2 * v + 0];
|
||||
_varray[p].tex[1] = shapes[0].mesh.texcoords[2 * v + 1];
|
||||
|
||||
p++;
|
||||
}
|
||||
p = 0;
|
||||
|
||||
//TEXCOORDS NOT MAPPING PROPERLY? WHY?
|
||||
/*
|
||||
if (shapes[0].mesh.texcoords.size() > 0) {
|
||||
for (size_t k = 0; k < shapes[0].mesh.indices.size() / 3; k++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
int idx = shapes[0].mesh.indices[3 * k + j];
|
||||
|
||||
_varray[p].tex[0] = shapes[0].mesh.texcoords[2 * idx + 0];
|
||||
_varray[p].tex[1] = shapes[0].mesh.texcoords[2 * idx + 1];
|
||||
|
||||
std::cout << shapes[0].mesh.texcoords[2 * idx + 0] << " "
|
||||
<< shapes[0].mesh.texcoords[2 * idx + 1] << std::endl;
|
||||
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//testing with one triangle - works.
|
||||
/*
|
||||
_varray[0].location[0] = 0;
|
||||
|
||||
@@ -405,119 +405,138 @@ void RenderableFov::render(const RenderData& data){
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
// update only when time progresses.
|
||||
if (_oldTime != _time){
|
||||
std::string shape, instrument;
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
|
||||
// fetch data for specific instrument (shape, boresight, bounds etc)
|
||||
bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, boresight, bounds);
|
||||
if (!found) LERROR("Could not locate instrument"); // fixlater
|
||||
std::string instrument = ImageSequencer::ref().getActiveInstrument();
|
||||
|
||||
float size = 4 * sizeof(float);
|
||||
int indx = 0;
|
||||
bool drawFOV = false;
|
||||
|
||||
// set target based on visibility to specific instrument,
|
||||
// from here on the _fovTarget is the target for all spice functions.
|
||||
//std::string potential[5] = { "Jupiter", "Io", "Europa", "Ganymede", "Callisto" };
|
||||
std::string potential[2] = { "Pluto", "Charon" };
|
||||
|
||||
_fovTarget = potential[0]; //default
|
||||
for (int i = 0; i < 2; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
|
||||
_spacecraft, _method,
|
||||
_aberrationCorrection, _time);
|
||||
if (_withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
//_instrumentID = instrument;
|
||||
if (instrument == "MVIC"){
|
||||
if (_instrumentID == "NH_RALPH_MVIC_PAN1" ||
|
||||
_instrumentID == "NH_RALPH_MVIC_PAN2" ||
|
||||
_instrumentID == "NH_RALPH_MVIC_RED" ||
|
||||
_instrumentID == "NH_RALPH_MVIC_BLUE" ||
|
||||
_instrumentID == "NH_RALPH_MVIC_FT"){
|
||||
drawFOV = true;
|
||||
}
|
||||
|
||||
computeColors();
|
||||
double t2 = openspace::ImageSequencer::ref().getNextCaptureTime();
|
||||
double diff = (t2 - _time);
|
||||
double t = 0.0;
|
||||
if (diff <= 30.0) t = 1.f - diff / 30.0;
|
||||
|
||||
double targetEpoch;
|
||||
// for each FOV vector
|
||||
for (int i = 0; i < 4; i++){
|
||||
// compute surface intercept
|
||||
_interceptTag[i] = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection,
|
||||
_time, targetEpoch, bounds[i], ipoint, ivec);
|
||||
// if not found, use the orthogonal projected point
|
||||
if (!_interceptTag[i]) _projectionBounds[i] = orthogonalProjection(bounds[i]);
|
||||
|
||||
// VBO1 : draw vectors representing outer points of FOV.
|
||||
if (_interceptTag[i]){
|
||||
_interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
|
||||
_interceptVector[3] += 3;
|
||||
//_interceptVector = pscInterpolate(_interceptVector, bsvec, t);
|
||||
// INTERCEPTIONS
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_start), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(_interceptVector.vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_end), size);
|
||||
indx += 4;
|
||||
}
|
||||
else if (_withinFOV){
|
||||
// FOV OUTSIDE OBJECT
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0,0,1,1)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(_projectionBounds[i].vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(blue), size);
|
||||
indx += 4;
|
||||
}else{
|
||||
glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3]+1);
|
||||
corner = tmp*corner;
|
||||
// "INFINITE" FOV
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_gray), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(corner), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
}
|
||||
}
|
||||
_interceptTag[4] = _interceptTag[0]; // 0 & 5 same point
|
||||
// Draw surface square!
|
||||
fovProjection(_interceptTag, bounds);
|
||||
updateData();
|
||||
}
|
||||
_oldTime = _time;
|
||||
|
||||
glLineWidth(1.f);
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glDrawArrays(_mode, 0, _vtotal[0]);
|
||||
glBindVertexArray(0);
|
||||
else if (instrument == _instrumentID){
|
||||
drawFOV = true;
|
||||
}
|
||||
if (drawFOV){
|
||||
// update only when time progresses.
|
||||
if (_oldTime != _time){
|
||||
std::string shape, instrument;
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
|
||||
//render points
|
||||
glPointSize(2.f);
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal[0]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//second vbo
|
||||
glLineWidth(2.f);
|
||||
glBindVertexArray(_vaoID[1]);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, _vtotal[1]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
/*glPointSize(5.f);
|
||||
glBindVertexArray(_vaoID2);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal2);
|
||||
glBindVertexArray(0);
|
||||
*/
|
||||
// fetch data for specific instrument (shape, boresight, bounds etc)
|
||||
bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, boresight, bounds);
|
||||
if (!found) LERROR("Could not locate instrument");
|
||||
|
||||
float size = 4 * sizeof(float);
|
||||
int indx = 0;
|
||||
|
||||
// set target based on visibility to specific instrument,
|
||||
// from here on the _fovTarget is the target for all spice functions.
|
||||
//std::string potential[5] = { "Jupiter", "Io", "Europa", "Ganymede", "Callisto" };
|
||||
std::string potential[2] = { "Pluto", "Charon" };
|
||||
|
||||
_fovTarget = potential[0]; //default
|
||||
for (int i = 0; i < 2; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
|
||||
_spacecraft, _method,
|
||||
_aberrationCorrection, _time);
|
||||
if (_withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
computeColors();
|
||||
double t2 = openspace::ImageSequencer::ref().getNextCaptureTime();
|
||||
double diff = (t2 - _time);
|
||||
double t = 0.0;
|
||||
if (diff <= 30.0) t = 1.f - diff / 30.0;
|
||||
|
||||
double targetEpoch;
|
||||
// for each FOV vector
|
||||
for (int i = 0; i < 4; i++){
|
||||
// compute surface intercept
|
||||
_interceptTag[i] = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection,
|
||||
_time, targetEpoch, bounds[i], ipoint, ivec);
|
||||
// if not found, use the orthogonal projected point
|
||||
if (!_interceptTag[i]) _projectionBounds[i] = orthogonalProjection(bounds[i]);
|
||||
|
||||
// VBO1 : draw vectors representing outer points of FOV.
|
||||
if (_interceptTag[i]){
|
||||
_interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
|
||||
_interceptVector[3] += 3;
|
||||
//_interceptVector = pscInterpolate(_interceptVector, bsvec, t);
|
||||
// INTERCEPTIONS
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_start), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(_interceptVector.vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_end), size);
|
||||
indx += 4;
|
||||
}
|
||||
else if (_withinFOV){
|
||||
// FOV OUTSIDE OBJECT
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0, 0, 1, 1)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(_projectionBounds[i].vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(blue), size);
|
||||
indx += 4;
|
||||
}
|
||||
else{
|
||||
glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3] + 1);
|
||||
corner = tmp*corner;
|
||||
// "INFINITE" FOV
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_gray), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(corner), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
}
|
||||
}
|
||||
_interceptTag[4] = _interceptTag[0]; // 0 & 5 same point
|
||||
fovProjection(_interceptTag, bounds);
|
||||
updateData();
|
||||
}
|
||||
_oldTime = _time;
|
||||
|
||||
glLineWidth(1.f);
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glDrawArrays(_mode, 0, _vtotal[0]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//render points
|
||||
glPointSize(2.f);
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal[0]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//second vbo
|
||||
glLineWidth(2.f);
|
||||
glBindVertexArray(_vaoID[1]);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, _vtotal[1]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
/*glPointSize(5.f);
|
||||
glBindVertexArray(_vaoID2);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal2);
|
||||
glBindVertexArray(0);
|
||||
*/
|
||||
}
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ struct ImageParams{
|
||||
double startTime;
|
||||
double stopTime;
|
||||
std::string path;
|
||||
std::string activeInstrument;
|
||||
bool projected;
|
||||
};
|
||||
|
||||
@@ -73,12 +74,13 @@ void ImageSequencer::deinitialize(){
|
||||
_sequencer = nullptr;
|
||||
}
|
||||
|
||||
void ImageSequencer::createImage(double t1, double t2, std::string path){
|
||||
void ImageSequencer::createImage(double t1, double t2, std::string instrument, std::string path){
|
||||
// insert
|
||||
ImageParams image;
|
||||
image.startTime = t1;
|
||||
image.stopTime = t2;
|
||||
image.path = path;
|
||||
image.activeInstrument = instrument;
|
||||
image.projected = false;
|
||||
|
||||
_timeStamps.push_back(image);
|
||||
@@ -102,20 +104,14 @@ double ImageSequencer::nextCaptureTime(double _time){
|
||||
return end;
|
||||
};
|
||||
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { _time, 0, "", false }, cmp);
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { _time, 0, "", "", false }, cmp);
|
||||
|
||||
if (_time < _nextCapture) return _nextCapture;
|
||||
return it->startTime;
|
||||
}
|
||||
|
||||
bool ImageSequencer::getImagePath(std::string _currentTime, std::string& path, bool closedInterval){
|
||||
double currentEt = 0;
|
||||
openspace::SpiceManager::ref().getETfromDate(_currentTime, currentEt);
|
||||
bool success = getImagePath(currentEt, path, closedInterval);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ImageSequencer::getImagePath(double& _currentTime, std::string& path, bool closedInterval){
|
||||
bool ImageSequencer::getImagePath(double& currentTime, std::string& path, bool closedInterval){
|
||||
auto binary_find = [](std::vector<ImageParams>::iterator begin,
|
||||
std::vector<ImageParams>::iterator end,
|
||||
const ImageParams &val,
|
||||
@@ -128,22 +124,23 @@ bool ImageSequencer::getImagePath(double& _currentTime, std::string& path, bool
|
||||
return end;
|
||||
};
|
||||
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { _currentTime, 0, "", false }, cmp);
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { currentTime, 0, "", "", false }, cmp);
|
||||
//check [start, stop]
|
||||
if (closedInterval && (it == _timeStamps.end() || it->stopTime < _currentTime || it->projected)){
|
||||
if (closedInterval && (it == _timeStamps.end() || it->stopTime < currentTime || it->projected)){
|
||||
return false;
|
||||
}else if (!closedInterval && (it == _timeStamps.end() || it->projected)){
|
||||
return false;
|
||||
}
|
||||
double upcoming = nextCaptureTime(_currentTime);
|
||||
double upcoming = nextCaptureTime(currentTime);
|
||||
if (_nextCapture != upcoming){
|
||||
_nextCapture = upcoming;
|
||||
_intervalLength = upcoming - _currentTime;
|
||||
_intervalLength = upcoming - currentTime;
|
||||
}
|
||||
|
||||
it->projected = true;
|
||||
path = it->path;
|
||||
_currentTime = it->startTime;
|
||||
currentTime = it->startTime;
|
||||
_activeInstrument = it->activeInstrument;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -270,12 +267,46 @@ bool ImageSequencer::parsePlaybookFile(const std::string& fileName, std::string
|
||||
else if (met < metRef){
|
||||
et -= diff;
|
||||
}
|
||||
/*
|
||||
std::string str;
|
||||
openspace::SpiceManager::ref().getDateFromET(et, str);
|
||||
std::cout << str << std::endl;
|
||||
*/
|
||||
createImage(et, et + shutter, _defaultCaptureImage);
|
||||
createImage(et, et + shutter, "NH_LORRI", _defaultCaptureImage);
|
||||
}
|
||||
pos = timestr.find("MVIC");
|
||||
if (pos != std::string::npos){
|
||||
timestr = timestr.substr(24, 9);
|
||||
std::string::size_type sz; // alias of size_t
|
||||
double met = std::stod(timestr, &sz);
|
||||
double diff;
|
||||
openspace::SpiceManager::ref().getETfromDate("2015-07-14T11:50:00.00", et);
|
||||
|
||||
diff = abs(met - metRef);
|
||||
if (met > metRef){
|
||||
et += diff;
|
||||
}
|
||||
else if (met < metRef){
|
||||
et -= diff;
|
||||
}
|
||||
|
||||
createImage(et, et + shutter, "MVIC", _defaultCaptureImage);
|
||||
}
|
||||
pos = timestr.find("RALPH_LEISA");
|
||||
if (pos != std::string::npos){
|
||||
timestr = timestr.substr(24, 9);
|
||||
std::string::size_type sz; // alias of size_t
|
||||
double met = std::stod(timestr, &sz);
|
||||
double diff;
|
||||
openspace::SpiceManager::ref().getETfromDate("2015-07-14T11:50:00.00", et);
|
||||
|
||||
diff = abs(met - metRef);
|
||||
if (met > metRef){
|
||||
et += diff;
|
||||
}
|
||||
else if (met < metRef){
|
||||
et -= diff;
|
||||
}
|
||||
std::string d;
|
||||
SpiceManager::ref().getDateFromET(et, d);
|
||||
std::cout << d << std::endl;
|
||||
|
||||
createImage(et, et + shutter, "NH_RALPH_LEISA", _defaultCaptureImage);
|
||||
}
|
||||
} while (!file.eof());
|
||||
std::sort(_timeStamps.begin(), _timeStamps.end(), cmp);
|
||||
@@ -321,7 +352,7 @@ bool ImageSequencer::loadSequence(const std::string dir){
|
||||
path.replace(path.begin() + position, path.end(), ext);
|
||||
std::vector<std::string>::const_iterator it = std::find(sequencePaths.begin(), sequencePaths.end(), path);
|
||||
if ( it != sequencePaths.end()){
|
||||
createImage(timestamps[0], timestamps[1], path);
|
||||
createImage(timestamps[0], timestamps[1], "NH_LORRI", path); /// fix active instrument!
|
||||
std::sort(_timeStamps.begin(), _timeStamps.end(), cmp);
|
||||
}
|
||||
std::string timestr;
|
||||
|
||||
Reference in New Issue
Block a user