mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Cleanup of RenderableCrawlingLine
Cleanup of RenderableFOV Add function to SpiceManager that does not return the light travel time
This commit is contained in:
@@ -461,6 +461,33 @@ public:
|
||||
AberrationCorrection aberrationCorrection, double ephemerisTime,
|
||||
double& lightTime) const;
|
||||
|
||||
/**
|
||||
* Returns the \p position of a \p target body relative to an \p observer in a
|
||||
* specific \p referenceFrame, optionally corrected for \p lightTime (planetary
|
||||
* aberration) and stellar aberration (\p aberrationCorrection).
|
||||
* \param target The target body name or the target body's NAIF ID
|
||||
* \param observer The observing body name or the observing body's NAIF ID
|
||||
* \param referenceFrame The reference frame of the output position vector
|
||||
* \param aberrationCorrection The aberration correction used for the position
|
||||
* calculation
|
||||
* \param ephemerisTime The time at which the position is to be queried
|
||||
* \return The position of the \p target relative to the \p observer in the specified
|
||||
* \p referenceFrame
|
||||
* \throws SpiceException If the \p target or \p observer do not name a valid
|
||||
* NAIF object, \p referenceFrame does not name a valid reference frame or if there is
|
||||
* not sufficient data available to compute the position or neither the target nor the
|
||||
* observer have coverage.
|
||||
* \pre \p target must not be empty.
|
||||
* \pre \p observer must not be empty.
|
||||
* \pre \p referenceFrame must not be empty.
|
||||
* \post If an exception is thrown, \p lightTime will not be modified.
|
||||
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkpos_c.html
|
||||
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html
|
||||
*/
|
||||
glm::dvec3 targetPosition(const std::string& target,
|
||||
const std::string& observer, const std::string& referenceFrame,
|
||||
AberrationCorrection aberrationCorrection, double ephemerisTime) const;
|
||||
|
||||
/**
|
||||
* This method returns the transformation matrix that defines the transformation from
|
||||
* the reference frame \p from to the reference frame \p to. As both reference frames
|
||||
|
||||
@@ -72,6 +72,7 @@ void NewHorizonsModule::internalInitialize() {
|
||||
|
||||
std::vector<documentation::Documentation> NewHorizonsModule::documentations() const {
|
||||
return {
|
||||
RenderableFov::Documentation(),
|
||||
RenderableModelProjection::Documentation(),
|
||||
RenderablePlanetProjection::Documentation(),
|
||||
ProjectionComponent::Documentation()
|
||||
|
||||
@@ -24,26 +24,84 @@
|
||||
|
||||
#include <modules/newhorizons/rendering/renderablecrawlingline.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <modules/newhorizons/util/imagesequencer.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderableCrawlingLine";
|
||||
|
||||
const char* KeySource = "Source";
|
||||
const char* KeyTarget = "Target";
|
||||
const char* KeyInstrument = "Instrument";
|
||||
const char* KeyReferenceFrame = "Frame";
|
||||
const char* KeyColor = "RGB";
|
||||
const char* KeyColor = "Color";
|
||||
const char* KeyColorStart = "Start";
|
||||
const char* KeyColorEnd = "End";
|
||||
|
||||
static const int SourcePosition = 0;
|
||||
static const int TargetPosition = 1;
|
||||
}
|
||||
struct VBOData {
|
||||
float position[3];
|
||||
float color[4];
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableCrawlingLine::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableCrawlingLine",
|
||||
"newhorizons_renderable_crawlingline",
|
||||
{
|
||||
{
|
||||
KeySource,
|
||||
new StringVerifier,
|
||||
"Denotes the SPICE name of the source of the renderable crawling line, "
|
||||
"for example, the space craft",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyTarget,
|
||||
new StringVerifier,
|
||||
"Denotes the SPICE name of the target of the crawling line",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
KeyInstrument,
|
||||
new StringVerifier,
|
||||
"Denotes the SPICE name of the instrument that is used to render the "
|
||||
"crawling line",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyColor,
|
||||
new TableVerifier({
|
||||
{
|
||||
{
|
||||
KeyColorStart,
|
||||
new DoubleVector4Verifier,
|
||||
"The color at the start of the line",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
KeyColorEnd,
|
||||
new DoubleVector4Verifier,
|
||||
"The color at the end of the line",
|
||||
Optional::No
|
||||
}
|
||||
},
|
||||
Exhaustive::Yes
|
||||
}),
|
||||
"Specifies the colors that are used for the crawling line. One value "
|
||||
"determines the starting color of the line, the second value is the "
|
||||
"color at the end of the line.",
|
||||
Optional::No
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _program(nullptr)
|
||||
@@ -53,54 +111,60 @@ RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictiona
|
||||
, _frameCounter(0)
|
||||
, _drawLine(false)
|
||||
{
|
||||
dictionary.getValue(KeySource, _source);
|
||||
dictionary.getValue(KeyTarget, _target);
|
||||
dictionary.getValue(KeyInstrument, _instrumentName);
|
||||
dictionary.getValue(KeyReferenceFrame, _referenceFrame);
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableCrawlingLine"
|
||||
);
|
||||
|
||||
_source = dictionary.value<std::string>(KeySource);
|
||||
_target = dictionary.value<std::string>(KeyTarget);
|
||||
_instrumentName = dictionary.value<std::string>(KeyInstrument);
|
||||
|
||||
if (dictionary.hasKeyAndValue<glm::vec3>(KeyColor)) {
|
||||
dictionary.getValue(KeyColor, _lineColor);
|
||||
}
|
||||
else {
|
||||
_lineColor = glm::vec3(1);
|
||||
}
|
||||
_lineColorBegin = dictionary.value<glm::vec4>(
|
||||
std::string(KeyColor) + "." + KeyColorStart
|
||||
);
|
||||
|
||||
_lineColorEnd = dictionary.value<glm::vec4>(
|
||||
std::string(KeyColor) + "." + KeyColorEnd
|
||||
);
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= !_source.empty();
|
||||
ready &= !_target.empty();
|
||||
ready &= !_instrumentName.empty();
|
||||
ready &= (_program != nullptr);
|
||||
return ready;
|
||||
return (_program != nullptr);
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::initialize() {
|
||||
bool completeSuccess = true;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_program = renderEngine.buildRenderProgram("RenderableCrawlingLine",
|
||||
_program = renderEngine.buildRenderProgram(
|
||||
"RenderableCrawlingLine",
|
||||
"${MODULE_NEWHORIZONS}/shaders/crawlingline_vs.glsl",
|
||||
"${MODULE_NEWHORIZONS}/shaders/crawlingline_fs.glsl");
|
||||
|
||||
|
||||
if (!_program)
|
||||
return false;
|
||||
"${MODULE_NEWHORIZONS}/shaders/crawlingline_fs.glsl"
|
||||
);
|
||||
|
||||
glGenVertexArrays(1, &_vao);
|
||||
glGenBuffers(1, &_vbo);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(psc), NULL, GL_DYNAMIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(VBOData), NULL, GL_DYNAMIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, (void*)0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(VBOData), (void*)0);
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(VBOData),
|
||||
reinterpret_cast<void*>(offsetof(VBOData, color))
|
||||
);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
return completeSuccess;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::deinitialize(){
|
||||
@@ -119,73 +183,107 @@ bool RenderableCrawlingLine::deinitialize(){
|
||||
}
|
||||
|
||||
void RenderableCrawlingLine::render(const RenderData& data) {
|
||||
if (_drawLine) {
|
||||
_program->activate();
|
||||
_frameCounter++;
|
||||
// fetch data
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = glm::mat4(data.camera.viewRotationMatrix());
|
||||
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
|
||||
// setup the data to the shader
|
||||
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_program->setUniform("ModelTransform", transform);
|
||||
|
||||
int frame = _frameCounter % 60;
|
||||
float fadingFactor = static_cast<float>(sin((frame * 3.14159) / 60));
|
||||
float alpha = 0.6f + fadingFactor*0.4f;
|
||||
|
||||
glLineWidth(2.f);
|
||||
|
||||
_program->setUniform("_alpha", alpha);
|
||||
_program->setUniform("color", _lineColor);
|
||||
setPscUniforms(*_program.get(), data.camera, data.position);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_program->deactivate();
|
||||
if (!_drawLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
_program->activate();
|
||||
_frameCounter++;
|
||||
|
||||
glm::dmat4 modelTransform =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
|
||||
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
|
||||
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
|
||||
|
||||
glm::dmat4 modelViewProjectionTransform =
|
||||
data.camera.projectionMatrix() *
|
||||
glm::mat4(data.camera.combinedViewMatrix() *
|
||||
modelTransform
|
||||
)
|
||||
;
|
||||
//glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
|
||||
|
||||
// setup the data to the shader
|
||||
//_program->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
|
||||
//_program->setUniform("projectionTransform", data.camera.projectionMatrix());
|
||||
_program->setUniform("modelViewProjection", modelViewProjectionTransform);
|
||||
|
||||
int frame = _frameCounter % 60;
|
||||
float fadingFactor = static_cast<float>(sin((frame * 3.14159) / 60));
|
||||
float alpha = 0.6f + fadingFactor*0.4f;
|
||||
|
||||
glLineWidth(2.f);
|
||||
|
||||
_program->setUniform("_alpha", alpha);
|
||||
//_program->setUniform("color", _lineColor);
|
||||
//setPscUniforms(*_program.get(), data.camera, data.position);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_program->deactivate();
|
||||
}
|
||||
|
||||
void RenderableCrawlingLine::update(const UpdateData& data) {
|
||||
if (_program->isDirty())
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
glm::dmat3 transformMatrix = SpiceManager::ref().positionTransformMatrix(_source, _referenceFrame, data.time);
|
||||
|
||||
glm::mat4 tmp = glm::mat4(1);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++){
|
||||
tmp[i][j] = static_cast<float>(transformMatrix[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
_positions[SourcePosition] = PowerScaledCoordinate::CreatePowerScaledCoordinate(0, 0, 0);
|
||||
glm::dmat3 transformMatrix = SpiceManager::ref().positionTransformMatrix(
|
||||
_source,
|
||||
//"ECLIPJ2000",
|
||||
"GALACTIC",
|
||||
data.time
|
||||
);
|
||||
|
||||
glm::dmat3 tm = SpiceManager::ref().frameTransformationMatrix(_instrumentName, "ECLIPJ2000", data.time);
|
||||
|
||||
//_positions[SourcePosition] = { 0.f, 0.f, 0.f, 0.f };
|
||||
|
||||
glm::dvec3 boresight;
|
||||
try {
|
||||
//try {
|
||||
SpiceManager::FieldOfViewResult res =
|
||||
SpiceManager::ref().fieldOfView(_source);
|
||||
boresight = res.boresightVector;
|
||||
|
||||
}
|
||||
catch (const SpiceManager::SpiceException& e) {
|
||||
LERROR(e.what());
|
||||
}
|
||||
|
||||
//}
|
||||
//catch (const SpiceManager::SpiceException& e) {
|
||||
//LERROR(e.what());
|
||||
//}
|
||||
|
||||
glm::vec4 target(boresight[0], boresight[1], boresight[2], 12);
|
||||
target = tmp * target;
|
||||
//target = glm::dmat4(tm) * target;
|
||||
|
||||
_positions[TargetPosition] = target;
|
||||
//_positions[TargetPosition] = target;
|
||||
//_positions[TargetPosition] = {
|
||||
// target.x * pow(10, target.w),
|
||||
// target.y * pow(10, target.w),
|
||||
// target.z * pow(10, target.w),
|
||||
// 0
|
||||
//};
|
||||
|
||||
VBOData vboData[2] = {
|
||||
{
|
||||
{ 0.f, 0.f, 0.f },
|
||||
_lineColorBegin.r, _lineColorBegin.g, _lineColorBegin.b, _lineColorBegin.a
|
||||
},
|
||||
{
|
||||
{ target.x * pow(10, target.w), target.y * pow(10, target.w), target.z * pow(10, target.w) },
|
||||
{ _lineColorEnd.r, _lineColorEnd.g, _lineColorEnd.b, _lineColorEnd.a }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferSubData(
|
||||
GL_ARRAY_BUFFER,
|
||||
0,
|
||||
2 * sizeof(VBOData),
|
||||
vboData
|
||||
);
|
||||
//glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);
|
||||
|
||||
if (ImageSequencer::ref().isReady()) {
|
||||
_imageSequenceTime = ImageSequencer::ref().instrumentActiveTime(_instrumentName);
|
||||
@@ -193,5 +291,4 @@ void RenderableCrawlingLine::update(const UpdateData& data) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
@@ -27,8 +27,12 @@
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RenderableCrawlingLine : public Renderable {
|
||||
public:
|
||||
RenderableCrawlingLine(const ghoul::Dictionary& dictionary);
|
||||
@@ -41,6 +45,8 @@ public:
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
|
||||
@@ -48,9 +54,10 @@ private:
|
||||
std::string _source;
|
||||
std::string _target;
|
||||
std::string _referenceFrame;
|
||||
glm::vec3 _lineColor;
|
||||
|
||||
glm::vec4 _lineColorBegin;
|
||||
glm::vec4 _lineColorEnd;
|
||||
|
||||
psc _positions[2];
|
||||
int _frameCounter;
|
||||
|
||||
bool _drawLine;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/vec4property.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
@@ -44,6 +45,8 @@ class Texture;
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RenderableFov : public Renderable {
|
||||
public:
|
||||
RenderableFov(const ghoul::Dictionary& dictionary);
|
||||
@@ -55,79 +58,100 @@ public:
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
// Checks the field of view of the instrument for the current \p time against all of
|
||||
// the potential targets are returns the first name of the target that is in field of
|
||||
// view, the previous target, or the closest target to the space craft. The second
|
||||
// return value is whether the target is currently in the field of view
|
||||
std::pair<std::string,bool> determineTarget(double time);
|
||||
|
||||
private:
|
||||
void loadTexture();
|
||||
void allocateData();
|
||||
void insertPoint(std::vector<float>& arr, glm::vec4 p, glm::vec4 c);
|
||||
void fovSurfaceIntercept(bool H[], std::vector<glm::dvec3> bounds);
|
||||
void determineTarget();
|
||||
void updateGPU();
|
||||
void sendToGPU();
|
||||
void insertPoint(std::vector<float>& arr, glm::vec4 p, glm::vec4 c);
|
||||
|
||||
glm::vec4 squareColor(float t) const {
|
||||
return _colors.active.value() * t + _colors.square.value() * (1 - t);
|
||||
}
|
||||
|
||||
void computeColors();
|
||||
void computeIntercepts(const RenderData& data);
|
||||
psc orthogonalProjection(glm::dvec3 camvec);
|
||||
psc checkForIntercept(glm::dvec3 ray);
|
||||
psc pscInterpolate(psc p0, psc p1, float t);
|
||||
glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
|
||||
glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2);
|
||||
glm::vec4 endColor(float t) const {
|
||||
return _colors.active.value() * t + _colors.intersectionEnd.value() * (1 - t);
|
||||
}
|
||||
|
||||
glm::vec4 fovColor(float t) const {
|
||||
return _colors.active.value() * t + _colors.targetInFieldOfView.value() * (1 - t);
|
||||
}
|
||||
|
||||
void computeIntercepts(const UpdateData& data, const std::string& target , bool inFOV);
|
||||
glm::dvec3 orthogonalProjection(const glm::dvec3& camvec, double time, const std::string& target) const;
|
||||
glm::dvec3 checkForIntercept(const glm::dvec3& ray, double time, const std::string& target) const;
|
||||
//glm::dvec3 bisection(const glm::dvec3& p1, const glm::dvec3& p2, double time, const std::string& target, const glm::dvec3& previousHalf = glm::dvec3(0.0)) const;
|
||||
|
||||
// properties
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::BoolProperty _drawSolid;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
|
||||
|
||||
// instance variables
|
||||
int _nrInserted = 0;
|
||||
bool _rebuild = false;
|
||||
bool _interceptTag[35];
|
||||
bool _withinFOV;
|
||||
std::vector<psc> _projectionBounds;
|
||||
psc _interceptVector;
|
||||
|
||||
std::vector<float> _fovBounds;
|
||||
std::vector<float> _fovPlane;
|
||||
|
||||
// spice
|
||||
std::string _spacecraft;
|
||||
std::string _observer;
|
||||
std::string _frame;
|
||||
std::string _instrumentID;
|
||||
SpiceManager::AberrationCorrection _aberrationCorrection;
|
||||
std::string _fovTarget;
|
||||
glm::dvec3 ipoint, ivec;
|
||||
glm::dvec3 _previousHalf;
|
||||
glm::dvec3 _boresight;
|
||||
glm::dmat3 _stateMatrix;
|
||||
glm::mat4 _spacecraftRotation;
|
||||
std::vector<glm::dvec3> _bounds;
|
||||
std::vector<std::string> _potentialTargets;
|
||||
//std::vector<float> _fovBounds;
|
||||
//std::vector<float> _fovPlane;
|
||||
|
||||
std::string _previousTarget;
|
||||
bool _drawFOV;
|
||||
|
||||
// GPU
|
||||
GLuint _fovBoundsVAO;
|
||||
GLuint _fovBoundsVBO;
|
||||
unsigned int _vBoundsSize;
|
||||
GLuint _fovPlaneVAO;
|
||||
GLuint _fovPlaneVBO;
|
||||
unsigned int _vPlaneSize;
|
||||
GLenum _mode;
|
||||
struct {
|
||||
std::string spacecraft;
|
||||
std::string name;
|
||||
std::string referenceFrame;
|
||||
SpiceManager::AberrationCorrection aberrationCorrection;
|
||||
|
||||
// time
|
||||
double _time = 0;
|
||||
double _oldTime = 0;
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
std::vector<std::string> potentialTargets;
|
||||
} _instrument;
|
||||
|
||||
// colors
|
||||
glm::vec4 col_sq; // orthogonal white square
|
||||
glm::vec4 col_project; // color when projections occur
|
||||
glm::vec4 col_start; // intersection start color
|
||||
glm::vec4 col_end; // intersection end color
|
||||
glm::vec4 col_blue; // withinFov color
|
||||
glm::vec4 col_gray; // no intersection color
|
||||
float _interpolationTime;
|
||||
|
||||
struct RenderInformation {
|
||||
// Differentiating different vertex types
|
||||
using VertexColorType = int32_t;
|
||||
// This needs to be synced with the fov_vs.glsl shader
|
||||
static const VertexColorType VertexColorTypeDefaultStart = 0;
|
||||
static const VertexColorType VertexColorTypeDefaultEnd = 1;
|
||||
static const VertexColorType VertexColorTypeInFieldOfView = 2;
|
||||
static const VertexColorType VertexColorTypeActive = 3;
|
||||
static const VertexColorType VertexColorTypeIntersectionStart = 4;
|
||||
static const VertexColorType VertexColorTypeIntersectionEnd = 5;
|
||||
static const VertexColorType VertexColorTypeSquare = 6;
|
||||
|
||||
struct VBOData {
|
||||
GLfloat position[3];
|
||||
VertexColorType color;
|
||||
};
|
||||
|
||||
GLuint vao = 0;
|
||||
GLuint vbo = 0;
|
||||
// @SPEEDUP: Add an ibo to reduce the number of vertices drawn
|
||||
std::vector<VBOData> data;
|
||||
bool isDirty = true;
|
||||
};
|
||||
|
||||
RenderInformation _orthogonalPlane;
|
||||
RenderInformation _fieldOfViewBounds;
|
||||
|
||||
struct {
|
||||
properties::Vec4Property defaultStart; // Start color for uninteresting times
|
||||
properties::Vec4Property defaultEnd; // End color for uninteresting times
|
||||
properties::Vec4Property active; // Color use when a field-of-view is projecting
|
||||
properties::Vec4Property targetInFieldOfView; // Color to use for target in fov
|
||||
properties::Vec4Property intersectionStart; // Color at the start of intersection
|
||||
properties::Vec4Property intersectionEnd; // Color at the end of intersection
|
||||
properties::Vec4Property square; // Color for the orthogonal square
|
||||
} _colors;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -27,20 +27,15 @@ uniform vec4 objpos;
|
||||
uniform vec3 color;
|
||||
uniform float _alpha;
|
||||
|
||||
in vec4 vs_position;
|
||||
in vec4 vs_positionScreenSpace;
|
||||
in vec4 vs_color;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
vec4 diffuse = vs_color;
|
||||
float depth = pscDepth(position);
|
||||
diffuse.a = _alpha;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = diffuse;
|
||||
frag.depth = depth;
|
||||
frag.color = vec4(vs_color.rgb, vs_color.a * _alpha);
|
||||
frag.depth = vs_positionScreenSpace.w;
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -24,33 +24,24 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
layout(location = 0) in vec3 in_position;
|
||||
layout(location = 1) in vec4 in_color;
|
||||
|
||||
uniform vec3 color;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
uniform mat4 modelViewProjection;
|
||||
// uniform vec3 color;
|
||||
|
||||
out vec4 vs_color;
|
||||
out vec4 vs_position;
|
||||
out vec4 vs_positionScreenSpace;
|
||||
// out vec4 vs_positionCameraSpace;
|
||||
|
||||
const int targetId = 1;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
int id = gl_VertexID;
|
||||
|
||||
vec3 black = vec3(0.0);
|
||||
vec4 positionClipSpace = modelViewProjection * vec4(in_position, 1.0);
|
||||
vs_positionScreenSpace = z_normalization(positionClipSpace);
|
||||
gl_Position = vs_positionScreenSpace;
|
||||
|
||||
if(id == targetId)
|
||||
vs_color.xyz = black;
|
||||
else
|
||||
vs_color.xyz = color;
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
vs_color = in_color;
|
||||
}
|
||||
|
||||
@@ -22,28 +22,14 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
/*
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
in vec4 vs_point_position;
|
||||
in vec4 vs_point_velocity;
|
||||
*/
|
||||
|
||||
//out vec4 vs_point_position;
|
||||
in vec4 vs_point_velocity;
|
||||
in vec4 vs_positionScreenSpace;
|
||||
|
||||
|
||||
//out vec4 diffuse;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
in vec4 vs_color;
|
||||
in vec4 vs_positionScreenSpace;
|
||||
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
frag.color = vs_point_velocity;
|
||||
frag.color = vs_color;
|
||||
frag.depth = vs_positionScreenSpace.w;
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -24,63 +24,64 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
//uniform mat4 ViewProjection;
|
||||
//uniform mat4 ModelTransform;
|
||||
//uniform vec4 etColor;
|
||||
//uniform vec4 objectVelocity;
|
||||
|
||||
layout(location = 0) in vec4 in_point_position;
|
||||
layout(location = 1) in vec4 in_point_velocity;
|
||||
layout(location = 2) in vec2 in_point_timeindex;
|
||||
|
||||
|
||||
//out vec4 vs_point_position;
|
||||
out vec4 vs_point_velocity;
|
||||
|
||||
// Uniforms
|
||||
uniform mat4 modelViewProjectionTransform;
|
||||
|
||||
// Outputs
|
||||
out vec4 vs_positionScreenSpace;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 position = vec4(in_point_position.xyz * pow(10, in_point_position.w), 1);
|
||||
// This needs to be synced with the RenderableFov header
|
||||
const int VertexColorTypeDefaultStart = 0;
|
||||
const int VertexColorTypeDefaultEnd = 1;
|
||||
const int VertexColorTypeInFieldOfView = 2;
|
||||
const int VertexColorTypeActive = 3;
|
||||
const int VertexColorTypeIntersectionStart = 4;
|
||||
const int VertexColorTypeIntersectionEnd = 5;
|
||||
const int VertexColorTypeSquare = 6;
|
||||
|
||||
layout(location = 0) in vec3 in_point_position;
|
||||
layout (location = 1) in int colorInformation;
|
||||
|
||||
out vec4 vs_color;
|
||||
out vec4 vs_positionScreenSpace;
|
||||
|
||||
uniform mat4 modelViewProjectionTransform;
|
||||
|
||||
uniform vec4 defaultColorStart;
|
||||
uniform vec4 defaultColorEnd;
|
||||
uniform vec4 activeColor;
|
||||
uniform vec4 targetInFieldOfViewColor;
|
||||
uniform vec4 intersectionStartColor;
|
||||
uniform vec4 intersectionEndColor;
|
||||
uniform vec4 squareColor;
|
||||
uniform float interpolation;
|
||||
|
||||
void main() {
|
||||
vec4 position = vec4(in_point_position, 1);
|
||||
vec4 positionClipSpace = modelViewProjectionTransform * position;
|
||||
|
||||
// Write output
|
||||
vs_positionScreenSpace = z_normalization(positionClipSpace);
|
||||
gl_Position = vs_positionScreenSpace;
|
||||
|
||||
vs_point_velocity = in_point_velocity;
|
||||
|
||||
/*
|
||||
//vs_point_position = objpos;
|
||||
|
||||
// rotate and scale vertex with model transform and add the translation
|
||||
vec3 local_vertex_pos = mat3(ModelTransform) * in_point_position.xyz;
|
||||
//vec4 lvp = ModelTransform * in_point_position;
|
||||
|
||||
// PSC addition; local vertex position and the object power scaled world position
|
||||
vs_point_position = psc_addition(vec4(local_vertex_pos,in_point_position.w),objpos);
|
||||
//vs_point_position = psc_addition(lvp,objpos);
|
||||
|
||||
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
|
||||
vs_point_position = psc_addition(vs_point_position,vec4(-campos.xyz,campos.w));
|
||||
|
||||
// rotate the camera
|
||||
local_vertex_pos = mat3(camrot) * vs_point_position.xyz;
|
||||
vs_point_position = vec4(local_vertex_pos, vs_point_position.w);
|
||||
//vs_point_position = camrot* vs_point_position;
|
||||
|
||||
// project using the rescaled coordinates,
|
||||
//vec4 vs_point_position_rescaled = psc_scaling(vs_point_position, scaling);
|
||||
vec4 vs_point_position_rescaled = psc_to_meter(vs_point_position, scaling);
|
||||
//vs_point_position = vs_point_position_rescaled;
|
||||
|
||||
// project the position to view space
|
||||
gl_Position = ViewProjection * vs_point_position_rescaled;
|
||||
*/
|
||||
}
|
||||
switch (colorInformation) {
|
||||
case VertexColorTypeDefaultStart:
|
||||
vs_color = defaultColorStart;
|
||||
break;
|
||||
case VertexColorTypeDefaultEnd:
|
||||
vs_color = defaultColorEnd;
|
||||
break;
|
||||
case VertexColorTypeInFieldOfView:
|
||||
vs_color = activeColor * interpolation + targetInFieldOfViewColor * (1 - interpolation);
|
||||
break;
|
||||
case VertexColorTypeActive:
|
||||
vs_color = activeColor;
|
||||
break;
|
||||
case VertexColorTypeIntersectionStart:
|
||||
vs_color = intersectionStartColor;
|
||||
break;
|
||||
case VertexColorTypeIntersectionEnd:
|
||||
vs_color = activeColor * interpolation + intersectionEndColor * (1 - interpolation);
|
||||
break;
|
||||
case VertexColorTypeSquare:
|
||||
vs_color = activeColor * interpolation + squareColor * (1 - interpolation);
|
||||
break;
|
||||
default:
|
||||
vs_color = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,6 +565,21 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
|
||||
}
|
||||
}
|
||||
|
||||
glm::dvec3 SpiceManager::targetPosition(const std::string& target,
|
||||
const std::string& observer, const std::string& referenceFrame,
|
||||
AberrationCorrection aberrationCorrection, double ephemerisTime) const
|
||||
{
|
||||
double unused = 0.0;
|
||||
return targetPosition(
|
||||
target,
|
||||
observer,
|
||||
referenceFrame,
|
||||
aberrationCorrection,
|
||||
ephemerisTime,
|
||||
unused
|
||||
);
|
||||
}
|
||||
|
||||
glm::dmat3 SpiceManager::frameTransformationMatrix(const std::string& from,
|
||||
const std::string& to,
|
||||
double ephemerisTime) const
|
||||
|
||||
Reference in New Issue
Block a user