added ability to resize models so I don't have to tinker with gun model.
This commit is contained in:
parent
8ef9ef72ca
commit
1f6079dd25
3 changed files with 16 additions and 1 deletions
|
|
@ -20,6 +20,15 @@ void Model::translate(glm::vec3 translation) {
|
||||||
// set model transform
|
// set model transform
|
||||||
this->model = glm::translate(glm::mat4(1.0f), glm::vec3(this->position));
|
this->model = glm::translate(glm::mat4(1.0f), glm::vec3(this->position));
|
||||||
}
|
}
|
||||||
|
void Model::resize(glm::vec3 scale) {
|
||||||
|
// set worldspace postition
|
||||||
|
glm::mat4 transMatrix =
|
||||||
|
glm::translate(glm::mat4(1.0f), glm::vec3(this->position));
|
||||||
|
this->scale = scale;
|
||||||
|
|
||||||
|
// set model transform
|
||||||
|
this->model = glm::scale(transMatrix, glm::vec3(this->scale));
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ private:
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
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
|
||||||
|
glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
// Load in models using assimp
|
// Load in models using assimp
|
||||||
void loadModel(std::string path);
|
void loadModel(std::string path);
|
||||||
|
|
@ -52,6 +54,8 @@ public:
|
||||||
|
|
||||||
// Translate the model
|
// Translate the model
|
||||||
void translate(glm::vec3 translation);
|
void translate(glm::vec3 translation);
|
||||||
|
// Scale the model
|
||||||
|
void resize(glm::vec3 scale);
|
||||||
|
|
||||||
~Model();
|
~Model();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ int main(int argc, char **argv) {
|
||||||
Model cube(ROOT_DIR "data/models/cube/cube.obj");
|
Model cube(ROOT_DIR "data/models/cube/cube.obj");
|
||||||
Model gun(ROOT_DIR "data/models/gun/Cerberus_LP.FBX");
|
Model gun(ROOT_DIR "data/models/gun/Cerberus_LP.FBX");
|
||||||
cube.translate(glm::vec3(3.0f, 0.0f, -1.0f));
|
cube.translate(glm::vec3(3.0f, 0.0f, -1.0f));
|
||||||
gun.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.resize(glm::vec3(0.02f, 0.02f, 0.02f));
|
||||||
|
|
||||||
// Create player camera object
|
// Create player camera object
|
||||||
PlayerCamera camera;
|
PlayerCamera camera;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue