#ifndef __PLANETFACE_H__ #define __PLANETFACE_H__ #include "util/Common.h" #include "planet/Planet.h" #include "Shader.h" #include "Camera.h" #define RESOLUTION 128 enum Face { FACE_BOTTOM, FACE_TOP, FACE_LEFT, FACE_RIGHT, FACE_FRONT, FACE_BACK }; struct Vertex { glm::vec3 position; glm::vec3 normal; glm::vec2 uv; }; class Planet; class PlanetFace; class PlanetFaceNode { public: PlanetFaceNode(Planet* planet, PlanetFace* face, glm::vec3 position, const unsigned int level); ~PlanetFaceNode(); void tick(Camera* camera, GLfloat dtime); void draw(Camera* camera, Shader* shader); void generate(); void subdivide(); void merge(); void dispose(); bool isLeaf(); inline Planet* getPlanet() const { return m_planet; } inline PlanetFace* getPlanetFace() const { return m_planetFace; } inline glm::vec3 getAbsolutePosition() const { return m_planet->getPosition() + m_pos; } private: Planet* m_planet; PlanetFace* m_planetFace; PlanetFaceNode* m_parent; PlanetFaceNode* m_children[4]; unsigned int m_level; bool m_dirty; bool m_generated; bool m_leaf; GLuint m_ebo, m_vao, m_vbo; int m_indices; glm::vec3 m_pos; glm::vec3 m_left; glm::vec3 m_forward; }; class PlanetFace { public: PlanetFace(Planet* planet, const unsigned int face = Face::FACE_BOTTOM); ~PlanetFace(); void tick(Camera* camera, GLfloat dtime); void draw(Camera* camera, Shader* shader); inline Planet* getPlanet() const { return m_planet; } inline const glm::vec3 getNormal() const { return m_normal; } private: Planet* m_planet; unsigned int m_face; glm::vec3 m_normal; PlanetFaceNode* m_planetFace; }; #endif // __PLANETFACE_H__