* fixes, refactoring & color attribute for planets

This commit is contained in:
end 2016-09-29 02:50:51 +02:00
parent 6b8227b0c3
commit 1ee349e1fb
8 changed files with 111 additions and 67 deletions

View file

@ -5,36 +5,43 @@
#include <cstdlib>
namespace game {
class Planet : public Object {
public:
/**
* Planets are build out of one material.
* TODO: support mixture or multiple material per planet.
*/
enum class Material {
Rock,
Metal,
Sand,
Gas,
Ice,
Water,
Sun
};
class Planet : public Object {
public:
/**
* Planets are build out of one material.
* TODO: support mixture or multiple material per planet.
*/
enum class Material { Rock, Metal, Sand, Gas, Ice, Water, Sun };
Planet(const glm::vec2 &pos, int id, float r) : Planet(pos, id, r, Material::Rock)
{
Planet(const glm::vec2 &pos, int id, float r)
: Planet(pos, id, r, Material::Rock) {}
Planet(const glm::vec2 &pos, int id, float r, Material mat)
: Object(pos, r), id(id), material(mat), seed(rand()) {}
glm::vec3 getColor() const {
switch (material) {
case Material::Rock:
return {x : 0.19, y : 0.19, z : 0.19};
case Material::Metal:
return {x : 0.19, y : 0.19, z : 0.19};
case Material::Sand:
return {x : 0.19, y : 0.19, z : 0.19};
case Material::Gas:
return {x : 0.19, y : 0.19, z : 0.19};
case Material::Ice:
return {x : 0.19, y : 0.19, z : 0.19};
case Material::Water:
return {x : 0.19, y : 0.40, z : 0.72};
case Material::Sun:
return {x : 0.64, y : 0.67, z : 0.19};
}
return {x : 0.1, y : 0.1, z : 0.1};
}
Planet(const glm::vec2 &pos, int id, float r, Material mat)
: Object(pos, r)
, id(id)
, material(mat)
, seed(rand())
{
}
int id;
Material material; // for rendering and physics (can fly through sun and outer gas planets)
int seed; // just for rendering variation
};
int id;
Material material; // for rendering and physics (can fly through sun and
// outer gas planets)
int seed; // just for rendering variation
};
}