Rotation added to model (whole system is currently dirty)

This commit is contained in:
Warwick 2022-06-16 14:23:12 +01:00
parent 1f6079dd25
commit 3700494d84
3 changed files with 8 additions and 0 deletions

View file

@ -29,6 +29,9 @@ void Model::resize(glm::vec3 scale) {
// set model transform // set model transform
this->model = glm::scale(transMatrix, glm::vec3(this->scale)); this->model = glm::scale(transMatrix, glm::vec3(this->scale));
} }
void Model::rotate(float angle, glm::vec3 axis) {
this->model = glm::rotate(this->model, angle, axis);
}
void Model::loadModel(std::string path) { void Model::loadModel(std::string path) {
// Attempt to import model data using assimp // Attempt to import model data using assimp

View file

@ -25,6 +25,8 @@ private:
glm::vec4 position = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f); glm::vec4 position = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
// Scale // Scale
glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f); glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f);
// Rotation
glm::vec3 rotation = glm::vec3(0.0f, 0.0f, 0.0f);
// Load in models using assimp // Load in models using assimp
void loadModel(std::string path); void loadModel(std::string path);
@ -56,6 +58,8 @@ public:
void translate(glm::vec3 translation); void translate(glm::vec3 translation);
// Scale the model // Scale the model
void resize(glm::vec3 scale); void resize(glm::vec3 scale);
// Scale the model
void rotate(float angle, glm::vec3 axis);
~Model(); ~Model();
}; };

View file

@ -77,6 +77,7 @@ int main(int argc, char **argv) {
backpack.translate(glm::vec3(-3.0f, 0.0f, 0.0f)); backpack.translate(glm::vec3(-3.0f, 0.0f, 0.0f));
gun.translate(glm::vec3(0.0f, 1.0f, 0.0f)); gun.translate(glm::vec3(0.0f, 1.0f, 0.0f));
gun.resize(glm::vec3(0.02f, 0.02f, 0.02f)); gun.resize(glm::vec3(0.02f, 0.02f, 0.02f));
gun.rotate(glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
// Create player camera object // Create player camera object
PlayerCamera camera; PlayerCamera camera;