ass: added ImGui
This commit is contained in:
parent
93333821d8
commit
3eb73af274
31 changed files with 69057 additions and 201 deletions
50
include/myEngine/object.hpp
Normal file
50
include/myEngine/object.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <myEngine/model.hpp>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
class Object {
|
||||
public:
|
||||
Model& model;
|
||||
glm::vec3 position;
|
||||
glm::vec3 scale;
|
||||
glm::vec3 rotation;
|
||||
glm::vec3 acceleration;
|
||||
|
||||
Object(Model &model, glm::vec3 position, glm::vec3 scale, glm::vec3 rotation) : model(model), position(position), scale(scale), rotation(rotation) {}
|
||||
|
||||
glm::mat4 getModelMatrix() const {
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
model = glm::translate(model, position);
|
||||
model = glm::scale(model, scale);
|
||||
model = glm::rotate(model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
model = glm::rotate(model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
model = glm::rotate(model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
return model;
|
||||
}
|
||||
|
||||
void setPosition(const glm::vec3 &newPosition) {
|
||||
position = newPosition;
|
||||
}
|
||||
|
||||
void setScale(const glm::vec3 &newScale) {
|
||||
scale = newScale;
|
||||
}
|
||||
|
||||
void setRotation(const glm::vec3 &newRotation) {
|
||||
rotation = newRotation;
|
||||
}
|
||||
|
||||
void setAcceleration(const glm::vec3 &newAcceleration) {
|
||||
acceleration = newAcceleration;
|
||||
}
|
||||
|
||||
void Draw(Shader &shader, float deltaTime) {
|
||||
position += acceleration * deltaTime;
|
||||
acceleration = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
glm::mat4 modelMatrix = getModelMatrix();
|
||||
shader.setMat4("model", modelMatrix);
|
||||
model.Draw(shader);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue