Loading...
Searching...
No Matches
Sphere.h
Go to the documentation of this file.
1//
2// Created by denzel on 11/08/2025.
3//
4#pragma once
5#include <memory>
6#include <string>
7#include <vector>
8#include <glm/detail/type_vec.hpp>
9#include <glm/detail/type_vec3.hpp>
10
11#include "hellfire/graphics/material/Material.h"
12
13namespace hellfire {
14 class Mesh;
15 class Scene;
16}
17
18struct Vertex;
19
20namespace hellfire {
21 class Entity;
22 using EntityID = uint32_t;
23
24 class Sphere {
25 public:
26 struct Config {
27 glm::vec3 color = glm::vec3(1.0f);
28 std::shared_ptr<Material> material = nullptr;
30 glm::vec3 scale = glm::vec3(1.0f);
31 int rings = 32;
32 int sectors = 32;
33 };
34
35 static EntityID create(Scene *scene, const std::string &name, const Config &config);
36
37 static std::shared_ptr<Mesh> create_mesh(int rings = 32, int sectors = 32);
38
39 static void get_sphere_data(std::vector<Vertex> &vertices,
40 std::vector<unsigned int> &indices,
41 float radius, int rings = 32, int sectors = 32);
42
43 private:
44 // Helper method for icosphere generation
45 static void subdivide_triangle(std::vector<glm::vec3> &vertices,
46 const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3,
47 int depth);
48 };
49}
TransformComponent * transform()
Definition Entity.cpp:42
Manages a collection of entities and their hierarchical relationships.
Definition Scene.h:24
Entity * get_entity(EntityID id)
Retrieves an entity by its ID.
Definition Scene.cpp:81
EntityID create_entity(const std::string &name="GameObject")
Creates a new entity in the scene.
Definition Scene.cpp:29
static void get_sphere_data(std::vector< Vertex > &vertices, std::vector< unsigned int > &indices, float radius, int rings=32, int sectors=32)
Definition Sphere.cpp:55
static void subdivide_triangle(std::vector< glm::vec3 > &vertices, const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3, int depth)
Definition Sphere.cpp:104
static std::shared_ptr< Mesh > create_mesh(int rings=32, int sectors=32)
Definition Sphere.cpp:48
static EntityID create(Scene *scene, const std::string &name, const Config &config)
Definition Sphere.cpp:12
void set_position(float x, float y, float z)
Definition Vertex.h:5
std::shared_ptr< Material > material
Definition Sphere.h:28