-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameObject.hpp
More file actions
54 lines (42 loc) · 1.66 KB
/
Copy pathgameObject.hpp
File metadata and controls
54 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <vulkan/vulkan.h>
#include <vector>
#include "vertex.h"
#include <btBulletDynamicsCommon.h>
#include "textureManager.hpp"
#include "mesh.hpp"
class Renderer;
class TextureManager;
struct PhysicsConfig;
class GameObject
{
public:
glm::vec3 pos;
glm::vec3 rotationZYX; // degrees
glm::vec3 scale;
PhysicsConfig &config;
bool hide = false;
btCollisionShape *collisionShape = nullptr;
btCollisionObject *collisionObject = nullptr;
btMotionState *motionState = nullptr;
btRigidBody *rigidBody = nullptr;
btRaycastVehicle::btVehicleTuning tuning;
btRaycastVehicle *vehicle = nullptr;
btVehicleRaycaster *vehicleRaycaster = nullptr;
std::vector<Mesh> meshes;
GameObject(Renderer &renderer, PhysicsConfig &config, const glm::vec3 &pos, const glm::vec3 &scale, const glm::vec3 &rotationZYX);
~GameObject() {}
void draw(Renderer *renderer, int currentFrame, glm::mat4 view, glm::mat4 projectionMatrix, VkCommandBuffer commandBuffer);
void loadModel(Renderer &renderer, int *nextRenderingId, const std::string objPath, const std::string mtlPath);
void addMesh(Renderer &renderer, int *nextRenderingId, MaterialData &material, std::string texturePath, const std::vector<Vertex> &vertices, const std::vector<uint32_t> &indices);
void initPhysics(btDiscreteDynamicsWorld *dynamicsWorld);
void updatePhysics();
void cleanupPhysics(btDiscreteDynamicsWorld *dynamicsWorld);
void setScale(const glm::vec3 &newScale);
void setPosition(const glm::vec3 &newPosition);
void cleanupMeshes(VkDevice device, Renderer &renderer);
private:
std::vector<Vertex> vertices;
std::vector<uint32_t> indices;
bool initializedPhysics = false;
};