mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 20:50:19 -06:00
Merge branch 'thesis/2018/dsn' of github.com:OpenSpace/OpenSpace into thesis/2018/dsn
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "ConeProgram";
|
||||
@@ -414,9 +416,17 @@ void RenderableCone::update(const UpdateData& data) {
|
||||
for (int i = 0; i < numBaseVertices; ++i) {
|
||||
double rad = angleIncrement * i;
|
||||
glm::dvec3 p = baseCenterPosition + (((e0 * glm::cos(rad)) + (e1 * glm::sin(rad))) * radius);
|
||||
p = getCoordinatePosFromFocusNode(p);
|
||||
baseVertices.push_back(p);
|
||||
}
|
||||
|
||||
// work around for precision errors
|
||||
_focusNodePos = global::navigationHandler.focusNode()->worldPosition();
|
||||
_localTransform = glm::translate(glm::dmat4(1.0), _focusNodePos);
|
||||
_apexPosition = getCoordinatePosFromFocusNode(_apexPosition);
|
||||
baseCenterPosition = getCoordinatePosFromFocusNode(baseCenterPosition);
|
||||
|
||||
// upload all positions to the vertex array
|
||||
fillVertexArray(_vertexBaseArray, baseCenterPosition, baseVertices);
|
||||
fillVertexArray(_vertexLateralSurfaceArray, _apexPosition, baseVertices);
|
||||
|
||||
@@ -426,6 +436,17 @@ void RenderableCone::update(const UpdateData& data) {
|
||||
unbindGL();
|
||||
}
|
||||
|
||||
/* Returns a position that is relative to the current
|
||||
focus node. This is a method to handle precision
|
||||
problems that occur when placing our signal line endings. */
|
||||
glm::dvec3 RenderableCone::getCoordinatePosFromFocusNode(glm::dvec3 worldPos) {
|
||||
|
||||
glm::dvec3 diffPos = glm::dvec3(worldPos.x - _focusNodePos.x, worldPos.y - _focusNodePos.y,
|
||||
worldPos.z - _focusNodePos.z);
|
||||
|
||||
return diffPos;
|
||||
}
|
||||
|
||||
void RenderableCone::updateUniforms(const RenderData& data) {
|
||||
_programObject->setUniform(_uniformCache.modelView,
|
||||
data.camera.combinedViewMatrix() * _localTransform);
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace openspace {
|
||||
|
||||
private:
|
||||
void addVertexToVertexArray(std::vector<float> &_vertexArray,glm::dvec3 position,glm::vec4 color);
|
||||
glm::dvec3 getCoordinatePosFromFocusNode(glm::dvec3 worldPos);
|
||||
void updateUniforms(const RenderData& data);
|
||||
|
||||
/// The VBO layout of the vertex position
|
||||
@@ -141,6 +142,7 @@ namespace openspace {
|
||||
glm::vec3 _defaultColor = { 0.4,0.4,0.4};
|
||||
|
||||
std::string _apexNodeId, _baseDirNodeId = "";
|
||||
glm::dvec3 _focusNodePos;
|
||||
|
||||
/// Program object used to render the data stored in RenderInformation
|
||||
ghoul::opengl::ProgramObject* _programObject = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user