Skip to content
Snippets Groups Projects
Commit 2aab8f78 authored by Vegardoa's avatar Vegardoa
Browse files

Changed from using vec2 to vec3 to position map objects.

parent d7831649
No related branches found
No related tags found
No related merge requests found
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
class mapObj : public gameObj { class mapObj : public gameObj {
public: public:
GLint id; GLint id;
glm::vec2 pos; glm::vec3 pos;
glm::vec2 size; glm::vec2 size;
bool visible; bool visible;
// Longass constructor. // Longass constructor.
mapObj(){} mapObj(){}
mapObj(int i, glm::vec2 p, glm::vec2 s) :gameObj() { id = 0; pos = p; size = s; visible = true; } mapObj(int i, glm::vec3 p, glm::vec2 s) :gameObj() { id = 0; pos = p; size = s; visible = true; }
mapObj(GLenum primitive_mode, int numVertices, const GLfloat* vertices, const GLfloat* normal, const GLfloat* tex, texture* texProg, shader* shaProg, GLenum fill_mode, int i, glm::vec2 p, glm::vec2 s) : gameObj( primitive_mode, numVertices, vertices, normal, tex, texProg, shaProg, fill_mode) { id = i; pos = p; size = s; visible = true; } mapObj(GLenum primitive_mode, int numVertices, const GLfloat* vertices, const GLfloat* normal, const GLfloat* tex, texture* texProg, shader* shaProg, GLenum fill_mode, int i, glm::vec3 p, glm::vec2 s) : gameObj( primitive_mode, numVertices, vertices, normal, tex, texProg, shaProg, fill_mode) { id = i; pos = p; size = s; visible = true; }
}; };
......
...@@ -25,7 +25,7 @@ void levelLoader::loadLevel(const char* levelFilePath) { ...@@ -25,7 +25,7 @@ void levelLoader::loadLevel(const char* levelFilePath) {
while (lvlFile[i] == ' ' || lvlFile[i] == '\n')i++; while (lvlFile[i] == ' ' || lvlFile[i] == '\n')i++;
float lex = -size.x / 2.f * xsize; float bex = -size.y / 2.f * ysize; float lex = -size.x / 2.f * xsize; float bex = -size.y / 2.f * ysize;
float xAdd = float(k) * size.x + size.x / 2.f; float yAdd = float(j) * size.y + size.y / 2.f; float xAdd = float(k) * size.x + size.x / 2.f; float yAdd = float(j) * size.y + size.y / 2.f;
glm::vec2 pos = glm::vec2(lex + xAdd, bex + yAdd); glm::vec3 pos = glm::vec3(lex + xAdd, 0, bex + yAdd);
switch (lvlFile[i]) switch (lvlFile[i])
{ {
......
...@@ -46,7 +46,7 @@ bool pacman::collisionDetection(mapObj mapObject, glm::vec3 tempCamPos, float di ...@@ -46,7 +46,7 @@ bool pacman::collisionDetection(mapObj mapObject, glm::vec3 tempCamPos, float di
* Having 0.6 simply prevents us from seeing through the wall to a greater extent. * Having 0.6 simply prevents us from seeing through the wall to a greater extent.
*/ */
bool collisionX = tempCamPos.x >= (mapObject.pos.x*18.0f)- distFromSrc && tempCamPos.x <= (mapObject.pos.x*18.0f)+ distFromSrc; bool collisionX = tempCamPos.x >= (mapObject.pos.x*18.0f)- distFromSrc && tempCamPos.x <= (mapObject.pos.x*18.0f)+ distFromSrc;
bool collisionZ = tempCamPos.z >= (mapObject.pos.y*18.0f)- distFromSrc && tempCamPos.z <= (mapObject.pos.y*18.0f)+ distFromSrc; bool collisionZ = tempCamPos.z >= (mapObject.pos.z*18.0f)- distFromSrc && tempCamPos.z <= (mapObject.pos.z*18.0f)+ distFromSrc;
// NOTE!. mapObject.pos.y is really its z position. I just use a glm::vec2 since the "y" position doesnt matter for walls. The blocking wall's height is irrelevant since being on top of a wall isnt a necessary functionality // NOTE!. mapObject.pos.y is really its z position. I just use a glm::vec2 since the "y" position doesnt matter for walls. The blocking wall's height is irrelevant since being on top of a wall isnt a necessary functionality
/* /*
......
...@@ -23,7 +23,7 @@ void renderer::loadMap(std::vector<mapObj> mapObjects, pacman pacman){ ...@@ -23,7 +23,7 @@ void renderer::loadMap(std::vector<mapObj> mapObjects, pacman pacman){
* Prepare changes that are to be applied to the UNIFORM shader variables * Prepare changes that are to be applied to the UNIFORM shader variables
*/ */
glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f); glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f);
glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(iter->pos.x * 18, 0, iter->pos.y * 18)); glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(iter->pos.x * 18, iter->pos.y, iter->pos.z * 18));
//glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future //glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future
/* /*
...@@ -66,7 +66,7 @@ void renderer::updatePellet(std::vector<mapObj> pelletObj, pacman pacman){ ...@@ -66,7 +66,7 @@ void renderer::updatePellet(std::vector<mapObj> pelletObj, pacman pacman){
*/ */
glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f); glm::mat4 proj = glm::perspective(3.14f / 3.0f, (GLfloat)1024 / (GLfloat)768, 0.1f, -10.0f);
glm::mat4 modelCanvas = glm::mat4(1.0f); glm::mat4 modelCanvas = glm::mat4(1.0f);
glm::mat4 model = glm::translate(modelCanvas, glm::vec3(iter->pos.x * 18, -0.2f, iter->pos.y * 18)) * glm::scale(modelCanvas, glm::vec3(0.05f, 0.05f, 0.05f)); glm::mat4 model = glm::translate(modelCanvas, glm::vec3(iter->pos.x * 18, -0.2f, iter->pos.z * 18)) * glm::scale(modelCanvas, glm::vec3(0.05f, 0.05f, 0.05f));
//glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future //glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(view * model))); // Might get some use out of this one in the future
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment