49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
//
|
|
// Created by sebastian on 07.02.26.
|
|
//
|
|
|
|
#ifndef HEXTILE_H
|
|
#define HEXTILE_H
|
|
#include <memory>
|
|
|
|
#include "../../engine/layer/entities/Entity.h"
|
|
#include "../../engine/renderer/model/TexturedModel.h"
|
|
#include "glm/vec2.hpp"
|
|
#include "glm/vec3.hpp"
|
|
#include "glm/ext/quaternion_geometric.hpp"
|
|
|
|
enum class RessourceType {
|
|
NONE,
|
|
WOOD
|
|
};
|
|
|
|
struct HexTile {
|
|
glm::vec3 worldPos;
|
|
int q, r; //Axiale Koordinaten (hex-Koordinaten)
|
|
int ownerID = -1;
|
|
RessourceType resourceType = RessourceType::NONE;
|
|
float radius;
|
|
bool isHighlighted = false;
|
|
|
|
std::vector<std::shared_ptr<Entity>> entitiesOnTile;
|
|
|
|
|
|
bool intersect(const glm::vec3& rayOrigin, const glm::vec3& rayDirection, glm::vec3& intersectionPoint) const {
|
|
float t = -rayOrigin.y / rayDirection.y;
|
|
if (t < 0) return false; // Ray zeigt nach oben, nicht getroffen
|
|
|
|
intersectionPoint = rayOrigin + t * rayDirection;
|
|
|
|
glm::vec2 diff(intersectionPoint.x - worldPos.x, intersectionPoint.z - worldPos.z);
|
|
return glm::length(diff) <= radius -0.1f;
|
|
}
|
|
};
|
|
|
|
struct HexRenderData {
|
|
std::shared_ptr<TexturedModel> model;
|
|
glm::vec3 position;
|
|
bool highlight = false;
|
|
};
|
|
|
|
#endif //HEXTILE_H
|