2018-04-15 15:49:03 +00:00
|
|
|
#ifndef __PLANET_H__
|
|
|
|
#define __PLANET_H__
|
|
|
|
|
|
|
|
#include "util/Common.h"
|
2020-03-27 10:44:33 +00:00
|
|
|
#include "util/SimplexNoise.h"
|
2018-04-15 15:49:03 +00:00
|
|
|
#include "Shader.h"
|
2018-06-05 11:40:39 +00:00
|
|
|
#include "Camera.h"
|
2018-04-15 15:49:03 +00:00
|
|
|
|
2020-04-10 10:29:11 +00:00
|
|
|
#include "planet/PlanetIndexBuffer.h"
|
|
|
|
|
2020-03-27 10:44:33 +00:00
|
|
|
struct PlanetNoiseParams {
|
|
|
|
float frequency;
|
|
|
|
float amplitude;
|
|
|
|
float lacunarity;
|
|
|
|
float persistence;
|
|
|
|
};
|
|
|
|
|
2018-04-15 15:49:03 +00:00
|
|
|
class PlanetFace;
|
2020-04-10 10:29:11 +00:00
|
|
|
class PlanetFaceNode;
|
2018-04-15 15:49:03 +00:00
|
|
|
class Planet
|
|
|
|
{
|
|
|
|
public:
|
2020-03-27 10:44:33 +00:00
|
|
|
Planet(glm::vec3 position, float radius, PlanetNoiseParams &noiseParams);
|
2018-04-15 15:49:03 +00:00
|
|
|
~Planet();
|
|
|
|
|
|
|
|
inline void setLightDirection(glm::vec3 lightDir) { m_lightDir = lightDir; }
|
|
|
|
inline glm::vec3 getLightDirection() const { return m_lightDir; }
|
2018-06-05 11:40:39 +00:00
|
|
|
|
2018-06-06 18:11:17 +00:00
|
|
|
inline float getRadius() const { return m_radius; }
|
|
|
|
inline glm::vec3 getPosition() const { return m_position; }
|
|
|
|
|
|
|
|
void tick(Camera* camera, GLfloat dtime);
|
|
|
|
void draw(Camera* camera, Shader* shader);
|
2020-03-26 17:42:05 +00:00
|
|
|
|
2020-04-10 10:29:11 +00:00
|
|
|
inline SimplexNoise& getNoise() { return m_noise; }
|
|
|
|
inline PlanetFace* getFace(const unsigned int face) { return m_faces[face]; }
|
2023-02-23 19:33:50 +00:00
|
|
|
PlanetIndexBuffer* getIndexBuffer(const unsigned int detailTop, const unsigned int detailRight, const unsigned int detailBottom, const unsigned int detailLeft);
|
2020-03-27 10:44:33 +00:00
|
|
|
|
2023-02-24 13:34:40 +00:00
|
|
|
const glm::mat4 getTransformation();
|
2018-04-15 15:49:03 +00:00
|
|
|
private:
|
2022-02-25 16:39:45 +00:00
|
|
|
void connectFaces();
|
|
|
|
|
2023-02-23 19:33:50 +00:00
|
|
|
PlanetIndexBuffer* m_ibuffers[5][5][5][5];
|
2020-03-27 10:44:33 +00:00
|
|
|
SimplexNoise m_noise;
|
2018-04-15 15:49:03 +00:00
|
|
|
glm::vec3 m_position;
|
|
|
|
float m_radius;
|
|
|
|
|
|
|
|
glm::vec3 m_lightDir;
|
|
|
|
|
|
|
|
// 6 faces
|
|
|
|
PlanetFace* m_faces[6];
|
|
|
|
};
|
|
|
|
#endif // __PLANET_H__
|