72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include <GraphicsComponent.h>
|
|
#include <PhysicsComponent.h>
|
|
|
|
class GameObject
|
|
{
|
|
public:
|
|
unsigned int GameObjectID;
|
|
|
|
glm::vec3 Position;
|
|
|
|
glm::vec3 Rotation;
|
|
|
|
glm::vec3 Scale;
|
|
|
|
GameObject(glm::vec3 Position, glm::vec3 Rotation, glm::vec3 Scale)
|
|
: Graphics(nullptr),
|
|
Physics(nullptr),
|
|
Position(Position),
|
|
Rotation(Rotation),
|
|
Scale(Scale),
|
|
Front(0.0f, 0.0f, 1.0f),
|
|
Up(0.0f, 1.0f, 0.0f),
|
|
Right(1.0f, 0.0f, 0.0f),
|
|
WorldUp(0.0f, 1.0f, 0.0f)
|
|
{
|
|
GameObjectID = 0;
|
|
}
|
|
|
|
GameObject(GraphicsComponent* Graphics, PhysicsComponent* Physics)
|
|
: Graphics(Graphics),
|
|
Physics(Physics),
|
|
Position(0.0f, 0.0f, 0.0f),
|
|
Rotation(0.0f, 0.0f, 0.0f),
|
|
Scale(1.0f, 1.0f, 1.0f),
|
|
Front(0.0f, 0.0f, 1.0f),
|
|
Up(0.0f, 1.0f, 0.0f),
|
|
Right(1.0f, 0.0f, 0.0f),
|
|
WorldUp(0.0f, 1.0f, 0.0f)
|
|
{
|
|
GameObjectID = 0;
|
|
}
|
|
|
|
void Update(float DeltaTime)
|
|
{
|
|
//Graphics->Update();
|
|
//Physics->Update();
|
|
}
|
|
|
|
protected:
|
|
GraphicsComponent* Graphics;
|
|
PhysicsComponent* Physics;
|
|
|
|
glm::vec3 Front;
|
|
glm::vec3 Up;
|
|
glm::vec3 Right;
|
|
glm::vec3 WorldUp;
|
|
|
|
void UpdateVectors()
|
|
{
|
|
glm::vec3 UpdatedFront;
|
|
UpdatedFront.x = cos(glm::radians(Rotation.y)) * cos(glm::radians(Rotation.x));
|
|
UpdatedFront.y = sin(glm::radians(Rotation.x));
|
|
UpdatedFront.z = sin(glm::radians(Rotation.y)) * cos(glm::radians(Rotation.x));
|
|
Front = glm::normalize(UpdatedFront);
|
|
Right = glm::normalize(glm::cross(Front, WorldUp));
|
|
Up = glm::normalize(glm::cross(Right, Front));
|
|
}
|
|
}; |