Finality Engine
Loading...
Searching...
No Matches
TestScript.h
Go to the documentation of this file.
1#pragma once
2
3#include <Finality.h>
4#include <iostream>
5
6namespace FINALITY
7{
10 {
11 // without includeing glm::mat4 64 bytes
12 float Time;
13 };
14
17 {
18 public:
19 TestScript() = default;
20
21 private:
22 void Start() override
23 {
24 FI_CLIENT_INFO("TestScript Started using Push Constants!");
25
26 uint32_t baseOffset = 64;
27
29 {
30 auto& materialComp = GetComponent<MaterialComponent>();
31 if (materialComp.MaterialInstance)
32 {
33 materialComp.MaterialInstance->RegisterUniform("time", baseOffset + offsetof(MaterialCompLayout, Time), sizeof(float));
34 }
35 }
36 }
37
38 void Update(float dt) override
39 {
40 m_TotalTime += dt;
41 m_HelloTimer += dt;
42 m_RotationAngle += 50.0f * dt;
43
45 {
46 auto& transform = GetComponent<TransformComponent>();
47 transform.Rotation.x = m_RotationAngle;
48 transform.Rotation.y = m_RotationAngle * 0.5f;
49 }
50
52 {
53 auto& materialComp = GetComponent<MaterialComponent>();
54 if (materialComp.MaterialInstance)
55 {
56 materialComp.MaterialInstance->SetUniform1f("time", m_TotalTime);
57 }
58 }
59 }
60
61 void OnDestroy() override
62 {
63 FI_CLIENT_INFO("Test Script is destroyed");
64 }
65
66 private:
67 float m_HelloTimer = 0.0f;
68 float m_FPSTimer = 0.0f;
69 float m_RotationAngle = 0.0f;
70 float m_TotalTime = 0.0f;
71 };
72}
#define FI_CLIENT_INFO(...)
Definition Finality.h:55