Misc work

More cleanup of RenderablePlanet
Added const modifier to pss method
Added faster travel method for interactionhandler
This commit is contained in:
Alexander Bock
2014-05-05 18:04:53 +02:00
parent 44a8f6dfda
commit d09a1e0b54
10 changed files with 28 additions and 33 deletions
@@ -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;
+2 -2
View File
@@ -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_;
};
+8
View File
@@ -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");
+2 -1
View File
@@ -68,9 +68,10 @@ PlanetGeometry::~PlanetGeometry()
{
}
void PlanetGeometry::initialize(RenderablePlanet* parent)
bool PlanetGeometry::initialize(RenderablePlanet* parent)
{
_parent = parent;
return true;
}
void PlanetGeometry::deinitialize()
+8 -21
View File
@@ -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()
+2 -1
View File
@@ -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
View File
@@ -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_;
}