2024-01-08 16:17:25 +01:00
|
|
|
#include "./GameObject.h"
|
|
|
|
#include "glm.hpp"
|
|
|
|
#include "ext.hpp"
|
|
|
|
#include "src/Render_Utils.h"
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
class Planet : public GameObject
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
GameObject* center;
|
|
|
|
float distanceFromCenter;
|
|
|
|
float rotationSpeed;
|
|
|
|
Core::RenderContext sphereContext;
|
|
|
|
float scale;
|
|
|
|
glm::vec3 position;
|
|
|
|
glm::mat4 positionMatrix;
|
2024-01-31 13:42:00 +01:00
|
|
|
GLuint textureID;
|
|
|
|
GLuint normalMapID;
|
2024-02-07 23:13:51 +01:00
|
|
|
float startEulerYRotation = 0.f;
|
|
|
|
float startYMovement = 0.f;
|
2024-01-08 16:17:25 +01:00
|
|
|
|
|
|
|
public:
|
2024-01-31 13:42:00 +01:00
|
|
|
Planet(GameObject* center, float distanceFromCenter, float rotationSpeed, float scale, Core::RenderContext sphereContext, GLuint textureID, GLuint normalMapID) {
|
2024-01-08 16:17:25 +01:00
|
|
|
this->center = center;
|
|
|
|
this->distanceFromCenter = distanceFromCenter;
|
|
|
|
this->rotationSpeed = rotationSpeed;
|
|
|
|
this->sphereContext = sphereContext;
|
|
|
|
this->scale = scale;
|
|
|
|
this->position = glm::vec3(0);
|
2024-01-31 13:42:00 +01:00
|
|
|
this->textureID = textureID;
|
|
|
|
this->normalMapID = normalMapID;
|
2024-01-08 16:17:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
glm::mat4 getPositionMatrix() override {
|
|
|
|
return positionMatrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
void draw(float time, GLuint program) {
|
|
|
|
if (center == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float rotationAngle = glm::radians(time * rotationSpeed);
|
2024-02-07 23:13:51 +01:00
|
|
|
positionMatrix = center->getPositionMatrix() * glm::eulerAngleY(time * rotationSpeed + startEulerYRotation) * glm::translate(glm::vec3(distanceFromCenter, startYMovement, 0));
|
2024-01-08 16:17:25 +01:00
|
|
|
glm::mat4 modelMatrix = positionMatrix * glm::scale(glm::vec3(scale));
|
2024-02-04 20:31:21 +01:00
|
|
|
Core::drawObjectPBRTexture(sphereContext, modelMatrix, textureID, normalMapID, 0.7, 0.0, program);
|
2024-01-08 16:17:25 +01:00
|
|
|
}
|
2024-02-07 23:13:51 +01:00
|
|
|
|
|
|
|
void setStarteulerYRotation(float radians) {
|
|
|
|
startEulerYRotation = radians;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setStartYMovement(float value) {
|
|
|
|
startYMovement = value;
|
|
|
|
}
|
2024-01-08 16:17:25 +01:00
|
|
|
};
|