halt = true;
}
if (!isKHeld(sdl_event.key.keysym.sym))
+ {
KeyDown(sdl_event.key.keysym.sym);
-
+ key_toggle[sdl_event.key.keysym.sym] = !key_toggle[sdl_event.key.keysym.sym];
+ }
key_held[sdl_event.key.keysym.sym] = true;
break;
case SDL_KEYUP:
//MIPMAP QUALITY
break;
case SDLK_F6:
- //??? BLOOM
+ //??? BoundingBox
break;
case SDLK_F7:
//???
{
return key_held[_key];
}
+
bool Events::isMHeld(int const _key)
{
return mouse_held[_key];
}
+bool Events::isKToggleActive(int const _key)
+{
+ return key_toggle[_key];
+}
+
int Events::returnSet(int& value, int action2)
{
map<int, bool> Events::mouse_held;
map<int, bool> Events::pad_held;
+map<int, bool> Events::key_toggle;
+
int Events::view_x = 0;
int Events::view_y = 0;
bool static isKHeld(int const);
bool static isMHeld(int const);
+ bool static isKToggleActive(int const);
+
private:
void static mousemotion(SDL_MouseMotionEvent sdl_motion);
map<int, bool> static mouse_held;
map<int, bool> static pad_held;
+ map<int, bool> static key_toggle;
+
int static view_x;
int static view_y;
// load LVL
tmp_Scene->addObject(new SceneObject(shader1, scale(3.f * vec3(1.f,.3f,1.f)), "level_test.dae", "sample_2D.png"));
+ tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(0.f,2.f,0.f)), new BBox() , ""));
//Player
SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "Player.dae", "model_player_2D.png");
BBox::BBox()
{
- numvertices = 4;
- numfaces = 2;
+ numvertices = 8;
float vertex[] { -.5f, -.5f, -.5f, .5f, -.5f, -.5f, .5f, .5f, -.5f, -.5f, .5f, -.5f, -.5f, -.5f, .5f, .5f, -.5f, .5f, .5f, .5f, .5f, -.5f, .5f, .5f };
{
glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL1);
glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL2);
- glDrawElements(GL_LINE_STRIP, 8, GL_UNSIGNED_INT, indexS1);
+ glDrawElements(GL_LINES, 8, GL_UNSIGNED_INT, indexS1);
glBindVertexArray(0);
}
\ No newline at end of file
#include "../Graphix.h"
+#include "BBox.h"
+
+#include "../../Events.h"
+
Model::Model() :
numfaces(0),
numvertices(0),
void Model::drawModel() const
{
- glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0);
+ if(Events::isKToggleActive(SDLK_F3))
+ glDrawElements(GL_LINE_LOOP, numfaces * 3, GL_UNSIGNED_INT, 0);
+ else
+ glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const
{
+ bool wireframe = Events::isKToggleActive(SDLK_F3);
//Message::info("Error from before?");
//Graphix::getGlError();
useModel(_shader);
//Message::info("IMesh loading Coordinates");
//Graphix::getGlError();
- useTexture(_texture, _shader);
+ if (!wireframe)
+ useTexture(_texture, _shader);
//Message::info("IMesh loading Texture");
//Graphix::getGlError();
useModelMat(_modelMat, _shader);
//system("pause");
}
-void Model::drawBBox() const
+void Model::drawBBox(Shader* _shader,const mat4& _modelMat) const
{
-
+ if (BoundingBox==nullptr)
+ {
+ exBBox = true;
+ BoundingBox = new BBox();
+// BBoxShader = new Shader("basic_FS.hlsl", "basic_VS.hlsl");
+// BoundingBox->bindShader(BBoxShader);
+
+
+ }
+ BoundingBox->bindShader(_shader);
+ BoundingBox->drawModel(_shader, (Texture*)nullptr, _modelMat);
}
void Model::updateBB(const vec3& _min, const vec3& _max)
if (tmp >= 0)
glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model));
}
+
+Model* Model::BoundingBox = nullptr;
+Shader* Model::BBoxShader = nullptr;
+bool Model::exBBox = false;
\ No newline at end of file
virtual void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const;
/* Draws a BoundingBox around the Model */
- virtual void drawBBox() const;
+ virtual void drawBBox(Shader* shader,const mat4 & modelMat) const;
protected:
uint numvertices, numfaces;
virtual void useModelMat(const mat4& model, Shader* shader) const;
virtual void drawModel() const;
+ static Model* BoundingBox;
+ static Shader* BBoxShader;
+ static bool exBBox;
+
private:
vec3 BBsize, BBposition;
void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const
{
-
}
void SkyBox::useTexture(Texture* _texture, Shader* _shader) const
{
+}
+void SkyBox::drawBBox(Shader* _shader, const mat4& _modelMat) const
+{
}
void useModelMat(const mat4& model, Shader* shader) const;
void useTexture(Texture* texture, Shader* shader) const;
+ void drawBBox(Shader* shader, const mat4& modelMat) const;
+
};
#include "Graphix.h"
+#include "../Events.h"
+
using std::string;
using std::cout;
// drawModel();
model->drawModel(shader, texture, modelMat);
+ if (Events::isKToggleActive(SDLK_F6))
+ model->drawBBox(shader, modelMat);
}
void SceneObject::collisions(SceneObject* _other)