TazGraph Project v0.1.0
Loading...
Searching...
No Matches
BoxComponent.h
1#pragma once
2
3#include "../../../Components.h"
4
5class BoxComponent : public Component
6{
7public:
8 TazColor color = { 255, 255, 255, 255 };
9
10 TransformComponent* transform = nullptr;
11
12 float temp_rotation = 0.0f;
13
15 {
16
17 }
18
19
21
22 }
23
24 void init() override {
25 if (!entity->hasComponent<TransformComponent>()) {
27 }
28 transform = &entity->GetComponent<TransformComponent>();
29
30 }
31
32 void update(float deltaTime) override {
33 temp_rotation += 0.1f;
34 }
35
36 void draw(size_t v_index, PlaneColorRenderer& batch, TazGraphEngine::Window& window) {
37 batch.drawBox(v_index, transform->size, transform->position, transform->rotation, color);
38 }
39
40 void draw(size_t v_index, LineRenderer& batch, TazGraphEngine::Window& window) {
41 batch.drawBox(v_index, transform->size, transform->position, color, transform->rotation, 5.0f);
42 }
43
44 void draw(size_t v_index, LightRenderer& batch, TazGraphEngine::Window& window) {
45 batch.drawBox(v_index, transform->size, transform->position, transform->rotation, color);
46 }
47
48 std::string GetComponentName() override {
49 return "BoxComponent";
50 }
51
52 void showGUI(std::vector<BaseComponent*> otherComponents = {}) override {
53 showGUI(otherComponents, { entity });
54
55 }
56
57 void showGUI(std::vector<BaseComponent*> otherComponents, std::vector<Entity*> otherEntities) override {
58 ImGui::Separator();
59
60 ImVec4 a_color = ImVec4(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
61 if (ImGui::ColorPicker4("TazColor", (float*)&a_color)) {
62 TazColor newColor = {
63 (GLubyte)(a_color.x * 255),
64 (GLubyte)(a_color.y * 255),
65 (GLubyte)(a_color.z * 255),
66 (GLubyte)(a_color.w * 255)
67 };
68
69 for (auto& e : otherEntities) {
70 if (e->hasComponent<BoxComponent>()) {
71 e->GetComponent<BoxComponent>().color = newColor;
72 }
73 }
74 }
75 };
76
77};
Definition BoxComponent.h:6
Definition GECS.h:131
T & addComponent(TArgs &&... mArgs)
have addScript function
Definition GECS.h:345
Definition LightRenderer.h:15
Definition LineRenderer.h:6
Definition PlaneColorRenderer.h:14
Definition Window.h:12
Definition TransformComponent.h:7
Definition Vertex.h:44