mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-24 21:39:02 -05:00
Misc work
More cleanup of RenderablePlanet Added const modifier to pss method Added faster travel method for interactionhandler
This commit is contained in:
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
PlanetGeometry();
|
||||
virtual ~PlanetGeometry();
|
||||
virtual void initialize(RenderablePlanet* parent);
|
||||
virtual bool initialize(RenderablePlanet* parent);
|
||||
virtual void deinitialize();
|
||||
virtual void render() = 0;
|
||||
|
||||
|
||||
@@ -48,9 +48,6 @@ public:
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
void setProgramObject(ghoul::opengl::ProgramObject* programObject = nullptr);
|
||||
void setTexture(ghoul::opengl::Texture* texture);
|
||||
|
||||
void render(const Camera* camera, const psc& thisPosition) override;
|
||||
void update() override;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
~SimpleSphereGeometry();
|
||||
|
||||
|
||||
void initialize(RenderablePlanet* parent) override;
|
||||
bool initialize(RenderablePlanet* parent) override;
|
||||
void deinitialize() override;
|
||||
void render() override;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
const double * value_ptr();
|
||||
const float * value_ptrf();
|
||||
glm::dvec2 getVec2() const;
|
||||
glm::vec2 getVec2f();
|
||||
glm::vec2 getVec2f() const;
|
||||
double length() const;
|
||||
float lengthf() const;
|
||||
|
||||
@@ -81,7 +81,7 @@ private:
|
||||
glm::dvec2 vec_;
|
||||
|
||||
// float vector used when returning float values
|
||||
glm::vec2 vecf_;
|
||||
mutable glm::vec2 vecf_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -351,6 +351,14 @@ void InteractionHandler::keyboardCallback(int key, int action) {
|
||||
pss dist(speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'T') {
|
||||
pss dist(-speed * 100.0 * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'G') {
|
||||
pss dist(speed * 100.0 * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
/*
|
||||
if (key == '1') {
|
||||
SceneGraphNode* node = getSceneGraphNode("sun");
|
||||
|
||||
@@ -68,9 +68,10 @@ PlanetGeometry::~PlanetGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
void PlanetGeometry::initialize(RenderablePlanet* parent)
|
||||
bool PlanetGeometry::initialize(RenderablePlanet* parent)
|
||||
{
|
||||
_parent = parent;
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlanetGeometry::deinitialize()
|
||||
|
||||
@@ -60,21 +60,20 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
_geometry
|
||||
= planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
|
||||
}
|
||||
path += "/";
|
||||
|
||||
// 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 = "";
|
||||
if (dictionary.hasKey("Textures.Color"))
|
||||
if (dictionary.hasKey("Textures.Color")) {
|
||||
dictionary.getValue("Textures.Color", texturePath);
|
||||
|
||||
_colorTexturePath = path + texturePath;
|
||||
_colorTexturePath = path + "/" + texturePath;
|
||||
}
|
||||
|
||||
for (properties::Property* p : _geometry->properties())
|
||||
addProperty(p);
|
||||
|
||||
// addProperty(_colorTexturePath);
|
||||
//_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
|
||||
|
||||
// createSphere();
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
|
||||
}
|
||||
|
||||
RenderablePlanet::~RenderablePlanet()
|
||||
@@ -92,7 +91,7 @@ bool RenderablePlanet::initialize()
|
||||
loadTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
|
||||
_geometry->initialize(this);
|
||||
completeSuccess &= _geometry->initialize(this);
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
@@ -107,18 +106,6 @@ bool RenderablePlanet::deinitialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderablePlanet::setProgramObject(ghoul::opengl::ProgramObject* programObject)
|
||||
{
|
||||
assert(programObject);
|
||||
_programObject = programObject;
|
||||
}
|
||||
|
||||
void RenderablePlanet::setTexture(ghoul::opengl::Texture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
_texture = texture;
|
||||
}
|
||||
|
||||
void RenderablePlanet::render(const Camera* camera, const psc& thisPosition)
|
||||
{
|
||||
// TODO replace with more robust assert
|
||||
|
||||
@@ -85,10 +85,11 @@ SimpleSphereGeometry::~SimpleSphereGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleSphereGeometry::initialize(RenderablePlanet* parent)
|
||||
bool SimpleSphereGeometry::initialize(RenderablePlanet* parent)
|
||||
{
|
||||
PlanetGeometry::initialize(parent);
|
||||
bool success = PlanetGeometry::initialize(parent);
|
||||
createSphere();
|
||||
return success;
|
||||
}
|
||||
|
||||
void SimpleSphereGeometry::deinitialize()
|
||||
|
||||
@@ -177,8 +177,9 @@ bool SceneGraph::initialize()
|
||||
// TODO: Set distance and camera direction in some more smart way
|
||||
// TODO: Set scaling dependent on the position and distance
|
||||
// set position for camera
|
||||
const pss bound = positionNode->calculateBoundingSphere();
|
||||
psc cameraPosition = positionNode->getPosition();
|
||||
cameraPosition += psc(0.0, 0.0, 1.0, 2.0);
|
||||
cameraPosition += psc(glm::vec4(0.f, 0.f, bound.getVec2f()));
|
||||
c->setPosition(cameraPosition);
|
||||
c->setCameraDirection(glm::vec3(0, 0, -1));
|
||||
c->setScaling(glm::vec2(1.0, 0.0));
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ glm::dvec2 pss::getVec2() const{
|
||||
return vec_;
|
||||
}
|
||||
|
||||
glm::vec2 pss::getVec2f() {
|
||||
glm::vec2 pss::getVec2f() const {
|
||||
vecf_ = glm::vec2(vec_);
|
||||
return vecf_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user